Пример #1
0
def pytest_collection_modifyitems(session, config, items):
    # Just to print out the appliance's streams
    reporter(config).write("\nAppliance's streams: [{}]\n".format(", ".join(get_streams_id())))
    # Bail out if the appliance stream or version do not match
    check_stream = config.getvalue("check_stream").lower().strip()
    if check_stream:
        curr = current_stream()
        if check_stream != curr:
            raise Exception(
                "Stream mismatch - wanted {} but appliance is {}".format(check_stream, curr))
Пример #2
0
def pytest_collection_modifyitems(session, config, items):
    # Just to print out the appliance's streams
    reporter(config).write("\nAppliance's streams: [{}]\n".format(", ".join(
        get_streams_id())))
    # Bail out if the appliance stream or version do not match
    check_stream = config.getvalue("check_stream").lower().strip()
    if check_stream:
        curr = current_stream()
        if check_stream != curr:
            raise Exception(
                "Stream mismatch - wanted {} but appliance is {}".format(
                    check_stream, curr))
def pytest_generate_tests(metafunc):
    if metafunc.function in {test_rh_updates}:
        return
    """ Generates tests specific to RHSM or SAT6 with proxy-on or off """
    argnames = ['reg_method', 'reg_data', 'proxy_url', 'proxy_creds']
    argvalues = []
    idlist = []

    stream = version.current_stream()
    try:
        all_reg_data = conf.cfme_data.get('redhat_updates',
                                          {})['streams'][stream]
    except KeyError:
        logger.warning('Could not find rhsm data for stream in yaml')
        pytest.mark.uncollect(
            metafunc.function,
            message='Could not find rhsm data for stream in yaml')
        return

    if 'reg_method' in metafunc.fixturenames:
        for reg_method in REG_METHODS:

            reg_data = all_reg_data.get(reg_method)
            if not reg_data or not reg_data.get('test_registration', False):
                continue

            proxy_data = conf.cfme_data.get('redhat_updates',
                                            {}).get('http_proxy', False)
            if proxy_data and reg_data.get('use_http_proxy', False):
                proxy_url = proxy_data['url']
                proxy_creds_key = proxy_data['credentials']
                proxy_creds = conf.credentials[proxy_creds_key]
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = '{}-{}'.format(reg_method, 'proxy_on')
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = '{}-{}'.format(reg_method, 'proxy_off')
            idlist.append(argid)
            argvalues.append(argval)
        parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames = ['reg_method', 'reg_data', 'proxy_url', 'proxy_creds']
    argvalues = []
    idlist = []

    stream = version.current_stream()
    try:
        all_reg_data = conf.cfme_data.get('redhat_updates',
                                          {})['streams'][stream]
    except KeyError:
        pytest.mark.uncollect(metafunc.function)
        return

    if 'reg_method' in metafunc.fixturenames:
        for reg_method in REG_METHODS:
            # We cannot validate against Satellite 5
            if metafunc.function.__name__ == 'test_rh_creds_validation' and reg_method == 'sat5':
                continue

            reg_data = all_reg_data.get(reg_method)
            if not reg_data or not reg_data.get('test_registration', False):
                continue

            proxy_data = conf.cfme_data['redhat_updates'].get(
                'http_proxy', False)
            if proxy_data and reg_data.get('use_http_proxy', False):
                proxy_url = proxy_data['url']
                proxy_creds_key = proxy_data['credentials']
                proxy_creds = conf.credentials[proxy_creds_key]
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = '{}-{}'.format(reg_method, 'proxy_on')
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = '{}-{}'.format(reg_method, 'proxy_off')
            idlist.append(argid)
            argvalues.append(argval)
        parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    """ Generates tests specific to RHSM or SAT6 with proxy-on or off """
    argnames = ['reg_method', 'reg_data', 'proxy_url', 'proxy_creds']
    argvalues = []
    idlist = []

    stream = version.current_stream()
    try:
        all_reg_data = conf.cfme_data.get('redhat_updates', {})['streams'][stream]
    except KeyError:
        logger.warning('Could not find rhsm data for stream in yaml')
        pytest.mark.uncollect(
            metafunc.function, message='Could not find rhsm data for stream in yaml')
        return

    if 'reg_method' in metafunc.fixturenames:
        for reg_method in REG_METHODS:

            reg_data = all_reg_data.get(reg_method)
            if not reg_data or not reg_data.get('test_registration', False):
                continue

            proxy_data = conf.cfme_data.get('redhat_updates', {}).get('http_proxy', False)
            if proxy_data and reg_data.get('use_http_proxy', False):
                proxy_url = proxy_data['url']
                proxy_creds_key = proxy_data['credentials']
                proxy_creds = conf.credentials[proxy_creds_key]
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = '{}-{}'.format(reg_method, 'proxy_on')
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = '{}-{}'.format(reg_method, 'proxy_off')
            idlist.append(argid)
            argvalues.append(argval)
        parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames = ["reg_method", "reg_data", "proxy_url", "proxy_creds"]
    argvalues = []
    idlist = []

    stream = version.current_stream()
    try:
        all_reg_data = conf.cfme_data.get("redhat_updates", {})["streams"][stream]
    except KeyError:
        pytest.mark.uncollect(metafunc.function)
        return

    if "reg_method" in metafunc.fixturenames:
        for reg_method in REG_METHODS:
            # We cannot validate against Satellite 5
            if metafunc.function.__name__ == "test_rh_creds_validation" and reg_method == "sat5":
                continue

            reg_data = all_reg_data.get(reg_method, None)
            if not reg_data or not reg_data.get("test_registration", False):
                continue

            proxy_data = conf.cfme_data["redhat_updates"].get("http_proxy", False)
            if proxy_data and reg_data.get("use_http_proxy", False):
                proxy_url = proxy_data["url"]
                proxy_creds_key = proxy_data["credentials"]
                proxy_creds = conf.credentials[proxy_creds_key]
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = "{}-{}".format(reg_method, "proxy_on")
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = "{}-{}".format(reg_method, "proxy_off")
            idlist.append(argid)
            argvalues.append(argval)
        parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
def pytest_generate_tests(metafunc):
    argnames = ['reg_method', 'reg_data', 'proxy_url', 'proxy_creds']
    argvalues = []
    idlist = []

    stream = version.current_stream()
    try:
        all_reg_data = conf.cfme_data.get('redhat_updates', {})['streams'][stream]
    except KeyError:
        pytest.mark.uncollect(metafunc.function)
        return

    if 'reg_method' in metafunc.fixturenames:
        for reg_method in REG_METHODS:
            # We cannot validate against Satellite 5
            if metafunc.function.__name__ == 'test_rh_creds_validation' and reg_method == 'sat5':
                continue

            reg_data = all_reg_data.get(reg_method, None)
            if not reg_data or not reg_data.get('test_registration', False):
                continue

            proxy_data = conf.cfme_data['redhat_updates'].get('http_proxy', False)
            if proxy_data and reg_data.get('use_http_proxy', False):
                proxy_url = proxy_data['url']
                proxy_creds_key = proxy_data['credentials']
                proxy_creds = conf.credentials[proxy_creds_key]
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = '{}-{}'.format(reg_method, 'proxy_on')
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = '{}-{}'.format(reg_method, 'proxy_off')
            idlist.append(argid)
            argvalues.append(argval)
        parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
Пример #8
0
    app.wait_for_web_ui()


@pytest.fixture(scope="function")
def stabilize_current_appliance(backup_orig_state):
    app = get_or_create_current_appliance()
    app.reboot(wait_for_web_ui=False)
    app.stop_evm_service()


@pytest.mark.ignore_stream('5.5', 'upstream')
@pytest.mark.tier(2)
@pytest.mark.uncollectif(
    lambda db_version:
        db_version >= version.current_version() or
        version.get_stream(db_version) == version.current_stream())
@pytest.mark.meta(
    blockers=[BZ(1354466, unblock=lambda db_url: 'ldap' not in db_url)])
def test_db_migrate(stabilize_current_appliance, db_url, db_version, db_desc):
    app = get_or_create_current_appliance()

    # Download the database
    logger.info("Downloading database: {}".format(db_desc))
    url_basename = os_path.basename(db_url)
    rc, out = app.ssh_client.run_command(
        'curl -o "/tmp/{}" "{}"'.format(url_basename, db_url), timeout=30)
    assert rc == 0, "Failed to download database: {}".format(out)

    # The v2_key is potentially here
    v2key_url = os_path.join(os_path.dirname(db_url), "v2_key")

@pytest.fixture(scope="module")
def temp_appliance_extended_db(temp_appliance_preconfig):
    app = temp_appliance_preconfig
    app.stop_evm_service()
    app.extend_db_partition()
    app.start_evm_service()
    return app


@pytest.mark.ignore_stream('5.5', 'upstream')
@pytest.mark.tier(2)
@pytest.mark.uncollectif(
    lambda db_version: db_version >= version.current_version(
    ) or version.get_stream(db_version) == version.current_stream())
@pytest.mark.meta(
    blockers=[BZ(1354466, unblock=lambda db_url: 'ldap' not in db_url)])
def test_db_migrate(app_creds, temp_appliance_extended_db, db_url, db_version,
                    db_desc):
    app = temp_appliance_extended_db

    # Download the database
    logger.info("Downloading database: {}".format(db_desc))
    url_basename = os_path.basename(db_url)
    rc, out = app.ssh_client.run_command('curl -o "/tmp/{}" "{}"'.format(
        url_basename, db_url),
                                         timeout=30)
    assert rc == 0, "Failed to download database: {}".format(out)

    # The v2_key is potentially here