Проверять запущенный TTL-контейнер при таймауте Compose Desktop

This commit is contained in:
2026-11-01 17:15:45 +03:00
parent 412b1bb09d
commit 8846b0554e
2 changed files with 19 additions and 3 deletions
+1
View File
@@ -3,3 +3,4 @@
*.sql text eol=lf
*.yaml text eol=lf
*.cfg text eol=lf
evidence/* -whitespace
+18 -3
View File
@@ -66,12 +66,27 @@ def main():
print("Checking short session expiry and indexed history", flush=True)
ttl_name = config["name"] + "-ttl-check"
assert not command(["docker", "ps", "-a", "--filter", "name=^/" + ttl_name + "$", "--format", "{{.ID}}"])
created = False
try:
compose("run", "-d", "--no-deps", "--name", ttl_name, "-e", "SESSION_TTL_SECONDS=2", "api")
try:
compose("run", "-d", "--no-deps", "--name", ttl_name,
"-e", "SESSION_TTL_SECONDS=2", "api", timeout=45)
except subprocess.TimeoutExpired:
# A detached Compose command on Desktop can time out after Docker
# already started its container. Inspect the unique name rather
# than create another process or treat an unknown startup as PASS.
row = json.loads(command(["docker", "inspect", ttl_name]))[0]
labels = row["Config"]["Labels"]
assert labels["com.docker.compose.project"] == config["name"]
assert labels["com.docker.compose.service"] == "api"
assert "SESSION_TTL_SECONDS=2" in row["Config"]["Env"]
assert row["State"]["Running"], "TTL container did not start"
created = True
checks("expiry.txt", "env", "EXPIRY_BASE_URL=http://" + ttl_name + ":8080", "python", "scripts/check_expiry.py")
finally:
command(["docker", "stop", "--time", "6", ttl_name])
command(["docker", "rm", ttl_name])
if created:
command(["docker", "stop", "--time", "6", ttl_name])
command(["docker", "rm", ttl_name])
checks("explain-run.txt", "make", "explain")
checks("smoke-final.txt", "make", "test")
saved("published-smoke.txt", [sys.executable, "-X", "utf8", "tests/smoke.py", "--base-url", base_url])