Exercise packaged runtime topology
This commit is contained in:
@@ -104,10 +104,28 @@ def _wait_for(
|
||||
probe: Callable[[], subprocess.CompletedProcess[str]],
|
||||
*,
|
||||
timeout: float,
|
||||
container: str | None = None,
|
||||
) -> None:
|
||||
deadline = time.monotonic() + timeout
|
||||
last = ""
|
||||
while time.monotonic() < deadline:
|
||||
if container is not None:
|
||||
state = _run(
|
||||
("docker", "inspect", "--format", "{{.State.Running}}", container),
|
||||
check=False,
|
||||
timeout=30,
|
||||
)
|
||||
if state.returncode != 0 or state.stdout.strip() != "true":
|
||||
logs = _run(
|
||||
("docker", "logs", "--tail", "100", container),
|
||||
check=False,
|
||||
timeout=30,
|
||||
)
|
||||
detail = _tail(logs.stdout + logs.stderr, limit=8000)
|
||||
raise SmokeError(
|
||||
f"{label} container exited before readiness: "
|
||||
f"{detail or 'no diagnostic output'}"
|
||||
)
|
||||
result = probe()
|
||||
if result.returncode == 0:
|
||||
return
|
||||
@@ -212,13 +230,15 @@ def run_smoke(
|
||||
started = time.monotonic()
|
||||
|
||||
def record(check_id: str, began: float) -> None:
|
||||
duration = round(time.monotonic() - began, 3)
|
||||
checks.append(
|
||||
{
|
||||
"id": check_id,
|
||||
"state": "passed",
|
||||
"duration_seconds": round(time.monotonic() - began, 3),
|
||||
"duration_seconds": duration,
|
||||
}
|
||||
)
|
||||
print(f"PASS {platform} {check_id} ({duration}s)", flush=True)
|
||||
|
||||
common_runtime = [
|
||||
"--platform",
|
||||
@@ -309,6 +329,7 @@ def run_smoke(
|
||||
timeout=30,
|
||||
),
|
||||
timeout=timeout,
|
||||
container=names["postgres"],
|
||||
)
|
||||
_wait_for(
|
||||
"Redis",
|
||||
@@ -318,6 +339,7 @@ def run_smoke(
|
||||
timeout=30,
|
||||
),
|
||||
timeout=timeout,
|
||||
container=names["redis"],
|
||||
)
|
||||
record("managed_dependencies_ready", began)
|
||||
|
||||
@@ -347,6 +369,40 @@ def run_smoke(
|
||||
)
|
||||
record("release_migrations", began)
|
||||
|
||||
began = time.monotonic()
|
||||
_run(
|
||||
(
|
||||
"docker",
|
||||
"run",
|
||||
"--rm",
|
||||
"--name",
|
||||
f"{prefix}-schema",
|
||||
*common_runtime,
|
||||
*_env_arguments(
|
||||
environment,
|
||||
role="migration",
|
||||
node_id=f"runtime-smoke-{slug}-schema",
|
||||
),
|
||||
api_image,
|
||||
"python",
|
||||
"-c",
|
||||
(
|
||||
"import os;"
|
||||
"from sqlalchemy import create_engine,inspect;"
|
||||
"engine=create_engine(os.environ['DATABASE_URL']);"
|
||||
"tables=set(inspect(engine).get_table_names());"
|
||||
"required={'alembic_version','core_scopes','core_system_settings',"
|
||||
"'core_runtime_nodes'};"
|
||||
"missing=required-tables;"
|
||||
"assert not missing, f'missing release tables: {sorted(missing)}';"
|
||||
"engine.dispose()"
|
||||
),
|
||||
),
|
||||
timeout=timeout,
|
||||
redactions=redactions,
|
||||
)
|
||||
record("release_schema_contract", began)
|
||||
|
||||
began = time.monotonic()
|
||||
_run(
|
||||
(
|
||||
@@ -357,6 +413,8 @@ def run_smoke(
|
||||
names["api"],
|
||||
"--network-alias",
|
||||
"api",
|
||||
"--network-alias",
|
||||
"load-balancer",
|
||||
*common_runtime,
|
||||
*_env_arguments(
|
||||
environment,
|
||||
@@ -388,6 +446,7 @@ def run_smoke(
|
||||
timeout=30,
|
||||
),
|
||||
timeout=timeout,
|
||||
container=names["api"],
|
||||
)
|
||||
_run(
|
||||
(
|
||||
@@ -446,6 +505,7 @@ def run_smoke(
|
||||
timeout=30,
|
||||
),
|
||||
timeout=timeout,
|
||||
container=names["web"],
|
||||
)
|
||||
_run(
|
||||
("docker", "exec", names["web"], "sh", "-c", "test \"$(id -u)\" = 101"),
|
||||
@@ -507,6 +567,7 @@ def run_smoke(
|
||||
timeout=30,
|
||||
),
|
||||
timeout=timeout,
|
||||
container=names["worker"],
|
||||
)
|
||||
_run(("docker", "stop", "--time", "20", names["worker"]), timeout=30)
|
||||
record("worker_delivery_and_shutdown", began)
|
||||
|
||||
Reference in New Issue
Block a user