changeset 463:29aaa3df718f

added verbosity and retries for test sometimes failing on CI
author Alain Mazy <am@osimis.io>
date Thu, 07 Apr 2022 09:46:24 +0200
parents 281a599f5338
children 216231c18c2e
files Tests/Tests.py
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Wed Mar 30 09:54:11 2022 +0200
+++ b/Tests/Tests.py	Thu Apr 07 09:46:24 2022 +0200
@@ -208,7 +208,7 @@
 
         systemInfo = DoGet(_REMOTE, '/system')
         if systemInfo["Version"] == "mainline":
-            print "Skipping version checks since you're currently in mainline"
+            print("Skipping version checks since you're currently in mainline")
             return
 
         self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 8, 6))
@@ -2411,6 +2411,9 @@
 
 
     def test_incoming_jpeg(self):
+        # since this test fails regularly on CI, enable verbosity
+        DoPut(_REMOTE, '/tools/log-level', 'verbose')
+
         def storescu(image, acceptUnknownSopClassUid):
             if acceptUnknownSopClassUid:
                 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ]
@@ -2439,6 +2442,7 @@
         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))
         self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
@@ -2456,6 +2460,8 @@
         storescu('UnknownSopClassUid.dcm', True)
         self.assertEqual(2, len(DoGet(_REMOTE, '/patients')))
 
+        # set back normal verbosity
+        DoPut(_REMOTE, '/tools/log-level', 'default')
 
     def test_storescu_jpeg(self):
         self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports']))
@@ -3717,8 +3723,14 @@
         CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID')
 
     def test_httpClient_lua(self):
+        retries = 3
+        result = ''
+        
         with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f:
-            result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua')
+            # retry since this test sometimes fails if httpbin.org is unresponsive
+            while retries > 0 and not ('OK' in result):
+                result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua')
+                retries -= 1
 
         self.assertIn('OK', result)