]> granicus.if.org Git - icinga2/commitdiff
Fix the vm-test runner's error handling
authorJohannes Meyer <johannes.meyer@netways.de>
Wed, 5 Feb 2014 12:22:27 +0000 (13:22 +0100)
committerJohannes Meyer <johannes.meyer@netways.de>
Wed, 5 Feb 2014 13:22:57 +0000 (14:22 +0100)
test/jenkins/files/utils.py
test/jenkins/run_tests.py

index 65066df05c34ecba3cc68c44b484e601b6ee7b9b..6dcbb424260a516809b78c0828e47d99be62ca95 100644 (file)
@@ -117,9 +117,14 @@ class LiveStatusSocket(object):
         while not self._connected and time.time() - start < timeout:
             try:
                 self.connect()
-            except socket.error, error:
-                if error.errno != 111:
-                    raise
+            except socket.error:
+                # Icinga2 does some "magic" with the socket during startup
+                # which causes random errors being raised (EACCES, ENOENT, ..)
+                # so we just ignore them until the timeout is reached
+                time.sleep(1)
+        if not self._connected:
+            # Raise the very last exception once the timeout is reached
+            raise
 
     def close(self):
         if self._connected:
index 1780638c7c9cc86f5c50ae0f502372d50f15c315..a0e9121e0089ac4c1e2d77c013924278102fb6b3 100755 (executable)
@@ -85,15 +85,23 @@ class TestSuite(object):
 
     def _remove_file(self, path):
         command = self._config['commands']['clean'].format(path)
-        subprocess.call(command, stdout=DEVNULL, shell=True)
+        rc = subprocess.call(command, stdout=DEVNULL, shell=True)
+        if rc != 0:
+            print 'WARNING: Cannot remove file "{0}" ({1})'.format(path, rc)
 
     def _exec_command(self, command):
         command = self._config['commands']['exec'].format(command)
-        subprocess.call(command, stdout=DEVNULL, shell=True)
+        rc = subprocess.call(command, stdout=DEVNULL, shell=True)
+        if rc != 0:
+            print 'WARNING: Command "{0}" exited with exit code "{1}"' \
+                  ''.format(command, rc)
 
     def _copy_file(self, source, destination):
         command = self._config['commands']['copy'].format(source, destination)
-        subprocess.call(command, stdout=DEVNULL, shell=True)
+        rc = subprocess.call(command, stdout=DEVNULL, shell=True)
+        if rc != 0:
+            print 'WARNING: Cannot copy file "{0}" to "{1}" ({2})' \
+                  ''.format(source, destination, rc)
 
     def _copy_test(self, path):
         self._copy_file(path, os.path.join(self._config['settings']['test_root'],