def test_db_migrate(temp_appliance_extended_db, db_url, db_version, db_desc): """ Polarion: assignee: jhenner initialEstimate: 1/4h casecomponent: Appliance """ app = temp_appliance_extended_db # Download the database logger.info("Downloading database: {}".format(db_desc)) url_basename = os_path.basename(db_url) loc = "/tmp/" result = app.ssh_client.run_command('curl -o "{}{}" "{}"'.format( loc, url_basename, db_url), timeout=30) assert result.success, "Failed to download database: {}".format( result.output) # The v2_key is potentially here v2key_url = os_path.join(os_path.dirname(db_url), "v2_key") # Stop EVM service and drop vmdb_production DB app.evmserverd.stop() app.db.drop() app.db.create() # restore new DB result = app.ssh_client.run_command( 'pg_restore -v --dbname=vmdb_production {}{}'.format( loc, url_basename), timeout=600) assert result.success, "Failed to restore new database: {}".format( result.output) app.db.migrate() # fetch v2_key try: result = app.ssh_client.run_command('curl "{}"'.format(v2key_url), timeout=15) assert result.success, "Failed to download v2_key: {}".format( result.output) assert ":key:" in result.output, "Not a v2_key file: {}".format( result.output) result = app.ssh_client.run_command( 'curl -o "/var/www/miq/vmdb/certs/v2_key" "{}"'.format(v2key_url), timeout=15) assert result.success, "Failed to download v2_key: {}".format( result.output) # or change all invalid (now unavailable) passwords to 'invalid' except AssertionError: app.db.fix_auth_key() app.db.fix_auth_dbyml() # start evmserverd, wait for web UI to start and try to log in try: app.evmserverd.start() except ApplianceException: result = app.ssh_client.run_rake_command("evm:start") assert result.success, "Couldn't start evmserverd: {}".format( result.output) app.wait_for_web_ui(timeout=600) app.db.reset_user_pass() wait_for(lambda: navigate_to(app.server, 'LoginScreen'), handle_exception=True) app.server.login(app.user)
def test_db_migrate(temp_appliance_extended_db, db_url, db_version, db_desc): """ Polarion: assignee: jhenner initialEstimate: 1/4h casecomponent: Appliance """ app = temp_appliance_extended_db # Download the database logger.info("Downloading database: {}".format(db_desc)) url_basename = os_path.basename(db_url) loc = "/tmp/" result = app.ssh_client.run_command( 'curl -o "{}{}" "{}"'.format(loc, url_basename, db_url), timeout=30) assert result.success, "Failed to download database: {}".format(result.output) # The v2_key is potentially here v2key_url = os_path.join(os_path.dirname(db_url), "v2_key") # Stop EVM service and drop vmdb_production DB app.evmserverd.stop() app.db.drop() app.db.create() # restore new DB result = app.ssh_client.run_command( 'pg_restore -v --dbname=vmdb_production {}{}'.format(loc, url_basename), timeout=600) assert result.success, "Failed to restore new database: {}".format(result.output) app.db.migrate() # fetch v2_key try: result = app.ssh_client.run_command( 'curl "{}"'.format(v2key_url), timeout=15) assert result.success, "Failed to download v2_key: {}".format(result.output) assert ":key:" in result.output, "Not a v2_key file: {}".format(result.output) result = app.ssh_client.run_command( 'curl -o "/var/www/miq/vmdb/certs/v2_key" "{}"'.format(v2key_url), timeout=15) assert result.success, "Failed to download v2_key: {}".format(result.output) # or change all invalid (now unavailable) passwords to 'invalid' except AssertionError: app.db.fix_auth_key() app.db.fix_auth_dbyml() # start evmserverd, wait for web UI to start and try to log in try: app.evmserverd.start() except ApplianceException: result = app.ssh_client.run_rake_command("evm:start") assert result.success, "Couldn't start evmserverd: {}".format(result.output) app.wait_for_web_ui(timeout=600) app.db.reset_user_pass() wait_for(lambda: navigate_to(app.server, 'LoginScreen'), handle_exception=True) app.server.login(app.user)
def test_services_performance(appliance_with_performance_db): """ Polarion: assignee: jhenner initialEstimate: 1/4h casecomponent: Services Bugzilla: 1688937 1686433 """ app = appliance_with_performance_db assert 50000 == app.rest_api.collections.services.count my_service = MyService(app) # Timeit seems to accept callable as well as string of Python code on cPython. assert timeit(lambda: navigate_to(my_service, 'All', use_resetter=False), number=1) < 180