Skip to content

Commit b286479

Browse files
committed
TST: wait for startup of save-and-restore service
1 parent f89e3c6 commit b286479

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

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 = 30
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+
with httpx.Client(base_url=BASE_URL, timeout=1) as client:
12+
url = f"/node/{root_node_uid}"
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 (httpx.ConnectError, httpx.ReadError):
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)