6 class node_run_tests(Test):
8 Attempt to copy the specified node test files onto a node using
9 the plc root key and execute them. If no test files are specified,
13 def call(self, hostname, tests = None, root_key_path = "/etc/planetlab/root_ssh_key.rsa"):
15 # Verify root key exists
16 if not os.path.isfile(root_key_path):
17 raise Exception, "no such private key file %(root_key_path)s" % locals()
19 node_tests_path = self.config.node_tests_path
20 node_test_files = self.config.node_tests_path
23 invalid_tests = set(tests).difference(node_test_files)
25 raise Exception, "Invalid test(s) %s. File(s) not found in %s" % \
26 (" ".join(list(invalid_tests)), node_tests_path)
30 # Add full path to test files
31 test_files_abs = [node_tests_path + os.sep + file for file in tests]
33 # Copy files onto node
34 copy_command = "scp -i %s %s root@%s:/tmp/ " % (root_key_path, " ".join(test_files_abs), hostname)
35 if self.config.verbose:
36 utils.header(copy_command)
37 (status, output) = utils.commands(copy_command)
39 # execute each file individually
41 exe_command = "ssh -i %(root_key_path)s root@%(hostname)s /tmp/%(file)s"
42 for file in test_files:
43 command = exe_command % locals()
44 if self.config.verbose:
46 (status, output) = utils.commands(command, False)
47 results[file] = (status, output)
51 if __name__ == '__main__':
52 args = tuple(sys.argv[1:])
53 plc_remote_call()(*args)