+ vserver_names.append("%(VSERVER_BASENAME)s-%(distro)s-%(DATE)s" % locals())
+
+stop_vservers(exempt = vserver_names)
+
+for vserver_name in vserver_names:
+ try:
+ # Setup configuration
+ logfile_dir = "/var/log/qaapi/%(vserver_name)s" % locals()
+ config = Config(logdir = logfile_dir)
+ config.load("qa/qa_config.py")
+
+ config.plcs[plc_name]['vserver'] = vserver_name
+ config.plcs[plc_name]['host'] = config.hostname
+ config.plcs[plc_name]['ip'] = config.ip
+ config.plcs[plc_name].update_ip()
+ person_email = config.persons.values()[0]['email']
+
+ # Set plc configuration options
+ config_options = {}
+ for service in ['API', 'WWW', 'BOOT',' DB']:
+ config_options['PLC_'+service+'_HOST'] = config.plcs[plc_name]['ip']
+ config_options['PLC_'+service+'_IP'] = config.plcs[plc_name]['ip']
+ config_options['PLC_ROOT_USER'] = 'root@localhost.localdomain'
+ config_options['PLC_ROOT_PASSWORD'] = 'root'
+
+ # Set node configuration options
+ nodelist = ['vm1.paris.cs.princeton.edu']
+ node_tests = ['node_cpu_sched.py', 'pf2test.pl' ]
+ slice = config.slices['ts_slice1']
+
+ steps = {}
+ steps[1] = Step("Create vserver %s" % vserver_name, create_vserver,
+ (vserver_name, VSERVER_HOME, mailto), config.logfile.filename)
+ steps[2] = Step("Mount plc %s " % plc_name, config.plcs[plc_name].commands,
+ ("/sbin/service plc mount",), config.logfile.filename)
+ steps[3] = Step("Configure plc %s" % plc_name, plc_configure(config), (plc_name, config_options,),
+ config.logfile.filename)
+ steps[4] = Step("Start plc %s " % plc_name, plc_start(config), (plc_name,),
+ config.logfile.filename)
+ steps[5] = Step("Add test data", add_test_data(config), (plc_name,), config.logfile.filename)
+ steps[6] = Step("Sync person public key", sync_person_key(config), (person_email,),
+ config.logfile.filename, False)
+ # XX fix logfile parameter
+ step_method = api_unit_test(config)
+ #steps[7] = Step("API unit test", step_method, (plc_name,), step_method.logfile.filename, False)
+
+ for node in nodelist:
+ if not node in config.nodes.keys(): continue
+ node = config.nodes[node]
+ node['vserver'] = vserver_name
+ step_num = max(steps.keys()) + 1
+
+ # Boot node
+ steps[step_num] = Step("Boot node %s" % node['hostname'], boot_node(config),
+ (plc_name, node['hostname']), node.logfile.filename)
+
+ # Check if node is fully booted
+ ready_step = Step("Check %s is ready" % node['hostname'], node.is_ready, (), node.logfile.filename)
+ steps[step_num].next_steps.append(ready_step)
+
+ # Download test scripts
+ download_scripts = Step("Download test scripts onto %s" % node['hostname'], node.download_testscripts,
+ (), config.logfile.filename)
+ steps[step_num].next_steps.append(download_scripts)
+
+
+ # XX fix logfile parameter
+ # XX node_run_tests should only run the test, download test on node before calling node_run_test
+ for test in node_tests:
+ # Create a separate logfile for this script
+ log_filename = "%s/%s-%s.log" % (config.logfile.dir, test, node['hostname'])
+ test_logfile = Logfile(log_filename)
+ step_method = node_run_tests(config, test_logfile)
+ test_step = Step("%s test on node %s" % (test, node['hostname']),
+ step_method, (node['hostname'], plc_name, test),
+ step_method.logfile.filename, False)
+ steps[step_num].next_steps.append(test_step)
+
+ # enter test slice
+ step_num = step_num + 1
+ steps[step_num] = Step("Enter slice %s on %s" % (slice['name'], node['hostname']),
+ node.slice_commands, ("echo `whoami`@`hostname`", slice['name']),
+ node.logfile.filename, False)
+
+ # Copy contents of /var/log
+ step_num = step_num + 1
+ steps[step_num] = Step("Get %s logs" % node['hostname'], node.get_logs, (),
+ node.logfile.filename, False)
+
+ # Now that all the steps are defined, run them
+ order = steps.keys()
+ order.sort()
+ results = {}
+ for num in order:
+ steps[num].run()
+ steps[num].notify_contacts()
+ if steps[num].fatal and not steps[num].passed:
+ break
+
+ # Generate summary email
+ to = ["qa@planet-lab.org"]
+ subject = "PLC - %(distro)s - %(DATE)s QA summary" % locals()
+ body = """
+ The following are the results of QA tests for %(DATE)s %(distro)s MyPLC.\n\n""" % locals()