5 from qa.TestScripts import TestScript, TestScripts
6 from qa.logger import Logfile
8 class node_run_tests(Test):
10 Attempt to download and execute the specified test scripts onto a node
11 and execute them run them. If no test files are specified,
15 def __init__(self, config = None, logfile = None):
16 if not config: config = Config()
17 if not logfile: logfile = Logfile(config.logfile.dir + 'testscript.log')
18 Test.__init__(self, config, logfile)
20 def call(self, hostname, plcname, test):
22 node = self.config.get_node(hostname)
23 plc = self.config.get_plc(plcname)
24 node_tests = ['node_cpu_sched.py', 'pf2test.pl']
25 node_tests_path = self.config.node_tests_path
26 node_test_files = self.config.node_tests_path
27 tests_dir = node['tests_dir']
31 invalid_tests = set([test]).difference(node_tests)
33 raise Exception, "Invalid test(s) %s. File(s) not found in %s" % \
34 (" ".join(list(invalid_tests)), node_tests_path)
37 if self.config.verbose:
38 utils.header("Running %(test)s test on %(hostname)s" % locals(), logfile = self.logfile)
39 script = self.config.get_node_test(test)
41 exe_pre, exe_script, exe_post = None, script['name'], None
42 if script['pre']: exe_pre = script['exe_pre']
43 if script['args']: exe_script = "%s %s" % (script['name'], script['args'])
44 if script['post']: exe_post = script['exe_post']
46 for command in [exe_pre, exe_script, exe_post]:
48 command = "cd %(tests_dir)s/%(archive_dir)s && ./%(command)s" % locals()
49 print >> node.logfile, command
50 print >> self.logfile, command
52 # Execute script on node
53 (stdout, stderr) = node.popen(command, False)
54 print >> node.logfile, "".join(stdout)
55 print >> logfile, "".join(stdout)
56 if self.config.verbose:
57 utils.header(stdout, logfile = self.config.logfile)
58 results[test] = (stdout, stderr)
62 if __name__ == '__main__':
63 args = tuple(sys.argv[1:])
64 plc_remote_call()(*args)