forked from ManageIQ/integration_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1LP][RFR] No more session fixtures (ManageIQ#9639)
there is a plan to implement appliance markers and generate appliances based on those markers. We should get rid of session scoped fixuters using appliance fixture. This PR is one of steps we have to undertake to achieve above. Adding hook registering and calling for the appliance stack, in order to call methods on appliances, whenever they're used for tests. Replaces previous session scoped fixtures that were modifying the appliance at the start of the session.
- Loading branch information
Showing
11 changed files
with
77 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +0,0 @@ | ||
import pytest | ||
|
||
from cfme.utils.appliance import DummyAppliance | ||
from cfme.utils.log import logger | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def ensure_websocket_role_disabled(appliance): | ||
# TODO: This is a temporary solution until we find something better. | ||
if isinstance(appliance, DummyAppliance) or appliance.is_dev: | ||
return | ||
server_settings = appliance.server.settings | ||
roles = server_settings.server_roles_db | ||
if 'websocket' in roles and roles['websocket']: | ||
logger.info('Disabling the websocket role to ensure we get no intrusive popups') | ||
server_settings.disable_server_roles('websocket') | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def fix_missing_hostname(appliance): | ||
"""Fix for hostname missing from the /etc/hosts file | ||
Note: Affects RHOS-based appliances but can't hurt the others so | ||
it's applied on all. | ||
""" | ||
if isinstance(appliance, DummyAppliance) or appliance.is_dev: | ||
return | ||
logger.info("Checking appliance's /etc/hosts for a resolvable hostname") | ||
hosts_grep_cmd = 'grep {} /etc/hosts'.format(appliance.get_resolvable_hostname()) | ||
with appliance.ssh_client as ssh_client: | ||
if ssh_client.run_command(hosts_grep_cmd).failed: | ||
logger.info('Setting appliance hostname') | ||
if not appliance.set_resolvable_hostname(): | ||
# not resolvable, just use hostname output through appliance_console_cli to modify | ||
cli_hostname = ssh_client.run_command('hostname').output.rstrip('\n') | ||
logger.warning('Unable to resolve hostname, using `hostname`: %s', cli_hostname) | ||
appliance.appliance_console_cli.set_hostname(cli_hostname) | ||
|
||
if ssh_client.run_command('grep $(hostname) /etc/hosts').failed: | ||
logger.error('Failed to mangle /etc/hosts') | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def fix_missing_appliance_name(appliance): | ||
"""Fix for an empty appliance server name""" | ||
if isinstance(appliance, DummyAppliance) or appliance.is_dev: | ||
return | ||
logger.info('Checking appliance server name is set') | ||
if appliance.server.name == '': | ||
appliance.update_advanced_settings( | ||
{ | ||
'server': { | ||
'name': getattr(appliance, '_default_name', 'EVM') | ||
} | ||
} | ||
) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
|
||
@pytest.fixture(scope="session") | ||
def cfme_data(request): | ||
def cfme_data(): | ||
return conf.cfme_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters