pr / done (pull_request) Successful in 1m42s
scripts/verify-compose-profile-contracts.sh는 prCheck의 게이트인데 판정 열 가지가 셸 안의 jq라 시험이 없다. 고장 난 입력을 넣어 보면 넷이 통과한다. - 계약의 lanes가 비면 lane 반복이 돌지 않고 "all 0 lanes match"로 끝난다. - persistence-jpa를 켠 lane에 expectedPersistenceVendor가 없으면 통과한다. smoke는 보고된 vendor를 그 칸과 비교하니 그 lane은 매번 실패한다. - heap dump 경로는 짧은 `tmpfs:` 목록의 같은 항목만 비교한다. 위 디렉터리의 tmpfs(/var/tmp)나 long syntax `type: tmpfs` volume은 통과한다. - Redis 계정을 이름 그대로가 아니라 정규식으로 찾아 `.`이 아무 글자와 맞는다. `ca.skeleton-application`을 가리키는 lane이 `ca-skeleton-application` 줄로 통과한다. 판정을 scripts/compose-contract-verdict.py로 옮긴다. 셸은 docker만 부른다. `version`으로 Compose 하한을 먼저 보고, `lanes`가 준 lane별 인자로 `config --services`와 `config --format json`을 돌려 출력과 rc를 파일에 쓴다. rc는 조건 밖에서 읽는다. 그다음 `judge`가 그 디렉터리를 읽는다. 판정은 위 넷을 실패로 보고, 파일 없는 lane, 겹치는 id, smoke가 읽는 목록이 없거나 그 목록에 이름이 아닌 원소가 든 lane, 셸이 렌더 기록을 남기지 않은 lane도 실패로 본다. docker 호출의 stdin은 /dev/null이라 lane 목록을 먹지 않는다. scripts/tests/test_compose_contract_verdict.py가 판정마다 고장 난 입력과 정상 입력을 보고, 셸을 가짜 docker로 돌려 lane 인자·rc 기록·판정 rc를 본다. prCheck의 testDocumentChecks가 돌린다. 루트 build.gradle의 주석은 PR 단계 Exec 태스크마다 시험 파일을 적어 사실과 맞춘다. 버린 안: 모델 JSON의 service key로 `config --services`를 대신하기. 렌더를 한 번 줄이지만 지금 lane 결과와 같은지 따로 보여야 해서 두 호출을 그대로 둔다. bats는 desktop과 runner 둘 다에 새 도구를 깔아야 한다. 위험·한계: 판정이 jq와 다른 곳은 위 넷 말고도 있다. main이 통과시키고 이제 실패로 보는 것: 같은 사용자를 두 줄에서 켠 ACL(Redis가 거절한다), 값이 null·false인 realm의 `_` key, 최상위 값이 둘인 realm, LANE_ID 꼴이 아닌 id, 빈 springRuntime, `files`가 없는 lane, 이름이 아닌 목록 원소, 읽을 수 없는 Compose 버전. main이 실패시키고 이제 통과하는 것: ACL 줄의 겹친 공백과 CRLF, 끝에 `/`가 붙은 bind target, 로캘에 따라 달라지던 service 정렬, list 꼴 environment, 파일 하나로 bind mount한 ACL(target이 --aclfile 경로와 같음). Redis가 ACL 줄의 `\r`와 겹친 공백을 받아들인다는 것은 acl.c를 열어 보지 않은 판단이다. 실제 계약 18 lane에서는 main과 이 트리의 출력 줄이 같다(PR 본문). 검증: 노트북 `python3 -m unittest discover -s scripts/tests` 275개 통과. 판정의 빈 lane 거절·vendor 검사·heap 상위 tmpfs·long syntax tmpfs·비밀번호 글자 비교· 정확한 service 집합·사용자 이름 비교·렌더 기록 없음·파일 없는 lane·목록 원소 검사를 되돌리거나, judge_lane에서 판정 하나를 빼거나 realm 판정을 빼거나, 셸의 두 렌더 rc를 `|| true`로 삼키거나, docker가 stdin을 읽게 두거나, judge 호출을 지우거나 `|| true`로 바꾸거나, version 실패를 무시하거나, profile 인자를 빼면 새 시험이 실패한다(변이 23개 모두). desktop RED·GREEN과 prCheck 결과는 PR 본문에 있다. Refs: REV-BE-0016
87 lines
5.5 KiB
Bash
Executable File
87 lines
5.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The static half of the Compose contract: every lane renders, and renders exactly what it claims.
|
|
#
|
|
# Called by: the pull-request stage `prCheck` (`verifyComposeProfiles`, root build.gradle) and
|
|
# scripts/run-compose-runtime-smoke.sh before it starts the lanes.
|
|
#
|
|
# This file keeps the docker calls and nothing else. Which lanes to render and with which files and
|
|
# profiles, and every judgement below, are scripts/compose-contract-verdict.py, whose cases in
|
|
# scripts/tests try each judgement on broken input without Docker. Each judgement used to be jq here,
|
|
# and a jq branch could not be tried on a broken input: an empty lane list passed as "all 0 lanes
|
|
# match", and so did a JPA lane with no expected vendor and a heap dump path under a tmpfs.
|
|
#
|
|
# Ten things are checked, and each exists because assuming it cost something:
|
|
#
|
|
# 1. the Compose version, because `!override` is what stops the dev overlay's tmpfs merging with
|
|
# the base's and colliding with a bind mount, and it needs 2.24.4;
|
|
# 2. the exact service set per lane — exact, not a superset, because a lane that quietly gains a
|
|
# service is a lane whose evidence describes a different stack than the one that ran;
|
|
# 3. the rendered SPRING_PROFILES_ACTIVE, because a Compose profile selects services and says
|
|
# nothing about which environment the application thinks it is in;
|
|
# 4. mount-target uniqueness in the merged model, because that collision is exactly what made the
|
|
# dev stack unrenderable and "the syntax looks right" is not the same as "the targets are
|
|
# distinct";
|
|
# 5. the service-role partition, because a service the lane renders and files under no role is
|
|
# started by nothing and checked by nothing, and a one-shot filed as a --wait target hangs the
|
|
# lane for its full timeout on a container that was built to exit;
|
|
# 6. the expected application report (expectedCapabilitiesOn, expectedPersistenceVendor) names
|
|
# only catalogued capabilities and a vendor that agrees with persistence-jpa, because an
|
|
# expectation the application cannot report fails every run of the lane;
|
|
# 7. a lane that switches Redis on authenticates as an account its Redis provisions, because the
|
|
# lanes ran Redis open and the application anonymous, and the two startup warnings that trade
|
|
# prints failed the "startup is silent" check of every such lane (r3-J). Lowering that warning
|
|
# would hide the same trade in production; the lane has to look like a deployment instead.
|
|
# 8. a lane's appMemoryLimit, when it has one, is a Compose memory size, because the smoke wrapper
|
|
# writes it into the application's mem_limit and a malformed one fails only at `up`.
|
|
# 9. the application's heap dump path (-XX:HeapDumpPath in the Dockerfile) is on no tmpfs, neither
|
|
# one at that path nor one at a directory above it, because a tmpfs is charged to the
|
|
# container's memory limit and is gone once the container exits: the dump written at an
|
|
# OutOfMemoryError could only push the container into an OOM kill and was never there to read
|
|
# (2026-11-12 review).
|
|
# 10. the Keycloak realm artifact carries no key Keycloak refuses to deserialize, because the import
|
|
# fails on one and the container exits before the lane reaches what it was testing.
|
|
#
|
|
# Static only. Nothing starts here; scripts/run-compose-runtime-smoke.sh owns that.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
CONTRACTS="${REPO_ROOT}/src/bootstrap/app/compose-lanes/compose-profile-contracts.json"
|
|
VERDICT="${REPO_ROOT}/scripts/compose-contract-verdict.py"
|
|
|
|
command -v python3 >/dev/null 2>&1 || { echo "python3 is required" >&2; exit 78; }
|
|
command -v docker >/dev/null 2>&1 || { echo "docker is required" >&2; exit 78; }
|
|
[[ -r "${CONTRACTS}" ]] || { echo "missing ${CONTRACTS}" >&2; exit 78; }
|
|
cd "${REPO_ROOT}"
|
|
|
|
RENDERED="$(mktemp -d "${TMPDIR:-/tmp}/compose-contract.XXXXXX")"
|
|
trap 'rm -rf "${RENDERED}"' EXIT
|
|
|
|
# 1. The version is judged before anything renders: an older Compose fails the dev overlay's render
|
|
# with a merge error that says nothing about the version.
|
|
compose_version="$(docker compose version --short)"
|
|
python3 "${VERDICT}" version "${CONTRACTS}" "${compose_version}"
|
|
|
|
# Every lane the contract lets the verdict render, as its id and its `docker compose` arguments. A
|
|
# lane it cannot render (no files, an unknown file) is not listed; `judge` reports it.
|
|
python3 "${VERDICT}" lanes "${CONTRACTS}" >"${RENDERED}/lanes.tsv"
|
|
|
|
# Each call's output and exit status go to files, and the status is read outside any condition so a
|
|
# failed render is recorded as itself. stderr of `config --services` goes to its own file rather than
|
|
# into the list: merged with `2>&1`, Compose's warning about an unset interpolation variable arrived
|
|
# as an extra "service" and twelve lanes failed with a log line in place of a container name.
|
|
# stdin is /dev/null: the loop reads the lane list from stdin, and a call that read it would leave
|
|
# the lanes after it without a record.
|
|
while IFS=$'\t' read -r -a fields; do
|
|
lane="${RENDERED}/${fields[0]}"
|
|
args=("${fields[@]:1}")
|
|
status=0
|
|
docker compose "${args[@]}" config --services </dev/null >"${lane}.services" 2>"${lane}.services.err" || status=$?
|
|
echo "${status}" >"${lane}.services.rc"
|
|
status=0
|
|
docker compose "${args[@]}" config --format json </dev/null >"${lane}.json" 2>"${lane}.json.err" || status=$?
|
|
echo "${status}" >"${lane}.json.rc"
|
|
done <"${RENDERED}/lanes.tsv"
|
|
|
|
# 2-10, and the shape of every lane.
|
|
python3 "${VERDICT}" judge "${CONTRACTS}" "${RENDERED}"
|