def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Release current logger before running logrotate. utils.release_logging() # Run log rotate before ACK produces any log. for host_ref in session.xenapi.host.get_all(): session.xenapi.host.call_plugin(host_ref, 'autocertkit', 'run_ack_logrotate', {}) utils.configure_logging('auto-cert-kit') pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() if 'generate' in config: # Generate config file only utils.log.info("Test file generated") return "OK" # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Release current logger before running logrotate. utils.release_logging() # Run log rotate before ACK produces any log. for host_ref in session.xenapi.host.get_all(): res = session.xenapi.host.call_plugin(host_ref, 'autocertkit', 'run_ack_logrotate', {}) utils.configure_logging('auto-cert-kit') pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() if 'generate' in config: #Generate config file only utils.log.info("Test file generated") return "OK" #Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) config['xs_version'] = utils.get_xenserver_version(session) pre_flight_checks(session, config) generate_test_config(session, config, test_run_file) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() if 'generate' in config: #Generate config file only utils.log.info("Test file generated") return "OK" #Kick off the testrunner test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Ensure that all hosts in the pool have booted up. utils.wait_for_hosts(session) # Start Logger utils.init_ack_logging(session) utils.log.info("Options: %s" % config) # Pre checks before running tests pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) if 'generate' in config: # Generate config file only utils.log.info("Test file generated") session.logout() return "OK" # cleanup in case previous run did not complete entirely if utils.pool_wide_cleanup(session): utils.reboot_normally(session) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def main(config, test_run_file): """Main routine - assess which tests should be run, and create output file""" session = get_xapi_session(config) # Start Logger utils.init_ack_logging(session) utils.log.info("Options: %s" % config) # Pre checks before running tests pre_flight_checks(session, config) config['xs_version'] = utils.get_xenserver_version(session) config['xcp_version'] = utils.get_xcp_version(session) generate_test_config(session, config, test_run_file) if 'generate' in config: # Generate config file only utils.log.info("Test file generated") session.logout() return "OK" # cleanup in case previous run did not complete entirely if utils.pool_wide_cleanup(session): utils.reboot_normally(session) # Logout of XAPI session anyway - the test runner will create a new session # if needed. (We might only be generating). session.logout() # Kick off the testrunner utils.log.info("Starting Test Runner from ACK CLI.") test_file, output = test_runner.run_tests_from_file(test_run_file)
def append_xml_config(self, doc, xml_node): """Append xml config for running the tests. xml_node should be the devices xml tag under which each device to be certified hangs.""" device_node = doc.createElement('device') device_config = self.get_device_config() if device_config: for k, v in device_config.iteritems(): device_node.setAttribute(k, v) # Set the unique device id device_node.setAttribute('udid', str(self.get_uid())) # Set the device type device_node.setAttribute('tag', self.TAG) cts_node = doc.createElement('certification_tests') device_node.appendChild(cts_node) test_classes = self.get_test_classes() for test_class_name, test_class in test_classes: skipthis = False xs_version = utils.get_xenserver_version(self.session) if test_class.REQUIRED_FOR: if utils.eval_expr(test_class.REQUIRED_FOR, xs_version): if not utils.REQ_CAP in test_class.caps: test_class.caps.append(utils.REQ_CAP) else: if utils.REQ_CAP in test_class.caps: test_class.caps.remove(utils.REQ_CAP) skipthis = True class_node = doc.createElement('test_class') class_node.setAttribute('name', test_class_name) class_node.setAttribute( 'caps', str(test_class(self.session, self.config).caps)) class_node.setAttribute( 'order', str(test_class(self.session, self.config).order)) test_methods = test_class(self.session, self.config).list_tests() for method in test_methods: method_node = doc.createElement('test_method') method_node.setAttribute('name', str(method)) #Result/Info fields result_node = doc.createElement('result') info_node = doc.createElement('info') if skipthis: result_node.appendChild(doc.createTextNode('skip')) reason_node = doc.createElement('reason') reason_node.appendChild( doc.createTextNode( '%s is not required for XenServer %s.' % (test_class_name, xs_version))) method_node.appendChild(reason_node) else: result_node.appendChild(doc.createTextNode('NULL')) method_node.appendChild(result_node) method_node.appendChild(info_node) testname_node = doc.createElement('test_name') testname_node.appendChild( doc.createTextNode( '%s.%s' % (test_class_name.split('.')[1], str(method)))) method_node.appendChild(testname_node) class_node.appendChild(method_node) cts_node.appendChild(class_node) xml_node.appendChild(device_node)
def append_xml_config(self, doc, xml_node): """Append xml config for running the tests. xml_node should be the devices xml tag under which each device to be certified hangs.""" device_node = doc.createElement('device') device_config = self.get_device_config() if device_config: for k, v in device_config.iteritems(): device_node.setAttribute(k, v) # Set the unique device id device_node.setAttribute('udid', str(self.get_uid())) # Set the device type device_node.setAttribute('tag', self.TAG) cts_node = doc.createElement('certification_tests') device_node.appendChild(cts_node) test_classes = self.get_test_classes() for test_class_name, test_class in test_classes: skipthis = False xs_version = utils.get_xenserver_version(self.session) if test_class.REQUIRED_FOR: if utils.eval_expr(test_class.REQUIRED_FOR, xs_version): if not utils.REQ_CAP in test_class.caps: test_class.caps.append(utils.REQ_CAP) else: if utils.REQ_CAP in test_class.caps: test_class.caps.remove(utils.REQ_CAP) skipthis = True class_node = doc.createElement('test_class') class_node.setAttribute('name', test_class_name) class_node.setAttribute('caps', str(test_class(self.session,self.config).caps)) class_node.setAttribute('order', str(test_class(self.session,self.config).order)) test_methods = test_class(self.session, self.config).list_tests() for method in test_methods: method_node = doc.createElement('test_method') method_node.setAttribute('name', str(method)) #Result/Info fields result_node = doc.createElement('result') info_node = doc.createElement('info') if skipthis: result_node.appendChild(doc.createTextNode('skip')) reason_node = doc.createElement('reason') reason_node.appendChild(doc.createTextNode('%s is not required for XenServer %s.' % (test_class_name, xs_version))) method_node.appendChild(reason_node) else: result_node.appendChild(doc.createTextNode('NULL')) method_node.appendChild(result_node) method_node.appendChild(info_node) testname_node = doc.createElement('test_name') testname_node.appendChild(doc.createTextNode('%s.%s' % (test_class_name.split('.')[1], str(method)))) method_node.appendChild(testname_node) class_node.appendChild(method_node) cts_node.appendChild(class_node) xml_node.appendChild(device_node)