forked from mtusi2026/mtusi2026lab3
Проверять запущенный TTL-контейнер при таймауте Compose Desktop
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
*.sql text eol=lf
|
*.sql text eol=lf
|
||||||
*.yaml text eol=lf
|
*.yaml text eol=lf
|
||||||
*.cfg text eol=lf
|
*.cfg text eol=lf
|
||||||
|
evidence/* -whitespace
|
||||||
|
|||||||
+18
-3
@@ -66,12 +66,27 @@ def main():
|
|||||||
print("Checking short session expiry and indexed history", flush=True)
|
print("Checking short session expiry and indexed history", flush=True)
|
||||||
ttl_name = config["name"] + "-ttl-check"
|
ttl_name = config["name"] + "-ttl-check"
|
||||||
assert not command(["docker", "ps", "-a", "--filter", "name=^/" + ttl_name + "$", "--format", "{{.ID}}"])
|
assert not command(["docker", "ps", "-a", "--filter", "name=^/" + ttl_name + "$", "--format", "{{.ID}}"])
|
||||||
|
created = False
|
||||||
try:
|
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")
|
checks("expiry.txt", "env", "EXPIRY_BASE_URL=http://" + ttl_name + ":8080", "python", "scripts/check_expiry.py")
|
||||||
finally:
|
finally:
|
||||||
command(["docker", "stop", "--time", "6", ttl_name])
|
if created:
|
||||||
command(["docker", "rm", ttl_name])
|
command(["docker", "stop", "--time", "6", ttl_name])
|
||||||
|
command(["docker", "rm", ttl_name])
|
||||||
checks("explain-run.txt", "make", "explain")
|
checks("explain-run.txt", "make", "explain")
|
||||||
checks("smoke-final.txt", "make", "test")
|
checks("smoke-final.txt", "make", "test")
|
||||||
saved("published-smoke.txt", [sys.executable, "-X", "utf8", "tests/smoke.py", "--base-url", base_url])
|
saved("published-smoke.txt", [sys.executable, "-X", "utf8", "tests/smoke.py", "--base-url", base_url])
|
||||||
|
|||||||
Reference in New Issue
Block a user