Mercurial > hg > orthanc-tests
comparison NewTests/helpers.py @ 601:3e15e950c462
new transfer tests in the concurrency section
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 19 Jan 2024 15:03:47 +0100 |
parents | f4f0e2d24a51 |
children | 4b3d13e498a5 |
comparison
equal
deleted
inserted
replaced
600:58384ae69f41 | 601:3e15e950c462 |
---|---|
4 import json | 4 import json |
5 import os | 5 import os |
6 import typing | 6 import typing |
7 import shutil | 7 import shutil |
8 import glob | 8 import glob |
9 import time | |
9 from threading import Thread | 10 from threading import Thread |
10 | 11 |
11 | 12 |
12 import pathlib | 13 import pathlib |
13 here = pathlib.Path(__file__).parent.resolve() | 14 here = pathlib.Path(__file__).parent.resolve() |
15 | 16 |
16 default_base_config = { | 17 default_base_config = { |
17 "AuthenticationEnabled": False, | 18 "AuthenticationEnabled": False, |
18 "RemoteAccessAllowed": True | 19 "RemoteAccessAllowed": True |
19 } | 20 } |
21 | |
22 | |
23 def get_container_health(container_name): | |
24 try: | |
25 # Run the docker inspect command | |
26 result = subprocess.run( | |
27 ["docker", "inspect", "--format", "{{.State.Health.Status}}", container_name], | |
28 capture_output=True, | |
29 text=True, | |
30 check=True, | |
31 ) | |
32 | |
33 # Extract the health status from the command output | |
34 return result.stdout.strip() | |
35 | |
36 except subprocess.CalledProcessError as e: | |
37 print(f"Error checking container health: {e}") | |
38 return None | |
39 | |
40 def wait_container_healthy(container_name): | |
41 retry = 0 | |
42 | |
43 while (get_container_health(container_name) != "healthy" and retry < 200): | |
44 print(f"Waiting for {container_name} to be healty") | |
45 time.sleep(1) | |
46 | |
20 | 47 |
21 | 48 |
22 class Helpers: | 49 class Helpers: |
23 | 50 |
24 orthanc_under_tests_hostname: str = 'localhost' | 51 orthanc_under_tests_hostname: str = 'localhost' |