X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=qaapi%2Fqa%2Ftests%2Fnode_run_tests.py;h=9738b402b86ce301bec52f9cbc4a913b5f9bbd52;hb=49fa462d47644636794fde03920ba7aca0d08a74;hp=20f642333a9871ae1e20ac40b562d00637ce0065;hpb=5893245b93b97e91d4a9adb6721cf4e011fb3301;p=tests.git diff --git a/qaapi/qa/tests/node_run_tests.py b/qaapi/qa/tests/node_run_tests.py index 20f6423..9738b40 100755 --- a/qaapi/qa/tests/node_run_tests.py +++ b/qaapi/qa/tests/node_run_tests.py @@ -12,79 +12,50 @@ class node_run_tests(Test): then all are used. """ - def call(self, hostname, plcname, tests = None): + def __init__(self, config = None, logfile = None): + if not config: config = Config() + if not logfile: logfile = Logfile(config.logfile.dir + 'testscript.log') + Test.__init__(self, config, logfile) + + def call(self, hostname, plcname, test): node = self.config.get_node(hostname) plc = self.config.get_plc(plcname) - plc_ip = plc.update_ip() node_tests = ['node_cpu_sched.py', 'pf2test.pl'] node_tests_path = self.config.node_tests_path node_test_files = self.config.node_tests_path tests_dir = node['tests_dir'] - print >> node.logfile, "Running Node Tests" - - # Create tests archive - (archive_filename, archive_filepath) = self.config.archive_node_tests() - archive_dir = archive_filename.split('.tar')[0] - - # Copy tests archive to plc's webroot - plc.scp_to_webroot("%(archive_filepath)s" % locals()) - - # Download url onto node - url = "http://%(plc_ip)s/%(archive_filename)s" % locals() - node.wget(url, tests_dir) - - # Extract tests archive - tarx_cmd = "cd %(tests_dir)s && tar -xzm -f %(archive_filename)s" % locals() - print >> node.logfile, tarx_cmd - node.popen(tarx_cmd) - - # Make tests executable - # XX Should find a better way to do this - chmod_cmd = "cd %s/%s && chmod 755 %s " % (tests_dir, archive_dir, " ".join(node_tests) ) - print >> node.logfile, chmod_cmd - node.popen(chmod_cmd) - # Verify test files - if tests: - invalid_tests = set(tests).difference(node_tests) + if test: + invalid_tests = set([test]).difference(node_tests) if invalid_tests: raise Exception, "Invalid test(s) %s. File(s) not found in %s" % \ (" ".join(list(invalid_tests)), node_tests_path) - else: - tests = node_tests - - #tests = self.config.get_node_tests(tests) - # Add full path to test files - #test_files_abs = [node_tests_path + os.sep + file for file in tests] - - results = {} - for test in tests: - if self.config.verbose: - utils.header("Running %(test)s test on %(hostname)s" % locals(), logfile = self.config.logfile) - script = self.config.get_node_test(test) + + result = {} + if self.config.verbose: + utils.header("Running %(test)s test on %(hostname)s" % locals(), logfile = self.logfile) + script = self.config.get_node_test(test) - exe_pre, exe_script, exe_post = None, script['name'], None - if script['pre']: exe_pre = script['exe_pre'] - if script['args']: exe_script = "%s %s" % (script['name'], script['args']) - if script['post']: exe_post = script['exe_post'] + exe_pre, exe_script, exe_post = None, script['name'], None + if script['pre']: exe_pre = script['exe_pre'] + if script['args']: exe_script = "%s %s" % (script['name'], script['args']) + if script['post']: exe_post = script['exe_post'] - # Create a separate logfile for this script - logfile = Logfile(self.config.logfile.dir + script['name'] + ".log") - for command in [exe_pre, exe_script, exe_post]: - if command: - command = "cd %(tests_dir)s/%(archive_dir)s && ./%(command)s" % locals() - print >> node.logfile, command - print >> logfile, command - - # Execute script on node - (stdout, stderr) = node.popen(command, False) - print >> node.logfile, "".join(stdout) - print >> logfile, "".join(stdout) - if self.config.verbose: - utils.header(stdout, logfile = self.config.logfile) - results[test] = (stdout, stderr) + for command in [exe_pre, exe_script, exe_post]: + if command: + command = "cd %(tests_dir)s/%(archive_dir)s && ./%(command)s" % locals() + print >> node.logfile, command + print >> self.logfile, command + + # Execute script on node + (stdout, stderr) = node.popen(command, False) + print >> node.logfile, "".join(stdout) + print >> logfile, "".join(stdout) + if self.config.verbose: + utils.header(stdout, logfile = self.config.logfile) + results[test] = (stdout, stderr) return 1