comparison NewTests/PostgresUpgrades/test_pg_upgrades.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 58384ae69f41
children d743c210cbc8
comparison
equal deleted inserted replaced
600:58384ae69f41 601:3e15e950c462
1 import subprocess 1 import subprocess
2 import time 2 import time
3 import unittest 3 import unittest
4 from orthanc_api_client import OrthancApiClient 4 from orthanc_api_client import OrthancApiClient
5 from helpers import Helpers 5 from helpers import Helpers, wait_container_healthy
6 6
7 import pathlib 7 import pathlib
8 import os 8 import os
9 here = pathlib.Path(__file__).parent.resolve() 9 here = pathlib.Path(__file__).parent.resolve()
10 10
11
12 def get_container_health(container_name):
13 try:
14 # Run the docker inspect command
15 result = subprocess.run(
16 ["docker", "inspect", "--format", "{{.State.Health.Status}}", container_name],
17 capture_output=True,
18 text=True,
19 check=True,
20 )
21
22 # Extract the health status from the command output
23 return result.stdout.strip()
24
25 except subprocess.CalledProcessError as e:
26 print(f"Error checking container health: {e}")
27 return None
28
29 def wait_container_healthy(container_name):
30 retry = 0
31
32 while (get_container_health(container_name) != "healthy" and retry < 200):
33 print(f"Waiting for {container_name} to be healty")
34 time.sleep(1)
35 11
36 class TestPgUpgrades(unittest.TestCase): 12 class TestPgUpgrades(unittest.TestCase):
37 13
38 @classmethod 14 @classmethod
39 def cleanup(cls): 15 def cleanup(cls):
46 def setUpClass(cls): 22 def setUpClass(cls):
47 cls.cleanup() 23 cls.cleanup()
48 24
49 @classmethod 25 @classmethod
50 def tearDownClass(cls): 26 def tearDownClass(cls):
51 pass 27 cls.cleanup()
52 # cls.cleanup()
53 28
54 29
55 def test_upgrades_downgrades_with_pg_15(self): 30 def test_upgrades_downgrades_with_pg_15(self):
56 31
57 print("Pullling container") 32 print("Pullling container")