changeset 593:f4f0e2d24a51

more pg-transactions tests
author Alain Mazy <am@osimis.io>
date Thu, 14 Dec 2023 10:41:09 +0100
parents 6753d96dd71f
children 27be80b4b1a9
files NewTests/Concurrency/test_concurrency.py NewTests/helpers.py NewTests/requirements.txt
diffstat 3 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/NewTests/Concurrency/test_concurrency.py	Tue Dec 12 15:31:45 2023 +0100
+++ b/NewTests/Concurrency/test_concurrency.py	Thu Dec 14 10:41:09 2023 +0100
@@ -150,7 +150,7 @@
             workers_count=workers_count)
 
         elapsed = time.time() - start_time
-        print(f"test_concurrent_uploads_same_study with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
+        print(f"TIMING test_concurrent_uploads_same_study with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
 
         self.assertTrue(self.o.is_alive())
 
@@ -177,9 +177,9 @@
         self.assertEqual(0, stats.get("CountSeries"))
         self.assertEqual(0, stats.get("CountInstances"))
         self.assertEqual(0, int(stats.get("TotalDiskSize")))
+        # time.sleep(10000)
         self.assertTrue(self.is_storage_empty(self._storage_name))
 
-
     def test_concurrent_anonymize_same_study(self):
         self.o.delete_all_content()
         self.clear_storage(storage_name=self._storage_name)
@@ -199,7 +199,7 @@
             workers_count=workers_count)
 
         elapsed = time.time() - start_time
-        print(f"test_concurrent_anonymize_same_study with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
+        print(f"TIMING test_concurrent_anonymize_same_study with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
 
         self.assertTrue(self.o.is_alive())
 
@@ -213,8 +213,13 @@
         self.assertEqual(2 * (1 + workers_count * repeat_count), stats.get("CountSeries"))
         self.assertEqual(50 * (1 + workers_count * repeat_count), stats.get("CountInstances"))
 
+        start_time = time.time()
+
         self.o.instances.delete(orthanc_ids=self.o.instances.get_all_ids())
 
+        elapsed = time.time() - start_time
+        print(f"TIMING test_concurrent_anonymize_same_study deletion took: {elapsed:.3f} s")
+
         self.assertEqual(0, len(self.o.studies.get_all_ids()))
         self.assertEqual(0, len(self.o.series.get_all_ids()))
         self.assertEqual(0, len(self.o.instances.get_all_ids()))
@@ -244,7 +249,7 @@
             workers_count=workers_count)
 
         elapsed = time.time() - start_time
-        print(f"test_upload_delete_same_study_from_multiple_threads with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
+        print(f"TIMING test_upload_delete_same_study_from_multiple_threads with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
 
         self.assertTrue(self.o.is_alive())
 
--- a/NewTests/helpers.py	Tue Dec 12 15:31:45 2023 +0100
+++ b/NewTests/helpers.py	Thu Dec 14 10:41:09 2023 +0100
@@ -137,7 +137,14 @@
     @classmethod
     def clear_storage(cls, storage_name: str):
         storage_path = cls.get_storage_path(storage_name=storage_name)
-        shutil.rmtree(storage_path, ignore_errors=True)
+
+        # clear the directory but keep it !
+        for root, dirs, files in os.walk(storage_path):
+            for f in files:
+                os.unlink(os.path.join(root, f))
+            for d in dirs:
+                shutil.rmtree(os.path.join(root, d))
+                shutil.rmtree(storage_path, ignore_errors=True)
 
     @classmethod
     def is_storage_empty(cls, storage_name: str):
--- a/NewTests/requirements.txt	Tue Dec 12 15:31:45 2023 +0100
+++ b/NewTests/requirements.txt	Thu Dec 14 10:41:09 2023 +0100
@@ -1,3 +1,3 @@
-orthanc-api-client>=0.13.6
+orthanc-api-client>=0.14.4
 orthanc-tools>=0.8.9
 uvicorn
\ No newline at end of file