Mercurial > hg > orthanc-tests
changeset 468:e1867aeb57e2
retries storescu if it succeeds while it should fail
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 20 Apr 2022 14:53:22 +0200 |
parents | 038fb852e2be |
children | c19d33c5defe 1f6c9debddf6 |
files | Tests/Tests.py |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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):