then all are used.
"""
- def call(self, hostname, tests = None, root_key_path = "/etc/planetlab/root_ssh_key.rsa"):
-
- # Verify root key exists
- if not os.path.isfile(root_key_path):
- raise Exception, "no such private key file %(root_key_path)s" % locals()
+ def call(self, hostname, plcname, tests = None):
+ node_tests = ['node_cpu_sched.py', 'pf2test.pl']
node_tests_path = self.config.node_tests_path
node_test_files = self.config.node_tests_path
+ archive_name = 'tests.tar.gz'
+ archive_path = '/tmp/'
+ tests_path = '/usr/share/'
+ tests_dir = 'tests/'
+
+ node = self.config.get_node(hostname)
+ plc = self.config.get_plc(plcname)
+ plc_ip = plc.update_ip()
+
+ print >> node.logfile, "Running Node Tests"
+
+ # Create tests archive
+ if self.config.verbose:
+ utils.header("Updating tests archive at %(archive_path)s" % locals())
+ utils.commands("mkdir -p %(archive_path)s/%(tests_dir)s" % locals())
+ utils.commands("cp -Rf %(node_tests_path)s/* %(archive_path)s/%(tests_dir)s" % locals())
+ tar_cmd = "cd %(archive_path)s && tar -czf /%(archive_path)s/%(archive_name)s %(tests_dir)s" % locals()
+ print >> node.logfile, tar_cmd
+ (status, output) = utils.commands(tar_cmd)
+
+ # Copy tests archive to plc's webroot
+ if self.config.verbose:
+ utils.header("Copying tests archive onto %(plcname)s webroot" % locals())
+ plc.scp_to("%(archive_path)s/%(archive_name)s" % locals(), "/var/www/html/")
+
+ if self.config.verbose:
+ utils.header("Downloading tests archive onto %(hostname)s" % locals())
+ cleanup_cmd = "rm -f %(tests_path)s/%(archive_name)s" % locals()
+ print >> node.logfile, cleanup_cmd
+ node.commands(cleanup_cmd, False)
+ wget_cmd = "wget -nH -P %(tests_path)s http://%(plc_ip)s/%(archive_name)s" % locals()
+ print >> node.logfile, wget_cmd
+ # Download tests onto
+ node.commands(wget_cmd)
+
+ # Extract tests archive
+ tarx_cmd = "cd %(tests_path)s && tar -xzm -f %(archive_name)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/tests && chmod 755 %s " % (tests_path, " ".join(node_tests) )
+ print >> node.logfile, chmod_cmd
+ node.popen(chmod_cmd)
+
# Verify test files
if tests:
- invalid_tests = set(tests).difference(node_test_files)
+ invalid_tests = set(tests).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 = test_files
+ tests = node_tests
# Add full path to test files
test_files_abs = [node_tests_path + os.sep + file for file in tests]
- # Copy files onto node
- copy_command = "scp -i %s %s root@%s:/tmp/ " % (root_key_path, " ".join(test_files_abs), hostname)
- if self.config.verbose:
- utils.header(copy_command)
- (status, output) = utils.commands(copy_command)
-
- # execute each file individually
results = {}
- exe_command = "ssh -i %(root_key_path)s root@%(hostname)s /tmp/%(file)s"
- for file in test_files:
- command = exe_command % locals()
+ for test in tests:
+ if self.config.verbose:
+ utils.header("Running %(test)s test on %(hostname)s" % locals())
+ command = "cd %(tests_path)s/tests && ./%(test)s" % locals()
+ print >> node.logfile, command
+ (stdout, stderr) = node.popen(command, False)
+ print >> node.logfile, "".join(stdout)
+
if self.config.verbose:
- utils.header(command)
- (status, output) = utils.commands(command, False)
- results[file] = (status, output)
+ if status == 0:
+ utils.header("%(test)s Susccessful " % locals())
+ else:
+ utils.header("%(test)s Failed " % locals())
+ utils.header(output)
+ results[test] = (stdout, stderr)
return 1