From e1f4fb4cfa44e3ed05a6fbbae029004cd073522c Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 22 Nov 2026 21:58:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix(verify):=20=EC=9B=90=EA=B2=A9=20?= =?UTF-8?q?=EB=8B=A8=EA=B3=84=EC=97=90=20=EB=B9=88=20stdin=EC=9D=84=20?= =?UTF-8?q?=EC=A4=98=20=EC=8B=A4=ED=8C=A8=EA=B0=80=20rc=3D0=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=81=9D=EB=82=98=EC=A7=80=20=EC=95=8A=EA=B2=8C=20?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --on으로 보내는 원격 스크립트는 bash -s의 stdin으로 들어간다. 단계 안 프로세스가 stdin을 읽으면 그 뒤에 남은 합계, verify: rc= 줄, exit를 먹는다. bash는 EOF로 끝나고 마지막 pipeline인 tee의 rc 0을 돌려준다. nightly와 round가 부르는 compose smoke의 docker compose exec -T가 stdin을 읽는 명령이라, 두 단계의 실패가 바깥 rc=0으로 보일 수 있다. 단계 pipeline의 첫 명령 묶음에 `)로 안다. +도는지, 단계의 rc가 그대로 나가는지, 단계가 stdin을 읽어도 합계·rc 줄과 그 rc로 끝나는지 본다. 잠금 대기는 Linux +`/proc/locks`의 대기 줄(`->`)로 안다. python3 -m unittest discover -s scripts/tests """ @@ -220,6 +221,13 @@ with open(sys.argv[sys.argv.index("--classes") + 1], "w", encoding="utf-8") as c classes.write("this run\\n") """ +# Stands in for run-compose-runtime-smoke.sh: reads its stdin to the end, as `docker compose exec -T` does, and +# ends with the rc the test chose. +FAKE_SMOKE = """#!/bin/sh +cat > /dev/null +exit "${FAKE_SMOKE_RC:-0}" +""" + LEAF = ":adapter:outbound:sample" RUN_LIMIT = 60 # seconds a run may take once nothing holds it back @@ -233,6 +241,8 @@ class RemoteLogTest(ThrowawayRepoTest): def setUp(self) -> None: super().setUp() self.write("scripts/junit-summary.py", FAKE_SUMMARY) + self.write("scripts/run-compose-runtime-smoke.sh", FAKE_SMOKE) + self.write("scripts/ci/verify-configuration-cache.sh", "exit 0\n") # round runs it before the smoke self.write("gradle/modules.json", f'{{"modules": [{{"gradle_path": "{LEAF}"}}]}}\n') self.write("gradlew", FAKE_GRADLEW) (self.repo / "gradlew").chmod(0o755) @@ -457,6 +467,25 @@ class RemoteLogTest(ThrowawayRepoTest): # then self.assertEqual((result.returncode, self.log().splitlines()[-1]), (3, "verify: rc=3"), result.stderr) + def assert_a_stdin_reading_stage_ends_with(self, rc: int) -> None: + """REV-BE-0050. The remote script is the stdin of `bash -s`: a stage that reads its stdin must not get + the lines after it (summary, rc line, exit).""" + for stage in ("nightly", "round"): + with self.subTest(stage=stage): + # when + result = self.run_stage(stage, FAKE_SMOKE_RC=str(rc)) + + # then + log = self.log(stage) + end = re.search(r"^summary: .*\nverify: rc=(\d+)\n\Z", log, re.MULTILINE) + self.assertEqual((result.returncode, end and end.group(1)), (rc, str(rc)), log + result.stderr) + + def test_a_stage_that_reads_stdin_and_fails_ends_with_the_summary_and_its_rc(self) -> None: + self.assert_a_stdin_reading_stage_ends_with(3) + + def test_a_stage_that_reads_stdin_and_passes_ends_with_the_summary_and_its_rc(self) -> None: + self.assert_a_stdin_reading_stage_ends_with(0) + if __name__ == "__main__": unittest.main() diff --git a/scripts/verify.sh b/scripts/verify.sh index 32533ab9..83fc77d3 100755 --- a/scripts/verify.sh +++ b/scripts/verify.sh @@ -183,11 +183,13 @@ fi echo "verify: 잠금을 얻었다" >&2 || exit 4 rm -f ~/$log-logs/$stage-classes.tsv # 단계가 합계 전에 끊겨도 지난 실행의 목록이 새 로그 옆에 남지 않는다 # 첫 줄은 이 로그가 어느 트리·기준의 실행인지, 둘째 줄은 단계 직전 부하다. +# 이 스크립트가 bash -s의 stdin이다. 단계 안 프로세스(docker compose exec -T 등)가 읽으면 아래 합계·rc·exit 줄을 먹고 +# bash가 tee의 rc 0으로 끝나므로 단계에는 빈 stdin을 준다(REV-BE-0050). { echo "verify: tree $tree base $base $stage${target:+ $target} \$(date '+%Y-%m-%dT%H:%M:%S%z')" echo "verify: \$(uptime)" VERIFY_LOCKED=1 ./scripts/verify.sh $stage $target --on here ${NO_CACHE[*]} -} 2>&1 | tee ~/$log-logs/$stage.log +} &1 | tee ~/$log-logs/$stage.log rc=\${PIPESTATUS[0]} # 새 worktree라 여기 있는 JUnit XML은 모두 이번 실행의 것이다. worktree를 지우면 XML도 사라지므로 그 전에 합계를 # 로그에 쓰고, lane(태스크)별로 돈 클래스 목록을 로그 폴더에 남긴다(docs/work/reference/gates.md 4절). -- 2.54.0 From 0a25e3a23d3d3795b71fc0edddf01c9507d4b92b Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 22 Nov 2026 22:06:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test(verify):=20=EB=B9=88=20stdin=EC=9D=B4?= =?UTF-8?q?=20smoke=EB=A7=8C=EC=9D=B4=20=EC=95=84=EB=8B=88=EB=9D=BC=20?= =?UTF-8?q?=EB=8B=A8=EA=B3=84=20=EC=A0=84=EC=B2=B4=EC=97=90=20=EA=B1=B8?= =?UTF-8?q?=EB=A6=AC=EB=8A=94=EC=A7=80=20=EC=8B=9C=ED=97=98=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit stdin을 읽는 가짜가 smoke 하나라, /dev/null if flock -n -s "$FAKE_LOCK" true; then echo "stage: lock free"; else echo "stage: lock held"; fi exit "${FAKE_STAGE_RC:-0}" """ @@ -467,24 +468,30 @@ class RemoteLogTest(ThrowawayRepoTest): # then self.assertEqual((result.returncode, self.log().splitlines()[-1]), (3, "verify: rc=3"), result.stderr) - def assert_a_stdin_reading_stage_ends_with(self, rc: int) -> None: + def assert_a_stdin_reading_stage_ends_with(self, rc: int, stage: str, **child: str) -> None: """REV-BE-0050. The remote script is the stdin of `bash -s`: a stage that reads its stdin must not get the lines after it (summary, rc line, exit).""" + # when + result = self.run_stage(stage, **child) + + # then + log = self.log(stage) + end = re.search(r"^summary: .*\nverify: rc=(\d+)\n\Z", log, re.MULTILINE) + self.assertEqual((result.returncode, end and end.group(1)), (rc, str(rc)), log + result.stderr) + + def test_a_smoke_that_reads_stdin_and_fails_ends_with_the_summary_and_its_rc(self) -> None: + for stage in ("nightly", "round"): # the two stages that run the smoke + with self.subTest(stage=stage): + self.assert_a_stdin_reading_stage_ends_with(3, stage, FAKE_SMOKE_RC="3") + + def test_a_smoke_that_reads_stdin_and_passes_ends_with_the_summary_and_its_rc(self) -> None: for stage in ("nightly", "round"): with self.subTest(stage=stage): - # when - result = self.run_stage(stage, FAKE_SMOKE_RC=str(rc)) + self.assert_a_stdin_reading_stage_ends_with(0, stage, FAKE_SMOKE_RC="0") - # then - log = self.log(stage) - end = re.search(r"^summary: .*\nverify: rc=(\d+)\n\Z", log, re.MULTILINE) - self.assertEqual((result.returncode, end and end.group(1)), (rc, str(rc)), log + result.stderr) - - def test_a_stage_that_reads_stdin_and_fails_ends_with_the_summary_and_its_rc(self) -> None: - self.assert_a_stdin_reading_stage_ends_with(3) - - def test_a_stage_that_reads_stdin_and_passes_ends_with_the_summary_and_its_rc(self) -> None: - self.assert_a_stdin_reading_stage_ends_with(0) + def test_a_gradle_that_reads_stdin_and_fails_ends_with_the_summary_and_its_rc(self) -> None: + # pr has no smoke: an empty stdin given to the smoke alone does not pass this + self.assert_a_stdin_reading_stage_ends_with(3, "pr", FAKE_STAGE_READS_STDIN="1", FAKE_STAGE_RC="3") if __name__ == "__main__": -- 2.54.0