def pytest_collection_modifyitems(session, config, items): # Just to print out the appliance's streams from fixtures.terminalreporter import reporter from cfme.utils.version import current_stream 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")
urls = process_url(cfme_data['basic_info'][update_url]) output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') return temp_appliance_preconfig_funcscope_upgrade @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) # MBU Backup is to large for /tmp loc = "/tmp/" if db_desc != "MBU Backup" else "/" rc, out = app.ssh_client.run_command('curl -o "{}{}" "{}"'.format( loc, url_basename, db_url), timeout=30) assert rc == 0, "Failed to download database: {}".format(out)
output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') return temp_appliance_preconfig_funcscope_upgrade @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 v2key_url = os_path.join(os_path.dirname(db_url), "v2_key")