From e8a2089fc8b4feab5cb70fbfc4fae8f9a9e16f02 Mon Sep 17 00:00:00 2001 From: Ian Flores Siaca Date: Fri, 6 Mar 2026 09:36:11 -0800 Subject: [PATCH] Make content deploy timeout configurable with 600s default --- selftests/test_config.py | 29 ++++++++++++++++++++++++++++ src/vip/config.py | 2 ++ tests/connect/test_content_deploy.py | 11 +++++++---- vip.toml.example | 4 ++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/selftests/test_config.py b/selftests/test_config.py index 394be31..000df4c 100644 --- a/selftests/test_config.py +++ b/selftests/test_config.py @@ -41,6 +41,14 @@ def test_explicit_api_key_takes_precedence(self, monkeypatch): cc = ConnectConfig(url="https://connect.example.com", api_key="explicit-key") assert cc.api_key == "explicit-key" + def test_default_deploy_timeout(self): + cc = ConnectConfig(url="https://connect.example.com") + assert cc.deploy_timeout == 600 + + def test_explicit_deploy_timeout(self): + cc = ConnectConfig(url="https://connect.example.com", deploy_timeout=1200) + assert cc.deploy_timeout == 1200 + class TestVIPConfig: def test_product_config_lookup(self): @@ -177,6 +185,27 @@ def test_email_and_monitoring_flags(self, tmp_toml): assert cfg.monitoring_enabled is True assert cfg.security_policy_checks_enabled is True + def test_deploy_timeout_from_toml(self, tmp_toml): + path = tmp_toml( + """ +[connect] +url = "https://connect.example.com" +deploy_timeout = 1200 +""" + ) + cfg = load_config(path) + assert cfg.connect.deploy_timeout == 1200 + + def test_deploy_timeout_defaults_when_missing(self, tmp_toml): + path = tmp_toml( + """ +[connect] +url = "https://connect.example.com" +""" + ) + cfg = load_config(path) + assert cfg.connect.deploy_timeout == 600 + def test_full_config(self, tmp_toml): path = tmp_toml( """ diff --git a/src/vip/config.py b/src/vip/config.py index 5a46211..1653272 100644 --- a/src/vip/config.py +++ b/src/vip/config.py @@ -31,6 +31,7 @@ class ConnectConfig(ProductConfig): """Connect-specific configuration.""" api_key: str = "" + deploy_timeout: int = 600 def __post_init__(self) -> None: if not self.api_key: @@ -152,6 +153,7 @@ def load_config(path: str | Path | None = None) -> VIPConfig: url=connect_raw.get("url", ""), version=connect_raw.get("version"), api_key=connect_raw.get("api_key", ""), + deploy_timeout=connect_raw.get("deploy_timeout", 600), ), workbench=ProductConfig( enabled=workbench_raw.get("enabled", True), diff --git a/tests/connect/test_content_deploy.py b/tests/connect/test_content_deploy.py index 3e02f68..ada68a6 100644 --- a/tests/connect/test_content_deploy.py +++ b/tests/connect/test_content_deploy.py @@ -210,9 +210,10 @@ def upload_and_deploy(connect_client, deploy_state): @when("I wait for the deployment to complete") -def wait_for_deploy(connect_client, deploy_state): +def wait_for_deploy(connect_client, deploy_state, vip_config): task_id = deploy_state["task_id"] - deadline = time.time() + 300 # 5-minute timeout (package installs can be slow) + timeout = vip_config.connect.deploy_timeout + deadline = time.time() + timeout while time.time() < deadline: try: task = connect_client.get_task(task_id) @@ -250,11 +251,13 @@ def wait_for_deploy(connect_client, deploy_state): raise if task is None: pytest.fail( - "Deployment did not complete within 300 seconds and final task " + f"Deployment did not complete within {timeout} seconds and final task " "state could not be retrieved due to repeated transient errors." ) output = "\n".join(task.get("output", [])) - pytest.fail(f"Deployment did not complete within 300 seconds\n\n--- Task output ---\n{output}") + pytest.fail( + f"Deployment did not complete within {timeout} seconds\n\n--- Task output ---\n{output}" + ) @then("the content is accessible via HTTP") diff --git a/vip.toml.example b/vip.toml.example index d1fa5be..959e806 100644 --- a/vip.toml.example +++ b/vip.toml.example @@ -21,6 +21,10 @@ url = "https://connect.example.com" # Prefer setting the VIP_CONNECT_API_KEY environment variable. # api_key = "..." +# Timeout in seconds for content deployments (default: 600) +# Increase this for environments with slower package installation. +deploy_timeout = 600 + [workbench] enabled = true url = "https://workbench.example.com"