Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions selftests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
"""
Expand Down
2 changes: 2 additions & 0 deletions src/vip/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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),
Expand Down
11 changes: 7 additions & 4 deletions tests/connect/test_content_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions vip.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading