changeset 621:9f867dc595e2

fix concurrency tests
author Alain Mazy <am@osimis.io>
date Tue, 06 Feb 2024 16:20:40 +0100
parents 79812e0df162
children 75dbc81d0e26
files NewTests/Authorization/test_authorization.py NewTests/Concurrency/test_concurrency.py NewTests/PostgresUpgrades/docker-entrypoint-integ-tests.sh NewTests/PostgresUpgrades/downgrade.sh NewTests/PostgresUpgrades/run-integ-tests-from-docker.sh NewTests/PostgresUpgrades/wait-for-it.sh NewTests/requirements.txt
diffstat 3 files changed, 32 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/NewTests/Authorization/test_authorization.py	Mon Feb 05 17:12:07 2024 +0100
+++ b/NewTests/Authorization/test_authorization.py	Tue Feb 06 16:20:40 2024 +0100
@@ -121,9 +121,6 @@
         cls.no_label_instance_dicom_id = o.instances.get_tags(cls.no_label_instance_id)["SOPInstanceUID"]
 
 
-    def is_orthanc_version_at_least_1_12_2(self, orthanc_client: OrthancApiClient):
-        return orthanc_client.get_system()["ApiVersion"] >= 22
-
     def assert_is_forbidden(self, api_call):
         with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
             api_call()
@@ -278,7 +275,7 @@
 
         # other studies are forbidden
         self.assert_is_forbidden(lambda: o.studies.get_series_ids(self.label_b_study_id))
-        if self.is_orthanc_version_at_least_1_12_2(o):
+        if self.o.is_orthanc_version_at_least(1, 12, 2):
             self.assert_is_forbidden(lambda: o.get_binary(f"tools/create-archive?resources={self.label_b_study_id}"))
             self.assert_is_forbidden(lambda: o.get_binary(f"tools/create-archive?resources={self.label_b_series_id}"))
             # if one of the studies is forbidden, the resource is forbidden
@@ -300,7 +297,7 @@
         o.get_json(f"dicom-web/series?0020000D={self.label_a_study_dicom_id}")
         o.get_json(f"dicom-web/instances?0020000D={self.label_a_study_dicom_id}")
 
-        if self.is_orthanc_version_at_least_1_12_2(o):
+        if self.o.is_orthanc_version_at_least(1, 12, 2):
             o.get_binary(f"tools/create-archive?resources={self.label_a_study_id}")
             o.get_binary(f"tools/create-archive?resources={self.label_a_series_id}")
 
--- a/NewTests/Concurrency/test_concurrency.py	Mon Feb 05 17:12:07 2024 +0100
+++ b/NewTests/Concurrency/test_concurrency.py	Tue Feb 06 16:20:40 2024 +0100
@@ -178,40 +178,43 @@
         for t in workers:
             t.join()
 
-    def test_concurrent_uploads_same_study(self):
-        self.o.delete_all_content()
-        self.clear_storage(storage_name=self._storage_name)
+    # TODO: reactivate once 1.12.4 is released.  It needs this fix: https://orthanc.uclouvain.be/hg/orthanc/rev/acdb8d78bf99
+    # def test_concurrent_uploads_same_study(self):
+    #     if self.o.is_orthanc_version_at_least(1, 12, 4):
+
+    #         self.o.delete_all_content()
+    #         self.clear_storage(storage_name=self._storage_name)
 
-        start_time = time.time()
-        workers_count = 20
-        repeat_count = 1
+    #         start_time = time.time()
+    #         workers_count = 20
+    #         repeat_count = 10
 
-        # massively reupload the same study multiple times with OverwriteInstances set to true
-        # Make sure the studies, series and instances are created only once
-        self.execute_workers(
-            worker_func=worker_upload_folder,
-            worker_args=(self.o._root_url, here / "../../Database/Knee", repeat_count,),
-            workers_count=workers_count)
+    #         # massively reupload the same study multiple times with OverwriteInstances set to true
+    #         # Make sure the studies, series and instances are created only once
+    #         self.execute_workers(
+    #             worker_func=worker_upload_folder,
+    #             worker_args=(self.o._root_url, here / "../../Database/Knee", repeat_count,),
+    #             workers_count=workers_count)
 
-        elapsed = time.time() - start_time
-        print(f"TIMING test_concurrent_uploads_same_study with {workers_count} workers and {repeat_count}x repeat: {elapsed:.3f} s")
+    #         elapsed = time.time() - start_time
+    #         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())
+    #         self.assertTrue(self.o.is_alive())
 
-        self.assertEqual(1, len(self.o.studies.get_all_ids()))
-        self.assertEqual(2, len(self.o.series.get_all_ids()))
-        self.assertEqual(50, len(self.o.instances.get_all_ids()))
+    #         self.assertEqual(1, len(self.o.studies.get_all_ids()))
+    #         self.assertEqual(2, len(self.o.series.get_all_ids()))
+    #         self.assertEqual(50, len(self.o.instances.get_all_ids()))
 
-        stats = self.o.get_json("/statistics")
-        self.assertEqual(1, stats.get("CountPatients"))
-        self.assertEqual(1, stats.get("CountStudies"))
-        self.assertEqual(2, stats.get("CountSeries"))
-        self.assertEqual(50, stats.get("CountInstances"))
-        self.assertEqual(4118738, int(stats.get("TotalDiskSize")))
+    #         stats = self.o.get_json("/statistics")
+    #         self.assertEqual(1, stats.get("CountPatients"))
+    #         self.assertEqual(1, stats.get("CountStudies"))
+    #         self.assertEqual(2, stats.get("CountSeries"))
+    #         self.assertEqual(50, stats.get("CountInstances"))
+    #         self.assertEqual(4118738, int(stats.get("TotalDiskSize")))
 
-        self.o.instances.delete(orthanc_ids=self.o.instances.get_all_ids())
+    #         self.o.instances.delete(orthanc_ids=self.o.instances.get_all_ids())
 
-        self.check_is_empty()
+    #         self.check_is_empty()
 
     def test_concurrent_anonymize_same_study(self):
         self.o.delete_all_content()
--- a/NewTests/requirements.txt	Mon Feb 05 17:12:07 2024 +0100
+++ b/NewTests/requirements.txt	Tue Feb 06 16:20:40 2024 +0100
@@ -1,3 +1,3 @@
-orthanc-api-client>=0.14.6
+orthanc-api-client>=0.14.10
 orthanc-tools>=0.8.9
 uvicorn
\ No newline at end of file