From 142b5265be763020b772595c65c3adabaf1f3223 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:13:37 +0900 Subject: [PATCH 1/7] =?UTF-8?q?docs(grpc):=20executor=20=ED=8F=AC=ED=99=94?= =?UTF-8?q?=20=EC=83=81=ED=83=9C=20=EC=BD=94=EB=93=9C=EB=A5=BC=20UNAVAILAB?= =?UTF-8?q?LE(SERVER=5FBUSY)=EB=A1=9C=20=EB=B0=94=EB=A1=9C=EC=9E=A1?= =?UTF-8?q?=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: AGENTS.md 설정 표의 executorQueueCapacity 줄, README 「P1 qualification과 P2 유보」 절, GrpcCallAdmission 클래스 Javadoc 첫 문장이 executor·대기열이 넘친 호출을 RESOURCE_EXHAUSTED로 닫는다고 쓴다. 코드(GrpcCallAdmission)는 OperationalError.SERVER_BUSY로 닫고, 그 상태는 UNAVAILABLE이다(GrpcStatusMapper). 같은 Javadoc의 뒤 단락은 이미 SERVER_BUSY(UNAVAILABLE)로, README 「서버 한도」 절과 wire 시험 DisplayName은 UNAVAILABLE(SERVER_BUSY)로 쓴다. 2026-11-12 공용 코드 통일 때 세 곳이 남았다. 고친 것: 문서 두 줄은 `UNAVAILABLE`(`SERVER_BUSY`)로 쓴다. Javadoc 첫 문장은 뒤 단락과 같은 `SERVER_BUSY`(`UNAVAILABLE`) 순서로 쓴다. Javadoc은 main 소스지만 주석만 바꾼다. 메시지 크기 상한과 RATE_LIMIT 대응의 RESOURCE_EXHAUSTED는 그대로 맞으므로 두지 않는다. 위험·한계: 문서 두 줄과 Javadoc 한 문장만 바꾼다. 동작은 바뀌지 않는다. 검증: - grpc leaf에서 RESOURCE_EXHAUSTED가 남은 곳은 메시지 크기 상한(문서 둘, wire 시험), RATE_LIMIT 대응(GrpcStatusMapper와 그 시험, README 표, carrier 시험), README의 2026-11-12 전 이력 한 줄뿐이다(grep). - scripts/verify.sh docs rc=0(노트북). --- src/adapter/inbound/grpc/AGENTS.md | 2 +- src/adapter/inbound/grpc/README.md | 2 +- .../caskeleton/adapter/inbound/grpc/GrpcCallAdmission.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/adapter/inbound/grpc/AGENTS.md b/src/adapter/inbound/grpc/AGENTS.md index 6110e583..2b4df9b6 100644 --- a/src/adapter/inbound/grpc/AGENTS.md +++ b/src/adapter/inbound/grpc/AGENTS.md @@ -62,7 +62,7 @@ Package root: `dev.caskeleton.adapter.inbound.grpc`. | `maxInboundMetadataBytes` | `8192` | 호출당 metadata 상한 (플랫폼과 같은 값) | | `maxConcurrentCallsPerConnection` | `100` | 연결당 동시 호출(HTTP/2 stream) 상한. 넘친 호출은 클라이언트에서 기다린다 | | `executorMaxPoolSize` | `32` | feature 호출을 실행하는 고정 스레드 수 (플랫폼 executor 기본값) | -| `executorQueueCapacity` | `256` | 스레드를 기다릴 수 있는 호출 수(1..10000). 넘친 호출은 즉시 `RESOURCE_EXHAUSTED` | +| `executorQueueCapacity` | `256` | 스레드를 기다릴 수 있는 호출 수(1..10000). 넘친 호출은 즉시 `UNAVAILABLE`(`SERVER_BUSY`) | | `defaultDeadline` | `10s` | deadline 없는(또는 더 긴) feature 호출의 서버 deadline. 넘으면 `DEADLINE_EXCEEDED` | | `keepAliveTime` / `keepAliveTimeout` | `30s` / `10s` | 서버 keep-alive ping 간격 / 응답 대기 (플랫폼 `GrpcServerProfile.stable`) | | `permitKeepAliveTime` | `30s` | 클라이언트 ping 최소 간격. `keepAliveTime` 이하 | diff --git a/src/adapter/inbound/grpc/README.md b/src/adapter/inbound/grpc/README.md index 2d85b064..a8b232eb 100644 --- a/src/adapter/inbound/grpc/README.md +++ b/src/adapter/inbound/grpc/README.md @@ -214,7 +214,7 @@ Spring Boot BOM은 `io.grpc:*`/protobuf 버전을 관리하지 않는다. 이 reflection-off, 모든 오류 경로의 안정 code/category 및 sentinel redaction을 검증한다. 서버 한도도 같은 wire 에서 검증한다: 1 MiB 초과 요청 `RESOURCE_EXHAUSTED`(정확히 1 MiB 는 통과), deadline 없는 느린 호출의 서버 기본 deadline `DEADLINE_EXCEEDED`, 더 짧은 클라이언트 deadline 유지, 연결당 동시 -호출 상한, executor·대기열 포화 시 즉시 `RESOURCE_EXHAUSTED`. `GrpcServerRunnerBootTest`는 종료 +호출 상한, executor·대기열 포화 시 즉시 `UNAVAILABLE`(`SERVER_BUSY`). `GrpcServerRunnerBootTest`는 종료 drain 동안 listener 가 살아서 health NOT_SERVING 을 답하는지 검증한다. 이는 local plaintext unary 경계에 대한 P1 증거이며 production-ready 주장 근거가 아니다. diff --git a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcCallAdmission.java b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcCallAdmission.java index f86c4012..aed34aa1 100644 --- a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcCallAdmission.java +++ b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcCallAdmission.java @@ -15,8 +15,8 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; /** - * Bounds how many feature calls the server holds, and refuses the rest with {@code - * RESOURCE_EXHAUSTED} (review 03-09). + * Bounds how many feature calls the server holds, and refuses the rest with {@code SERVER_BUSY} + * ({@code UNAVAILABLE}) (review 03-09). * *

Why not just a bounded executor: when a bounded {@code ThreadPoolExecutor} rejects, io.grpc * does not answer the call. The rejection is logged on the Netty thread and the stream stays open -- 2.54.0 From 2f863c330571fbcc70e571a1b4945af40127e1c8 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:13:37 +0900 Subject: [PATCH 2/7] =?UTF-8?q?test(grpc):=20=EC=A2=85=EB=A3=8C=20drain=20?= =?UTF-8?q?2=EC=B4=88=C2=B7grace=205=EC=B4=88=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=EC=9D=84=20=EB=8B=A8=EC=96=B8=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: AGENTS.md 설정 표는 종료 기본값을 grace 5초, drain 2초로 쓰고, README 「graceful shutdown」 항목도 drain 기본 2초를 쓴다. 로드밸런서가 드레이닝과 장애를 가르는 것은 drain이 기본으로 켜져 있기 때문이다. 그런데 이 두 값을 단언하는 시험이 없다. 4db443e7b 뒤로 listener를 띄우는 시험은 모두 속도 때문에 drain을 0으로 주고, drain 시험은 자기 값(drain 6초, grace 8초)을 준다. 그래서 main의 기본 drain을 2에서 0으로 바꿔도 시험이 모두 통과한다(아래 검증). 고친 것: GrpcSafeActivationTest에 시험 하나를 더한다. 설정 객체를 새로 만들어 [drain, grace]가 정확히 [2, 5]인지 본다. 버린 안: 이미 있는 기본값 시험 둘에 두 값을 더하는 것. 첫째는 이름이 노출 기본값(enabled·reflection·plaintext)만 말하고, 둘째 (transportBoundDefaultsMatchTheVendoredPlatformDefaults)는 플랫폼 literal과 같은지를 본다. drain·grace는 어댑터가 정한 값이라 둘 어디에도 맞지 않는다. 위험·한계: 시험 하나를 더한다. 기본값을 바꾸는 사람은 이 시험과 문서 두 곳을 같이 고쳐야 한다. 그것이 목적이다. 검증(desktop, 버릴 worktree, :adapter:inbound:grpc:test --tests <클래스>, --rerun --no-build-cache, nice 19, 공유 잠금 아래. 변이는 커밋하지 않았다): - 고치기 전 트리(main 941a0e58) + 기본 drain 2→0 변이: GrpcSafeActivationTest 13개 모두 통과. - 이 브랜치 트리 37b4f375 그대로 3회: 네 클래스 35개 모두 통과. - 37b4f375 + 기본 drain 2→0: 새 시험만 실패. 「Expecting actual: [0, 5] to contain exactly (and in same order): [2, 5]」. - 37b4f375 + 기본 grace 5→6: 새 시험만 실패. 실제 [2, 6]. --- .../inbound/grpc/GrpcSafeActivationTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcSafeActivationTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcSafeActivationTest.java index 4d64f118..795583f6 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcSafeActivationTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcSafeActivationTest.java @@ -139,6 +139,23 @@ class GrpcSafeActivationTest { Duration.ofSeconds(30)); } + @Test + @DisplayName("종료 기본값은 grace 5초 안에서 listener를 연 채 2초 drain한다") + void shutdownDefaultsDrainTwoSecondsInsideAFiveSecondGrace() { + // given — the AGENTS.md table states both values and the README graceful-shutdown item the 2 s + // drain, and a load balancer relies on the drain being on by default. No boot test runs with + // these defaults: the others set the drain to 0 for speed, and the drain test sets its own 6 s + // drain and 8 s grace. + GrpcServerSettings properties = new GrpcServerSettings(); + + // when + var shutdown = + List.of(properties.getShutdownDrainSeconds(), properties.getShutdownGraceSeconds()); + + // then + assertThat(shutdown).containsExactly(2, 5); + } + @Test @DisplayName("drain 대기가 종료 grace보다 길면 기동이 실패한다") void aDrainDelayLongerThanTheShutdownGraceFailsStartup() { -- 2.54.0 From 40a10def4542698b4ce3b7c65747926e351db151 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:13:37 +0900 Subject: [PATCH 3/7] =?UTF-8?q?test(grpc):=20wire=20=EC=8B=9C=ED=97=98?= =?UTF-8?q?=EC=9D=98=20handler=20=EA=B8=B0=EB=A1=9D=EC=9D=84=20=EC=8B=9C?= =?UTF-8?q?=ED=97=98=EB=A7=88=EB=8B=A4=20=EC=83=88=EB=A1=9C=20=EB=91=94?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: GrpcP1BoundaryWireTest는 handler가 쓰는 static 셋을 모든 시험이 나눈다. close handler latch(CLOSE_HANDLER_RAN)는 JVM에서 한 번만 내려가고, 느린 호출 수(SLOW_IN_FLIGHT·SLOW_MAX_IN_FLIGHT)는 앞 시험의 늦은 호출이 다음 시험 값에 섞일 수 있다. 그래서 close handler 시험은 그 시험의 호출이 handler를 돌렸는지를 보지 못한다. close handler를 JVM 첫 호출에만 거는 변이에 그 시험을 두 번 돌리면, 둘째 반복이 첫째가 내린 latch를 보고 통과한다(아래 검증). 고친 것: 셋을 record HandlerTrace 하나로 묶고, static final AtomicReference TRACE를 @BeforeEach가 새것으로 바꾼다. handler는 시작할 때의 TRACE를 잡는다. 시험 본문에 있던 SLOW_MAX_IN_FLIGHT.set(0)은 @BeforeEach가 대신하므로 지운다. 버린 안: TRACE를 volatile static으로 두고 다시 대입하는 것. instance 메서드(@BeforeEach)가 static 필드에 쓰는 꼴이라 SpotBugs ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD(testQualityCheck MEDIUM)에 걸린다. 시험 인스턴스 필드로 옮기는 안은 handler가 static 메서드에서 만들어져 닿지 못한다. 위험·한계: 앞 시험의 호출이 다음 시험의 @BeforeEach 뒤에 시작하면 그 호출은 새 TRACE에 쓴다. context는 ApplicationContextRunner.run() 안에서 동기로 닫히고 남은 handler는 stop()의 shutdownNow()가 interrupt하므로 지금은 그런 호출이 없다. 검증(desktop, 버릴 worktree, :adapter:inbound:grpc:test --tests <클래스>, --rerun --no-build-cache, nice 19, 공유 잠금 아래. 변이는 커밋하지 않았다): 변이: handler가 close handler를 JVM 첫 호출에만 걸고, close handler 시험을 @RepeatedTest(2)로 두 번 돌린다. - 고치기 전 트리(main 941a0e58) + 변이: 두 반복 모두 통과(0.022초씩). 둘째 반복은 첫째가 내린 latch를 봤다. - 이 브랜치 트리 37b4f375 그대로 3회: 네 클래스 35개 모두 통과. - 37b4f375 + 변이: 둘째 반복만 5.03초 뒤 실패. 「Expecting value to be true but was false」(close handler latch를 5초 기다린 결과). --- .../inbound/grpc/GrpcP1BoundaryWireTest.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java index 065a8b20..6d7148d7 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java @@ -45,6 +45,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -74,7 +75,6 @@ class GrpcP1BoundaryWireTest { unaryMethod("CloseHandler"); private static final MethodDescriptor SLOW_METHOD = unaryMethod("Slow"); private static final MethodDescriptor GATED_METHOD = unaryMethod("Gated"); - private static final CountDownLatch CLOSE_HANDLER_RAN = new CountDownLatch(1); /** The platform's GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, which this adapter mirrors. */ private static final int ONE_MIB = 1024 * 1024; @@ -93,8 +93,14 @@ class GrpcP1BoundaryWireTest { /** The longest a gated handler waits, so a test that forgets to release cannot hang the JVM. */ private static final long GATE_CAP_SECONDS = 30; - private static final AtomicInteger SLOW_IN_FLIGHT = new AtomicInteger(); - private static final AtomicInteger SLOW_MAX_IN_FLIGHT = new AtomicInteger(); + /** + * What the feature handlers saw in the current test. Each test starts with a fresh one, and a + * handler takes the one current when it starts, so nothing an earlier test's calls did can pass + * or fail a later test: the close-handler latch counts down only once, and a slow call still + * finishing from an earlier test would count into the in-flight numbers. + */ + private static final AtomicReference TRACE = + new AtomicReference<>(new HandlerTrace()); private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() @@ -109,6 +115,11 @@ class GrpcP1BoundaryWireTest { // production default. In-flight calls still get the shutdown grace. "app.grpc.server.shutdown-drain-seconds=0"); + @BeforeEach + void startAFreshHandlerTrace() { + TRACE.set(new HandlerTrace()); + } + @Test void missingAuthenticationMetadataIsRejectedWithAStableContract() { withChannel( @@ -232,7 +243,7 @@ class GrpcP1BoundaryWireTest { unary(authenticated(channel), CLOSE_HANDLER_METHOD, "ok"); // then - assertThat(await(CLOSE_HANDLER_RAN)).isTrue(); + assertThat(await(TRACE.get().closeHandlerRan())).isTrue(); }); } @@ -347,7 +358,6 @@ class GrpcP1BoundaryWireTest { contextRunner.withPropertyValues("app.grpc.server.max-concurrent-calls-per-connection=1"), channel -> { // given - SLOW_MAX_IN_FLIGHT.set(0); Channel caller = authenticated(channel); CallOptions bounded = CallOptions.DEFAULT.withDeadlineAfter(5, TimeUnit.SECONDS); ListenableFuture first = @@ -360,7 +370,7 @@ class GrpcP1BoundaryWireTest { // then assertThat(responses).containsExactly("slow-done", "slow-done"); - assertThat(SLOW_MAX_IN_FLIGHT.get()).isEqualTo(1); + assertThat(TRACE.get().slowMaxInFlight().get()).isEqualTo(1); }); } @@ -625,7 +635,7 @@ class GrpcP1BoundaryWireTest { ServerCalls.asyncUnaryCall( (String request, StreamObserver observer) -> { ((ServerCallStreamObserver) observer) - .setOnCloseHandler(CLOSE_HANDLER_RAN::countDown); + .setOnCloseHandler(TRACE.get().closeHandlerRan()::countDown); observer.onNext(request); observer.onCompleted(); })) @@ -658,7 +668,8 @@ class GrpcP1BoundaryWireTest { * Context is cancelled — the cooperative behavior a deadline is meant to trigger. */ private static void holdUntilCancelled() { - SLOW_MAX_IN_FLIGHT.accumulateAndGet(SLOW_IN_FLIGHT.incrementAndGet(), Math::max); + HandlerTrace trace = TRACE.get(); + trace.slowMaxInFlight().accumulateAndGet(trace.slowInFlight().incrementAndGet(), Math::max); try { long until = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(SLOW_HANDLER_HOLD_MILLIS); while (System.nanoTime() < until && !Context.current().isCancelled()) { @@ -667,7 +678,7 @@ class GrpcP1BoundaryWireTest { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { - SLOW_IN_FLIGHT.decrementAndGet(); + trace.slowInFlight().decrementAndGet(); } } @@ -694,6 +705,15 @@ class GrpcP1BoundaryWireTest { return false; } + /** Whether the close handler ran, and how many slow calls the handler held at once. */ + private record HandlerTrace( + CountDownLatch closeHandlerRan, AtomicInteger slowInFlight, AtomicInteger slowMaxInFlight) { + + HandlerTrace() { + this(new CountDownLatch(1), new AtomicInteger(), new AtomicInteger()); + } + } + private enum StringMarshaller implements MethodDescriptor.Marshaller { INSTANCE; -- 2.54.0 From 300373293151f5ba9959717793dcf52fd1f7daed Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:13:37 +0900 Subject: [PATCH 4/7] =?UTF-8?q?test(grpc):=20=EC=8B=9C=ED=97=98=EC=9D=B4?= =?UTF-8?q?=20=EB=8B=AB=EC=9D=80=20=EC=B1=84=EB=84=90=EA=B3=BC=20runner.st?= =?UTF-8?q?op()=EC=9D=B4=20=EB=81=9D=EB=82=AC=EB=8A=94=EC=A7=80=20?= =?UTF-8?q?=EB=8B=A8=EC=96=B8=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: GrpcServerRunnerBootTest와 GrpcRequiresPermissionWireTest는 finally에서 채널을 닫고 awaitTermination의 반환값을 버린다. drain 시험은 runner.stop()을 돌린 스레드를 join(20초)하고 그 반환값도 버린다. 채널이 닫히지 않거나 stop()이 걸려도 시험은 기다리기만 하고 통과한다(아래 검증). 남은 채널·스레드는 다음 시험과 Gradle worker에 남는다. 고친 것: - BootTest에 helper close(channel)를 두고 세 곳에서 쓴다. shutdownNow().awaitTermination(5초)이 true인지 「test channel terminated」로 단언한다. - drain 시험의 finally는 stopped = stopping.join(20초) → close(channel) → assertThat(stopped) 순서다. 채널을 먼저 닫고 나서 단언해, stop()이 걸려도 채널은 닫힌다. 20초는 stop()의 상한인 grace 8초 (drain 포함)보다 넉넉하다. - PermissionWireTest의 finally도 awaitTermination 반환값을 같은 메시지로 단언한다. 위험·한계: finally 안의 단언은 try 본문이 이미 실패했을 때 그 실패를 가린다. 채널 shutdownNow()는 진행 중인 호출을 끊고 바로 닫히므로 5초 안에 끝나지 않는 경우는 그 자체가 결함이다. 검증(desktop, 버릴 worktree, :adapter:inbound:grpc:test --tests <클래스>, --rerun --no-build-cache, nice 19, 공유 잠금 아래. 변이는 커밋하지 않았다): 변이 셋: (a) GrpcServerRunner.stop()이 drain보다 25초 더 잔다, (b) BootTest 채널의 shutdownNow()를 지운다, (c) PermissionWireTest 채널의 shutdownNow()를 지운다. - 고치기 전 트리(main 941a0e58): 셋 다 통과. (a) drain 시험이 53.9초 걸리고 통과, (b) skeleton 시험 5.88초 통과, (c) 두 시험 5.95·5.07초 통과. 기다리기만 하고 아무것도 단언하지 않았다. - 이 브랜치 트리 37b4f375 그대로 3회: 네 클래스 35개 모두 통과. - 37b4f375 + (a): drain 시험 실패 「[runner.stop() returned within 20 s] Expecting value to be true but was false」. - 37b4f375 + (b): skeleton 시험 실패 「[test channel terminated]」. - 37b4f375 + (c): 두 시험 모두 실패 「[test channel terminated]」. --- .../grpc/GrpcRequiresPermissionWireTest.java | 4 +++- .../inbound/grpc/GrpcServerRunnerBootTest.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcRequiresPermissionWireTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcRequiresPermissionWireTest.java index 8330d4e6..5fb76590 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcRequiresPermissionWireTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcRequiresPermissionWireTest.java @@ -120,7 +120,9 @@ class GrpcRequiresPermissionWireTest { result[0] = action.apply(channel); } finally { channel.shutdownNow(); - channel.awaitTermination(5, TimeUnit.SECONDS); + assertThat(channel.awaitTermination(5, TimeUnit.SECONDS)) + .as("test channel terminated") + .isTrue(); } }); @SuppressWarnings("unchecked") // the single value action.apply returned diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcServerRunnerBootTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcServerRunnerBootTest.java index 31aef859..a2549ed4 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcServerRunnerBootTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcServerRunnerBootTest.java @@ -73,7 +73,7 @@ class GrpcServerRunnerBootTest { assertThat(listServicesViaReflection(channel)) .contains("grpc.health.v1.Health", "grpc.reflection.v1.ServerReflection"); } finally { - channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + close(channel); } }); } @@ -95,7 +95,7 @@ class GrpcServerRunnerBootTest { .contains("grpc.health.v1.Health", "grpc.reflection.v1.ServerReflection") .doesNotContain("test.Private"); } finally { - channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + close(channel); } }); } @@ -135,8 +135,10 @@ class GrpcServerRunnerBootTest { .as("health answers from the first one other than SERVING, for %s more", HOLD) .containsOnly(ServingStatus.NOT_SERVING.name()); } finally { - stopping.join(Duration.ofSeconds(20)); - channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS); + // stop() takes at most the 8 s grace, drain included; 20 s means it hung. + boolean stopped = stopping.join(Duration.ofSeconds(20)); + close(channel); + assertThat(stopped).as("runner.stop() returned within 20 s").isTrue(); } }); } @@ -168,6 +170,12 @@ class GrpcServerRunnerBootTest { return answers; } + private static void close(ManagedChannel channel) throws InterruptedException { + assertThat(channel.shutdownNow().awaitTermination(5, TimeUnit.SECONDS)) + .as("test channel terminated") + .isTrue(); + } + private static String answer(ManagedChannel channel) { try { return health(channel).name(); -- 2.54.0 From 791bf1a98f29c14632c973f20e314a99bba9d2de Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:13:37 +0900 Subject: [PATCH 5/7] =?UTF-8?q?build(grpc):=20transport=20lane=EC=9D=B4=20?= =?UTF-8?q?GrpcServerRunnerBootTest=EB=8F=84=20=EB=8F=8C=EB=A6=B0=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: lane grpcTransportQualificationTest는 requires에 적은 클래스만 고른다(StrictTestLanePlugin이 includeTestsMatching으로 건다). requires에 GrpcServerRunnerBootTest가 없어 main 단계의 lane은 이 시험을 돌리지 않는다. 그런데 README 「P1 qualification」 절은 종료 drain 동안 listener가 살아 health NOT_SERVING을 답하는 것을 이 시험의 P1 증거로 든다. 증거로 든 시험이 증거 lane에 없다. 고친 것: requires에 GrpcServerRunnerBootTest를 더한다. requires에 든 클래스가 돌지 않으면 lane이 실패하고(StrictTestLanePlugin의 required 검사), 이 lane은 skip도 실패로 친다(rejectSkipped = true). 그래서 이 시험이 lane에서 빠지는 것도 막는다. AGENTS.md 「P1 증거와 한계」에 이 시험이 무엇을 보는지 한 줄을 더한다. 위험·한계: lane 시간이 BootTest만큼(약 6초, drain 시험이 정한다) 는다. 기본 test task는 바뀌지 않는다. 검증(desktop, 버릴 worktree, :adapter:inbound:grpc:grpcTransportQualificationTest, --rerun --no-build-cache, nice 19, 공유 잠금 아래): - 고치기 전 트리(main 941a0e58): rc=0. 결과 폴더 grpcTransportQualificationTest/에 XML 셋(GrpcP1BoundaryWireTest 16, GrpcRequiresPermissionWireTest 2, GrpcSafeActivationTest 13)뿐이고 GrpcServerRunnerBootTest XML이 없다. - 이 브랜치 트리 37b4f375: rc=0. XML 넷. GrpcServerRunnerBootTest는 tests=3 skipped=0 failures=0 errors=0이다. --- src/adapter/inbound/grpc/AGENTS.md | 2 ++ src/adapter/inbound/grpc/build.gradle | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/adapter/inbound/grpc/AGENTS.md b/src/adapter/inbound/grpc/AGENTS.md index 2b4df9b6..07a3f114 100644 --- a/src/adapter/inbound/grpc/AGENTS.md +++ b/src/adapter/inbound/grpc/AGENTS.md @@ -110,6 +110,8 @@ listener 시작이 실패한다. 정책은 `Optional authenticate(Met - `GrpcRequiresPermissionWireTest`: handler가 부른 `@RequiresPermission` 유스케이스를 web 어댑터의 method security와 권한 port가 판정하고, 권한 없는 호출자는 wire에서 `PERMISSION_DENIED` (`AUTHZ_INSUFFICIENT_PERMISSION`)를 받는다. web 어댑터는 이 시험에만 쓰는 `testImplementation`이다. +- `GrpcServerRunnerBootTest`: feature 없이 기동한 서버의 health·reflection, 그리고 종료 drain 동안 listener가 살아 + health `NOT_SERVING`을 답하는지(로드밸런서가 드레이닝과 장애를 가르는 근거). 이 증거는 local insecure unary qualification일 뿐 production-ready 근거가 아니다. TLS/mTLS, external bind, 메서드별 deadline, streaming/backpressure, generated protobuf 호환성은 P2로 남아 있다. diff --git a/src/adapter/inbound/grpc/build.gradle b/src/adapter/inbound/grpc/build.gradle index 473018ad..fa395f81 100644 --- a/src/adapter/inbound/grpc/build.gradle +++ b/src/adapter/inbound/grpc/build.gradle @@ -58,7 +58,8 @@ strictTestLanes { description = 'Runs exact no-skip gRPC conditional transport wire evidence.' requires 'dev.caskeleton.adapter.inbound.grpc.GrpcSafeActivationTest', 'dev.caskeleton.adapter.inbound.grpc.GrpcP1BoundaryWireTest', - 'dev.caskeleton.adapter.inbound.grpc.GrpcRequiresPermissionWireTest' + 'dev.caskeleton.adapter.inbound.grpc.GrpcRequiresPermissionWireTest', + 'dev.caskeleton.adapter.inbound.grpc.GrpcServerRunnerBootTest' rejectSkipped = true } } -- 2.54.0 From b9b3f107385b92e1d766d4343200e0d492ead66b Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:33:53 +0900 Subject: [PATCH 6/7] =?UTF-8?q?test(grpc):=20executor=20=ED=8F=AC=ED=99=94?= =?UTF-8?q?=20=EC=8B=9C=ED=97=98=EC=9D=B4=20SERVER=5FBUSY=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EC=99=80=20retryable=EC=9D=84=20=EB=8B=A8=EC=96=B8?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: README 「P1 qualification과 P2 유보」 절과 시험 DisplayName은 executor·대기열이 넘친 호출이 UNAVAILABLE(SERVER_BUSY)로 닫힌다고 쓴다. 그런데 시험 aCallBeyondTheExecutorAndQueueIsRefusedAtOnceAsServerBusy는 상태 코드 UNAVAILABLE과 분류 문구만 본다. outcome()이 Status.fromThrowable로 trailer를 버리기 때문이다. 그래서 GrpcCallAdmission이 같은 분류(TRANSIENT_DEPENDENCY)의 다른 코드로 닫아도 시험이 통과한다(아래 검증). README 「서버 한도」 절이 쓰는 retryable도 단언하지 않는다. 고친 것: outcome()이 상태 코드·설명과 함께 trailer의 error-code와 error-retryable을 record Outcome에 담는다. 거절된 호출 하나의 (분류 문구, 오류 코드, retryable)이 (TRANSIENT_DEPENDENCY 문구, SERVER_BUSY, "true")인지 한 번에 단언한다. 통과한 두 호출은 trailer 칸이 null이다. 위험·한계: 시험만 바꾼다. 다른 오류 경로 시험은 이미 assertFailure로 error-code를 본다. 검증(desktop, 버릴 worktree, :adapter:inbound:grpc:test --tests *GrpcP1BoundaryWireTest, --rerun --no-build-cache, nice 19, 공유 잠금 아래. 변이는 커밋하지 않았다): 변이 둘: (a) GrpcCallAdmission이 SERVER_BUSY 대신 DB_UNAVAILABLE(같은 분류, 503, retryable)로 닫는다, (b) GrpcStatusMapper가 error-retryable을 늘 "false"로 쓴다. - 고치기 전 트리(273ad3b3): 둘 다 통과(16개, 실패 0). - 고친 트리(f2eaeab3): 변이 없이 3회 16개 통과. (a)·(b) 모두 이 시험 하나만 실패한다. (a)는 오류 코드 DB_UNAVAILABLE, 기대 SERVER_BUSY. (b)는 retryable "false", 기대 "true". --- .../inbound/grpc/GrpcP1BoundaryWireTest.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java index 6d7148d7..c6d350db 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java @@ -3,6 +3,7 @@ package dev.caskeleton.adapter.inbound.grpc; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; import static org.assertj.core.api.Assertions.catchThrowableOfType; +import static org.assertj.core.api.Assertions.tuple; import com.google.common.util.concurrent.ListenableFuture; import dev.caskeleton.shared.error.Category; @@ -398,23 +399,40 @@ class GrpcP1BoundaryWireTest { // when boolean refusedWhileHeld = awaitAnyDone(calls); gate.countDown(); - List outcomes = calls.stream().map(GrpcP1BoundaryWireTest::outcome).toList(); + List outcomes = calls.stream().map(GrpcP1BoundaryWireTest::outcome).toList(); // then assertThat(refusedWhileHeld).as("one call is refused while the others hold").isTrue(); assertThat(outcomes) - .extracting(Status::getCode) + .extracting(Outcome::code) .containsExactlyInAnyOrder(Status.Code.OK, Status.Code.OK, Status.Code.UNAVAILABLE); assertThat(outcomes) - .filteredOn(status -> !status.isOk()) - .extracting(Status::getDescription) - .containsExactly(ClientErrorMessages.of(Category.TRANSIENT_DEPENDENCY)); + .filteredOn(outcome -> outcome.code() != Status.Code.OK) + .extracting(Outcome::description, Outcome::errorCode, Outcome::retryable) + .containsExactly( + tuple( + ClientErrorMessages.of(Category.TRANSIENT_DEPENDENCY), + OperationalError.SERVER_BUSY.code(), + "true")); }); } - private static Status outcome(ListenableFuture call) { + /** How one call ended: its status, and the error trailers the server closed it with. */ + private record Outcome( + Status.Code code, String description, String errorCode, String retryable) {} + + private static Outcome outcome(ListenableFuture call) { Throwable failure = catchThrowable(() -> call.get(GATE_CAP_SECONDS, TimeUnit.SECONDS)); - return failure == null ? Status.OK : Status.fromThrowable(failure); + if (failure == null) { + return new Outcome(Status.Code.OK, null, null, null); + } + Status status = Status.fromThrowable(failure); + Metadata trailers = Status.trailersFromThrowable(failure); + return new Outcome( + status.getCode(), + status.getDescription(), + trailers == null ? null : trailers.get(GrpcStatusMapper.CODE_KEY), + trailers == null ? null : trailers.get(GrpcStatusMapper.RETRYABLE_KEY)); } /** Whether one of {@code calls} completes while the gate still holds the others. */ -- 2.54.0 From 33f5c0e01fd91063174dbdebfd30984640ff8e7e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 20 Nov 2026 22:49:08 +0900 Subject: [PATCH 7/7] =?UTF-8?q?docs(ledger):=20be-test-speed=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EC=9D=98=20=EC=8B=A4=EC=B8=A1=EC=9D=84=20=EB=8D=94?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit be-test-speed(BE-9 시험 지원 코드, BE-10 grpc 시험 설정, JPA claim 대기, grpc 리뷰 넘김)의 실측 줄이 장부에 없다. 작업은 세션 아홉에 걸쳤고 숫자는 각 세션 노트에만 있었다. - 세션 아홉의 기록을 ledger.py usage로 하나씩 뽑아 더했다 (max_context는 가장 큰 세션 값). transcript 칸에 아홉을 쉼표로 적는다. - ledger.py append로 더했다(필수 칸 검사). 위험과 한계: 실측은 2026-11-20 22:48까지의 기록이라 이 PR을 연 뒤의 호출은 들어 있지 않다. 세 값 모두 p80을 넘었고 이유는 why 칸에 있다. (4) JPA TRUNCATE는 이 PR 병합 뒤에 하므로 result는 partial이고, 끝나면 actual 줄을 하나 더한다. 검증: 노트북 scripts/verify.sh docs rc=0(장부 형식 시험 포함). 이 커밋을 포함한 트리로 desktop leaf :adapter:inbound:grpc·pr --no-cache· main. --- docs/ledger/estimates.jsonl | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ledger/estimates.jsonl b/docs/ledger/estimates.jsonl index 9f365ea0..9d291c90 100644 --- a/docs/ledger/estimates.jsonl +++ b/docs/ledger/estimates.jsonl @@ -23,3 +23,4 @@ {"schema": 1, "kind": "estimate", "task": "laptop-runner", "transcript": "27674009-98d8-4e0c-8946-fb1e590c4128", "started_at": "2026-11-20T07:00:00+09:00", "base": "a68ff147be881f6ede908a286c0fbc1f963f2307", "task_kind": "operate", "size": "large", "minutes": {"p30": 66, "p50": 99, "p80": 165}, "calls": {"p30": 165, "p50": 230, "p80": 330}, "output_tokens": {"p30": 145000, "p50": 203000, "p80": 290000}, "basis": "large 선례 7건 실측 중앙값에서 출발, 손 결정 6개·검증 run 3~4개와 대기, 보정 시간 0.55·호출 0.66·출력 0.58 곱함", "recorded_at": "2026-11-20T07:30+09:00"} {"schema": 1, "kind": "actual", "task": "be-ci-next", "transcript": "7f6aac72-543c-4f2a-a47c-550e4c727f99,5ef6a5a6-043b-4872-b8bf-0cc4ce2aee1f,0f7cd6ee-31dc-47e0-b33f-6900d1138d00,2d8f74db-59db-4b0f-970f-202c4a5fc46c,b669ba0e-0219-4098-a956-8479e8a74007,00277f8c-7b41-4984-ab25-6dd8d96e0786,a84946d1-7a15-491a-90fd-a8c21280ef0b", "minutes": 1139, "active_minutes": 485, "calls": 1652, "output_tokens": 1611695, "cache_read_tokens": 329186023, "max_context": 497013, "within": "over", "result": "done", "commits": ["fcd2edf4", "a0166b16", "2cfe2266", "9b76a3b4", "e9ee917f", "72268f30", "7c052142", "58d24346", "946f09bf", "5d9e7372", "3917dc01", "11c63825", "design-docs:45a1c2d", "design-docs:e535319"], "why": "세 값 모두 p80 위(작업 중 485분/254, 호출 1652/470, 출력 1.61M/348K). 예측은 PR 셋이었는데 총괄이 BE-5·BE-6+8과 리뷰가 찾은 고침 둘(#60·#61)을 더해 백엔드 PR 여덟·design-docs PR 둘이 됐다. context 250K 규칙으로 세션 일곱에 나눠 했고, 세션마다 노트·brief를 다시 읽었다. desktop은 runner·다른 세션과 잠금을 나눠 탐침·verify마다 기다렸다. BE-4 탐침의 dead store는 exclude-test.xml(이름 unused)과 Error Prone UnusedVariable 때문에 SpotBugs까지 가지 않아 세 번 고쳐 돌렸다. 다음 예측은 PR 수가 아니라 총괄이 더할 수 있는 고침 몫과 세션 인계 수를 근거로 쓴다. 실측은 2026-11-20 17:28까지 세션 일곱의 기록 합(max_context는 가장 큰 세션)", "recorded_at": "2026-11-20T17:29+09:00"} {"schema": 1, "kind": "actual", "task": "laptop-runner", "transcript": "27674009-98d8-4e0c-8946-fb1e590c4128", "minutes": 115, "active_minutes": 98, "calls": 220, "output_tokens": 329320, "within": "p50", "result": "done", "commits": ["b932d49b7", "1b9fbeb8a", "162c37c9f", "a1b6edccd"], "why": "시간·호출은 p50 안. 출력은 p80(290K) 위: H5로 설치를 묶음+install.sh로 다시 짰고, 리뷰 2라운드와 PR 뒤 도착한 총괄 답 넷(stop 시험·즉시 판단·incident·install 조건)을 반영했다", "recorded_at": "2026-11-20T17:29+09:00"} +{"schema": 1, "kind": "actual", "task": "be-test-speed", "transcript": "46edb129-6c98-443f-b613-4c03a1995124,be35f975-1717-424b-be6e-d61f27431e20,fbf3edef-7c37-4d0d-831f-5e1869ec290c,2cac7b38-fb8e-4c7f-a664-f2b68025fc9b,c1a67390-a2f1-47a2-abf2-b69c1bddc72f,80b376f3-2368-4ed9-b993-334654d8e345,494a6187-4199-47db-a496-45f89ed5a586,6758746a-5e95-4999-9266-db165c5ece4c,b12d8138-aca2-4be2-8e15-bb4db5f431e2", "minutes": 992, "active_minutes": 277, "calls": 945, "output_tokens": 928115, "cache_read_tokens": 161892768, "max_context": 378335, "within": "over", "result": "partial", "commits": ["e9a57f95", "7de08bc3", "8259d0ca", "4db443e7", "120093a0", "e5558f25", "142b5265", "2f863c33", "40a10def", "30037329", "791bf1a9", "b9b3f107"], "why": "세 값 모두 p80 위(작업 중 277분/187, 호출 945/297, 출력 0.93M/203K). 예측은 PR 둘(BE-9·BE-10)이었는데 JPA claim 대기(#64)와 grpc 넘김 PR이 더해져 넷이 됐다. 리뷰가 넘긴 고침도 더해졌다(lease fencing, grpc 넘김의 다섯과 그 확인 리뷰의 셋). context 규칙으로 세션 아홉에 나눠 했고 세션마다 인계를 다시 읽었다. desktop 잠금을 다른 세션과 나눠 탐침·verify마다 기다렸다(RED 묶음은 다른 세션의 verify.sh merge 뒤로 11분). 다음 예측은 PR 수가 아니라 리뷰가 넘길 고침 몫과 세션 인계 수를 근거로 쓴다. 결과는 partial: (4) JPA TRUNCATE는 (3) grpc PR 병합 뒤에 하므로 이 줄에 없고, 끝나면 actual 줄을 하나 더한다. 실측은 2026-11-20 22:48까지 세션 아홉의 기록 합(max_context는 가장 큰 세션)", "recorded_at": "2026-11-20T22:48+09:00"} -- 2.54.0