Skip to content

Commit b295050

Browse files
Pigbibicodex
andcommitted
Align startup validation with POST-only routes
Co-Authored-By: Codex <noreply@openai.com>
1 parent a87d703 commit b295050

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

scripts/validate_cloud_run_startup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def validate_startup() -> None:
5959
}
6060
required_routes = {
6161
"/health": {"GET"},
62-
"/run": {"GET", "POST"},
62+
"/run": {"POST"},
6363
"/dry-run": {"GET", "POST"},
64-
"/probe": {"GET", "POST"},
64+
"/probe": {"POST"},
6565
"/monitor-dispatch": {"GET", "POST"},
6666
}
6767
missing_or_invalid = {

tests/test_cloud_run_startup_validation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
import sys
12
from pathlib import Path
3+
from types import SimpleNamespace
4+
5+
from flask import Flask
6+
7+
from scripts import validate_cloud_run_startup
28

39

410
ROOT = Path(__file__).resolve().parents[1]
@@ -12,3 +18,22 @@ def test_production_startup_validation_is_a_ci_and_image_build_gate():
1218
assert command in dockerfile
1319
assert "Validate production Cloud Run startup" in ci_workflow
1420
assert f"uv run --no-sync {command}" in ci_workflow
21+
22+
23+
def test_startup_validation_accepts_post_only_execution_routes(monkeypatch):
24+
app = Flask(__name__)
25+
for index, (path, methods) in enumerate(
26+
{
27+
"/health": ["GET"],
28+
"/run": ["POST"],
29+
"/dry-run": ["GET", "POST"],
30+
"/probe": ["POST"],
31+
"/monitor-dispatch": ["GET", "POST"],
32+
}.items()
33+
):
34+
app.add_url_rule(path, f"route_{index}", lambda: "ok", methods=methods)
35+
36+
monkeypatch.setattr(validate_cloud_run_startup, "_install_smoke_environment", lambda: None)
37+
monkeypatch.setitem(sys.modules, "main", SimpleNamespace(app=app))
38+
39+
validate_cloud_run_startup.validate_startup()

0 commit comments

Comments
 (0)