# HG changeset patch # User Alain Mazy # Date 1650459202 -7200 # Node ID e1867aeb57e26c3527465d7f4073683f6ee0aca3 # Parent 038fb852e2be022c5dc6095d23151fe744ea7a0a retries storescu if it succeeds while it should fail diff -r 038fb852e2be -r e1867aeb57e2 Tests/Tests.py --- a/Tests/Tests.py Tue Apr 19 12:14:16 2022 +0200 +++ b/Tests/Tests.py Wed Apr 20 14:53:22 2022 +0200 @@ -2423,22 +2423,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'))) @@ -2456,9 +2461,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):