예제 #1
0
def run_all(config_file, pkgName, git, patch, skip_setup, read_cache, project,
            suite_dir, test_cases, base_dir, output_dir, verbose, virttype,
            debug, debugcase, re_run, commands):
    """
    Main process of DTS, it will run all test suites in the config file.
    """

    global requested_tests
    global result
    global excel_report
    global json_report
    global stats_report
    global log_handler
    global check_case_inst

    # save global variable
    serializer = Serializer()

    # load check/support case lists
    check_case_inst = CheckCase()

    # prepare the output folder
    if output_dir == '':
        output_dir = settings.FOLDERS['Output']

    if not os.path.exists(output_dir):
        os.mkdir(output_dir)

    # add external library
    exec_file = os.path.realpath(__file__)
    extra_libs_path = exec_file.replace('framework/dts.py', '') + 'extra_libs'
    sys.path.insert(1, extra_libs_path)

    # add python module search path
    sys.path.append(suite_dir)

    # enable debug mode
    if debug is True:
        settings.save_global_setting(settings.DEBUG_SETTING, 'yes')
    if debugcase is True:
        settings.save_global_setting(settings.DEBUG_CASE_SETTING, 'yes')

    # init log_handler handler
    if verbose is True:
        logger.set_verbose()

    if re_run < 0:
        re_run = 0

    logger.log_dir = output_dir
    log_handler = getLogger('dts')
    log_handler.config_execution('dts')

    # run designated test case
    requested_tests = test_cases

    # Read config file
    dts_cfg_folder = settings.load_global_setting(settings.DTS_CFG_FOLDER)
    if dts_cfg_folder != '':
        config_file = dts_cfg_folder + os.sep + config_file

    config = ConfigParser.SafeConfigParser()
    load_cfg = config.read(config_file)
    if len(load_cfg) == 0:
        raise ConfigParseException(config_file)

    # parse commands
    dts_commands = dts_parse_commands(commands)

    os.environ["TERM"] = "dumb"

    # change rst output folder
    rst.path2Result = output_dir

    # report objects
    excel_report = ExcelReporter(output_dir + '/test_results.xls')
    json_report = JSONReporter(output_dir + '/test_results.json')
    stats_report = StatsReporter(output_dir + '/statistics.txt')
    result = Result()

    crbInsts = []
    crbs_conf = CrbsConf()
    crbs = crbs_conf.load_crbs_config()

    # for all Execution sections
    for section in config.sections():
        dts_parse_param(config, section)

        # verify if the delimiter is good if the lists are vertical
        duts, targets, test_suites = dts_parse_config(config, section)
        for dut in duts:
            log_handler.info("\nDUT " + dut)

        # look up in crbs - to find the matching IP
        for dut in duts:
            for crb in crbs:
                if crb['section'] == dut:
                    crbInsts.append(crb)
                    break

        # only run on the dut in known crbs
        if len(crbInsts) == 0:
            log_handler.error(" SKIP UNKNOWN CRB")
            continue

        result.dut = duts[0]

        # init global lock
        create_parallel_locks(len(duts))

        # init dut, tester crb
        duts, tester = dts_crbs_init(crbInsts, skip_setup, read_cache, project,
                                     base_dir, serializer, virttype)
        tester.set_re_run(re_run)
        # register exit action
        atexit.register(quit_execution, duts, tester)

        check_case_inst.check_dut(duts[0])

        # Run DUT prerequisites
        if dts_run_prerequisties(duts, tester, pkgName, patch, dts_commands,
                                 serializer) is False:
            dts_crbs_exit(duts, tester)
            continue

        dts_run_target(duts, tester, targets, test_suites)

        dts_crbs_exit(duts, tester)

    save_all_results()
예제 #2
0
def run_all(config_file, skip_setup, project, suite_dir, base_dir, output_dir,
            dpdk_dir):
    """
    Main process of SPDK tests, it will run all test suites in the config file.
    """
    global result
    global log_handler
    # save global variable
    serializer = Serializer()
    # prepare the output folder
    if output_dir == '':
        output_dir = settings.FOLDERS['Output']
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    # add python module search path
    sys.path.append(suite_dir)
    sys.path.append(dpdk_dir)
    logger.log_dir = output_dir
    log_handler = getLogger('spdk')
    log_handler.config_execution('spdk')
    # Read config file
    config = ConfigParser.SafeConfigParser()
    load_cfg = config.read(config_file)
    if len(load_cfg) == 0:
        raise ConfigParseException(config_file)
    os.environ["TERM"] = "dumb"
    # report objects
    result = Result()
    crbInsts = []
    crbs_conf = CrbsConf()
    crbs = crbs_conf.load_crbs_config()
    # for all Exectuion sections
    for section in config.sections():
        spdk_parse_param(config, section)
        # verify if the delimiter is good if the lists are vertical
        dutIPs, targets, test_suites = spdk_parse_config(config, section)
        for dutIP in dutIPs:
            log_handler.info("\nDUT " + dutIP)
        # look up in crbs - to find the matching IP
        for dutIP in dutIPs:
            for crb in crbs:
                if crb['IP'] == dutIP:
                    crbInsts.append(crb)
                    break
        # only run on the dut in known crbs
        if len(crbInsts) == 0:
            cwd = os.path.dirname(os.path.dirname(__file__))
            path1 = cwd + '/framework/execution.cfg'
            path2 = cwd + '/framework/crbs.cfg'
            print "               <Target_IP_Address> is", dutIP, "in", path1
            log_handler.error(" SKIP UNKNOWN TARGET")
            if dutIP != '<Target_IP_Address>':
                print "               Please check IP Address information in", path1, "and", path2
            continue
        result.dut = dutIPs[0]
        # init dut, tester crb
        duts, tester = spdk_crbs_init(crbInsts, skip_setup, project, base_dir,
                                      serializer, dpdk_dir)
        # register exit action
        atexit.register(quit_execution, duts, tester)
        # Run DUT prerequisites
        if spdk_run_prerequisties(duts, tester, serializer) is False:
            spdk_crbs_exit(duts, tester)
            continue
        spdk_run_target(duts, tester, targets, test_suites)
        spdk_crbs_exit(duts, tester)
예제 #3
0
def run_all(config_file, pkgName, git, patch, skip_setup,
            read_cache, project, suite_dir, test_cases,
            base_dir, output_dir, verbose, debug):
    """
    Main process of DTS, it will run all test suites in the config file.
    """

    global config
    global serializer
    global nic
    global requested_tests
    global result
    global excel_report
    global stats
    global log_handler
    global debug_mode

    # prepare the output folder
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)

    # add python module search path
    for folder in FOLDERS.values():
        sys.path.append(folder)
    sys.path.append(suite_dir)

    # enable debug mode
    if debug is True:
        debug_mode = True

    # init log_handler handler
    if verbose is True:
        logger.set_verbose()

    logger.log_dir = output_dir
    log_handler = getLogger('dts')
    log_handler.config_execution('dts')

    # run designated test case
    requested_tests = test_cases

    # Read config file
    config = ConfigParser.SafeConfigParser()
    config.read(config_file)

    # register exit action
    atexit.register(close_crb_sessions)

    os.environ["TERM"] = "dumb"

    serializer = Serializer()

    # excel report and statistics file
    result = Result()
    rst.path2Result = output_dir
    excel_report = ExcelReporter(output_dir + '/test_results.xls')
    stats = StatsReporter(output_dir + '/statistics.txt')

    # for all Exectuion sections
    for section in config.sections():
        dts_parse_param(section)

        # verify if the delimiter is good if the lists are vertical
        dutIP, targets, test_suites, nics = dts_parse_config(section)

        log_handler.info("\nDUT " + dutIP)

        # look up in crbs - to find the matching IP
        crbInst = None
        for crb in crbs:
            if crb['IP'] == dutIP:
                crbInst = crb
                break

        # only run on the dut in known crbs
        if crbInst is None:
            log_handler.error(" SKIP UNKNOWN CRB")
            continue

        result.dut = dutIP

        # init dut, tester crb
        dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics)

        # Run DUT prerequisites
        if dts_run_prerequisties(pkgName, patch) is False:
            dts_crbs_exit()
            continue

        dts_run_target(crbInst, targets, test_suites, nics)

        dts_crbs_exit()

    save_all_results()
예제 #4
0
def run_all(config_file, pkgName, git, patch, skip_setup, read_cache, project,
            suite_dir, test_cases, base_dir, output_dir, verbose, debug):
    """
    Main process of DTS, it will run all test suites in the config file.
    """

    global config
    global serializer
    global nic
    global requested_tests
    global result
    global excel_report
    global stats
    global log_handler
    global debug_mode

    # prepare the output folder
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)

    # add python module search path
    for folder in FOLDERS.values():
        sys.path.append(folder)
    sys.path.append(suite_dir)

    # enable debug mode
    if debug is True:
        debug_mode = True

    # init log_handler handler
    if verbose is True:
        logger.set_verbose()

    logger.log_dir = output_dir
    log_handler = getLogger('dts')
    log_handler.config_execution('dts')

    # run designated test case
    requested_tests = test_cases

    # Read config file
    config = ConfigParser.SafeConfigParser()
    config.read(config_file)

    # register exit action
    atexit.register(close_crb_sessions)

    os.environ["TERM"] = "dumb"

    serializer = Serializer()

    # excel report and statistics file
    result = Result()
    rst.path2Result = output_dir
    excel_report = ExcelReporter(output_dir + '/test_results.xls')
    stats = StatsReporter(output_dir + '/statistics.txt')

    # for all Exectuion sections
    for section in config.sections():
        dts_parse_param(section)

        # verify if the delimiter is good if the lists are vertical
        dutIP, targets, test_suites, nics = dts_parse_config(section)

        log_handler.info("\nDUT " + dutIP)

        # look up in crbs - to find the matching IP
        crbInst = None
        for crb in crbs:
            if crb['IP'] == dutIP:
                crbInst = crb
                break

        # only run on the dut in known crbs
        if crbInst is None:
            log_handler.error(" SKIP UNKNOWN CRB")
            continue

        result.dut = dutIP

        # init dut, tester crb
        dts_crbs_init(crbInst, skip_setup, read_cache, project, base_dir, nics)

        # Run DUT prerequisites
        if dts_run_prerequisties(pkgName, patch) is False:
            dts_crbs_exit()
            continue

        dts_run_target(crbInst, targets, test_suites, nics)

        dts_crbs_exit()

    save_all_results()
예제 #5
0
def run_all(config_file, pkgName, patch, force_setup, read_cache, project,
            suite_dir, test_cases, base_dir, output_dir, verbose, virttype,
            debug, debugcase, re_run, commands, pktgen, test_configs):
    """
    Main process of DTS, it will run all test suites in the config file.
    """

    global requested_tests
    global result
    global excel_report
    global json_report
    global stats_report
    global log_handler
    global check_case_inst

    # save global variable
    serializer = Serializer()

    # load check/support case lists
    check_case_inst = CheckCase()

    # prepare the output folder
    if output_dir == '':
        output_dir = settings.FOLDERS['Output']

    if not os.path.exists(output_dir):
        os.mkdir(output_dir)

    # add python module search path
    sys.path.append(suite_dir)

    # enable debug mode
    if debug is True:
        settings.save_global_setting(settings.DEBUG_SETTING, 'yes')
    if debugcase is True:
        settings.save_global_setting(settings.DEBUG_CASE_SETTING, 'yes')

    # init log_handler handler
    if verbose is True:
        logger.set_verbose()

    if re_run < 0:
        re_run = 0

    logger.log_dir = output_dir
    log_handler = getLogger('dts')
    log_handler.config_execution('dts')

    # run designated test case
    requested_tests = test_cases

    # Read config file
    dts_cfg_folder = settings.load_global_setting(settings.DTS_CFG_FOLDER)
    if dts_cfg_folder != '':
        config_file = dts_cfg_folder + os.sep + config_file

    config = ConfigParser.SafeConfigParser()
    load_cfg = config.read(config_file)
    if len(load_cfg) == 0:
        raise ConfigParseException(config_file)

    # parse commands
    dts_commands = dts_parse_commands(commands)

    os.environ["TERM"] = "dumb"

    # change rst output folder
    rst.path2Result = output_dir

    # report objects
    excel_report = ExcelReporter(output_dir + '/test_results.xls')
    json_report = JSONReporter(output_dir + '/test_results.json')
    stats_report = StatsReporter(output_dir + '/statistics.txt')
    result = Result()

    crbInsts = []
    crbs_conf = CrbsConf()
    crbs = crbs_conf.load_crbs_config()

    # for all Exectuion sections
    for section in config.sections():
        # Skip configuration sections
        if section in ['DPDK', 'Pktgen', 'Tester_DPDK', 'Tester_Pktgen',\
                'latency', 'reset']:
            continue
        dts_parse_param(config, section)

        # verify if the delimiter is good if the lists are vertical
        duts, targets, test_suites = dts_parse_config(config, section)

        # look up in crbs - to find the matching IP
        for dut in duts:
            for crb in crbs:
                if crb['section'] == dut:
                    crbInsts.append(crb)
                    break

        # only run on the dut in known crbs
        if len(crbInsts) == 0:
            log_handler.error(" SKIP UNKNOWN CRB")
            continue

        result.dut = duts[0]

        # init dut, tester crb
        duts, testers = dts_crbs_init(crbInsts, read_cache, project, base_dir,
                                      serializer, virttype, test_configs)
        for tester in testers:
            tester.set_re_run(re_run)
        # register exit action
        atexit.register(quit_execution, duts, testers)

        check_case_inst.change_dut(duts[0])

        test_configs["force_setup"] = force_setup
        # Check if set-up is installed on all CRBs:
        if force_setup is False:
            setup_ready = True
            dut_dpdk_repo = parse_repo(dict(config.items("DPDK")))
            dut_pktgen_repo = parse_repo(dict(config.items("Pktgen")))
            for dut in duts:
                setup_ready = setup_ready and dut.check_setup(
                    dut_dpdk_repo, dut_pktgen_repo,
                    test_configs["skip_target_env_setup"])
            tester_dpdk_repo = parse_repo(dict(config.items("Tester_DPDK")))\
                if "Tester_DPDK" in config.sections() else dut_dpdk_repo
            tester_pktgen_repo = parse_repo(dict(config.items("Tester_Pktgen")))\
                if "Tester_Pktgen" in config.sections() else dut_pktgen_repo
            for tester in testers:
                setup_ready = setup_ready and tester.check_setup(
                    tester_dpdk_repo, tester_pktgen_repo,
                    test_configs["skip_target_env_setup"])
        else:
            setup_ready = False

        show_speedup_options_messages(read_cache, setup_ready,
                                      test_configs["try_reuse_pcaps"],
                                      test_cases)
        for tester in testers:
            tester.set_speedup_options(read_cache, setup_ready)
        for dut in duts:
            dut.set_speedup_options(read_cache, setup_ready)

        # Clone DPDK and Pktgen repos and apply patches
        if not setup_ready:
            prepare_repos(config, pkgName, pktgen)

        # Run DUT prerequisites
        if dts_run_prerequisties(duts, testers, pkgName, patch, dts_commands,
                                 serializer, pktgen, test_configs) is False:
            dts_crbs_exit(duts, testers)
            continue

        dts_run_target(duts, testers, targets, test_suites, test_configs)

        dts_crbs_exit(duts, testers)

    save_all_results()