Exemple #1
0
def pytest_configure(config):

    reporter = terminalreporter.reporter()
    if config.getoption('--dummy-appliance'):
        appliances = [DummyAppliance.from_config(config)]
        reporter.write_line('Retrieved Dummy Appliance', red=True)
    elif stack.top:
        appliances = [stack.top]
    elif config.option.appliances:
        appliances = appliances_from_cli(config.option.appliances, config.option.appliance_version)
        reporter.write_line('Retrieved these appliances from the --appliance parameters', red=True)
    elif config.getoption('--use-sprout'):
        from .sprout.plugin import mangle_in_sprout_appliances

        mangle_in_sprout_appliances(config)
        # TODO : handle direct sprout pass on?
        appliances = appliances_from_cli(config.option.appliances, None)
        reporter.write_line('Retrieved these appliances from the --sprout-* parameters', red=True)
    else:
        appliances = load_appliances_from_config(conf.env)
        reporter.write_line('Retrieved these appliances from the conf.env', red=True)

    if not stack.top:
        for appliance in appliances:
            reporter.write_line('* {!r}'.format(appliance), cyan=True)
    appliance = appliances[0]
    if not appliance.is_dev:
        appliance.set_session_timeout(86400)
    stack.push(appliance)
    plugin = ApplianceHolderPlugin(appliance, appliances)
    config.pluginmanager.register(plugin, PLUGIN_KEY)
Exemple #2
0
def pytest_configure(config):

    if config.getoption('--help'):
        return
    reporter = terminalreporter.reporter()
    if config.getoption('--dummy-appliance'):
        appliances = [DummyAppliance.from_config(config)]
        reporter.write_line('Retrieved Dummy Appliance', red=True)
    elif stack.top:
        appliances = [stack.top]
    elif config.option.appliances:
        appliances = appliances_from_cli(config.option.appliances, config.option.appliance_version)
        reporter.write_line('Retrieved these appliances from the --appliance parameters', red=True)
    elif config.getoption('--use-sprout'):
        from cfme.test_framework.sprout.plugin import mangle_in_sprout_appliances

        mangle_in_sprout_appliances(config)
        # TODO : handle direct sprout pass on?
        appliances = appliances_from_cli(config.option.appliances, None)
        reporter.write_line('Retrieved these appliances from the --sprout-* parameters', red=True)
    else:
        appliances = load_appliances_from_config(conf.env)
        reporter.write_line('Retrieved these appliances from the conf.env', red=True)

    if not stack.top:
        for appliance in appliances:
            reporter.write_line('* {!r}'.format(appliance), cyan=True)
    appliance = appliances[0]
    if not appliance.is_dev:
        appliance.set_session_timeout(86400)
    stack.push(appliance)
    plugin = ApplianceHolderPlugin(appliance, appliances)
    config.pluginmanager.register(plugin, PLUGIN_KEY)
Exemple #3
0
def pytest_sessionfinish(session, exitstatus):
    udf_log_file = log_path.join('unused_data_files.log')

    if udf_log_file.check():
        # Clean up old udf log if it exists
        udf_log_file.remove()

    if session.config.option.udf_report is False:
        # Short out here if not making a report
        return

    # Output an unused data files log after a test run
    data_files = set()
    for dirpath, dirnames, filenames in os.walk(str(data_path)):
        for filename in filenames:
            filepath = os.path.join(dirpath, filename)
            data_files.add(filepath)
    unused_data_files = data_files - seen_data_files

    if unused_data_files:
        # Write the log of unused data files out, minus the data dir prefix
        udf_log = ''.join(
            (line[len(str(data_path)):] + '\n' for line in unused_data_files)
        )
        udf_log_file.write(udf_log + '\n')

        # Throw a notice into the terminal reporter to check the log
        tr = reporter()
        tr.write_line('')
        tr.write_sep(
            '-',
            '%d unused data files after test run, check %s' % (
                len(unused_data_files), udf_log_file.basename
            )
        )
Exemple #4
0
def pytest_sessionfinish(session, exitstatus):
    udf_log_file = log_path.join('unused_data_files.log')

    if udf_log_file.check():
        # Clean up old udf log if it exists
        udf_log_file.remove()

    if session.config.option.udf_report is False:
        # Short out here if not making a report
        return

    # Output an unused data files log after a test run
    data_files = set()
    for dirpath, dirnames, filenames in os.walk(str(data_path)):
        for filename in filenames:
            filepath = os.path.join(dirpath, filename)
            data_files.add(filepath)
    unused_data_files = data_files - seen_data_files

    if unused_data_files:
        # Write the log of unused data files out, minus the data dir prefix
        udf_log = ''.join(
            (line[len(str(data_path)):] + '\n' for line in unused_data_files))
        udf_log_file.write(udf_log + '\n')

        # Throw a notice into the terminal reporter to check the log
        tr = reporter()
        tr.write_line('')
        tr.write_sep(
            '-', '%d unused data files after test run, check %s' %
            (len(unused_data_files), udf_log_file.basename))
def pytest_sessionstart(session):
    config = session.config
    # Just to print out the appliance's streams
    from cfme.fixtures.terminalreporter import reporter
    holder = config.pluginmanager.getplugin('appliance-holder')

    reporter(config).write("\nAppliance's streams: [{}]\n".format(", ".join(
        get_streams_id(holder.held_appliance))))
    # Bail out if the appliance stream or version do not match
    check_stream = config.getvalue("check_stream").lower().strip()
    if check_stream:
        holder = config.pluginmanager.get_plugin("appliance-holder")
        curr = holder.held_appliance.version.stream()
        if check_stream != curr:
            raise Exception(
                "Stream mismatch - wanted {} but appliance is {}".format(
                    check_stream, curr))
def pytest_sessionstart(session):
    config = session.config
    # Just to print out the appliance's streams
    from cfme.fixtures.terminalreporter import reporter
    holder = config.pluginmanager.getplugin('appliance-holder')

    reporter(config).write(
        "\nAppliance's streams: [{}]\n".format(
            ", ".join(get_streams_id(holder.held_appliance))))
    # Bail out if the appliance stream or version do not match
    check_stream = config.getvalue("check_stream").lower().strip()
    if check_stream:
        holder = config.pluginmanager.get_plugin("appliance-holder")
        curr = holder.held_appliance.version.stream()
        if check_stream != curr:
            raise Exception(
                "Stream mismatch - wanted {} but appliance is {}".format(
                    check_stream, curr))
Exemple #7
0
def pytest_configure(config):

    if config.getoption('--help'):
        return
    reporter = terminalreporter.reporter()
    if config.getoption('--dummy-appliance'):
        appliances = [
            DummyAppliance.from_config(config)
            for _ in range(config.getoption('--num-dummies'))
        ]
        if not config.option.collectonly:
            config.option.collectonly = True

        reporter.write_line('Retrieved Dummy Appliance', red=True)
    elif stack.top:
        appliances = [stack.top]
    elif config.option.appliances:
        appliances = appliances_from_cli(config.option.appliances,
                                         config.option.appliance_version)
        reporter.write_line(
            'Retrieved these appliances from the --appliance parameters',
            red=True)
    elif config.getoption('--use-sprout'):
        from cfme.test_framework.sprout.plugin import mangle_in_sprout_appliances

        mangle_in_sprout_appliances(config)
        # TODO : handle direct sprout pass on?
        appliances = appliances_from_cli(config.option.appliances, None)
        reporter.write_line(
            'Retrieved these appliances from the --sprout-* parameters',
            red=True)
    else:
        appliances = load_appliances_from_config(conf.env)
        reporter.write_line('Retrieved these appliances from the conf.env',
                            red=True)

    if not stack.top:
        for appliance in appliances:
            reporter.write_line(f'* {appliance!r}', cyan=True)
    appliance = appliances[0]

    stack.push(appliance)
    plugin = ApplianceHolderPlugin(appliance, appliances)
    config.pluginmanager.register(plugin, PLUGIN_KEY)

    if not any((isinstance(appliance, DummyAppliance), appliance.is_dev)):
        config.hook.pytest_appliance_setup(config=config)
def pytest_configure(config):
    """Configures the parallel session, then fires pytest_parallel_configured."""
    reporter = terminalreporter.reporter()
    holder = config.pluginmanager.get_plugin(APPLIANCE_PLUGIN)

    appliances = holder.appliances

    if len(appliances) > 1:
        session = ParallelSession(config, appliances)
        config.pluginmanager.register(session, "parallel_session")
        store.parallelizer_role = 'master'
        reporter.write_line(
            'As a parallelizer master kicking off parallel session for these {} appliances'.format(
                len(appliances)),
            green=True)
        config.hook.pytest_parallel_configured(parallel_session=session)
    else:
        reporter.write_line('No parallelization required', green=True)
        config.hook.pytest_parallel_configured(parallel_session=None)
Exemple #9
0
def pytest_configure(config):
    """Configures the parallel session, then fires pytest_parallel_configured."""
    if config.getoption('--help'):
        return

    reporter = terminalreporter.reporter()
    holder = config.pluginmanager.get_plugin(APPLIANCE_PLUGIN)

    appliances = holder.appliances

    if len(appliances) > 1:
        session = ParallelSession(config, appliances)
        config.pluginmanager.register(session, "parallel_session")
        store.parallelizer_role = 'master'
        reporter.write_line(
            f'Parallelizer master starting session for {len(appliances)} appliances',
            green=True)
        config.hook.pytest_parallel_configured(parallel_session=session)
    else:
        reporter.write_line('No parallelization required', green=True)
        config.hook.pytest_parallel_configured(parallel_session=None)