コード例 #1
0
ファイル: blockers.py プロジェクト: apagac/cfme_tests
def pytest_collection_modifyitems(session, config, items):
    if not config.getvalue("list_blockers"):
        return
    store.terminalreporter.write("Loading blockers ...\n", bold=True)
    blocking = set([])
    for item in items:
        if "blockers" not in item._metadata:
            continue
        for blocker in item._metadata["blockers"]:
            if isinstance(blocker, int):
                # TODO: DRY
                blocker_object = Blocker.parse("BZ#{}".format(blocker))
            else:
                blocker_object = Blocker.parse(blocker)
            if blocker_object.blocks:
                blocking.add(blocker_object)
    if blocking:
        store.terminalreporter.write("Known blockers:\n", bold=True)
        for blocker in blocking:
            if isinstance(blocker, BZ):
                bug = blocker.bugzilla_bug
                store.terminalreporter.write("- #{} - {}\n".format(bug.id, bug.status))
                store.terminalreporter.write("  {}\n".format(bug.summary))
                store.terminalreporter.write(
                    "  {} -> {}\n".format(str(bug.version), str(bug.target_release)))
                store.terminalreporter.write(
                    "  https://bugzilla.redhat.com/show_bug.cgi?id={}\n\n".format(bug.id))
            elif isinstance(blocker, GH):
                bug = blocker.data
                store.terminalreporter.write("- {}\n".format(str(bug)))
                store.terminalreporter.write("  {}\n".format(bug.title))
            else:
                store.terminalreporter.write("- {}\n".format(str(blocker.data)))
    else:
        store.terminalreporter.write("No blockers detected!\n", bold=True)
コード例 #2
0
ファイル: blockers.py プロジェクト: apagac/cfme_tests
def blockers(uses_blockers, meta):
    """Returns list of all assigned blockers.

    Returns:
        List of :py:class:`utils.blockers.Blocker` instances.
    """
    result = []
    for blocker in meta.get("blockers", []):
        if isinstance(blocker, int):
            result.append(Blocker.parse("BZ#{}".format(blocker)))
        elif isinstance(blocker, Blocker):
            result.append(blocker)
        else:
            result.append(Blocker.parse(blocker))
    return result
コード例 #3
0
ファイル: blockers.py プロジェクト: nachandr/cfme_tests
def blockers(uses_blockers, meta):
    """Returns list of all assigned blockers.

    Returns:
        List of :py:class:`utils.blockers.Blocker` instances.
    """
    result = []
    for blocker in meta.get("blockers", []):
        if isinstance(blocker, int):
            result.append(Blocker.parse(f"BZ#{blocker}"))
        elif isinstance(blocker, Blocker):
            result.append(blocker)
        else:
            result.append(Blocker.parse(blocker))
    return result
コード例 #4
0
ファイル: blockers.py プロジェクト: apagac/cfme_tests
def blocker(uses_blockers):
    """Return any blocker that matches the expression.

    Returns:
        Instance of :py:class:`utils.blockers.Blocker`
    """
    return lambda b, **kwargs: Blocker.parse(b, **kwargs)
コード例 #5
0
ファイル: blockers.py プロジェクト: nachandr/cfme_tests
def blocker(uses_blockers):
    """Return any blocker that matches the expression.

    Returns:
        Instance of :py:class:`utils.blockers.Blocker`
    """
    return lambda b, **kwargs: Blocker.parse(b, **kwargs)
コード例 #6
0
def pytest_runtest_protocol(item):
    holder = item.config.pluginmanager.getplugin('appliance-holder')
    global session_ver
    global session_build
    global session_stream
    appliance = holder.held_appliance
    if not session_ver:
        session_ver = str(appliance.version)
        session_build = appliance.build
        session_stream = appliance.version.stream()
        if str(session_ver) not in session_build:
            session_build = "{}-{}".format(str(session_ver), session_build)
        fire_art_hook(item.config,
                      'session_info',
                      version=session_ver,
                      build=session_build,
                      stream=session_stream)

    tier = item.get_marker('tier')
    if tier:
        tier = tier.args[0]

    requirement = item.get_marker('requirement')
    if requirement:
        requirement = requirement.args[0]

    try:
        params = item.callspec.params
        param_dict = {p: get_name(v) for p, v in params.iteritems()}
    except:
        param_dict = {}
    ip = appliance.address
    # This pre_start_test hook is needed so that filedump is able to make get the test
    # object set up before the logger starts logging. As the logger fires a nested hook
    # to the filedumper, and we can't specify order inriggerlib.
    meta = item.get_marker('meta')
    if meta and 'blockers' in meta.kwargs:
        blocker_spec = meta.kwargs['blockers']
        blockers = []
        for blocker in blocker_spec:
            if isinstance(blocker, int):
                blockers.append(BZ(blocker).url)
            else:
                blockers.append(Blocker.parse(blocker).url)
    else:
        blockers = []
    fire_art_test_hook(item, 'pre_start_test', slaveid=store.slaveid, ip=ip)
    fire_art_test_hook(item,
                       'start_test',
                       slaveid=store.slaveid,
                       ip=ip,
                       tier=tier,
                       requirement=requirement,
                       param_dict=param_dict,
                       issues=blockers)
    yield
コード例 #7
0
def pytest_collection_modifyitems(session, config, items):
    if not config.getvalue("list_blockers"):
        return
    store.terminalreporter.write("Loading blockers ...\n", bold=True)
    blocking = set([])
    for item in items:
        if "blockers" not in item._metadata:
            continue
        for blocker in item._metadata["blockers"]:
            if isinstance(blocker, int):
                # TODO: DRY
                blocker_object = Blocker.parse("BZ#{}".format(blocker))
            else:
                blocker_object = Blocker.parse(blocker)
            if blocker_object.blocks:
                blocking.add(blocker_object)
    if blocking:
        store.terminalreporter.write("Known blockers:\n", bold=True)
        for blocker in blocking:
            if isinstance(blocker, BZ):
                bug = blocker.bugzilla_bug
                store.terminalreporter.write("- #{} - {}\n".format(
                    bug.id, bug.status))
                store.terminalreporter.write("  {}\n".format(bug.summary))
                store.terminalreporter.write("  {} -> {}\n".format(
                    str(bug.version), str(bug.target_release)))
                store.terminalreporter.write(
                    "  https://bugzilla.redhat.com/show_bug.cgi?id={}\n\n".
                    format(bug.id))
            elif isinstance(blocker, GH):
                bug = blocker.data
                store.terminalreporter.write("- {}\n".format(str(bug)))
                store.terminalreporter.write("  {}\n".format(bug.title))
            else:
                store.terminalreporter.write("- {}\n".format(str(
                    blocker.data)))
    else:
        store.terminalreporter.write("No blockers detected!\n", bold=True)
コード例 #8
0
def pytest_runtest_protocol(item):
    global session_ver
    global session_build
    global session_stream
    appliance = find_appliance(item)
    if not session_ver:
        session_ver = str(appliance.version)
        session_build = appliance.build
        session_stream = appliance.version.stream()
        if str(session_ver) not in session_build:
            session_build = "{}-{}".format(str(session_ver), session_build)
        try:
            proc = subprocess.Popen(['git', 'describe', '--tags'],
                                    stdout=subprocess.PIPE)
            proc.wait()
            session_fw_version = proc.stdout.read().strip()
        except:
            session_fw_version = None
        fire_art_hook(item.config,
                      'session_info',
                      version=session_ver,
                      build=session_build,
                      stream=session_stream,
                      fw_version=session_fw_version)

    tier = item.get_marker('tier')
    if tier:
        tier = tier.args[0]

    requirement = item.get_marker('requirement')
    if requirement:
        requirement = requirement.args[0]

    try:
        params = item.callspec.params
        param_dict = {p: get_name(v) for p, v in params.items()}
    except:
        param_dict = {}
    ip = appliance.hostname
    # This pre_start_test hook is needed so that filedump is able to make get the test
    # object set up before the logger starts logging. As the logger fires a nested hook
    # to the filedumper, and we can't specify order inriggerlib.
    meta = item.get_marker('meta')
    if meta and 'blockers' in meta.kwargs:
        blocker_spec = meta.kwargs['blockers']
        blockers = []
        for blocker in blocker_spec:
            if isinstance(blocker, int):
                blockers.append(BZ(blocker).url)
            else:
                blockers.append(Blocker.parse(blocker).url)
    else:
        blockers = []
    fire_art_test_hook(item, 'pre_start_test', slaveid=store.slaveid, ip=ip)
    fire_art_test_hook(item,
                       'start_test',
                       slaveid=store.slaveid,
                       ip=ip,
                       tier=tier,
                       requirement=requirement,
                       param_dict=param_dict,
                       issues=blockers)
    yield
コード例 #9
0
def pytest_runtest_protocol(item):
    global session_ver
    global session_build
    global session_stream
    appliance = find_appliance(item)
    if not session_ver:
        session_ver = str(appliance.version)
        session_build = appliance.build
        session_stream = appliance.version.stream()
        if str(session_ver) not in session_build:
            session_build = "{}-{}".format(str(session_ver), session_build)
        session_fw_version = None
        try:
            proc = subprocess.Popen(['git', 'describe', '--tags'],
                                    stdout=subprocess.PIPE)
            proc.wait()
            session_fw_version = proc.stdout.read().strip()
        except Exception:
            pass  # already set session_fw_version to None
        fire_art_hook(
            item.config, 'session_info',
            version=session_ver,
            build=session_build,
            stream=session_stream,
            fw_version=session_fw_version
        )

    tier = item.get_marker('tier')
    if tier:
        tier = tier.args[0]

    requirement = item.get_marker('requirement')
    if requirement:
        requirement = requirement.args[0]

    param_dict = {}
    try:
        params = item.callspec.params
        param_dict = {p: get_name(v) for p, v in params.items()}
    except Exception:
        pass  # already set param_dict
    ip = appliance.hostname
    # This pre_start_test hook is needed so that filedump is able to make get the test
    # object set up before the logger starts logging. As the logger fires a nested hook
    # to the filedumper, and we can't specify order inriggerlib.
    meta = item.get_marker('meta')
    if meta and 'blockers' in meta.kwargs:
        blocker_spec = meta.kwargs['blockers']
        blockers = []
        for blocker in blocker_spec:
            if isinstance(blocker, int):
                blockers.append(BZ(blocker).url)
            else:
                blockers.append(Blocker.parse(blocker).url)
    else:
        blockers = []
    fire_art_test_hook(
        item, 'pre_start_test',
        slaveid=store.slaveid, ip=ip)
    fire_art_test_hook(
        item, 'start_test',
        slaveid=store.slaveid, ip=ip,
        tier=tier, requirement=requirement, param_dict=param_dict, issues=blockers)
    yield