Exemple #1
0
def main():
    running = False

    # Check for manifest file
    if not os.path.exists(TEST_FILE):
        print "4:Manifest file has not been created. Have run the kit? (Has an error occured?)"
        sys.exit(0)

    # Check for the python process
    if check_for_process():
        running = True

    # Check the XML file to find out how many tests have been run
    try:
        ack_run = models.parse_xml(TEST_FILE)
    except:
        print "5:An error has occured reading. %s" % TEST_FILE
        sys.exit(1)

    p, f, s, w = ack_run.get_status()

    if w == 0:
        print "0:Finished (Passed:%d, Failed:%d, Skipped:%d)" % (p, f, s)
    elif not running and utils.get_reboot_flag():
        print "3:Server rebooting... (Passed:%d, Failed:%d, Skipped:%d, Waiting:%d)" % (
            p, f, s, w)
    elif not running and not utils.get_reboot_flag():
        print "1:Process not running. An error has occurred. (Passed:%d, Failed:%d, Skipped: %d, Waiting:%d)" % (
            p, f, s, w)
        sys.exit(1)
    else:
        perc = float(p + f + s) / float(w + p + f + s) * 100
        print "2:Running - %d%% Complete (Passed:%d, Failed:%d, Skipped:%d, Waiting:%d)" % (
            perc, p, f, s, w)
Exemple #2
0
def main():
    running = False

    # Check for manifest file
    if not os.path.exists(TEST_FILE):
        print "4:Manifest file has not been created. Have run the kit? (Has an error occured?)"
        sys.exit(0)

    # Check for the python process
    if check_for_process():
        running = True

    # Check the XML file to find out how many tests have been run
    try:
        ack_run = models.parse_xml(TEST_FILE)
    except:
        print "5:An error has occured reading. %s" % TEST_FILE
        sys.exit(1)

    p, f, s, w = ack_run.get_status()

    if w == 0:
        print "0:Finished (Passed:%d, Failed:%d, Skipped:%d)" % (p, f, s)
    elif not running and utils.get_reboot_flag():
        print "3:Server rebooting... (Passed:%d, Failed:%d, Skipped:%d, Waiting:%d)" % (p, f, s, w)
    elif not running and not utils.get_reboot_flag():
        print "1:Process not running. An error has occurred. (Passed:%d, Failed:%d, Skipped: %d, Waiting:%d)" % (p, f, s, w)
        sys.exit(1)
    else:
        perc = float(p + f + s) / float(w + p + f + s) * 100
        print "2:Running - %d%% Complete (Passed:%d, Failed:%d, Skipped:%d, Waiting:%d)" % (perc, p, f, s, w)
def run_tests_from_file(test_file):
    """Open the testfile, retrieve the next un-executed to completion test"""

    session = get_local_xapi_session()

    # Ensure that all hosts in the pool have booted up. (for the case where
    # we have had to reboot to switch backend).
    wait_for_hosts(session)

    ack_model = models.parse_xml(test_file)

    config = ack_model.get_global_config()

    log.debug("ACK Model: %s" % ack_model.is_finished())
    while not ack_model.is_finished():
        log.debug("Test Run Status: P %d, F %d, W %d" % (ack_model.get_status()))

        next_test = ack_model.get_next_test_class()

        # Merge device specific config into the global config dict object
        # that will then be passed to the test class.
        config["device_config"] = next_test.get_device_config()

        log.debug("About to run test: '%s'" % next_test.get_name())
        results = run_test(session, next_test.get_name(), config)

        # Update the python objects with results
        next_test.update(results)

        # Save the updated test class back to the config file
        next_test.save(test_file)

    log.debug("Logging out of xapi session %s" % session.handle)
    session.xenapi.session.local_logout()

    # Note: due to XAPI character restrictions, we have to encode this filename
    # in the XAPI plugin itself. This should be fixed in the future if possible.

    txt_result_file = "/root/results.txt"
    result = test_report.post_test_report(test_file, txt_result_file)

    # Note: due to the XAPI character restrictions, we can not
    # pass to the plugin paths. This means that the test_run.conf file
    # has to be hardcoded as part of the output package in the plugin.
    package_loc = call_ack_plugin(session, "create_output_package")

    if result:
        log.debug("Your hardware has passed all of the expected tests")
        log.debug("Please upload %s to a Citrix Tracker submission." % package_loc)
    else:
        log.debug("Error: Not all of the hardware tests passed certification.")
        log.debug("Please look at the logs found in /var/log/auto-cert-kit.log")
        log.debug("A fuller summary of the tests can be found in %s" % txt_result_file)
        log.debug("The output package has been saved here: %s" % package_loc)

    return test_file, package_loc
Exemple #4
0
def run_tests_from_file(test_file):
    """Open the testfile, retrieve the next un-executed to completion test"""

    session = get_local_xapi_session()

    #Ensure that all hosts in the pool have booted up. (for the case where
    #we have had to reboot to switch backend).
    wait_for_hosts(session)

    ack_model = models.parse_xml(test_file)

    config = ack_model.get_global_config()

    log.debug("ACK Model: %s" % ack_model.is_finished())
    if not ack_model.is_finished():
        # Ensure that we cleanup before running tests, in case
        # the system has been left in a failed state.
        pool_wide_cleanup(session)

    while not ack_model.is_finished():
        log.debug("Test Run Status: P %d, F %d, S %d, W %d" %
                  (ack_model.get_status()))

        tc_info = get_reboot_flag()
        test_name = None
        if tc_info and 'test_method' in tc_info:
            test_name = tc_info['test_method']

        next_test_class = ack_model.get_next_test_class(tc_info)
        next_test_method = next_test_class.get_next_test_method(test_name)
        if not next_test_method:
            raise Exception("No more test method to run from test class: %s" %
                            next_test_class.get_name())

        # Merge device specific config into the global config dict object
        # that will then be passed to the test class.
        config['device_config'] = next_test_class.get_device_config()

        log.debug("About to run test: '%s.%s'" %
                  (next_test_class.get_name(), next_test_method.get_name()))
        test_inst = get_test_class(next_test_class.get_name())(session, config)
        result = test_inst.run(to_bool(get_value(config, 'debug')),
                               next_test_method.get_name())

        # Update the python objects with results
        next_test_class.update(result)

        # Save the updated test class back to the config file
        next_test_class.save(test_file)

        # Reset reboot flag
        clear_reboot_flag()

    log.debug("Logging out of xapi session %s" % session.handle)
    session.xenapi.session.local_logout()

    # Note: due to XAPI character restrictions, we have to encode this filename
    # in the XAPI plugin itself. This should be fixed in the future if possible.

    txt_result_file = "/root/results.txt"
    result = test_report.post_test_report(test_file, txt_result_file)

    # Note: due to the XAPI character restrictions, we can not
    # pass to the plugin paths. This means that the test_run.conf file
    # has to be hardcoded as part of the output package in the plugin.
    package_loc = call_ack_plugin(session, 'create_output_package')

    if result:
        log.debug("Your hardware has passed all of the expected tests")
        log.debug("Please upload %s to a Citrix Tracker submission." %
                  package_loc)
    else:
        log.debug("Error: Not all of the hardware tests passed certification.")
        log.debug(
            "Please look at the logs found in /var/log/auto-cert-kit.log")
        log.debug("A fuller summary of the tests can be found in %s" %
                  txt_result_file)
        log.debug("The output package has been saved here: %s" % package_loc)

    return test_file, package_loc
Exemple #5
0
def run_tests_from_file(test_file):
    """Open the testfile, retrieve the next un-executed to completion test"""

    session = get_local_xapi_session()

    # Ensure that all hosts in the pool have booted up. (for the case where
    # we have had to reboot to switch backend).
    wait_for_hosts(session)

    ack_model = models.parse_xml(test_file)

    config = ack_model.get_global_config()

    log.debug("ACK Model: %s" % ack_model.is_finished())
    if not ack_model.is_finished():
        # Ensure that we cleanup before running tests, in case
        # the system has been left in a failed state.
        pool_wide_cleanup(session)

    while not ack_model.is_finished():
        log.debug("Test Run Status: P %d, F %d, S %d, W %d" %
                  (ack_model.get_status()))

        tc_info = get_reboot_flag()
        test_name = None
        if tc_info and 'test_method' in tc_info:
            test_name = tc_info['test_method']

        next_test_class = ack_model.get_next_test_class(tc_info)
        next_test_method = next_test_class.get_next_test_method(test_name)
        if not next_test_method:
            raise Exception("No more test method to run from test class: %s" %
                            next_test_class.get_name())

        # Merge device specific config into the global config dict object
        # that will then be passed to the test class.
        config['device_config'] = next_test_class.get_device_config()

        log.debug("About to run test: '%s'" % (next_test_class.get_name()))
        test_inst = get_test_class(next_test_class.get_name())(session, config)
        result = test_inst.run(
            to_bool(get_value(config, 'debug')), next_test_method.get_name())

        # Update the python objects with results
        next_test_class.update(result)

        # Save the updated test class back to the config file
        next_test_class.save(test_file)

        # Reset reboot flag
        clear_reboot_flag()

    log.debug("Logging out of xapi session %s" % session.handle)
    session.xenapi.session.local_logout()

    # Note: due to XAPI character restrictions, we have to encode this filename
    # in the XAPI plugin itself. This should be fixed in the future if
    # possible.

    txt_result_file = "/root/results.txt"
    result = test_report.post_test_report(test_file, txt_result_file)

    # Note: due to the XAPI character restrictions, we can not
    # pass to the plugin paths. This means that the test_run.conf file
    # has to be hardcoded as part of the output package in the plugin.
    package_loc = call_ack_plugin(session, 'create_output_package')

    if result:
        log.debug("Your hardware has passed all of the expected tests")
        log.debug("Please upload %s to a Citrix Tracker submission." %
                  package_loc)
    else:
        log.debug("Error: Not all of the hardware tests passed certification.")
        log.debug("Please look at the logs found in /var/log/auto-cert-kit.log")
        log.debug("A fuller summary of the tests can be found in %s" %
                  txt_result_file)
        log.debug("The output package has been saved here: %s" % package_loc)

    return test_file, package_loc
Exemple #6
0
def run_tests_from_file(test_file):
    """Open the testfile, retrieve the next un-executed to completion test"""

    session = get_local_xapi_session()
    # Ensure that all hosts in the pool have booted up. (for the case where
    # we have had to reboot to switch backend).
    wait_for_hosts(session)

    ack_model = models.parse_xml(test_file)

    config = ack_model.get_global_config()

    if "vpx_dlvm_file" in config.keys():
        utils.vpx_dlvm_file = config["vpx_dlvm_file"]

    log.debug("ACK Model, finished: %s" % ack_model.is_finished())

    while not ack_model.is_finished():
        log.debug("Test Run Status: P %d, F %d, S %d, W %d, R %d" %
                  (ack_model.get_status()))

        next_test_class, next_test_method = ack_model.get_next_test()
        if not next_test_method:
            raise Exception("No more test method to run from test class: %s" %
                            next_test_class.get_name())

        class_name = next_test_class.get_name()
        method_name = next_test_method.get_name()

        # Merge useful info into the global config dict object
        # that will then be passed to the test class.
        config['device_config'] = next_test_class.get_device_config()
        config['test_method'] = next_test_method
        config['test_class'] = next_test_class

        log.debug("About to run test: '%s'" % method_name)

        # set to running status, then status.py will know it
        running_status = {'test_name': method_name, 'status': 'running'}
        next_test_class.update([running_status])
        next_test_class.save(test_file)

        debug = to_bool(get_value(config, 'debug'))
        test_inst = get_test_class(class_name)(session, config)
        results = test_inst.run(debug, method_name)

        result = results[0]
        reboot = False
        if get_value(result, 'superior') == 'reboot':
            reboot = True
            test_inst.unset_superior(result)

        # Update the python objects with results
        next_test_class.update(results)
        # Save the updated test class back to the config file
        next_test_class.save(test_file)

        if reboot:
            reboot_normally(session)

    log.debug("Logging out of xapi session %s" % session.handle)
    session.xenapi.session.local_logout()

    # Note: due to XAPI character restrictions, we have to encode this filename
    # in the XAPI plugin itself. This should be fixed in the future if
    # possible.

    txt_result_file = "/root/results.txt"
    result = test_report.post_test_report(test_file, txt_result_file)

    # Note: due to the XAPI character restrictions, we can not
    # pass to the plugin paths. This means that the test_run.conf file
    # has to be hardcoded as part of the output package in the plugin.
    package_loc = call_ack_plugin(session, 'create_output_package')

    if result:
        log.debug("Your hardware has passed all of the expected tests")
        log.debug("Please upload %s to a Citrix Tracker submission." %
                  package_loc)
    else:
        log.debug("Error: Not all of the hardware tests passed certification.")
        log.debug(
            "Please look at the logs found in /var/log/auto-cert-kit.log")
        log.debug("A fuller summary of the tests can be found in %s" %
                  txt_result_file)
        log.debug("The output package has been saved here: %s" % package_loc)

    return test_file, package_loc
def run_tests_from_file(test_file):
    """Open the testfile, retrieve the next un-executed to completion test"""

    session = get_local_xapi_session()

    # Ensure that all hosts in the pool have booted up. (for the case where
    # we have had to reboot to switch backend).
    wait_for_hosts(session)

    ack_model = models.parse_xml(test_file)

    config = ack_model.get_global_config()

    if "vpx_dlvm_file" in config.keys():
        utils.vpx_dlvm_file = config["vpx_dlvm_file"]

    log.debug("ACK Model, finished: %s" % ack_model.is_finished())

    while not ack_model.is_finished():
        log.debug("Test Run Status: P %d, F %d, S %d, W %d, R %d" %
                  (ack_model.get_status()))

        next_test_class, next_test_method = ack_model.get_next_test()
        if not next_test_method:
            raise Exception("No more test method to run from test class: %s" %
                            next_test_class.get_name())

        class_name = next_test_class.get_name()
        method_name = next_test_method.get_name()

        # Merge useful info into the global config dict object
        # that will then be passed to the test class.
        config['device_config'] = next_test_class.get_device_config()
        config['test_method'] = next_test_method
        config['test_class'] = next_test_class

        log.debug("About to run test: '%s'" % method_name)

        # set to running status, then status.py will know it
        running_status = {'test_name': method_name, 'status': 'running'}
        next_test_class.update([running_status])
        next_test_class.save(test_file)

        debug = to_bool(get_value(config, 'debug'))
        test_inst = get_test_class(class_name)(session, config)
        results = test_inst.run(debug, method_name)

        result = results[0]
        reboot = False
        if get_value(result, 'superior') == 'reboot':
            reboot = True
            test_inst.unset_superior(result)

        # Update the python objects with results
        next_test_class.update(results)
        # Save the updated test class back to the config file
        next_test_class.save(test_file)

        if reboot:
            reboot_normally(session)

    log.debug("Logging out of xapi session %s" % session.handle)
    session.xenapi.session.local_logout()

    # Note: due to XAPI character restrictions, we have to encode this filename
    # in the XAPI plugin itself. This should be fixed in the future if
    # possible.

    txt_result_file = "/root/results.txt"
    result = test_report.post_test_report(test_file, txt_result_file)

    # Note: due to the XAPI character restrictions, we can not
    # pass to the plugin paths. This means that the test_run.conf file
    # has to be hardcoded as part of the output package in the plugin.
    package_loc = call_ack_plugin(session, 'create_output_package')

    if result:
        log.debug("Your hardware has passed all of the expected tests")
        log.debug("Please upload %s to a Citrix Tracker submission." %
                  package_loc)
    else:
        log.debug("Error: Not all of the hardware tests passed certification.")
        log.debug("Please look at the logs found in /var/log/auto-cert-kit.log")
        log.debug("A fuller summary of the tests can be found in %s" %
                  txt_result_file)
        log.debug("The output package has been saved here: %s" % package_loc)

    return test_file, package_loc