From 95b8270bab73fb339f89fe2bbb431010f9a89402 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 19 Nov 2026 01:03:36 +0900 Subject: [PATCH 1/2] =?UTF-8?q?test(messaging):=20Kafka=20=EC=8B=9C?= =?UTF-8?q?=ED=97=98=EC=9D=B4=20=EC=93=B0=EB=8A=94=20=EC=A4=91=EC=9D=B8=20?= =?UTF-8?q?=EA=B8=B0=EB=8F=99=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=8B=A4=ED=96=89=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: Testcontainers 2.0.5 KafkaContainer는 컨테이너를 `while [ ! -f /tmp/testcontainers_start.sh ]; do sleep 0.1; done; /tmp/testcontainers_start.sh`로 띄운 뒤 containerIsStarting에서 그 스크립트를 복사한다. 반복문은 파일이 생기자마자 실행하므로, 복사가 아직 파일을 쓰고 있으면 실행이 ETXTBSY(Text file busy)로 실패하고 셸이 126으로 끝난다. main run 330의 InboxRedeliveryIntegrationTest > initializationError (Container exited with code 126)가 이것이다. upstream testcontainers-java #11682는 열려 있고 고친 버전이 없다. 저장소에서 이 기동을 쓰는 곳은 두 시험뿐이다. 방법: 두 시험이 생성 직후 withCommand로 기동 명령을 덮어쓴다. 스크립트의 마지막 줄(`/etc/kafka/docker/run`)이 보일 때까지 grep으로 기다린 뒤 `exec bash <스크립트>`로 읽어 실행한다. 스크립트를 exec하지 않으니 ETXTBSY가 생길 수 없고, 마지막 줄까지 쓰인 뒤에만 읽는다. TC 2.0.5는 기동 명령을 생성자에서만 정하고 configure()는 listener만 바꾸므로(jar javap) 덮어쓴 명령이 남는다. 버린 대안: 공유 helper나 표시 파일을 복사하는 하위 클래스 — 두 leaf가 나눠 쓰려면 messaging-kafka에 testFixtures가 생기고 lockfile·registry 확인이 는다. 두 곳 같은 한 줄이라 각자 둔다. withStartupAttempts 재시도는 흔들림을 가리고, TC 올리기는 고친 버전이 없다. 위험·한계: TC가 스크립트 마지막 줄을 바꾸면 grep이 끝나지 않아 기동 대기 60초에서 실패한다. 조용히 통과하지 않는다(아래 변이). RED는 결정적으로 못 만든다. 원래 반복문은 sleep 0.1 덕에 docker CLI 탐침(고정 이미지, nproc 부하)에서 100회 중 0회 실패였다. 대신 sleep만 뺀 원래 반복문이 50회 중 42회 실패(모두 exit 126, Text file busy)했고, 고친 방식은 sleep 없이 100/100, sleep 0.1로 50/50 통과했다. 다른 이미지를 주면 grep·bash·sleep이 있어야 한다. 고정 이미지와 apache/kafka-native:4.1.0에 모두 있다. 검증: desktop 트리 1b3a97e2(이 커밋과 Java 같음), --no-build-cache. 두 leaf spotlessCheck·compileIntegrationTestJava·testQualityCheck rc=0. 두 lane --rerun 10회 rc=0(시험 inbox 3·relay 2, 실패·skip 0, 부하 5~15). nproc 부하 아래 3회 rc=0(부하 19~26). 변이: grep 패턴을 없는 줄로 바꾸면 두 lane 모두 initializationError(Timed out waiting for log output). 로그 desktop ~/be-kafka-126-logs/k1.log. Refs: testcontainers-java #11682 --- .../messaging/InboxRedeliveryIntegrationTest.java | 13 ++++++++++++- .../relay/ApplicationRelayKafkaIntegrationTest.java | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/adapter/inbound/messaging/src/integrationTest/java/dev/caskeleton/adapter/inbound/messaging/InboxRedeliveryIntegrationTest.java b/src/adapter/inbound/messaging/src/integrationTest/java/dev/caskeleton/adapter/inbound/messaging/InboxRedeliveryIntegrationTest.java index 4f4d911b..beaa261d 100644 --- a/src/adapter/inbound/messaging/src/integrationTest/java/dev/caskeleton/adapter/inbound/messaging/InboxRedeliveryIntegrationTest.java +++ b/src/adapter/inbound/messaging/src/integrationTest/java/dev/caskeleton/adapter/inbound/messaging/InboxRedeliveryIntegrationTest.java @@ -91,7 +91,18 @@ class InboxRedeliveryIntegrationTest { @BeforeAll static void startInfrastructure() { - kafka = new KafkaContainer(System.getProperty("ca.test.image.kafka")); + // Testcontainers' own start command execs /tmp/testcontainers_start.sh as soon as the file + // exists, while the copy can still hold it open for writing: ETXTBSY, exit 126 (main run 330; + // testcontainers-java #11682, open, no fixed version). This one waits for the script's last + // line and lets bash read it instead of exec'ing it, so the race is gone. If a Testcontainers + // upgrade changes that line, the start times out instead of passing by luck. + kafka = + new KafkaContainer(System.getProperty("ca.test.image.kafka")) + .withCommand( + "sh", + "-c", + "while ! grep -qs '^/etc/kafka/docker/run' /tmp/testcontainers_start.sh;" + + " do sleep 0.1; done; exec bash /tmp/testcontainers_start.sh"); postgres = new PostgreSQLContainer(System.getProperty("ca.test.image.postgres-16")); kafka.start(); postgres.start(); diff --git a/src/adapter/outbound/messaging-kafka/src/integrationTest/java/dev/caskeleton/adapter/outbound/messaging/kafka/relay/ApplicationRelayKafkaIntegrationTest.java b/src/adapter/outbound/messaging-kafka/src/integrationTest/java/dev/caskeleton/adapter/outbound/messaging/kafka/relay/ApplicationRelayKafkaIntegrationTest.java index d6ee97a3..ba002b72 100644 --- a/src/adapter/outbound/messaging-kafka/src/integrationTest/java/dev/caskeleton/adapter/outbound/messaging/kafka/relay/ApplicationRelayKafkaIntegrationTest.java +++ b/src/adapter/outbound/messaging-kafka/src/integrationTest/java/dev/caskeleton/adapter/outbound/messaging/kafka/relay/ApplicationRelayKafkaIntegrationTest.java @@ -70,9 +70,20 @@ class ApplicationRelayKafkaIntegrationTest { @BeforeAll static void startBroker() throws Exception { + // Testcontainers' own start command execs /tmp/testcontainers_start.sh as soon as the file + // exists, while the copy can still hold it open for writing: ETXTBSY, exit 126 (main run 330; + // testcontainers-java #11682, open, no fixed version). This one waits for the script's last + // line and lets bash read it instead of exec'ing it, so the race is gone. If a Testcontainers + // upgrade changes that line, the start times out instead of passing by luck. kafka = new KafkaContainer( - System.getProperty("relayLane.kafkaImage", System.getProperty("ca.test.image.kafka"))); + System.getProperty( + "relayLane.kafkaImage", System.getProperty("ca.test.image.kafka"))) + .withCommand( + "sh", + "-c", + "while ! grep -qs '^/etc/kafka/docker/run' /tmp/testcontainers_start.sh;" + + " do sleep 0.1; done; exec bash /tmp/testcontainers_start.sh"); kafka.start(); Properties admin = new Properties(); admin.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); -- 2.54.0 From d443c60ca7b4dfa461548e781db63a25beebd481 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 19 Nov 2026 01:03:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?docs(ledger):=20Kafka=20=EA=B8=B0=EB=8F=99?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EA=B2=BD=ED=95=A9=20?= =?UTF-8?q?=ED=9D=94=EB=93=A4=EB=A6=BC=EC=9D=84=20=EC=9E=A5=EB=B6=80?= =?UTF-8?q?=EC=97=90=20=EB=82=A8=EA=B8=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: main run 330의 InboxRedeliveryIntegrationTest#initializationError (Kafka 기동 exit 126, 범주 concurrency-order)가 흔들림 장부에 없다. CI 매뉴얼 8.5절은 흔들림 하나마다 한 줄을 남기게 한다. 방법: runner 기록(같은 날 3회 중 1회 실패)과 docker CLI 탐침 결과로 한 줄을 더한다. lane 반복은 고치기 전 트리에서 돌리지 않았다고 적는다. fixed_by는 장부 README대로 고친 PR이 병합된 뒤 채운다. 검증: 노트북 `python3 -m unittest scripts/tests/test_ledger.py` rc=0, `python3 scripts/check-docs.py`·`check-work-docs.py` rc=0. --- docs/ledger/flaky-tests.jsonl | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ledger/flaky-tests.jsonl b/docs/ledger/flaky-tests.jsonl index fd43a389..16dc06db 100644 --- a/docs/ledger/flaky-tests.jsonl +++ b/docs/ledger/flaky-tests.jsonl @@ -3,3 +3,4 @@ {"date": "2026-11-13", "test": "FailureInjectionContractTest#aSlowDripThroughToxiproxyEndsAtTheTotalDeadline[JDK]", "category": "fixed-time", "first_run": "228", "verdict": "runner 1회 실패(1.92초, 상한 1.5초). desktop 부하 6.5~8에서 10회 통과(호출 1,010~1,021ms)", "quarantined_until": "", "fixed_by": "백엔드 #34"} {"date": "2026-11-13", "test": "LiveEventLogContractTest#concurrentWritersAllocateDistinctPositions", "category": "concurrency-order", "first_run": "260", "verdict": "replay 순서를 writer 제출 순서로 단언했다. 둘째 writer를 먼저 돌린 탐침에서 재현. 고침 PR 백엔드 #39(열림)", "quarantined_until": "", "fixed_by": ""} {"date": "2026-11-13", "test": "JettyAttemptDeadlineTest#aSlowDripExchangeIsAbortedAtTheAttemptDeadline", "category": "fixed-time", "first_run": "desktop ~/w2-reloc-logs/w2-reloc-a.log (main c7a18ec7, prCheck, 시작 부하 11~15)", "verdict": "desktop 1회 실패(1.68초, 상한 1.5초). PR 단계 test라 runner PR run에서도 날 수 있다", "quarantined_until": "", "fixed_by": ""} +{"date": "2026-11-18", "test": "InboxRedeliveryIntegrationTest#initializationError", "category": "concurrency-order", "first_run": "330", "verdict": "runner 같은 날 3회 중 1회 실패(nightly 324·main 327 통과). Kafka 기동 반복문이 복사가 끝나기 전의 스크립트를 실행해 exit 126(testcontainers-java #11682). lane 반복은 돌리지 않았다. docker CLI 탐침으로 부하 아래 원래 반복문 100회 중 0회 실패, sleep 뺀 반복문 50회 중 42회 실패(모두 exit 126, Text file busy)", "quarantined_until": "", "fixed_by": ""} -- 2.54.0