changeset 469:c19d33c5defe more-tags

merge default -> more-tags
author Alain Mazy <am@osimis.io>
date Wed, 20 Apr 2022 17:24:43 +0200
parents fc1c3ffed470 (current diff) e1867aeb57e2 (diff)
children 1f6c9debddf6
files Tests/Tests.py
diffstat 1 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Wed Apr 20 14:45:03 2022 +0200
+++ b/Tests/Tests.py	Wed Apr 20 17:24:43 2022 +0200
@@ -2466,22 +2466,27 @@
         # since this test fails regularly on CI, enable verbosity
         DoPut(_REMOTE, '/tools/log-level', 'verbose')
 
-        def storescu(image, acceptUnknownSopClassUid):
+        def storescu(image, acceptUnknownSopClassUid, expectSuccess = True, retries = 1):
             if acceptUnknownSopClassUid:
                 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ]
             else:
                 tmp = [ '-xs' ]
 
-            with open(os.devnull, 'w') as FNULL:
-                try:
-                    subprocess.check_call([ FindExecutable('storescu') ] + tmp +
-                                        [ _REMOTE['Server'], str(_REMOTE['DicomPort']),
-                                            GetDatabasePath(image) ],
-                                        stderr = FNULL)
-
-                except subprocess.CalledProcessError as e:
-                    print('storescu failed with error code: %s' % str(e.returncode))
-                    raise e
+            while retries > 0:
+                retries -= 1
+                with open(os.devnull, 'w') as FNULL:
+                    try:
+                        subprocess.check_call([ FindExecutable('storescu') ] + tmp +
+                                            [ _REMOTE['Server'], str(_REMOTE['DicomPort']),
+                                                GetDatabasePath(image) ],
+                                            stderr = FNULL)
+
+                        if expectSuccess:
+                            return
+                    except subprocess.CalledProcessError as e:
+                        print('storescu failed with error code: %s' % str(e.returncode))
+                        if not expectSuccess:
+                            raise e
 
         self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
 
@@ -2499,9 +2504,9 @@
         else:
             InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua')
         
-        # the following line regularly fails on CI !
-        self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False))
-        self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True))
+        # the following line regularly fails on CI because storescu still returns 0 although the C-Store fails !!
+        self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False, False, 3))
+        self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True, False, 3))
         self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
 
         if IsOrthancVersionAbove(_REMOTE, 1, 9, 0):