Skip to content

Commit d8cc905

Browse files
committed
TST: wait for startup of save-and-restore service
1 parent 79e6b18 commit d8cc905

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Start save-and-restore service
2929
run: |
3030
pushd container
31-
bash start-save-and-restore.sh
31+
./start-save-and-restore.sh
3232
popd
3333
3434
- name: Test with pytest

container/start-save-and-restore.sh

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set -x
22

33
python create_env_file.py
44
sudo docker compose -f save-and-restore.yml up -d
5+
python wait_for_startup.py
56

67
# Wait until the service is started.
7-
sleep 30
8+
#sleep 30

container/wait_for_startup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import time
2+
3+
import httpx
4+
5+
t_wait = 120
6+
BASE_URL = "http://localhost:8080/save-restore"
7+
root_node_uid = "44bef5de-e8e6-4014-af37-b8f6c8a939a2"
8+
9+
if __name__ == "__main__":
10+
t_start = time.time()
11+
url = f"/node/{root_node_uid}"
12+
with httpx.Client(base_url=BASE_URL, timeout=1) as client:
13+
while time.time() - t_start < t_wait:
14+
try:
15+
response = client.request("GET", url)
16+
if response.status_code == 200:
17+
print("Success: save-and-restore server is up")
18+
exit(0)
19+
except Exception:
20+
pass
21+
22+
print(f"TIMEOUT: save-and-restore server failed to start in {t_wait} seconds")
23+
exit(1)

0 commit comments

Comments
 (0)