Beispiel #1
0
 def __init__(self, duts, tester, target, suitename):
     self.suite_name = suitename
     self.dut = duts[0]
     self.duts = duts
     self.tester = tester
     self.target = target
     class_name = self.__class__.__name__
     self.logger = getLogger(class_name)
     self.logger.config_suite(class_name)
     self._requested_tests = None
     self.nics = []
     drivername = []
     execution_path = os.path.dirname(os.path.dirname(__file__))
     execution_file = execution_path + '/framework/execution.cfg'
     execution = open(execution_file, 'r')
     status = re.findall(r"\n+parameters=nic_type=(.*)", execution.read())
     status_nic = status[0].split(":")
     self.nic = status_nic[0]
     self.kdriver = self._get_nic_driver(self.nic)
     self._suite_result = Result()
     self._suite_result.dut = self.dut.crb['IP']
     self._suite_result.target = target
     self._suite_result.nic = self.nic
     self._suite_result.test_suite = self.suite_name
     if self._suite_result is None:
         raise ValueError("Result object should not None")
     if load_global_setting(PERF_SETTING) == "yes":
         self._enable_perf = True
     else:
         self._enable_perf = False
     if load_global_setting(FUNC_SETTING) == "yes":
         self._enable_func = True
     else:
         self._enable_func = False
     if load_global_setting(DEBUG_SETTING) == "yes":
         self._enable_debug = True
     else:
         self._enable_debug = False
     if load_global_setting(DEBUG_CASE_SETTING) == "yes":
         self._debug_case = True
     else:
         self._debug_case = False
     self.drivername = load_global_setting(HOST_DRIVER_SETTING)
Beispiel #2
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()
Beispiel #3
0
    def __init__(self, duts, tester, target, suitename):
        self.suite_name = suitename
        self.dut = duts[0]
        self.duts = duts
        self.tester = tester
        self.target = target

        # local variable
        self._requested_tests = None

        # check session and reconnect if possible
        for dutobj in self.duts:
            self._check_and_reconnect(crb=dutobj)
        self._check_and_reconnect(crb=self.tester)

        # covert netdevice to codename
        self.nics = []
        for portid in range(len(self.dut.ports_info)):
            nic_type = self.dut.ports_info[portid]['type']
            self.nics.append(get_nic_name(nic_type))
        if len(self.nics):
            self.nic = self.nics[0]
        else:
            self.nic = ''
        self.kdriver = self._get_nic_driver(self.nic)

        # result object for save suite result
        self._suite_result = Result()
        self._suite_result.dut = self.dut.crb['IP']
        self._suite_result.target = target
        self._suite_result.nic = self.nic
        self._suite_result.test_suite = self.suite_name
        if self._suite_result is None:
            raise ValueError("Result object should not None")

        # load running enviornment
        if load_global_setting(PERF_SETTING) == "yes":
            self._enable_perf = True
        else:
            self._enable_perf = False

        if load_global_setting(FUNC_SETTING) == "yes":
            self._enable_func = True
        else:
            self._enable_func = False

        if load_global_setting(DEBUG_SETTING) == "yes":
            self._enable_debug = True
        else:
            self._enable_debug = False

        if load_global_setting(DEBUG_CASE_SETTING) == "yes":
            self._debug_case = True
        else:
            self._debug_case = False

        self.drivername = load_global_setting(HOST_DRIVER_SETTING)

        # create rst format report for this suite
        self._rst_obj = RstReport('rst_report', target, self.nic, self.suite_name, self._enable_perf)

        # load suite configuration
        self._suite_conf = SuiteConf(self.suite_name)
        self._suite_cfg = self._suite_conf.suite_cfg
Beispiel #4
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)
Beispiel #5
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()
Beispiel #6
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()