Skip to content

Commit ccdc3d4

Browse files
committed
Fix Vespa integration readiness check
1 parent b726945 commit ccdc3d4

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

integrations/vespa/tests/conftest.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import os
88
import subprocess
99
import time
10+
import urllib.error
11+
import urllib.request
1012

1113
import pytest
1214

@@ -30,10 +32,21 @@ def deployed_vespa_app():
3032
],
3133
check=True,
3234
)
33-
subprocess.run(
34-
["docker", "exec", "vespa", "bash", "-lc", "/opt/vespa/bin/vespa-status deploy --wait 300"],
35-
check=True,
36-
)
35+
_wait_for_vespa_endpoint("http://localhost:8080/ApplicationStatus", deadline_s=300)
36+
37+
38+
def _wait_for_vespa_endpoint(url: str, *, deadline_s: float) -> None:
39+
deadline = time.monotonic() + deadline_s
40+
while time.monotonic() < deadline:
41+
try:
42+
with urllib.request.urlopen(url, timeout=5) as response: # noqa: S310
43+
if response.status == 200:
44+
return
45+
except (OSError, urllib.error.URLError):
46+
pass
47+
time.sleep(1)
48+
msg = f"Timed out waiting for Vespa endpoint {url}"
49+
raise AssertionError(msg)
3750

3851

3952
def wait_until_documents_count(document_store, expected_count: int, *, deadline_s: float = 90) -> None:

0 commit comments

Comments
 (0)