+ 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)
+