Example #1
0
def run(**kwargs):
    config_name = kwargs.get('config_name', None)
    groups = kwargs.get('run_groups', None)
    old_groups = kwargs.get('groups', None)
    explain = kwargs.get('explain', None)

    groups_to_run = []
    groups.extend(old_groups or [])
    for g in groups:
        if config_name:
            register_system_test_cases(
                groups=[g],
                configs=[config_name])
            groups_to_run.append("{0}({1})".format(g, config_name))
        else:
            register_system_test_cases(groups=[g])
            groups_to_run.append(g)
    if not set(groups_to_run) < set(get_groups()):
        sys.exit('There are no cases mapped to current group, '
                 'please be sure that you put right test group name.')
    if explain:
        print_explain(groups)
    else:
        register(groups=["run_system_test"], depends_on_groups=groups_to_run)
        TestProgram(groups=['run_system_test'],
                    argv=clean_argv()).run_and_exit()
Example #2
0
def run(**kwargs):
    config_name = kwargs.get('config_name', None)
    groups = kwargs.get('run_groups', [])
    old_groups = kwargs.get('groups', None)
    explain = kwargs.get('explain', None)

    groups_to_run = []
    groups.extend(old_groups or [])

    # Collect from pytest only once!
    pytest.main(['--collect-only', 'fuel_tests', ])
    from fuel_tests.tests.conftest import test_names

    for g in set(groups):
        if g in test_names:
            sys.exit(pytest.main('-m {}'.format(g)))
        if config_name:
            register_system_test_cases(
                groups=[g],
                configs=[config_name])
            groups_to_run.append("{0}({1})".format(g, config_name))
        else:
            register_system_test_cases(groups=[g])
            groups_to_run.append(g)
    if not set([split_group_config(i)[0] if split_group_config(i) else i
               for i in groups_to_run]) < set(get_groups()):
        sys.exit('There are no cases mapped to current group, '
                 'please be sure that you put right test group name.')
    if explain:
        print_explain(groups)
    else:
        register(groups=["run_system_test"], depends_on_groups=groups_to_run)
        TestProgram(groups=['run_system_test'],
                    argv=clean_argv_proboscis()).run_and_exit()
def run(**kwargs):
    config_name = kwargs.get('config_name', None)
    groups = kwargs.get('run_groups', [])
    old_groups = kwargs.get('groups', None)
    explain = kwargs.get('explain', None)

    groups_to_run = []
    groups.extend(old_groups or [])
    for g in set(groups):
        if config_name:
            register_system_test_cases(
                groups=[g],
                configs=[config_name])
            groups_to_run.append("{0}({1})".format(g, config_name))
        else:
            register_system_test_cases(groups=[g])
            groups_to_run.append(g)
    if not set([split_group_config(i)[0] if split_group_config(i) else i
               for i in groups_to_run]) < set(get_groups()):
        sys.exit('There are no cases mapped to current group, '
                 'please be sure that you put right test group name.')
    if explain:
        print_explain(groups)
    else:
        register(groups=["run_system_test"], depends_on_groups=groups_to_run)
        TestProgram(groups=['run_system_test'],
                    argv=clean_argv()).run_and_exit()
Example #4
0
def run(**kwargs):
    config_name = kwargs.get('config_name', None)
    groups = kwargs.get('run_groups', None)
    old_groups = kwargs.get('groups', None)
    explain = kwargs.get('explain', None)

    groups_to_run = []
    groups.extend(old_groups or [])
    for g in groups:
        if config_name:
            register_system_test_cases(groups=[g], configs=[config_name])
            groups_to_run.append("{0}({1})".format(g, config_name))
        else:
            register_system_test_cases(groups=[g])
            groups_to_run.append(g)
    if explain:
        print_explain(groups)
    else:
        register(groups=["run_system_test"], depends_on_groups=groups_to_run)
        TestProgram(groups=['run_system_test'],
                    argv=clean_argv()).run_and_exit()
def _create_test_plan_from_registry(groups):
    discover_import_tests(get_basepath(), tests_directory)
    define_custom_groups()
    for one in groups:
        register_system_test_cases(one)
    return TestPlan.create_from_registry(DEFAULT_REGISTRY)
def _create_test_plan_from_registry(groups):
    discover_import_tests(get_basepath(), tests_directory)
    define_custom_groups()
    for one in groups:
        register_system_test_cases(one)
    return TestPlan.create_from_registry(DEFAULT_REGISTRY)
def get_tests_descriptions(milestone_id, tests_include, tests_exclude, groups,
                           default_test_priority):
    from system_test.tests.actions_base import ActionsBase
    discover_import_tests(get_basepath(), tests_directory)
    define_custom_groups()
    for one in groups:
        register_system_test_cases(one)
    plan = TestPlan.create_from_registry(DEFAULT_REGISTRY)
    all_plan_tests = plan.tests[:]

    tests = []

    for jenkins_suffix in groups:
        group = groups[jenkins_suffix]
        plan.filter(group_names=[group])
        for case in plan.tests:
            if not case.entry.info.enabled:
                continue
            home = case.entry.home
            if not hasattr(case.entry, 'parent'):
                # Not a real case, some stuff needed by template based tests
                continue
            parent_home = case.entry.parent.home
            case_state = case.state
            if issubclass(parent_home, ActionsBase):
                case_name = parent_home.__name__
                test_group = parent_home.__name__
                if any([x['custom_test_group'] == test_group for x in tests]):
                    continue
            else:
                case_name = home.func_name
                test_group = case.entry.home.func_name
            if tests_include:
                if tests_include not in case_name:
                    logger.debug("Skipping '{0}' test because it doesn't "
                                 "contain '{1}' in method name"
                                 .format(case_name,
                                         tests_include))
                    continue
            if tests_exclude:
                if tests_exclude in case_name:
                    logger.debug("Skipping '{0}' test because it contains"
                                 " '{1}' in method name"
                                 .format(case_name,
                                         tests_exclude))
                    continue

            if issubclass(parent_home, ActionsBase):
                docstring = parent_home.__doc__.split('\n')
                case_state.instance._load_config()
                configuration = case_state.instance.config_name
                docstring[0] = "{0} on {1}".format(docstring[0], configuration)
                docstring = '\n'.join(docstring)
            else:
                docstring = home.func_doc or ''
                configuration = None
            docstring = '\n'.join([s.strip() for s in docstring.split('\n')])

            steps = [{"content": s, "expected": "pass"} for s in
                     docstring.split('\n') if s and s[0].isdigit()]

            test_duration = re.search(r'Duration\s+(\d+[s,m])\b', docstring)
            title = docstring.split('\n')[0] or case.entry.home.func_name

            if case.entry.home.func_name in GROUPS_TO_EXPAND:
                """Expand specified test names with the group names that are
                   used in jenkins jobs where this test is started.
                """
                title = ' - '.join([title, jenkins_suffix])
                test_group = '_'.join([case.entry.home.func_name,
                                       jenkins_suffix])

            test_case = {
                "title": title,
                "type_id": 1,
                "milestone_id": milestone_id,
                "priority_id": default_test_priority,
                "estimate": test_duration.group(1) if test_duration else "3m",
                "refs": "",
                "custom_test_group": test_group,
                "custom_test_case_description": docstring or " ",
                "custom_test_case_steps": steps
            }

            if not any([x['custom_test_group'] == test_group for x in tests]):
                tests.append(test_case)
            else:
                logger.warning("Testcase '{0}' run in multiple Jenkins jobs!"
                               .format(test_group))

        plan.tests = all_plan_tests[:]

    return tests
def get_tests_descriptions(milestone_id, tests_include, tests_exclude, groups,
                           default_test_priority):
    from system_test.tests.actions_base import ActionsBase
    discover_import_tests(get_basepath(), tests_directory)
    define_custom_groups()
    for one in groups:
        register_system_test_cases(one)
    plan = TestPlan.create_from_registry(DEFAULT_REGISTRY)
    all_plan_tests = plan.tests[:]

    tests = []

    for jenkins_suffix in groups:
        group = groups[jenkins_suffix]
        plan.filter(group_names=[group])
        for case in plan.tests:
            if not case.entry.info.enabled:
                continue
            home = case.entry.home
            if not hasattr(case.entry, 'parent'):
                # Not a real case, some stuff needed by template based tests
                continue
            parent_home = case.entry.parent.home
            case_state = case.state
            if issubclass(parent_home, ActionsBase):
                case_name = parent_home.__name__
                test_group = parent_home.__name__
                if any([x['custom_test_group'] == test_group for x in tests]):
                    continue
            else:
                case_name = home.func_name
                test_group = case.entry.home.func_name
            if tests_include:
                if tests_include not in case_name:
                    logger.debug("Skipping '{0}' test because it doesn't "
                                 "contain '{1}' in method name"
                                 .format(case_name,
                                         tests_include))
                    continue
            if tests_exclude:
                if tests_exclude in case_name:
                    logger.debug("Skipping '{0}' test because it contains"
                                 " '{1}' in method name"
                                 .format(case_name,
                                         tests_exclude))
                    continue

            if issubclass(parent_home, ActionsBase):
                docstring = parent_home.__doc__.split('\n')
                case_state.instance._load_config()
                configuration = case_state.instance.config_name
                docstring[0] = "{0} on {1}".format(docstring[0], configuration)
                docstring = '\n'.join(docstring)
            else:
                docstring = home.func_doc or ''
                configuration = None
            docstring = '\n'.join([s.strip() for s in docstring.split('\n')])

            steps = [{"content": s, "expected": "pass"} for s in
                     docstring.split('\n') if s and s[0].isdigit()]

            test_duration = re.search(r'Duration\s+(\d+[s,m])\b', docstring)
            title = docstring.split('\n')[0] or case.entry.home.func_name

            if case.entry.home.func_name in GROUPS_TO_EXPAND:
                """Expand specified test names with the group names that are
                   used in jenkins jobs where this test is started.
                """
                title = ' - '.join([title, jenkins_suffix])
                test_group = '_'.join([case.entry.home.func_name,
                                       jenkins_suffix])