added a test for pingcheck version to avoid trouble with IP parsing in 'older' pingch...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 22 Jan 2015 17:17:13 +0000 (18:17 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 22 Jan 2015 17:17:13 +0000 (18:17 +0100)
test/long_term_test.py

index 98146eb..b9c3756 100755 (executable)
@@ -639,13 +639,20 @@ class Tester:
 ### MAIN
 ########################################################################
 
-def test_version(pingcheck_binary, log):
-    """ run pingcheck --version; we want > 0.1 for proper IP parsing """
+def test_version(pingcheck_binary):
+    """ run pingcheck --version; we want > 0.1 for proper IP parsing
 
-    try:
-        output = check_output(['pingcheck', '--version'])
-    except:
-        pass
+    no try-catch here, also intended as test-run for pingcheck binary
+    """
+
+    output = subprocess.check_output([pingcheck_binary, '--version'], universal_newlines=True)
+    match = regexp('\s*pingcheck version (\d+\.\d+)\s*', output)
+    if match is None:
+        raise ValueError('Could not determine pingcheck version from output of {0} --version!'\
+                .format(pingcheck_binary))
+    version = float(match.groups()[0])
+    if version < 0.2:
+        raise ValueError('Pingcheck version is {0} but require version > 0.1!'.format(version))
 
 #end: test_version
 
@@ -858,13 +865,13 @@ def main():
     tester = None
     line_iter = None
     try:
-        # test version
-        #test_version(opts.pingcheck_binary, log)
-
         config_file, n_hosts = create_conf_file(opts.output_prefix)
         save_file = opts.output_prefix + '_save.pickle'
         log.info('created config file {0}'.format(config_file))
 
+        # test version
+        test_version(opts.pingcheck_binary)
+
         #signal.signal(signal.SIGCHLD, \
         #        lambda signum, curr_frame: handle_sigchild(signum, curr_frame, log, \
         #           (log, pinger, tester, line_iter, save_file) )