diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c86df504763..08c10775ce1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,33 @@ # configuration for pre-commit git hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - exclude: tests/foreman/data/ - - id: check-yaml - - id: debug-statements -- repo: https://github.com/psf/black - rev: 22.10.0 - hooks: - - id: black -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.277 - hooks: - - id: ruff - args: [--fix, --exit-non-zero-on-fix] -- repo: local - hooks: - - id: fix-uuids - name: Robottelo Custom Fix UUIDs script - description: This hook runs the scripts/fix_uuids.sh script - language: script - entry: scripts/fix_uuids.sh - verbose: true - types: [text] - require_serial: true + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + exclude: tests/foreman/data/ + - id: check-yaml + - id: debug-statements + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.277 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - repo: local + hooks: + - id: fix-uuids + name: Robottelo Custom Fix UUIDs script + description: This hook runs the scripts/fix_uuids.sh script + language: script + entry: scripts/fix_uuids.sh + verbose: true + types: [text] + require_serial: true + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.0 + hooks: + - id: gitleaks diff --git a/Makefile b/Makefile index 2f73c60d3b4..ff0920c70ee 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ test-docstrings: uuid-check testimony $(TESTIMONY_OPTIONS) validate tests/foreman/ui testimony $(TESTIMONY_OPTIONS) validate tests/foreman/virtwho testimony $(TESTIMONY_OPTIONS) validate tests/foreman/maintain + testimony $(TESTIMONY_OPTIONS) validate tests/upgrades test-robottelo: $(info "Running robottelo framework unit tests...") diff --git a/conftest.py b/conftest.py index cf2522051ca..632f6e2a0e4 100644 --- a/conftest.py +++ b/conftest.py @@ -38,6 +38,7 @@ 'pytest_fixtures.component.computeprofile', 'pytest_fixtures.component.contentview', 'pytest_fixtures.component.domain', + 'pytest_fixtures.component.discovery', 'pytest_fixtures.component.host', 'pytest_fixtures.component.hostgroup', 'pytest_fixtures.component.http_proxy', diff --git a/pytest_fixtures/component/discovery.py b/pytest_fixtures/component/discovery.py new file mode 100644 index 00000000000..e05b3859f2f --- /dev/null +++ b/pytest_fixtures/component/discovery.py @@ -0,0 +1,31 @@ +from fauxfactory import gen_string +import pytest + + +@pytest.fixture(scope='module') +def module_discovery_hostgroup(module_org, module_location, module_target_sat): + host = module_target_sat.api.Host(organization=module_org, location=module_location).create() + return module_target_sat.api.HostGroup( + organization=[module_org], + location=[module_location], + medium=host.medium, + root_pass=gen_string('alpha'), + operatingsystem=host.operatingsystem, + ptable=host.ptable, + domain=host.domain, + architecture=host.architecture, + ).create() + + +@pytest.fixture(scope='module') +def discovery_org(module_org, module_target_sat): + discovery_org = module_target_sat.update_setting('discovery_organization', module_org.name) + yield module_org + module_target_sat.update_setting('discovery_organization', discovery_org) + + +@pytest.fixture(scope='module') +def discovery_location(module_location, module_target_sat): + discovery_loc = module_target_sat.update_setting('discovery_location', module_location.name) + yield module_location + module_target_sat.update_setting('discovery_location', discovery_loc) diff --git a/requirements-optional.txt b/requirements-optional.txt index 6da8ffd5441..8d8abe4d798 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -2,7 +2,7 @@ flake8==6.1.0 pytest-cov==4.1.0 redis==5.0.1 -pre-commit==3.4.0 +pre-commit==3.5.0 # For generating documentation. sphinx==7.2.6 diff --git a/robottelo/cli/sm_packages.py b/robottelo/cli/sm_packages.py index d56a1156ec9..ece44a773e0 100644 --- a/robottelo/cli/sm_packages.py +++ b/robottelo/cli/sm_packages.py @@ -51,6 +51,7 @@ def is_locked(cls, options=None): def status(cls, options=None): """Build satellite-maintain packages status""" cls.command_sub = 'status' + cls.command_end = None options = options or {} return cls.sm_execute(cls._construct_command(options)) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 01acc11b653..e7d2548758b 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1726,7 +1726,7 @@ class Colored(Box): VMWARE_CONSTANTS = { 'folder': 'vm', - 'guest_os': 'Red Hat Enterprise Linux 8 (64-bit)', + 'guest_os': 'Red Hat Enterprise Linux 8 (64 bit)', 'scsicontroller': 'LSI Logic Parallel', 'virtualhw_version': 'Default', 'pool': 'Resources', diff --git a/robottelo/host_helpers/contenthost_mixins.py b/robottelo/host_helpers/contenthost_mixins.py index f009503666a..74566b0ffb0 100644 --- a/robottelo/host_helpers/contenthost_mixins.py +++ b/robottelo/host_helpers/contenthost_mixins.py @@ -154,6 +154,7 @@ class HostInfo: @property def applicable_errata_count(self): """return the applicable errata count for a host""" + self.run('subscription-manager repos') return self.nailgun_host.read().content_facet_attributes['errata_counts']['total'] diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 6ee09915587..cc17f606e38 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -781,7 +781,7 @@ def register( raise ValueError('Global registration method can be used with Satellite/Capsule only') if lifecycle_environment is not None: - options['lifecycle_environment_id'] = lifecycle_environment.id + options['lifecycle-environment-id'] = lifecycle_environment.id if operating_system is not None: options['operatingsystem-id'] = operating_system.id if hostgroup is not None: @@ -1968,7 +1968,7 @@ def delete_puppet_class(self, puppetclass_name): for hostgroup in puppet_class.read().hostgroup: hostgroup.delete_puppetclass(data={'puppetclass_id': puppet_class.id}) # Search and remove puppet class from affected hosts - for host in self.api.Host().search(query={'search': f'class={puppet_class.name}'}): + for host in self.api.Host(puppetclass=f'{puppet_class.name}').search(): host.delete_puppetclass(data={'puppetclass_id': puppet_class.id}) # Remove puppet class entity puppet_class.delete() diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py index a4b5d48adb4..b0fc77d861e 100644 --- a/robottelo/utils/vault.py +++ b/robottelo/utils/vault.py @@ -19,25 +19,31 @@ class Vault: def __init__(self, env_file='.env'): self.env_path = robottelo_root_dir.joinpath(env_file) + self.envdata = None + self.vault_enabled = None def setup(self): - self.export_vault_addr() + if self.env_path.exists(): + self.envdata = self.env_path.read_text() + is_enabled = re.findall('\nVAULT_ENABLED_FOR_DYNACONF=(.*)', self.envdata) + if is_enabled: + self.vault_enabled = is_enabled[0] + self.export_vault_addr() def teardown(self): del os.environ['VAULT_ADDR'] def export_vault_addr(self): - envdata = self.env_path.read_text() - vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', envdata)[0] + vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', self.envdata)[0] # Set Vault CLI Env Var os.environ['VAULT_ADDR'] = vaulturl # Dynaconf Vault Env Vars - if re.findall('VAULT_ENABLED_FOR_DYNACONF=(.*)', envdata)[0] == 'true': + if self.vault_enabled and self.vault_enabled in ['True', 'true']: if 'localhost:8200' in vaulturl: raise InvalidVaultURLForOIDC( - f"{vaulturl} doesnt supports OIDC login," + f"{vaulturl} doesn't support OIDC login," "please change url to corp vault in env file!" ) @@ -63,7 +69,11 @@ def exec_vault_command(self, command: str, **kwargs): return vcommand def login(self, **kwargs): - if 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ: + if ( + self.vault_enabled + and self.vault_enabled in ['True', 'true'] + and 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ + ): if self.status(**kwargs).returncode != 0: logger.warning( "Warning! The browser is about to open for vault OIDC login, " @@ -81,22 +91,22 @@ def login(self, **kwargs): ).stdout token = json.loads(str(token.decode('UTF-8')))['data']['id'] # Setting new token in env file - envdata = self.env_path.read_text() - envdata = re.sub( - '.*VAULT_TOKEN_FOR_DYNACONF=.*', f"VAULT_TOKEN_FOR_DYNACONF={token}", envdata + _envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', + f"VAULT_TOKEN_FOR_DYNACONF={token}", + self.envdata, ) - self.env_path.write_text(envdata) + self.env_path.write_text(_envdata) logger.info( "Success! New OIDC token added to .env file to access secrets from vault!" ) def logout(self): # Teardown - Setting dymmy token in env file - envdata = self.env_path.read_text() - envdata = re.sub( - '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", envdata + _envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", self.envdata ) - self.env_path.write_text(envdata) + self.env_path.write_text(_envdata) self.exec_vault_command('vault token revoke -self') logger.info("Success! OIDC token removed from Env file successfully!") diff --git a/tests/foreman/api/test_discoveredhost.py b/tests/foreman/api/test_discoveredhost.py index 9b4a5ae5e22..773175812cf 100644 --- a/tests/foreman/api/test_discoveredhost.py +++ b/tests/foreman/api/test_discoveredhost.py @@ -247,8 +247,6 @@ def test_positive_provision_pxe_less_host( :expectedresults: Host should be provisioned successfully - :CaseAutomation: NotAutomated - :CaseImportance: Critical """ sat = module_discovery_sat.sat @@ -274,9 +272,10 @@ def test_positive_provision_pxe_less_host( assert not sat.api.Host().search(query={"search": f'name={host.name}'}) pxeless_discovery_host.blank = True - @pytest.mark.stubbed @pytest.mark.tier3 - def test_positive_auto_provision_pxe_host(self): + def test_positive_auto_provision_pxe_host( + self, module_discovery_hostgroup, module_target_sat, discovery_org, discovery_location + ): """Auto provision a pxe-based host by executing discovery rules :id: c93fd7c9-41ef-4eb5-8042-f72e87e67e10 @@ -290,14 +289,24 @@ def test_positive_auto_provision_pxe_host(self): :expectedresults: Selected Host should be auto-provisioned successfully - :CaseAutomation: Automated - :CaseImportance: Critical """ + discovered_host = module_target_sat.api_factory.create_discovered_host() + + rule = module_target_sat.api.DiscoveryRule( + max_count=1, + hostgroup=module_discovery_hostgroup, + search_=f'name = {discovered_host["name"]}', + location=[discovery_location], + organization=[discovery_org], + ).create() + result = module_target_sat.api.DiscoveredHost(id=discovered_host['id']).auto_provision() + assert f'provisioned with rule {rule.name}' in result['message'] - @pytest.mark.stubbed @pytest.mark.tier3 - def test_positive_auto_provision_all(self): + def test_positive_auto_provision_all( + self, module_discovery_hostgroup, module_target_sat, discovery_org, discovery_location + ): """Auto provision all host by executing discovery rules :id: 954d3688-62d9-47f7-9106-a4fff8825ffa @@ -314,6 +323,19 @@ def test_positive_auto_provision_all(self): :CaseImportance: High """ + module_target_sat.api.DiscoveryRule( + max_count=25, + hostgroup=module_discovery_hostgroup, + search_=f'location = "{discovery_location.name}"', + location=[discovery_location], + organization=[discovery_org], + ).create() + + for _ in range(2): + module_target_sat.api_factory.create_discovered_host() + + result = module_target_sat.api.DiscoveredHost().auto_provision_all() + assert '2 discovered hosts were provisioned' in result['message'] @pytest.mark.stubbed @pytest.mark.tier3 @@ -337,9 +359,19 @@ def test_positive_refresh_facts_pxe_host(self): :CaseImportance: High """ - @pytest.mark.stubbed + @pytest.mark.on_premises_provisioning + @pytest.mark.parametrize('module_provisioning_sat', ['discovery'], indirect=True) + @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) + @pytest.mark.rhel_ver_match('9') @pytest.mark.tier3 - def test_positive_reboot_pxe_host(self): + def test_positive_reboot_pxe_host( + self, + module_provisioning_rhel_content, + module_discovery_sat, + provisioning_host, + provisioning_hostgroup, + pxe_loader, + ): """Rebooting a pxe based discovered host :id: 69c807f8-5646-4aa6-8b3c-5ecab69560fc @@ -352,10 +384,23 @@ def test_positive_reboot_pxe_host(self): :expectedresults: Selected host should be rebooted successfully - :CaseAutomation: Automated - :CaseImportance: Medium """ + sat = module_discovery_sat.sat + provisioning_host.power_control(ensure=False) + mac = provisioning_host._broker_args['provisioning_nic_mac_addr'] + wait_for( + lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [], + timeout=240, + delay=20, + ) + discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0] + discovered_host.hostgroup = provisioning_hostgroup + discovered_host.location = provisioning_hostgroup.location[0] + discovered_host.organization = provisioning_hostgroup.organization[0] + discovered_host.build = True + result = sat.api.DiscoveredHost(id=discovered_host.id).reboot() + assert 'Unable to perform reboot' not in result @pytest.mark.stubbed @pytest.mark.tier3 @@ -381,8 +426,6 @@ def test_positive_reboot_all_pxe_hosts(self): class TestFakeDiscoveryTests: """Tests that use fake discovered host. - :CaseAutomation: Automated - :CaseImportance: High """ diff --git a/tests/foreman/api/test_errata.py b/tests/foreman/api/test_errata.py index 504cdf3d390..8c6383a4c7a 100644 --- a/tests/foreman/api/test_errata.py +++ b/tests/foreman/api/test_errata.py @@ -158,12 +158,10 @@ def test_positive_install_in_hc(module_org, activation_key, custom_repo, target_ @pytest.mark.tier3 -@pytest.mark.rhel_ver_list([7, 8, 9]) +@pytest.mark.rhel_ver_match('[^6]') @pytest.mark.no_containers @pytest.mark.e2e -def test_positive_install_multiple_in_host( - module_org, activation_key, custom_repo, rhel_contenthost, target_sat -): +def test_positive_install_multiple_in_host(target_sat, rhel_contenthost, module_org, module_lce): """For a host with multiple applicable errata install one and ensure the rest of errata is still available @@ -183,15 +181,36 @@ def test_positive_install_multiple_in_host( :CaseLevel: System """ - rhel_contenthost.install_katello_ca(target_sat) - rhel_contenthost.register_contenthost(module_org.label, activation_key.name) + ak = target_sat.api.ActivationKey( + organization=module_org, + environment=module_lce, + ).create() + # Associate custom repos with org, lce, ak: + target_sat.cli_factory.setup_org_for_a_custom_repo( + { + 'url': settings.repos.yum_9.url, + 'organization-id': module_org.id, + 'lifecycle-environment-id': module_lce.id, + 'activationkey-id': ak.id, + } + ) + rhel_contenthost.register( + activation_keys=ak.name, + target=target_sat, + org=module_org, + loc=None, + ) assert rhel_contenthost.subscribed + # Installing outdated custom packages: for package in constants.FAKE_9_YUM_OUTDATED_PACKAGES: + rhel_contenthost.run(f'yum remove -y {str(package.split("-", 1)[0])}') assert rhel_contenthost.run(f'yum install -y {package}').status == 0 - applicable_errata_count = rhel_contenthost.applicable_errata_count - assert applicable_errata_count > 1 - rhel_contenthost.add_rex_key(satellite=target_sat) - for errata in settings.repos.yum_9.errata[1:4]: + assert rhel_contenthost.run(f'rpm -q {package}').status == 0 + # Each errata will be installed sequentially, + # after each install, applicable-errata-count should drop by one. + for errata in constants.FAKE_9_YUM_SECURITY_ERRATUM: + pre_errata_count = rhel_contenthost.applicable_errata_count + assert pre_errata_count >= 1 task_id = target_sat.api.JobInvocation().run( data={ 'feature': 'katello_errata_install', @@ -206,8 +225,8 @@ def test_positive_install_multiple_in_host( search_rate=20, max_tries=15, ) - applicable_errata_count -= 1 - assert rhel_contenthost.applicable_errata_count == applicable_errata_count + sleep(20) + assert rhel_contenthost.applicable_errata_count == pre_errata_count - 1 @pytest.mark.tier3 diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index 84ebc98af7c..3606b0a077d 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -56,7 +56,7 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location): ) assert vmware_cr['name'] == cr_name assert vmware_cr['locations'][0] == module_location.name - assert vmware_cr['organizations'] == module_org.name + assert vmware_cr['organizations'][0] == module_org.name assert vmware_cr['server'] == settings.vmware.vcenter assert vmware_cr['datacenter'] == settings.vmware.datacenter # List diff --git a/tests/foreman/cli/test_repositories.py b/tests/foreman/cli/test_repositories.py index f35a93603ab..2a98e9dbd58 100644 --- a/tests/foreman/cli/test_repositories.py +++ b/tests/foreman/cli/test_repositories.py @@ -17,6 +17,7 @@ :Upstream: No """ import pytest +from requests.exceptions import HTTPError @pytest.mark.rhel_ver_match('[^6]') @@ -47,3 +48,40 @@ def test_positive_custom_products_disabled_by_default( assert rhel_contenthost.subscribed product_details = rhel_contenthost.run('subscription-manager repos --list') assert 'Enabled: 0' in product_details.stdout + + +def test_negative_invalid_repo_fails_publish( + module_repository, + module_org, + target_sat, +): + """Verify that an invalid repository fails when trying to publish in a content view + + :id: 64e03f28-8213-467a-a229-44c8cbfaaef1 + + :steps: + 1. Create custom product and upload repository + 2. Run Katello commands to make repository invalid + 3. Create content view and add repository + 4. Verify Publish fails + + :expectedresults: Publishing a content view with an invalid repository fails + + :customerscenario: true + + :BZ: 2032040 + """ + repo = module_repository + target_sat.execute( + 'echo "root = ::Katello::RootRepository.last; ::Katello::Resources::Candlepin::Product.' + 'remove_content(root.product.organization.label, root.product.cp_id, root.content_id); ' + '::Katello::Resources::Candlepin::Content.destroy(root.product.organization.label, ' + 'root.content_id)" | foreman-rake console' + ) + cv = target_sat.api.ContentView( + organization=module_org.name, + repository=[repo.id], + ).create() + with pytest.raises(HTTPError) as context: + cv.publish() + assert 'Remove the invalid repository before publishing again' in context.value.response.text diff --git a/tests/foreman/destructive/test_capsule_loadbalancer.py b/tests/foreman/destructive/test_capsule_loadbalancer.py index 3d9fdf02604..04ba4614438 100644 --- a/tests/foreman/destructive/test_capsule_loadbalancer.py +++ b/tests/foreman/destructive/test_capsule_loadbalancer.py @@ -17,6 +17,7 @@ :Upstream: No """ import pytest +from wrapanapi import VmState from robottelo.config import settings from robottelo.constants import CLIENT_PORT, DataFile @@ -175,20 +176,20 @@ def loadbalancer_setup( @pytest.mark.e2e @pytest.mark.tier1 -def test_loadbalancer_register_client_using_ak_to_ha_proxy(loadbalancer_setup, rhel7_contenthost): - """Register the client using ak to the haproxy +def test_loadbalancer_install_package( + loadbalancer_setup, setup_capsules, rhel7_contenthost, module_org, module_location, request +): + r"""Install packages on a content host regardless of the registered capsule being available :id: bd3c2e50-18e2-4be7-8a7f-c32472e17c61 :Steps: 1. run `subscription-manager register --org=Your_Organization \ - --activationkey=Your_Activation_Key \ - --serverurl=https://loadbalancer.example.com:8443/rhsm \ - --baseurl=https://loadbalancer.example.com/pulp/content` - 2. Check which capsule the host got registered. - 3. Try package installation - 4. Remove the package and unregister the host - 5. Again register, verify it's the other capsule this time. + --activationkey=Your_Activation_Key \` + 2. Try package installation + 3. Check which capsule the host got registered. + 4. Remove the package + 5. Take down the capsule that the host was registered to 6. Try package installation again :expectedresults: The client should be get the package irrespective of the capsule @@ -196,20 +197,17 @@ def test_loadbalancer_register_client_using_ak_to_ha_proxy(loadbalancer_setup, r :CaseLevel: Integration """ - url = f'https://{loadbalancer_setup["setup_haproxy"]["haproxy"].hostname}' - server_url = f'{url}:8443/rhsm' - base_url = f'{url}/pulp/content' - - result = rhel7_contenthost.download_install_rpm( - repo_url=f'{url}/pub', package_name='katello-ca-consumer-latest.noarch' - ) - assert result.status == 0 - rhel7_contenthost.register_contenthost( - org=loadbalancer_setup['module_org'].label, - activation_key=loadbalancer_setup['content_for_client']['client_ak'].name, - serverurl=server_url, - baseurl=base_url, + # Register content host + result = rhel7_contenthost.register( + org=module_org, + loc=module_location, + activation_keys=loadbalancer_setup['content_for_client']['client_ak'].name, + target=setup_capsules['capsule_1'], + force=True, ) + assert result.status == 0, f'Failed to register host: {result.stderr}' + + # Try package installation result = rhel7_contenthost.execute('yum install -y tree') assert result.status == 0 @@ -227,42 +225,21 @@ def test_loadbalancer_register_client_using_ak_to_ha_proxy(loadbalancer_setup, r if loadbalancer_setup['setup_capsules']['capsule_1'].hostname in result.stdout else loadbalancer_setup['setup_capsules']['capsule_2'] ) - # Find the other capsule - for capsule in loadbalancer_setup['setup_capsules'].values(): - if registered_to_capsule != capsule: - other_capsule = capsule + # Remove the packages from the client result = rhel7_contenthost.execute('yum remove -y tree') assert result.status == 0 - # For other capsule - rhel7_contenthost.remove_katello_ca() - rhel7_contenthost.unregister() - - result = rhel7_contenthost.execute('rm -f katello-ca-consumer-latest.noarch.rpm') - assert result.status == 0 - - result = rhel7_contenthost.download_install_rpm( - repo_url=f'{url}/pub', package_name='katello-ca-consumer-latest.noarch' - ) - assert result.status == 0 - - rhel7_contenthost.register_contenthost( - org=loadbalancer_setup['module_org'].label, - activation_key=loadbalancer_setup['content_for_client']['client_ak'].name, - serverurl=server_url, - baseurl=base_url, - ) - result = rhel7_contenthost.execute('rpm -qa | grep katello-ca-consumer') - assert other_capsule.hostname in result.stdout + # Power off the capsule that the client is registered to + registered_to_capsule.power_control(state=VmState.STOPPED, ensure=True) + # Try package installation again result = rhel7_contenthost.execute('yum install -y tree') assert result.status == 0 - hosts = loadbalancer_setup['module_target_sat'].cli.Host.list( - {'organization-id': loadbalancer_setup['module_org'].id} - ) - assert rhel7_contenthost.hostname in [host['name'] for host in hosts] + @request.addfinalizer + def _finalize(): + registered_to_capsule.power_control(state=VmState.RUNNING, ensure=True) @pytest.mark.rhel_ver_match('[^6]') diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 2f50eca2d10..d0664d86e27 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -78,7 +78,12 @@ def test_positive_end_to_end_crud(session, module_org): indirect=True, ) def test_positive_end_to_end_register( - session, function_entitlement_manifest_org, repos_collection, rhel7_contenthost, target_sat + session, + function_entitlement_manifest_org, + default_location, + repos_collection, + rhel7_contenthost, + target_sat, ): """Create activation key and use it during content host registering @@ -98,10 +103,13 @@ def test_positive_end_to_end_register( repos_collection.setup_content(org.id, lce.id, upload_manifest=False) ak_name = repos_collection.setup_content_data['activation_key']['name'] - repos_collection.setup_virtual_machine(rhel7_contenthost) + repos_collection.setup_virtual_machine(rhel7_contenthost, install_katello_agent=False) with session: session.organization.select(org.name) - chost = session.contenthost.read(rhel7_contenthost.hostname, widget_names='details') + session.location.select(default_location.name) + chost = session.contenthost.read_legacy_ui( + rhel7_contenthost.hostname, widget_names='details' + ) assert chost['details']['registered_by'] == f'Activation Key {ak_name}' ak_values = session.activationkey.read(ak_name, widget_names='content_hosts') assert len(ak_values['content_hosts']['table']) == 1 diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index 1f93bbe673a..34d0127e983 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -557,6 +557,7 @@ def test_positive_virt_card(session, target_sat, module_location, module_org): settings.vmware.vm_name, hostgroup_name, module_location.name, + name=settings.vmware.vm_name, ) host_name = '.'.join([settings.vmware.vm_name, domain.name]) power_status = session.computeresource.vm_status(cr_name, settings.vmware.vm_name) diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 1d3b734e2ea..08ce12c02ff 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -1313,7 +1313,7 @@ def test_global_registration_form_populate( def test_global_registration_with_capsule_host( session, capsule_configured, - rhel7_contenthost, + rhel8_contenthost, module_org, module_location, module_product, @@ -1342,7 +1342,7 @@ def test_global_registration_with_capsule_host( :CaseAutomation: Automated """ - client = rhel7_contenthost + client = rhel8_contenthost repo = target_sat.api.Repository( url=settings.repos.yum_1.url, content_type=REPO_TYPE['yum'], @@ -1391,7 +1391,7 @@ def test_global_registration_with_capsule_host( session.location.select(loc_name=module_location.name) cmd = session.host.get_register_command( { - 'general.orgnization': module_org.name, + 'general.organization': module_org.name, 'general.location': module_location.name, 'general.operating_system': default_os.title, 'general.capsule': capsule_configured.hostname, @@ -1412,7 +1412,7 @@ def test_global_registration_with_capsule_host( @pytest.mark.usefixtures('enable_capsule_for_registration') @pytest.mark.no_containers def test_global_registration_with_gpg_repo_and_default_package( - session, module_activation_key, default_os, default_smart_proxy, rhel7_contenthost + session, module_activation_key, default_os, default_smart_proxy, rhel8_contenthost ): """Host registration form produces a correct registration command and host is registered successfully with gpg repo enabled and have default package @@ -1435,7 +1435,7 @@ def test_global_registration_with_gpg_repo_and_default_package( :parametrized: yes """ - client = rhel7_contenthost + client = rhel8_contenthost repo_name = 'foreman_register' repo_url = settings.repos.gr_yum_repo.url repo_gpg_url = settings.repos.gr_yum_repo.gpg_url @@ -1455,7 +1455,15 @@ def test_global_registration_with_gpg_repo_and_default_package( # rhel repo required for insights client installation, # syncing it to the satellite would take too long - client.create_custom_repos(rhel7=settings.repos.rhel7_os) + rhelver = client.os_version.major + if rhelver > 7: + repos = {f'rhel{rhelver}_os': settings.repos[f'rhel{rhelver}_os']['baseos']} + else: + repos = { + 'rhel7_os': settings.repos['rhel7_os'], + 'rhel7_extras': settings.repos['rhel7_extras'], + } + client.create_custom_repos(**repos) # run curl result = client.execute(cmd) assert result.status == 0 @@ -1571,7 +1579,7 @@ def test_global_re_registration_host_with_force_ignore_error_options( @pytest.mark.tier2 @pytest.mark.usefixtures('enable_capsule_for_registration') def test_global_registration_token_restriction( - session, module_activation_key, rhel7_contenthost, default_os, default_smart_proxy, target_sat + session, module_activation_key, rhel8_contenthost, default_os, default_smart_proxy, target_sat ): """Global registration token should be only used for registration call, it should be restricted for any other api calls. @@ -1589,7 +1597,7 @@ def test_global_registration_token_restriction( :parametrized: yes """ - client = rhel7_contenthost + client = rhel8_contenthost with session: cmd = session.host.get_register_command( { @@ -1609,7 +1617,7 @@ def test_global_registration_token_restriction( for curl_cmd in (curl_users, curl_hosts): result = client.execute(curl_cmd) assert result.status == 0 - 'Unable to authenticate user' in result.stdout + assert 'Unable to authenticate user' in result.stdout @pytest.mark.tier4 diff --git a/tests/foreman/ui/test_http_proxy.py b/tests/foreman/ui/test_http_proxy.py index 2f48559cac2..abe02f12002 100644 --- a/tests/foreman/ui/test_http_proxy.py +++ b/tests/foreman/ui/test_http_proxy.py @@ -110,6 +110,8 @@ def test_positive_assign_http_proxy_to_products_repositories( # Create repositories from UI. with target_sat.ui_session() as session: repo_a1_name = gen_string('alpha') + session.organization.select(org_name=module_org.name) + session.location.select(loc_name=module_location.name) session.repository.create( product_a.name, { diff --git a/tests/foreman/ui/test_rhcloud_insights.py b/tests/foreman/ui/test_rhcloud_insights.py index 6ba96238d21..153e2a11876 100644 --- a/tests/foreman/ui/test_rhcloud_insights.py +++ b/tests/foreman/ui/test_rhcloud_insights.py @@ -356,7 +356,7 @@ def test_insights_registration_with_capsule( cmd = session.host_new.get_register_command( { 'general.operating_system': default_os.title, - 'general.orgnization': org.name, + 'general.organization': org.name, 'general.capsule': rhcloud_capsule.hostname, 'general.activation_keys': ak.name, 'general.insecure': True, diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index 32a0b69e374..1e0396d4ce5 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -16,7 +16,6 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings @@ -25,54 +24,18 @@ create_http_proxy, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, - get_guest_info, ) -@pytest.fixture() -def form_data(default_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_server': settings.virtwho.esx.hypervisor_server, - 'organization_id': default_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - -@pytest.fixture(autouse=True) -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.mark.usefixtures('delete_host') +@pytest.mark.delete_host class TestVirtWhoConfigforEsx: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, target_sat, virtwho_config_api, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -84,23 +47,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, default_org.name) - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) + assert virtwho_config_api.status == 'unknown' + hypervisor_name, guest_name = deploy_type_api virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @@ -132,7 +83,9 @@ def test_positive_deploy_configure_by_id_script( assert result['subscription_status_label'] == 'Fully entitled' @pytest.mark.tier2 - def test_positive_debug_option(self, default_org, form_data, virtwho_config, target_sat): + def test_positive_debug_option( + self, default_org, form_data_api, virtwho_config_api, target_sat + ): """Verify debug option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" @@ -147,16 +100,18 @@ def test_positive_debug_option(self, default_org, form_data, virtwho_config, tar """ options = {'true': '1', 'false': '0', '1': '1', '0': '0'} for key, value in sorted(options.items(), key=lambda item: item[0]): - virtwho_config.debug = key - virtwho_config.update(['debug']) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.debug = key + virtwho_config_api.update(['debug']) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 - def test_positive_interval_option(self, default_org, form_data, virtwho_config, target_sat): + def test_positive_interval_option( + self, default_org, form_data_api, virtwho_config_api, target_sat + ): """Verify interval option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" @@ -180,17 +135,17 @@ def test_positive_interval_option(self, default_org, form_data, virtwho_config, '4320': '259200', } for key, value in sorted(options.items(), key=lambda item: int(item[0])): - virtwho_config.interval = key - virtwho_config.update(['interval']) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.interval = key + virtwho_config_api.update(['interval']) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -207,17 +162,19 @@ def test_positive_hypervisor_id_option( # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 - def test_positive_filter_option(self, default_org, form_data, virtwho_config, target_sat): + def test_positive_filter_option( + self, default_org, form_data_api, virtwho_config_api, target_sat + ): """Verify filter option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" @@ -236,26 +193,30 @@ def test_positive_filter_option(self, default_org, form_data, virtwho_config, ta whitelist['filter_host_parents'] = '.*redhat.com' blacklist['exclude_host_parents'] = '.*redhat.com' # Update Whitelist and check the result - virtwho_config.filtering_mode = whitelist['filtering_mode'] - virtwho_config.whitelist = whitelist['whitelist'] - virtwho_config.filter_host_parents = whitelist['filter_host_parents'] - virtwho_config.update(whitelist.keys()) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + virtwho_config_api.filtering_mode = whitelist['filtering_mode'] + virtwho_config_api.whitelist = whitelist['whitelist'] + virtwho_config_api.filter_host_parents = whitelist['filter_host_parents'] + virtwho_config_api.update(whitelist.keys()) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) assert get_configure_option('filter_hosts', config_file) == whitelist['whitelist'] assert ( get_configure_option('filter_host_parents', config_file) == whitelist['filter_host_parents'] ) # Update Blacklist and check the result - virtwho_config.filtering_mode = blacklist['filtering_mode'] - virtwho_config.blacklist = blacklist['blacklist'] - virtwho_config.exclude_host_parents = blacklist['exclude_host_parents'] - virtwho_config.update(blacklist.keys()) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + virtwho_config_api.filtering_mode = blacklist['filtering_mode'] + virtwho_config_api.blacklist = blacklist['blacklist'] + virtwho_config_api.exclude_host_parents = blacklist['exclude_host_parents'] + virtwho_config_api.update(blacklist.keys()) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) assert get_configure_option('exclude_hosts', config_file) == blacklist['blacklist'] assert ( get_configure_option('exclude_host_parents', config_file) @@ -263,7 +224,9 @@ def test_positive_filter_option(self, default_org, form_data, virtwho_config, ta ) @pytest.mark.tier2 - def test_positive_proxy_option(self, default_org, form_data, virtwho_config, target_sat): + def test_positive_proxy_option( + self, default_org, form_data_api, virtwho_config_api, target_sat + ): """Verify http_proxy option by "PUT /foreman_virt_who_configure/api/v2/configs/:id"" @@ -278,8 +241,10 @@ def test_positive_proxy_option(self, default_org, form_data, virtwho_config, tar :BZ: 1902199 """ - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) # Check default NO_PROXY option assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == '*' # Check HTTTP Proxy and No_PROXY option @@ -287,23 +252,27 @@ def test_positive_proxy_option(self, default_org, form_data, virtwho_config, tar http_type='http', org=default_org ) no_proxy = 'test.satellite.com' - virtwho_config.http_proxy_id = http_proxy_id - virtwho_config.no_proxy = no_proxy - virtwho_config.update(['http_proxy_id', 'no_proxy']) - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + virtwho_config_api.http_proxy_id = http_proxy_id + virtwho_config_api.no_proxy = no_proxy + virtwho_config_api.update(['http_proxy_id', 'no_proxy']) + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy_url assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check HTTTPs Proxy option https_proxy_url, https_proxy_name, https_proxy_id = create_http_proxy(org=default_org) - virtwho_config.http_proxy_id = https_proxy_id - virtwho_config.update(['http_proxy_id']) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + virtwho_config_api.http_proxy_id = https_proxy_id + virtwho_config_api.update(['http_proxy_id']) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy_url @pytest.mark.tier2 def test_positive_configure_organization_list( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify "GET /foreman_virt_who_configure/ @@ -317,14 +286,16 @@ def test_positive_configure_organization_list( :CaseImportance: Medium """ - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) - search_result = virtwho_config.get_organization_configs(data={'per_page': '1000'}) - assert [item for item in search_result['results'] if item['name'] == form_data['name']] + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) + search_result = virtwho_config_api.get_organization_configs(data={'per_page': '1000'}) + assert [item for item in search_result['results'] if item['name'] == form_data_api['name']] @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, default_org, form_data, target_sat + self, default_org, form_data_api, target_sat ): """Verify " hammer virt-who-config deploy hypervisor with special characters" @@ -341,25 +312,25 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ # check the hypervisor password contains single quotes - form_data['hypervisor_password'] = "Tes't" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - assert virtwho_config.status == 'unknown' - command = get_configure_command(virtwho_config.id, default_org.name) + form_data_api['hypervisor_password'] = "Tes't" + virtwho_config_api = target_sat.api.VirtWhoConfig(**form_data_api).create() + assert virtwho_config_api.status == 'unknown' + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_status = deploy_configure_by_command_check(command) assert deploy_status == 'Finished successfully' - config_file = get_configure_file(virtwho_config.id) + config_file = get_configure_file(virtwho_config_api.id) assert get_configure_option('rhsm_hostname', config_file) == target_sat.hostname assert ( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - virtwho_config.delete() + virtwho_config_api.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) # check the hypervisor password contains backtick - form_data['hypervisor_password'] = "my`password" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['hypervisor_password'] = "my`password" + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() assert virtwho_config.status == 'unknown' command = get_configure_command(virtwho_config.id, default_org.name) deploy_status = deploy_configure_by_command_check(command) @@ -372,11 +343,13 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( ) virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) @pytest.mark.tier2 - def test_positive_remove_env_option(self, default_org, form_data, virtwho_config, target_sat): + def test_positive_remove_env_option( + self, default_org, form_data_api, virtwho_config_api, target_sat + ): """remove option 'env=' from the virt-who configuration file and without any error :id: 981b6828-a7ed-46d9-9c6c-9fb22af4011e @@ -394,19 +367,19 @@ def test_positive_remove_env_option(self, default_org, form_data, virtwho_config :BZ: 1834897 """ - command = get_configure_command(virtwho_config.id, default_org.name) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_api['hypervisor_type'], debug=True, org=default_org.label ) virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" - config_file = get_configure_file(virtwho_config.id) + config_file = get_configure_file(virtwho_config_api.id) env_error = ( f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" ) diff --git a/tests/foreman/virtwho/api/test_esx_sca.py b/tests/foreman/virtwho/api/test_esx_sca.py index cd9cc3d3140..3a967cbded1 100644 --- a/tests/foreman/virtwho/api/test_esx_sca.py +++ b/tests/foreman/virtwho/api/test_esx_sca.py @@ -14,7 +14,6 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings @@ -23,45 +22,18 @@ create_http_proxy, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(module_sca_manifest_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_server': settings.virtwho.esx.hypervisor_server, - 'organization_id': module_sca_manifest_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.upgrade - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type + self, module_sca_manifest_org, target_sat, virtwho_config_api, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -73,30 +45,17 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) - deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) + assert virtwho_config_api.status == 'unknown' virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @pytest.mark.tier2 def test_positive_debug_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify debug option by "PUT @@ -112,17 +71,17 @@ def test_positive_debug_option( """ options = {'0': '0', '1': '1', 'false': '0', 'true': '1'} for key, value in options.items(): - virtwho_config.debug = key - virtwho_config.update(['debug']) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.debug = key + virtwho_config_api.update(['debug']) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 def test_positive_interval_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify interval option by "PUT @@ -147,17 +106,17 @@ def test_positive_interval_option( '4320': '259200', } for key, value in options.items(): - virtwho_config.interval = key - virtwho_config.update(['interval']) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.interval = key + virtwho_config_api.update(['interval']) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -172,12 +131,12 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ for value in ['uuid', 'hostname']: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @@ -185,7 +144,7 @@ def test_positive_hypervisor_id_option( @pytest.mark.parametrize('filter_type', ['whitelist', 'blacklist']) @pytest.mark.parametrize('option_type', ['edit', 'create']) def test_positive_filter_option( - self, module_sca_manifest_org, form_data, target_sat, filter_type, option_type + self, module_sca_manifest_org, form_data_api, target_sat, filter_type, option_type ): """Verify filter option by "PUT @@ -204,7 +163,7 @@ def test_positive_filter_option( regex = '.*redhat.com' whitelist = {'filtering_mode': '1', 'whitelist': regex} blacklist = {'filtering_mode': '2', 'blacklist': regex} - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() if option_type == "edit": if filter_type == "whitelist": whitelist['filter_host_parents'] = regex @@ -220,7 +179,7 @@ def test_positive_filter_option( virtwho_config.update(blacklist.keys()) command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) config_file = get_configure_file(virtwho_config.id) result = target_sat.api.VirtWhoConfig().search( @@ -245,20 +204,20 @@ def test_positive_filter_option( elif option_type == "create": virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) if filter_type == "whitelist": - form_data['filtering_mode'] = 1 - form_data['whitelist'] = regex - form_data['filter_host_parents'] = regex + form_data_api['filtering_mode'] = 1 + form_data_api['whitelist'] = regex + form_data_api['filter_host_parents'] = regex elif filter_type == "blacklist": - form_data['filtering_mode'] = 2 - form_data['blacklist'] = regex - form_data['exclude_host_parents'] = regex - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['filtering_mode'] = 2 + form_data_api['blacklist'] = regex + form_data_api['exclude_host_parents'] = regex + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) config_file = get_configure_file(virtwho_config.id) result = target_sat.api.VirtWhoConfig().search( @@ -283,7 +242,7 @@ def test_positive_filter_option( assert result.exclude_host_parents == regex @pytest.mark.tier2 - def test_positive_proxy_option(self, module_sca_manifest_org, form_data, target_sat): + def test_positive_proxy_option(self, module_sca_manifest_org, form_data_api, target_sat): """Verify http_proxy option by "PUT /foreman_virt_who_configure/api/v2/configs/:id"" @@ -300,10 +259,10 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data, target_ :BZ: 1902199 """ - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) # Check default NO_PROXY option assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == '*' @@ -317,7 +276,7 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data, target_ virtwho_config.update(['http_proxy_id', 'no_proxy']) command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy_url assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy @@ -332,21 +291,21 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data, target_ virtwho_config.http_proxy_id = https_proxy_id virtwho_config.update(['http_proxy_id']) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy_url virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) # Check the http proxy option, create virt-who config via http proxy id - form_data['http_proxy_id'] = http_proxy_id - form_data['no_proxy'] = no_proxy - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['http_proxy_id'] = http_proxy_id + form_data_api['no_proxy'] = no_proxy + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy_url assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy @@ -356,12 +315,12 @@ def test_positive_proxy_option(self, module_sca_manifest_org, form_data, target_ assert result.no_proxy == no_proxy virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) @pytest.mark.tier2 def test_positive_configure_organization_list( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify "GET /foreman_virt_who_configure/ @@ -375,16 +334,16 @@ def test_positive_configure_organization_list( :CaseImportance: Medium """ - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) - search_result = virtwho_config.get_organization_configs(data={'per_page': '1000'}) - assert [item for item in search_result['results'] if item['name'] == form_data['name']] + search_result = virtwho_config_api.get_organization_configs(data={'per_page': '1000'}) + assert [item for item in search_result['results'] if item['name'] == form_data_api['name']] @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, module_sca_manifest_org, form_data, target_sat + self, module_sca_manifest_org, form_data_api, target_sat ): """Verify "hammer virt-who-config deploy hypervisor with special characters" @@ -401,8 +360,8 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ # check the hypervisor password contains single quotes - form_data['hypervisor_password'] = "Tes't" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['hypervisor_password'] = "Tes't" + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() assert virtwho_config.status == 'unknown' command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_status = deploy_configure_by_command_check(command) @@ -415,11 +374,11 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( ) virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) # check the hypervisor password contains backtick - form_data['hypervisor_password'] = "my`password" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['hypervisor_password'] = "my`password" + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() assert virtwho_config.status == 'unknown' command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_status = deploy_configure_by_command_check(command) @@ -432,12 +391,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( ) virtwho_config.delete() assert not target_sat.api.VirtWhoConfig().search( - query={'search': f"name={form_data['name']}"} + query={'search': f"name={form_data_api['name']}"} ) @pytest.mark.tier2 def test_positive_remove_env_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """remove option 'env=' from the virt-who configuration file and without any error @@ -456,19 +415,19 @@ def test_positive_remove_env_option( :BZ: 1834897 """ - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" - config_file = get_configure_file(virtwho_config.id) + config_file = get_configure_file(virtwho_config_api.id) env_error = ( f"option {{\'{option}\'}} is not exist or not be enabled in {{\'{config_file}\'}}" ) diff --git a/tests/foreman/virtwho/api/test_hyperv.py b/tests/foreman/virtwho/api/test_hyperv.py index ec7c37ae6e7..e76e12f2669 100644 --- a/tests/foreman/virtwho/api/test_hyperv.py +++ b/tests/foreman/virtwho/api/test_hyperv.py @@ -16,50 +16,22 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(default_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_server': settings.virtwho.hyperv.hypervisor_server, - 'organization_id': default_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -71,23 +43,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, default_org.name) - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) + assert virtwho_config_api.status == 'unknown' + hypervisor_name, guest_name = deploy_type_api virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @@ -120,7 +80,7 @@ def test_positive_deploy_configure_by_id_script( @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -136,11 +96,11 @@ def test_positive_hypervisor_id_option( """ values = ['uuid', 'hostname'] for value in values: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_hyperv_sca.py b/tests/foreman/virtwho/api/test_hyperv_sca.py index 67f18934c8d..68dd7c0e4f1 100644 --- a/tests/foreman/virtwho/api/test_hyperv_sca.py +++ b/tests/foreman/virtwho/api/test_hyperv_sca.py @@ -16,50 +16,21 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(module_sca_manifest_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_server': settings.virtwho.hyperv.hypervisor_server, - 'organization_id': module_sca_manifest_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type + self, module_sca_manifest_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -71,30 +42,17 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) - deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) + assert virtwho_config_api.status == 'unknown' virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -109,11 +67,11 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ for value in ['uuid', 'hostname']: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_kubevirt.py b/tests/foreman/virtwho/api/test_kubevirt.py index e2fbe884f9a..88292e772db 100644 --- a/tests/foreman/virtwho/api/test_kubevirt.py +++ b/tests/foreman/virtwho/api/test_kubevirt.py @@ -16,58 +16,23 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, - get_guest_info, ) -@pytest.fixture() -def form_data(default_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'organization_id': default_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'kubeconfig_path': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - -@pytest.fixture(autouse=True) -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.mark.usefixtures('delete_host') +@pytest.mark.delete_host class TestVirtWhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -79,80 +44,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, default_org.name) - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) - virt_who_instance = ( - target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] - .status - ) - assert virt_who_instance == 'ok' - hosts = [ - ( - hypervisor_name, - f'product_id={settings.virtwho.sku.vdc_physical} and type=NORMAL', - ), - ( - guest_name, - f'product_id={settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED', - ), - ] - for hostname, sku in hosts: - host = target_sat.cli.Host.list({'search': hostname})[0] - subscriptions = target_sat.cli.Subscription.list( - {'organization': default_org.name, 'search': sku} - ) - vdc_id = subscriptions[0]['id'] - if 'type=STACK_DERIVED' in sku: - for item in subscriptions: - if hypervisor_name.lower() in item['type']: - vdc_id = item['id'] - break - target_sat.api.HostSubscription(host=host['id']).add_subscriptions( - data={'subscriptions': [{'id': vdc_id, 'quantity': 'Automatic'}]} - ) - result = target_sat.api.Host().search(query={'search': hostname})[0].read_json() - assert result['subscription_status_label'] == 'Fully entitled' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify "GET /foreman_virt_who_configure/api/ - - v2/configs/:id/deploy_script" - - :id: 77100dc7-644a-44a4-802a-2da562246cba - - :expectedresults: Config can be created and deployed - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config.status == 'unknown' - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) + assert virtwho_config_api.status == 'unknown' + hypervisor_name, guest_name = deploy_type_api virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @@ -185,7 +81,7 @@ def test_positive_deploy_configure_by_script( @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -201,11 +97,11 @@ def test_positive_hypervisor_id_option( """ values = ['uuid', 'hostname'] for value in values: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_kubevirt_sca.py b/tests/foreman/virtwho/api/test_kubevirt_sca.py index f64b719e9c4..364a637be5c 100644 --- a/tests/foreman/virtwho/api/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/api/test_kubevirt_sca.py @@ -14,48 +14,21 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(module_sca_manifest_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'organization_id': module_sca_manifest_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'kubeconfig_path': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type + self, module_sca_manifest_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -67,30 +40,17 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) - deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) + assert virtwho_config_api.status == 'unknown' virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -105,11 +65,11 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ for value in ['uuid', 'hostname']: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_libvirt.py b/tests/foreman/virtwho/api/test_libvirt.py index eb0806e5753..2d05ebd5e49 100644 --- a/tests/foreman/virtwho/api/test_libvirt.py +++ b/tests/foreman/virtwho/api/test_libvirt.py @@ -16,49 +16,22 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(default_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_server': settings.virtwho.libvirt.hypervisor_server, - 'organization_id': default_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -70,23 +43,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, default_org.name) - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) + assert virtwho_config_api.status == 'unknown' + hypervisor_name, guest_name = deploy_type_api virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @@ -119,7 +80,7 @@ def test_positive_deploy_configure_by_id_script( @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -135,11 +96,11 @@ def test_positive_hypervisor_id_option( """ values = ['uuid', 'hostname'] for value in values: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_libvirt_sca.py b/tests/foreman/virtwho/api/test_libvirt_sca.py index bead5b8e95f..d805b4da5ef 100644 --- a/tests/foreman/virtwho/api/test_libvirt_sca.py +++ b/tests/foreman/virtwho/api/test_libvirt_sca.py @@ -14,49 +14,21 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_option, ) -@pytest.fixture() -def form_data(module_sca_manifest_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_server': settings.virtwho.libvirt.hypervisor_server, - 'organization_id': module_sca_manifest_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type + self, module_sca_manifest_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -68,30 +40,17 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) - deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) + assert virtwho_config_api.status == 'unknown' virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT /foreman_virt_who_configure/api/v2/configs/:id" @@ -104,11 +63,11 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ for value in ['uuid', 'hostname']: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/api/test_nutanix.py b/tests/foreman/virtwho/api/test_nutanix.py index 5e4d4c51f34..d9ddc34938f 100644 --- a/tests/foreman/virtwho/api/test_nutanix.py +++ b/tests/foreman/virtwho/api/test_nutanix.py @@ -16,7 +16,6 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings @@ -27,53 +26,16 @@ get_configure_command, get_configure_file, get_configure_option, - get_guest_info, get_hypervisor_ahv_mapping, ) -@pytest.fixture() -def form_data(default_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_server': settings.virtwho.ahv.hypervisor_server, - 'organization_id': default_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_password': settings.virtwho.ahv.hypervisor_password, - 'prism_flavor': settings.virtwho.ahv.prism_flavor, - 'ahv_internal_debug': 'false', - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - -@pytest.fixture(autouse=True) -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.mark.usefixtures('delete_host') +@pytest.mark.delete_host class TestVirtWhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -85,23 +47,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, default_org.name) - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - hypervisor_name, guest_name = deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=default_org.label, - ) + assert virtwho_config_api.status == 'unknown' + hypervisor_name, guest_name = deploy_type_api virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @@ -138,7 +88,7 @@ def test_positive_deploy_configure_by_id_script( @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -154,19 +104,19 @@ def test_positive_hypervisor_id_option( """ values = ['uuid', 'hostname'] for value in values: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_api['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, default_org, form_data, target_sat, deploy_type + self, default_org, form_data_api, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" on nutanix prism central mode @@ -180,19 +130,19 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ - form_data['prism_flavor'] = "central" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['prism_flavor'] = "central" + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() assert virtwho_config.status == 'unknown' if deploy_type == "id": command = get_configure_command(virtwho_config.id, default_org.name) hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_api['hypervisor_type'], debug=True, org=default_org.label ) elif deploy_type == "script": script = virtwho_config.deploy_script() hypervisor_name, guest_name = deploy_configure_by_script( script['virt_who_config_script'], - form_data['hypervisor_type'], + form_data_api['hypervisor_type'], debug=True, org=default_org.label, ) @@ -238,7 +188,7 @@ def test_positive_prism_central_deploy_configure_by_id_script( @pytest.mark.tier2 def test_positive_prism_central_prism_central_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify prism_flavor option by "PUT @@ -253,16 +203,18 @@ def test_positive_prism_central_prism_central_option( :CaseImportance: Medium """ value = 'central' - virtwho_config.prism_flavor = value - virtwho_config.update(['prism_flavor']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, default_org.name) - deploy_configure_by_command(command, form_data['hypervisor_type'], org=default_org.label) + virtwho_config_api.prism_flavor = value + virtwho_config_api.update(['prism_flavor']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, default_org.name) + deploy_configure_by_command( + command, form_data_api['hypervisor_type'], org=default_org.label + ) assert get_configure_option("prism_central", config_file) == 'true' @pytest.mark.tier2 def test_positive_ahv_internal_debug_option( - self, default_org, form_data, virtwho_config, target_sat + self, default_org, form_data_api, virtwho_config_api, target_sat ): """Verify ahv_internal_debug option by hammer virt-who-config" @@ -284,18 +236,18 @@ def test_positive_ahv_internal_debug_option( :customerscenario: true """ - command = get_configure_command(virtwho_config.id, default_org.name) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_api['hypervisor_type'], debug=True, org=default_org.label ) result = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .ahv_internal_debug ) assert str(result) == 'False' # ahv_internal_debug does not set in virt-who-config-X.conf - config_file = get_configure_file(virtwho_config.id) + config_file = get_configure_file(virtwho_config_api.id) option = 'ahv_internal_debug' env_error = f"option {option} is not exist or not be enabled in {config_file}" try: @@ -308,21 +260,23 @@ def test_positive_ahv_internal_debug_option( # Update ahv_internal_debug option to true value = 'true' - virtwho_config.ahv_internal_debug = value - virtwho_config.update(['ahv_internal_debug']) - command = get_configure_command(virtwho_config.id, default_org.name) + virtwho_config_api.ahv_internal_debug = value + virtwho_config_api.update(['ahv_internal_debug']) + command = get_configure_command(virtwho_config_api.id, default_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_api['hypervisor_type'], debug=True, org=default_org.label + ) + assert ( + get_hypervisor_ahv_mapping(form_data_api['hypervisor_type']) == 'Host UUID found for VM' ) - assert get_hypervisor_ahv_mapping(form_data['hypervisor_type']) == 'Host UUID found for VM' result = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .ahv_internal_debug ) assert str(result) == 'True' # ahv_internal_debug bas been set to true in virt-who-config-X.conf - config_file = get_configure_file(virtwho_config.id) + config_file = get_configure_file(virtwho_config_api.id) assert get_configure_option("ahv_internal_debug", config_file) == 'true' # check message does not exist in log file /var/log/rhsm/rhsm.log message = 'Value for "ahv_internal_debug" not set, using default: False' diff --git a/tests/foreman/virtwho/api/test_nutanix_sca.py b/tests/foreman/virtwho/api/test_nutanix_sca.py index 05287279231..c075db7f795 100644 --- a/tests/foreman/virtwho/api/test_nutanix_sca.py +++ b/tests/foreman/virtwho/api/test_nutanix_sca.py @@ -16,10 +16,8 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, deploy_configure_by_script, @@ -29,38 +27,11 @@ ) -@pytest.fixture() -def form_data(module_sca_manifest_org, target_sat): - form = { - 'name': gen_string('alpha'), - 'debug': 1, - 'interval': '60', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_server': settings.virtwho.ahv.hypervisor_server, - 'organization_id': module_sca_manifest_org.id, - 'filtering_mode': 'none', - 'satellite_url': target_sat.hostname, - 'hypervisor_username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_password': settings.virtwho.ahv.hypervisor_password, - 'prism_flavor': settings.virtwho.ahv.prism_flavor, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat): - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() - yield virtwho_config - virtwho_config.delete() - assert not target_sat.api.VirtWhoConfig().search(query={'search': f"name={form_data['name']}"}) - - class TestVirtWhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_api', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type + self, default_org, virtwho_config_api, target_sat, deploy_type_api ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -72,30 +43,17 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - assert virtwho_config.status == 'unknown' - if deploy_type == "id": - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) - deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label - ) - elif deploy_type == "script": - script = virtwho_config.deploy_script() - deploy_configure_by_script( - script['virt_who_config_script'], - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) + assert virtwho_config_api.status == 'unknown' virt_who_instance = ( target_sat.api.VirtWhoConfig() - .search(query={'search': f'name={virtwho_config.name}'})[0] + .search(query={'search': f'name={virtwho_config_api.name}'})[0] .status ) assert virt_who_instance == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify hypervisor_id option by "PUT @@ -110,19 +68,19 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ for value in ['uuid', 'hostname']: - virtwho_config.hypervisor_id = value - virtwho_config.update(['hypervisor_id']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.hypervisor_id = value + virtwho_config_api.update(['hypervisor_id']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, module_sca_manifest_org, form_data, target_sat, deploy_type + self, module_sca_manifest_org, form_data_api, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" on nutanix prism central mode @@ -136,19 +94,22 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ - form_data['prism_flavor'] = "central" - virtwho_config = target_sat.api.VirtWhoConfig(**form_data).create() + form_data_api['prism_flavor'] = "central" + virtwho_config = target_sat.api.VirtWhoConfig(**form_data_api).create() assert virtwho_config.status == 'unknown' if deploy_type == "id": command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, + form_data_api['hypervisor_type'], + debug=True, + org=module_sca_manifest_org.label, ) elif deploy_type == "script": script = virtwho_config.deploy_script() deploy_configure_by_script( script['virt_who_config_script'], - form_data['hypervisor_type'], + form_data_api['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -164,7 +125,7 @@ def test_positive_prism_central_deploy_configure_by_id_script( @pytest.mark.tier2 def test_positive_prism_central_prism_central_option( - self, module_sca_manifest_org, form_data, virtwho_config, target_sat + self, module_sca_manifest_org, form_data_api, virtwho_config_api, target_sat ): """Verify prism_flavor option by "PUT @@ -179,11 +140,11 @@ def test_positive_prism_central_prism_central_option( :CaseImportance: Medium """ value = 'central' - virtwho_config.prism_flavor = value - virtwho_config.update(['prism_flavor']) - config_file = get_configure_file(virtwho_config.id) - command = get_configure_command(virtwho_config.id, module_sca_manifest_org.name) + virtwho_config_api.prism_flavor = value + virtwho_config_api.update(['prism_flavor']) + config_file = get_configure_file(virtwho_config_api.id) + command = get_configure_command(virtwho_config_api.id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_api['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option("prism_central", config_file) == 'true' diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index f38590b8ddf..2715febb34f 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -31,57 +31,22 @@ delete_configure_option, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, get_configure_option, - get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.esx.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - -@pytest.fixture(autouse=True) -def delete_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.mark.usefixtures('delete_host') +@pytest.mark.delete_host class TestVirtwhoConfigforEsx: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id|script. @@ -98,37 +63,28 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_debug_option(self, default_org, virtwho_config, session, form_data): + def test_positive_debug_option(self, default_org, virtwho_config_ui, org_session, form_data_ui): """Verify debug checkbox and the value changes of VIRTWHO_DEBUG :id: adb435c4-d02b-47b6-89f5-dce9a4ff7939 @@ -141,23 +97,25 @@ def test_positive_debug_option(self, default_org, virtwho_config, session, form_ :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '1' - session.virtwho_configure.edit(name, {'debug': False}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'debug': False}) + results = org_session.virtwho_configure.read(name) assert results['overview']['debug'] is False deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '0' @pytest.mark.tier2 - def test_positive_interval_option(self, default_org, virtwho_config, session, form_data): + def test_positive_interval_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify interval dropdown options and the value changes of VIRTWHO_INTERVAL. :id: 731f8361-38d4-40b9-9530-8d785d61eaab @@ -170,7 +128,7 @@ def test_positive_interval_option(self, default_org, virtwho_config, session, fo :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) intervals = { @@ -184,16 +142,18 @@ def test_positive_interval_option(self, default_org, virtwho_config, session, fo 'Every 3 days': '259200', } for option, value in sorted(intervals.items(), key=lambda item: int(item[1])): - session.virtwho_configure.edit(name, {'interval': option}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'interval': option}) + results = org_session.virtwho_configure.read(name) assert results['overview']['interval'] == option deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: cc494bd9-51d9-452a-bfa9-5cdcafef5197 @@ -206,23 +166,25 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) # esx and rhevm support hwuuid option values = ['uuid', 'hostname', 'hwuuid'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 - def test_positive_filtering_option(self, default_org, virtwho_config, session, form_data): + def test_positive_filtering_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Filtering dropdown options. :id: e17dda14-79cd-4cd2-8f29-60970b24a905 @@ -237,7 +199,7 @@ def test_positive_filtering_option(self, default_org, virtwho_config, session, f :BZ: 1735670 """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) @@ -248,28 +210,28 @@ def test_positive_filtering_option(self, default_org, virtwho_config, session, f whitelist['filtering_content.filter_host_parents'] = regex blacklist['filtering_content.exclude_host_parents'] = regex # Update Whitelist and check the result - session.virtwho_configure.edit(name, whitelist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, whitelist) + results = org_session.virtwho_configure.read(name) assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert regex == get_configure_option('filter_hosts', config_file) assert regex == get_configure_option('filter_host_parents', config_file) # Update Blacklist and check the result - session.virtwho_configure.edit(name, blacklist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) assert results['overview']['exclude_hosts'] == regex assert results['overview']['exclude_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert regex == get_configure_option('exclude_hosts', config_file) assert regex == get_configure_option('exclude_host_parents', config_file) @pytest.mark.tier2 - def test_positive_proxy_option(self, default_org, virtwho_config, session, form_data): + def test_positive_proxy_option(self, default_org, virtwho_config_ui, org_session, form_data_ui): """Verify 'HTTP Proxy' and 'Ignore Proxy' options. :id: 6659d577-0135-4bf0-81af-14b930011536 @@ -285,31 +247,31 @@ def test_positive_proxy_option(self, default_org, virtwho_config, session, form_ http_proxy, http_proxy_name, http_proxy_id = create_http_proxy( http_type='http', org=default_org ) - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) no_proxy = 'test.satellite.com' # Check the https proxy and No_PROXY settings - session.virtwho_configure.edit(name, {'proxy': https_proxy, 'no_proxy': no_proxy}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'proxy': https_proxy, 'no_proxy': no_proxy}) + results = org_session.virtwho_configure.read(name) assert results['overview']['proxy'] == https_proxy assert results['overview']['no_proxy'] == no_proxy deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('https_proxy', ETC_VIRTWHO_CONFIG) == https_proxy assert get_configure_option('no_proxy', ETC_VIRTWHO_CONFIG) == no_proxy # Check the http proxy setting - session.virtwho_configure.edit(name, {'proxy': http_proxy}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'proxy': http_proxy}) + results = org_session.virtwho_configure.read(name) assert results['overview']['proxy'] == http_proxy deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('http_proxy', ETC_VIRTWHO_CONFIG) == http_proxy @pytest.mark.tier2 - def test_positive_virtwho_roles(self, session): + def test_positive_virtwho_roles(self, org_session): """Verify the default roles for virtwho configure :id: cd6a5363-f9ba-4b52-892c-905634168fc5 @@ -337,14 +299,14 @@ def test_positive_virtwho_roles(self, session): }, 'Virt-who Viewer': {'Satellite virt who configure/config': ['view_virt_who_config']}, } - with session: + with org_session: for role_name, role_filters in roles.items(): - assert session.role.search(role_name)[0]['Name'] == role_name - assigned_permissions = session.filter.read_permissions(role_name) + assert org_session.role.search(role_name)[0]['Name'] == role_name + assigned_permissions = org_session.filter.read_permissions(role_name) assert sorted(assigned_permissions) == sorted(role_filters) @pytest.mark.tier2 - def test_positive_virtwho_configs_widget(self, default_org, session, form_data): + def test_positive_virtwho_configs_widget(self, default_org, org_session, form_data_ui): """Check if Virt-who Configurations Status Widget is working in the Dashboard UI :id: 5d61ce00-a640-4823-89d4-7b1d02b50ea6 @@ -363,38 +325,40 @@ def test_positive_virtwho_configs_widget(self, default_org, session, form_data): """ org_name = gen_string('alpha') name = gen_string('alpha') - form_data['name'] = name - with session: - session.organization.create({'name': org_name}) - session.organization.select(org_name) - session.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.organization.create({'name': org_name}) + org_session.organization.select(org_name) + org_session.virtwho_configure.create(form_data_ui) expected_values = [ {'Configuration Status': 'No Reports', 'Count': '1'}, {'Configuration Status': 'No Change', 'Count': '0'}, {'Configuration Status': 'OK', 'Count': '0'}, {'Configuration Status': 'Total Configurations', 'Count': '1'}, ] - values = session.dashboard.read('VirtWhoConfigStatus') + values = org_session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' # Check the 'Status' changed after deployed the virt-who config config_id = get_configure_id(name) config_command = get_configure_command(config_id, org_name) - deploy_configure_by_command(config_command, form_data['hypervisor_type'], org=org_name) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' + deploy_configure_by_command( + config_command, form_data_ui['hypervisor_type'], org=org_name + ) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' expected_values = [ {'Configuration Status': 'No Reports', 'Count': '0'}, {'Configuration Status': 'No Change', 'Count': '0'}, {'Configuration Status': 'OK', 'Count': '1'}, {'Configuration Status': 'Total Configurations', 'Count': '1'}, ] - values = session.dashboard.read('VirtWhoConfigStatus') + values = org_session.dashboard.read('VirtWhoConfigStatus') assert values['config_status'] == expected_values assert values['latest_config'] == 'No configuration found' - session.organization.select("Default Organization") + org_session.organization.select("Default Organization") @pytest.mark.tier2 - def test_positive_delete_configure(self, default_org, session, form_data): + def test_positive_delete_configure(self, default_org, org_session, form_data_ui): """Verify when a config is deleted the associated user is deleted. :id: 0e66dcf6-dc64-4fb2-b8a9-518f5adfa800 @@ -410,22 +374,24 @@ def test_positive_delete_configure(self, default_org, session, form_data): """ name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) restart_virtwho_service() assert get_virtwho_status() == 'logerror' @pytest.mark.tier2 - def test_positive_virtwho_reporter_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_reporter_role( + self, default_org, org_session, test_name, form_data_ui + ): """Verify the virt-who reporter role can TRULY work. :id: cd235ab0-d89c-464b-98d6-9d090ac40d8f @@ -438,9 +404,9 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -450,14 +416,14 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Update the virt-who config file config_id = get_configure_id(config_name) config_file = get_configure_file(config_id) @@ -467,19 +433,19 @@ def test_positive_virtwho_reporter_role(self, default_org, session, test_name, f restart_virtwho_service() assert get_virtwho_status() == 'logerror' # Check the permissioin of Virt-who Reporter - session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) - assert session.user.search(username)[0]['Username'] == username - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) + assert org_session.user.search(username)[0]['Username'] == username + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Reporter'] restart_virtwho_service() assert get_virtwho_status() == 'running' with Session(test_name, username, password) as newsession: assert not newsession.virtwho_configure.check_create_permission()['can_view'] - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_viewer_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_viewer_role(self, default_org, org_session, test_name, form_data_ui): """Verify the virt-who viewer role can TRULY work. :id: bf3be2e4-3853-41cc-9b3e-c8677f0b8c5f @@ -492,9 +458,9 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -504,17 +470,17 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Viewer - session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Viewer'] # Update the virt-who config file config_id = get_configure_id(config_name) @@ -535,11 +501,11 @@ def test_positive_virtwho_viewer_role(self, default_org, session, test_name, for assert not update_permission['can_edit'] newsession.virtwho_configure.read(config_name) # Delete the created user - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_virtwho_manager_role(self, default_org, session, test_name, form_data): + def test_positive_virtwho_manager_role(self, default_org, org_session, test_name, form_data_ui): """Verify the virt-who manager role can TRULY work. :id: a72023fb-7b23-4582-9adc-c5227dc7859c @@ -551,9 +517,9 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session: + with org_session: # Create an user - session.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -563,28 +529,28 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo } ) # Create a virt-who config plugin - form_data['name'] = config_name - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) - assert session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Manager - session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) - user = session.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Manager'] with Session(test_name, username, password) as newsession: # create_virt_who_config new_virt_who_name = gen_string('alpha') - form_data['name'] = new_virt_who_name - newsession.virtwho_configure.create(form_data) + form_data_ui['name'] = new_virt_who_name + newsession.virtwho_configure.create(form_data_ui) # view_virt_who_config values = newsession.virtwho_configure.read(new_virt_who_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=default_org.label + command, form_data_ui['hypervisor_type'], org=default_org.label ) assert newsession.virtwho_configure.search(new_virt_who_name)[0]['Status'] == 'ok' # edit_virt_who_config @@ -595,11 +561,11 @@ def test_positive_virtwho_manager_role(self, default_org, session, test_name, fo newsession.virtwho_configure.delete(modify_name) assert not newsession.virtwho_configure.search(modify_name) # Delete the created user - session.user.delete(username) - assert not session.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 - def test_positive_overview_label_name(self, default_org, form_data, session): + def test_positive_overview_label_name(self, default_org, form_data_ui, org_session): """Verify the label name on virt-who config Overview Page. :id: 21df8175-bb41-422e-a263-8677bc3a9565 @@ -613,20 +579,20 @@ def test_positive_overview_label_name(self, default_org, form_data, session): :CaseImportance: Medium """ name = gen_string('alpha') - form_data['name'] = name - hypervisor_type = form_data['hypervisor_type'] + form_data_ui['name'] = name + hypervisor_type = form_data_ui['hypervisor_type'] http_proxy_url, proxy_name, proxy_id = create_http_proxy(org=default_org) - form_data['proxy'] = http_proxy_url - form_data['no_proxy'] = 'test.satellite.com' + form_data_ui['proxy'] = http_proxy_url + form_data_ui['no_proxy'] = 'test.satellite.com' regex = '.*redhat.com' whitelist = {'filtering': 'Whitelist', 'filtering_content.filter_hosts': regex} blacklist = {'filtering': 'Blacklist', 'filtering_content.exclude_hosts': regex} if hypervisor_type == 'esx': whitelist['filtering_content.filter_host_parents'] = regex blacklist['filtering_content.exclude_host_parents'] = regex - form_data = dict(form_data, **whitelist) - with session: - session.virtwho_configure.create(form_data) + form_data = dict(form_data_ui, **whitelist) + with org_session: + org_session.virtwho_configure.create(form_data) fields = { 'status_label': 'Status', 'hypervisor_type_label': 'Hypervisor Type', @@ -647,11 +613,11 @@ def test_positive_overview_label_name(self, default_org, form_data, session): fields['kubeconfig_path_label'] = 'Kubeconfig Path' if hypervisor_type == 'esx': fields['filter_host_parents_label'] = 'Filter Host Parents' - results = session.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) for key, value in fields.items(): assert results['overview'][key] == value - session.virtwho_configure.edit(name, blacklist) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) del fields['filter_hosts_label'] if hypervisor_type == 'esx': del fields['filter_host_parents_label'] @@ -661,7 +627,9 @@ def test_positive_overview_label_name(self, default_org, form_data, session): assert results['overview'][key] == value @pytest.mark.tier2 - def test_positive_last_checkin_status(self, default_org, virtwho_config, form_data, session): + def test_positive_last_checkin_status( + self, default_org, virtwho_config_ui, form_data_ui, org_session + ): """Verify the Last Checkin status on Content Hosts Page. :id: 7448d482-d05c-4727-8980-176586e9e4a7 @@ -676,15 +644,15 @@ def test_positive_last_checkin_status(self, default_org, virtwho_config, form_da :CaseImportance: Medium """ - name = form_data['name'] - values = session.virtwho_configure.read(name, widget_names='deploy.command') + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name, widget_names='deploy.command') command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - time_now = session.browser.get_client_datetime() - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - checkin_time = session.contenthost.search(hypervisor_name)[0]['Last Checkin'] + time_now = org_session.browser.get_client_datetime() + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + checkin_time = org_session.contenthost.search(hypervisor_name)[0]['Last Checkin'] # 10 mins margin to check the Last Checkin time assert ( abs( @@ -698,7 +666,7 @@ def test_positive_last_checkin_status(self, default_org, virtwho_config, form_da @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, default_org, form_data, target_sat, session + self, default_org, form_data_ui, target_sat, org_session ): """Verify " hammer virt-who-config deploy hypervisor with special characters" @@ -715,12 +683,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name - with session: + form_data_ui['name'] = name + with org_session: # check the hypervisor password contains single quotes - form_data['hypervisor_content.password'] = "Tes't" - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "Tes't" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -731,12 +699,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) # check the hypervisor password contains backtick - form_data['hypervisor_content.password'] = "my`password" - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "my`password" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -747,12 +715,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_remove_env_option( - self, default_org, virtwho_config, form_data, target_sat, session + self, default_org, virtwho_config_ui, form_data_ui, target_sat, org_session ): """remove option 'env=' from the virt-who configuration file and without any error @@ -770,13 +738,13 @@ def test_positive_remove_env_option( :customerscenario: true """ - name = form_data['name'] - values = session.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_id = get_configure_id(name) diff --git a/tests/foreman/virtwho/ui/test_esx_sca.py b/tests/foreman/virtwho/ui/test_esx_sca.py index 6abda09c6e4..f8eb03fea98 100644 --- a/tests/foreman/virtwho/ui/test_esx_sca.py +++ b/tests/foreman/virtwho/ui/test_esx_sca.py @@ -28,58 +28,23 @@ delete_configure_option, deploy_configure_by_command, deploy_configure_by_command_check, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, get_configure_option, - get_guest_info, get_virtwho_status, restart_virtwho_service, update_configure_option, ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.esx.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.esx.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.esx.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.esx.hypervisor_password, - } - return form - - -@pytest.fixture(autouse=True) -def clean_host(form_data, target_sat): - guest_name, _ = get_guest_info(form_data['hypervisor_type']) - results = target_sat.api.Host().search(query={'search': guest_name}) - if results: - target_sat.api.Host(id=results[0].read_json()['id']).delete() - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - -@pytest.mark.usefixtures('clean_host') +@pytest.mark.delete_host class TestVirtwhoConfigforEsx: @pytest.mark.tier2 @pytest.mark.upgrade - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -96,29 +61,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_debug_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify debug checkbox and the value changes of VIRTWHO_DEBUG @@ -132,24 +79,24 @@ def test_positive_debug_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '1' - session_sca.virtwho_configure.edit(name, {'debug': False}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'debug': False}) + results = org_session.virtwho_configure.read(name) assert results['overview']['debug'] is False deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('debug', ETC_VIRTWHO_CONFIG) == '0' @pytest.mark.tier2 def test_positive_interval_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify interval dropdown options and the value changes of VIRTWHO_INTERVAL. @@ -163,7 +110,7 @@ def test_positive_interval_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) intervals = { @@ -177,17 +124,17 @@ def test_positive_interval_option( 'Every 3 days': '259200', } for option, value in intervals.items(): - session_sca.virtwho_configure.edit(name, {'interval': option}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'interval': option}) + results = org_session.virtwho_configure.read(name) assert results['overview']['interval'] == option deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('interval', ETC_VIRTWHO_CONFIG) == value @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -201,17 +148,17 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) # esx and rhevm support hwuuid option for value in ['uuid', 'hostname', 'hwuuid']: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @@ -219,7 +166,7 @@ def test_positive_hypervisor_id_option( @pytest.mark.parametrize('filter_type', ['whitelist', 'blacklist']) @pytest.mark.parametrize('option_type', ['edit', 'create']) def test_positive_filtering_option( - self, module_sca_manifest_org, session_sca, form_data, filter_type, option_type + self, module_sca_manifest_org, org_session, form_data_ui, filter_type, option_type ): """Verify Filtering dropdown options. @@ -243,11 +190,11 @@ def test_positive_filtering_option( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name + form_data_ui['name'] = name regex = '.*redhat.com' - with session_sca: + with org_session: if option_type == "edit": - session_sca.virtwho_configure.create(form_data) + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) @@ -256,19 +203,21 @@ def test_positive_filtering_option( # esx support filter-host-parents and exclude-host-parents options whitelist['filtering_content.filter_host_parents'] = regex # Update Whitelist and check the result - session_sca.virtwho_configure.edit(name, whitelist) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, whitelist) + results = org_session.virtwho_configure.read(name) assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex elif filter_type == "blacklist": blacklist = {'filtering': 'Blacklist', 'filtering_content.exclude_hosts': regex} blacklist['filtering_content.exclude_host_parents'] = regex - session_sca.virtwho_configure.edit(name, blacklist) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, blacklist) + results = org_session.virtwho_configure.read(name) assert results['overview']['exclude_hosts'] == regex assert results['overview']['exclude_host_parents'] == regex deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, + form_data_ui['hypervisor_type'], + org=module_sca_manifest_org.label, ) if filter_type == "whitelist": assert regex == get_configure_option('filter_hosts', config_file) @@ -276,25 +225,25 @@ def test_positive_filtering_option( elif filter_type == "blacklist": assert regex == get_configure_option('exclude_hosts', config_file) assert regex == get_configure_option('exclude_host_parents', config_file) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) elif option_type == "create": if filter_type == "whitelist": - form_data['filtering'] = "Whitelist" - form_data['filtering_content.filter_hosts'] = regex - form_data['filtering_content.filter_host_parents'] = regex + form_data_ui['filtering'] = "Whitelist" + form_data_ui['filtering_content.filter_hosts'] = regex + form_data_ui['filtering_content.filter_host_parents'] = regex elif filter_type == "blacklist": - form_data['filtering'] = "Blacklist" - form_data['filtering_content.exclude_hosts'] = regex - form_data['filtering_content.exclude_host_parents'] = regex - session_sca.virtwho_configure.create(form_data) + form_data_ui['filtering'] = "Blacklist" + form_data_ui['filtering_content.exclude_hosts'] = regex + form_data_ui['filtering_content.exclude_host_parents'] = regex + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) config_file = get_configure_file(config_id) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) if filter_type == "whitelist": assert results['overview']['filter_hosts'] == regex assert results['overview']['filter_host_parents'] == regex @@ -308,7 +257,7 @@ def test_positive_filtering_option( @pytest.mark.tier2 def test_positive_last_checkin_status( - self, module_sca_manifest_org, virtwho_config, form_data, session_sca + self, module_sca_manifest_org, virtwho_config_ui, form_data_ui, org_session ): """Verify the Last Checkin status on Content Hosts Page. @@ -324,15 +273,15 @@ def test_positive_last_checkin_status( :CaseImportance: Medium """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name, widget_names='deploy.command') + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name, widget_names='deploy.command') command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - time_now = session_sca.browser.get_client_datetime() - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - checkin_time = session_sca.contenthost.search(hypervisor_name)[0]['Last Checkin'] + time_now = org_session.browser.get_client_datetime() + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + checkin_time = org_session.contenthost.search(hypervisor_name)[0]['Last Checkin'] # 10 mins margin to check the Last Checkin time assert ( abs( @@ -346,7 +295,7 @@ def test_positive_last_checkin_status( @pytest.mark.tier2 def test_positive_remove_env_option( - self, module_sca_manifest_org, virtwho_config, form_data, target_sat, session_sca + self, module_sca_manifest_org, virtwho_config_ui, form_data_ui, target_sat, org_session ): """remove option 'env=' from the virt-who configuration file and without any error @@ -364,13 +313,13 @@ def test_positive_remove_env_option( :customerscenario: true """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' # Check the option "env=" should be removed from etc/virt-who.d/virt-who.conf option = "env" config_id = get_configure_id(name) @@ -388,7 +337,7 @@ def test_positive_remove_env_option( assert result.status == 1 @pytest.mark.tier2 - def test_positive_virtwho_roles(self, session_sca): + def test_positive_virtwho_roles(self, org_session): """Verify the default roles for virtwho configure :id: 3c2501d5-c122-49f0-baa4-4c0d678cb6fc @@ -416,14 +365,14 @@ def test_positive_virtwho_roles(self, session_sca): }, 'Virt-who Viewer': {'Satellite virt who configure/config': ['view_virt_who_config']}, } - with session_sca: + with org_session: for role_name, role_filters in roles.items(): - assert session_sca.role.search(role_name)[0]['Name'] == role_name - assigned_permissions = session_sca.filter.read_permissions(role_name) + assert org_session.role.search(role_name)[0]['Name'] == role_name + assigned_permissions = org_session.filter.read_permissions(role_name) assert sorted(assigned_permissions) == sorted(role_filters) @pytest.mark.tier2 - def test_positive_delete_configure(self, module_sca_manifest_org, session_sca, form_data): + def test_positive_delete_configure(self, module_sca_manifest_org, org_session, form_data_ui): """Verify when a config is deleted the associated user is deleted. :id: efc7253d-f455-4dc3-ae03-3ed5e215bd11 @@ -442,23 +391,23 @@ def test_positive_delete_configure(self, module_sca_manifest_org, session_sca, f :CaseImportance: Low """ name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) + form_data_ui['name'] = name + with org_session: + org_session.virtwho_configure.create(form_data_ui) config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) restart_virtwho_service() assert get_virtwho_status() == 'logerror' @pytest.mark.tier2 def test_positive_virtwho_reporter_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who reporter role can TRULY work. @@ -476,9 +425,9 @@ def test_positive_virtwho_reporter_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -488,14 +437,14 @@ def test_positive_virtwho_reporter_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Update the virt-who config file config_id = get_configure_id(config_name) config_file = get_configure_file(config_id) @@ -505,20 +454,20 @@ def test_positive_virtwho_reporter_role( restart_virtwho_service() assert get_virtwho_status() == 'logerror' # Check the permissioin of Virt-who Reporter - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) - assert session_sca.user.search(username)[0]['Username'] == username - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Reporter']}) + assert org_session.user.search(username)[0]['Username'] == username + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Reporter'] restart_virtwho_service() assert get_virtwho_status() == 'running' with Session(test_name, username, password) as newsession: assert not newsession.virtwho_configure.check_create_permission()['can_view'] - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_virtwho_viewer_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who viewer role can TRULY work. @@ -536,9 +485,9 @@ def test_positive_virtwho_viewer_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -548,17 +497,17 @@ def test_positive_virtwho_viewer_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Viewer - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Viewer']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Viewer'] # Update the virt-who config file config_id = get_configure_id(config_name) @@ -579,12 +528,12 @@ def test_positive_virtwho_viewer_role( assert not update_permission['can_edit'] newsession.virtwho_configure.read(config_name) # Delete the created user - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_virtwho_manager_role( - self, module_sca_manifest_org, session_sca, test_name, form_data + self, module_sca_manifest_org, org_session, test_name, form_data_ui ): """Verify the virt-who manager role can TRULY work. @@ -600,9 +549,9 @@ def test_positive_virtwho_manager_role( username = gen_string('alpha') password = gen_string('alpha') config_name = gen_string('alpha') - with session_sca: + with org_session: # Create an user - session_sca.user.create( + org_session.user.create( { 'user.login': username, 'user.mail': valid_emails_list()[0], @@ -612,28 +561,28 @@ def test_positive_virtwho_manager_role( } ) # Create a virt-who config plugin - form_data['name'] = config_name - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(config_name) + form_data_ui['name'] = config_name + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(config_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) - assert session_sca.virtwho_configure.search(config_name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(config_name)[0]['Status'] == 'ok' # Check the permissioin of Virt-who Manager - session_sca.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) - user = session_sca.user.read(username) + org_session.user.update(username, {'roles.resources.assigned': ['Virt-who Manager']}) + user = org_session.user.read(username) assert user['roles']['resources']['assigned'] == ['Virt-who Manager'] with Session(test_name, username, password) as newsession: # create_virt_who_config new_virt_who_name = gen_string('alpha') - form_data['name'] = new_virt_who_name - newsession.virtwho_configure.create(form_data) + form_data_ui['name'] = new_virt_who_name + newsession.virtwho_configure.create(form_data_ui) # view_virt_who_config values = newsession.virtwho_configure.read(new_virt_who_name) command = values['deploy']['command'] deploy_configure_by_command( - command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert newsession.virtwho_configure.search(new_virt_who_name)[0]['Status'] == 'ok' # edit_virt_who_config @@ -644,12 +593,12 @@ def test_positive_virtwho_manager_role( newsession.virtwho_configure.delete(modify_name) assert not newsession.virtwho_configure.search(modify_name) # Delete the created user - session_sca.user.delete(username) - assert not session_sca.user.search(username) + org_session.user.delete(username) + assert not org_session.user.search(username) @pytest.mark.tier2 def test_positive_deploy_configure_hypervisor_password_with_special_characters( - self, module_sca_manifest_org, form_data, target_sat, session_sca + self, module_sca_manifest_org, form_data_ui, target_sat, org_session ): """Verify " hammer virt-who-config deploy hypervisor with special characters" @@ -666,12 +615,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( :customerscenario: true """ name = gen_string('alpha') - form_data['name'] = name - with session_sca: + form_data_ui['name'] = name + with org_session: # check the hypervisor password contains single quotes - form_data['hypervisor_content.password'] = "Tes't" - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "Tes't" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -682,12 +631,12 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) # check the hypervisor password contains backtick - form_data['hypervisor_content.password'] = "my`password" - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['hypervisor_content.password'] = "my`password" + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_id = get_configure_id(name) deploy_status = deploy_configure_by_command_check(command) @@ -698,5 +647,5 @@ def test_positive_deploy_configure_hypervisor_password_with_special_characters( get_configure_option('username', config_file) == settings.virtwho.esx.hypervisor_username ) - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) diff --git a/tests/foreman/virtwho/ui/test_hyperv.py b/tests/foreman/virtwho/ui/test_hyperv.py index 56c2bbdb476..a35878e2fc2 100644 --- a/tests/foreman/virtwho/ui/test_hyperv.py +++ b/tests/foreman/virtwho/ui/test_hyperv.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,36 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -76,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: f2efc018-d57e-4dc5-895e-53af320237de @@ -119,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_hyperv_sca.py b/tests/foreman/virtwho/ui/test_hyperv_sca.py index d58d2c15ebd..3e7b0f01c5e 100644 --- a/tests/foreman/virtwho/ui/test_hyperv_sca.py +++ b/tests/foreman/virtwho/ui/test_hyperv_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,36 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.hyperv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.hyperv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.hyperv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.hyperv.hypervisor_password, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforHyperv: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -74,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -110,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_kubevirt.py b/tests/foreman/virtwho/ui/test_kubevirt.py index 289e4f385f1..19d5bce7f63 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt.py +++ b/tests/foreman/virtwho/ui/test_kubevirt.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,34 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'hypervisor_content.kubeconfig': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -74,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: 09826cc0-aa49-4355-8980-8097511eb7d7 @@ -117,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_kubevirt_sca.py b/tests/foreman/virtwho/ui/test_kubevirt_sca.py index c4b893947e7..6ad0bdf1f96 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/ui/test_kubevirt_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,34 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.kubevirt.hypervisor_type, - 'hypervisor_content.kubeconfig': settings.virtwho.kubevirt.hypervisor_config_file, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforKubevirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -72,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -108,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_libvirt.py b/tests/foreman/virtwho/ui/test_libvirt.py index 6c6b37fdc30..86b3d3e6532 100644 --- a/tests/foreman/virtwho/ui/test_libvirt.py +++ b/tests/foreman/virtwho/ui/test_libvirt.py @@ -16,13 +16,11 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -30,35 +28,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.libvirt.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -75,37 +49,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: b8b2b272-89f2-45d0-b922-6e988b20808b @@ -118,16 +85,16 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_libvirt_sca.py b/tests/foreman/virtwho/ui/test_libvirt_sca.py index 415ff38a37b..b6d33669744 100644 --- a/tests/foreman/virtwho/ui/test_libvirt_sca.py +++ b/tests/foreman/virtwho/ui/test_libvirt_sca.py @@ -14,13 +14,10 @@ :Upstream: No """ -from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( deploy_configure_by_command, - deploy_configure_by_script, get_configure_command, get_configure_file, get_configure_id, @@ -28,35 +25,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.libvirt.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.libvirt.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.libvirt.hypervisor_username, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforLibvirt: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -73,29 +46,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -109,16 +64,16 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('hypervisor_id', config_file) == value diff --git a/tests/foreman/virtwho/ui/test_nutanix.py b/tests/foreman/virtwho/ui/test_nutanix.py index d2a77961918..8bd1a3b23c7 100644 --- a/tests/foreman/virtwho/ui/test_nutanix.py +++ b/tests/foreman/virtwho/ui/test_nutanix.py @@ -32,38 +32,11 @@ ) -@pytest.fixture() -def form_data(): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.ahv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.ahv.hypervisor_password, - 'hypervisor_content.prism_flavor': "Prism Element", - 'ahv_internal_debug': False, - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session): - name = gen_string('alpha') - form_data['name'] = name - with session: - session.virtwho_configure.create(form_data) - yield virtwho_config - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) - - class TestVirtwhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, default_org, virtwho_config, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -80,37 +53,30 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - elif deploy_type == "script": - script = values['deploy']['script'] - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label - ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + hypervisor_name, guest_name = deploy_type_ui + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + 'status' + ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) + assert org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' @pytest.mark.tier2 - def test_positive_hypervisor_id_option(self, default_org, virtwho_config, session, form_data): + def test_positive_hypervisor_id_option( + self, default_org, virtwho_config_ui, org_session, form_data_ui + ): """Verify Hypervisor ID dropdown options. :id: e076a305-88f4-42fb-8ef2-cb55e38eb912 @@ -123,25 +89,25 @@ def test_positive_hypervisor_id_option(self, default_org, virtwho_config, sessio :CaseImportance: Medium """ - name = form_data['name'] - values = session.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) config_id = get_configure_id(name) config_command = values['deploy']['command'] config_file = get_configure_file(config_id) values = ['uuid', 'hostname'] for value in values: - session.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('hypervisor_id', config_file) == value @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, default_org, session, form_data, deploy_type + self, default_org, org_session, form_data_ui, deploy_type ): """Verify configure created and deployed with id on nutanix prism central mode @@ -160,49 +126,51 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ name = gen_string('alpha') - form_data['name'] = name - form_data['hypervisor_content.prism_flavor'] = "Prism Central" - with session: - session.virtwho_configure.create(form_data) - values = session.virtwho_configure.read(name) + form_data_ui['name'] = name + form_data_ui['hypervisor_content.prism_flavor'] = "Prism Central" + with org_session: + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) if deploy_type == "id": command = values['deploy']['command'] hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) elif deploy_type == "script": script = values['deploy']['script'] hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor_type'], debug=True, org=default_org.label + script, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) # Check the option "prism_central=true" should be set in etc/virt-who.d/virt-who.conf config_id = get_configure_id(name) config_file = get_configure_file(config_id) assert get_configure_option("prism_central", config_file) == 'true' - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = session.contenthost.search(hypervisor_name)[0]['Name'] + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + hypervisor_display_name = org_session.contenthost.search(hypervisor_name)[0]['Name'] vdc_physical = f'product_id = {settings.virtwho.sku.vdc_physical} and type=NORMAL' vdc_virtual = f'product_id = {settings.virtwho.sku.vdc_physical} and type=STACK_DERIVED' assert ( - session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ + org_session.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions'][ 'status' ] == 'Unsubscribed hypervisor' ) - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + org_session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert ( - session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] + org_session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + ) + assert ( + org_session.contenthost.read_legacy_ui(guest_name)['subscriptions']['status'] == 'Unentitled' ) - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - session.virtwho_configure.delete(name) - assert not session.virtwho_configure.search(name) + org_session.contenthost.add_subscription(guest_name, vdc_virtual) + assert org_session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_prism_central_prism_flavor_option( - self, default_org, virtwho_config, session, form_data + self, default_org, virtwho_config_ui, org_session, form_data_ui ): """Verify prism_flavor dropdown options. @@ -216,23 +184,25 @@ def test_positive_prism_central_prism_flavor_option( :CaseImportance: Medium """ - name = form_data['name'] - results = session.virtwho_configure.read(name) + name = form_data_ui['name'] + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "element" config_id = get_configure_id(name) config_command = get_configure_command(config_id, default_org.name) config_file = get_configure_file(config_id) - session.virtwho_configure.edit(name, {'hypervisor_content.prism_flavor': "Prism Central"}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit( + name, {'hypervisor_content.prism_flavor': "Prism Central"} + ) + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "central" deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=default_org.label + config_command, form_data_ui['hypervisor_type'], org=default_org.label ) assert get_configure_option('prism_central', config_file) == 'true' @pytest.mark.tier2 def test_positive_ahv_internal_debug_option( - self, default_org, virtwho_config, session, form_data + self, default_org, virtwho_config_ui, org_session, form_data_ui ): """Verify ahv_internal_debug option by hammer virt-who-config" @@ -253,15 +223,15 @@ def test_positive_ahv_internal_debug_option( :BZ: 2141719 :customerscenario: true """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) - values = session.virtwho_configure.read(name) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label ) - results = session.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert str(results['overview']['ahv_internal_debug']) == 'False' # ahv_internal_debug does not set in virt-who-config-X.conf option = 'ahv_internal_debug' @@ -275,14 +245,16 @@ def test_positive_ahv_internal_debug_option( assert check_message_in_rhsm_log(message) == message # Update ahv_internal_debug option to true - session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) - results = session.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) + results = org_session.virtwho_configure.read(name) command = results['deploy']['command'] assert str(results['overview']['ahv_internal_debug']) == 'True' deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=default_org.label + ) + assert ( + get_hypervisor_ahv_mapping(form_data_ui['hypervisor_type']) == 'Host UUID found for VM' ) - assert get_hypervisor_ahv_mapping(form_data['hypervisor_type']) == 'Host UUID found for VM' # ahv_internal_debug bas been set to true in virt-who-config-X.conf config_file = get_configure_file(config_id) assert get_configure_option("ahv_internal_debug", config_file) == 'true' diff --git a/tests/foreman/virtwho/ui/test_nutanix_sca.py b/tests/foreman/virtwho/ui/test_nutanix_sca.py index 3b53d038d71..42de668055e 100644 --- a/tests/foreman/virtwho/ui/test_nutanix_sca.py +++ b/tests/foreman/virtwho/ui/test_nutanix_sca.py @@ -17,7 +17,6 @@ from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.utils.virtwho import ( check_message_in_rhsm_log, deploy_configure_by_command, @@ -30,37 +29,11 @@ ) -@pytest.fixture() -def form_data(target_sat, module_sca_manifest_org): - form = { - 'debug': True, - 'interval': 'Every hour', - 'hypervisor_id': 'hostname', - 'hypervisor_type': settings.virtwho.ahv.hypervisor_type, - 'hypervisor_content.server': settings.virtwho.ahv.hypervisor_server, - 'hypervisor_content.username': settings.virtwho.ahv.hypervisor_username, - 'hypervisor_content.password': settings.virtwho.ahv.hypervisor_password, - 'hypervisor_content.prism_flavor': "Prism Element", - } - return form - - -@pytest.fixture() -def virtwho_config(form_data, target_sat, session_sca): - name = gen_string('alpha') - form_data['name'] = name - with session_sca: - session_sca.virtwho_configure.create(form_data) - yield virtwho_config - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) - - class TestVirtwhoConfigforNutanix: @pytest.mark.tier2 - @pytest.mark.parametrize('deploy_type', ['id', 'script']) + @pytest.mark.parametrize('deploy_type_ui', ['id', 'script'], indirect=True) def test_positive_deploy_configure_by_id_script( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type_ui ): """Verify configure created and deployed with id. @@ -76,29 +49,11 @@ def test_positive_deploy_configure_by_id_script( :CaseImportance: High """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) - if deploy_type == "id": - command = values['deploy']['command'] - deploy_configure_by_command( - command, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - elif deploy_type == "script": - script = values['deploy']['script'] - deploy_configure_by_script( - script, - form_data['hypervisor_type'], - debug=True, - org=module_sca_manifest_org.label, - ) - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' + assert org_session.virtwho_configure.search(form_data_ui['name'])[0]['Status'] == 'ok' @pytest.mark.tier2 def test_positive_hypervisor_id_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify Hypervisor ID dropdown options. @@ -112,18 +67,18 @@ def test_positive_hypervisor_id_option( :CaseImportance: Medium """ - name = form_data['name'] - values = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + values = org_session.virtwho_configure.read(name) config_id = get_configure_id(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) for value in ['uuid', 'hostname']: - session_sca.virtwho_configure.edit(name, {'hypervisor_id': value}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'hypervisor_id': value}) + results = org_session.virtwho_configure.read(name) assert results['overview']['hypervisor_id'] == value deploy_configure_by_command( command, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -132,7 +87,7 @@ def test_positive_hypervisor_id_option( @pytest.mark.tier2 @pytest.mark.parametrize('deploy_type', ['id', 'script']) def test_positive_prism_central_deploy_configure_by_id_script( - self, module_sca_manifest_org, session_sca, form_data, deploy_type + self, module_sca_manifest_org, org_session, form_data_ui, deploy_type ): """Verify configure created and deployed with id on nutanix prism central mode @@ -151,16 +106,16 @@ def test_positive_prism_central_deploy_configure_by_id_script( :CaseImportance: High """ name = gen_string('alpha') - form_data['name'] = name - form_data['hypervisor_content.prism_flavor'] = "Prism Central" - with session_sca: - session_sca.virtwho_configure.create(form_data) - values = session_sca.virtwho_configure.read(name) + form_data_ui['name'] = name + form_data_ui['hypervisor_content.prism_flavor'] = "Prism Central" + with org_session: + org_session.virtwho_configure.create(form_data_ui) + values = org_session.virtwho_configure.read(name) if deploy_type == "id": command = values['deploy']['command'] deploy_configure_by_command( command, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -168,7 +123,7 @@ def test_positive_prism_central_deploy_configure_by_id_script( script = values['deploy']['script'] deploy_configure_by_script( script, - form_data['hypervisor_type'], + form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label, ) @@ -176,13 +131,13 @@ def test_positive_prism_central_deploy_configure_by_id_script( config_id = get_configure_id(name) config_file = get_configure_file(config_id) assert get_configure_option("prism_central", config_file) == 'true' - assert session_sca.virtwho_configure.search(name)[0]['Status'] == 'ok' - session_sca.virtwho_configure.delete(name) - assert not session_sca.virtwho_configure.search(name) + assert org_session.virtwho_configure.search(name)[0]['Status'] == 'ok' + org_session.virtwho_configure.delete(name) + assert not org_session.virtwho_configure.search(name) @pytest.mark.tier2 def test_positive_prism_central_prism_flavor_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify prism_flavor dropdown options. @@ -196,25 +151,25 @@ def test_positive_prism_central_prism_flavor_option( :CaseImportance: Medium """ - name = form_data['name'] - results = session_sca.virtwho_configure.read(name) + name = form_data_ui['name'] + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "element" config_id = get_configure_id(name) config_command = get_configure_command(config_id, module_sca_manifest_org.name) config_file = get_configure_file(config_id) - session_sca.virtwho_configure.edit( + org_session.virtwho_configure.edit( name, {'hypervisor_content.prism_flavor': "Prism Central"} ) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert results['overview']['prism_flavor'] == "central" deploy_configure_by_command( - config_command, form_data['hypervisor_type'], org=module_sca_manifest_org.label + config_command, form_data_ui['hypervisor_type'], org=module_sca_manifest_org.label ) assert get_configure_option('prism_central', config_file) == 'true' @pytest.mark.tier2 def test_positive_ahv_internal_debug_option( - self, module_sca_manifest_org, virtwho_config, session_sca, form_data + self, module_sca_manifest_org, virtwho_config_ui, org_session, form_data_ui ): """Verify ahv_internal_debug option by hammer virt-who-config" @@ -237,15 +192,15 @@ def test_positive_ahv_internal_debug_option( :customerscenario: true """ - name = form_data['name'] + name = form_data_ui['name'] config_id = get_configure_id(name) - values = session_sca.virtwho_configure.read(name) + values = org_session.virtwho_configure.read(name) command = values['deploy']['command'] config_file = get_configure_file(config_id) deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label ) - results = session_sca.virtwho_configure.read(name) + results = org_session.virtwho_configure.read(name) assert str(results['overview']['ahv_internal_debug']) == 'False' # ahv_internal_debug does not set in virt-who-config-X.conf option = 'ahv_internal_debug' @@ -259,14 +214,16 @@ def test_positive_ahv_internal_debug_option( assert check_message_in_rhsm_log(message) == message # Update ahv_internal_debug option to true - session_sca.virtwho_configure.edit(name, {'ahv_internal_debug': True}) - results = session_sca.virtwho_configure.read(name) + org_session.virtwho_configure.edit(name, {'ahv_internal_debug': True}) + results = org_session.virtwho_configure.read(name) command = results['deploy']['command'] assert str(results['overview']['ahv_internal_debug']) == 'True' deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + command, form_data_ui['hypervisor_type'], debug=True, org=module_sca_manifest_org.label + ) + assert ( + get_hypervisor_ahv_mapping(form_data_ui['hypervisor_type']) == 'Host UUID found for VM' ) - assert get_hypervisor_ahv_mapping(form_data['hypervisor_type']) == 'Host UUID found for VM' # ahv_internal_debug bas been set to true in virt-who-config-X.conf config_file = get_configure_file(config_id) assert get_configure_option("ahv_internal_debug", config_file) == 'true' diff --git a/tests/upgrades/test_activation_key.py b/tests/upgrades/test_activation_key.py index 982e9e945a7..7e7cdf9de21 100644 --- a/tests/upgrades/test_activation_key.py +++ b/tests/upgrades/test_activation_key.py @@ -60,14 +60,14 @@ def test_pre_create_activation_key(self, activation_key_setup, target_sat): :steps: 1. Create the activation key. 2. Add subscription in the activation key. - 3: Check the subscription id of the activation key and compare it with custom_repos - product id. + 3. Check the subscription id of the activation key and compare it with custom_repos + product id. 4. Update the host collection in the activation key. :parametrized: yes :expectedresults: Activation key should be created successfully and it's subscription id - should be same with custom repos product id. + should be same with custom repos product id. """ ak = activation_key_setup['ak'] org_subscriptions = target_sat.api.Subscription( @@ -95,7 +95,7 @@ def test_post_crud_activation_key(self, dependent_scenario_name, target_sat): 3. Delete activation key. :expectedresults: Activation key's entities should be same after upgrade and activation - key update and delete should work. + key update and delete should work. """ pre_test_name = dependent_scenario_name org = target_sat.api.Organization().search(query={'search': f'name={pre_test_name}_org'}) diff --git a/tests/upgrades/test_bookmarks.py b/tests/upgrades/test_bookmarks.py index dde6b112a3b..a3f330e7569 100644 --- a/tests/upgrades/test_bookmarks.py +++ b/tests/upgrades/test_bookmarks.py @@ -77,7 +77,7 @@ def test_post_create_public_disable_bookmark(self, dependent_scenario_name, targ 2. Remove the bookmark. :expectedresults: Public disabled bookmarks details for all the system entities - should be unchanged after upgrade. + should be unchanged after upgrade. :CaseImportance: Critical """ @@ -106,7 +106,6 @@ def test_pre_create_public_enable_bookmark(self, request, target_sat): :id: preupgrade-93c419db-66b4-4c9a-a82a-a6a68703881f :Steps: - 1. Create public enable bookmarks before the upgrade for all system entities using available bookmark data. 2. Check the bookmark attribute(controller, name, query public) status @@ -142,12 +141,11 @@ def test_post_create_public_enable_bookmark(self, dependent_scenario_name, targe :id: postupgrade-93c419db-66b4-4c9a-a82a-a6a68703881f :Steps: - 1. Check the bookmark status after post-upgrade. 2. Remove the bookmark. :expectedresults: Public disabled bookmarks details for all the system entities - should be unchanged after upgrade. + should be unchanged after upgrade. :CaseImportance: Critical """ diff --git a/tests/upgrades/test_capsule.py b/tests/upgrades/test_capsule.py index 19f8ad87b9e..e4f2d8a0720 100644 --- a/tests/upgrades/test_capsule.py +++ b/tests/upgrades/test_capsule.py @@ -59,8 +59,7 @@ def test_pre_user_scenario_capsule_sync(self, target_sat, default_org, save_test :expectedresults: 1. The repo/rpm should be synced to satellite 2. Activation key's environment id should be available in the content views environment - id's list - + id's list """ ak_name = ( settings.upgrade.capsule_ak[settings.upgrade.os] diff --git a/tests/upgrades/test_errata.py b/tests/upgrades/test_errata.py index e35e8da634c..864f884c3da 100644 --- a/tests/upgrades/test_errata.py +++ b/tests/upgrades/test_errata.py @@ -115,17 +115,15 @@ def test_pre_scenario_generate_errata_for_client( :id: preupgrade-88fd28e6-b4df-46c0-91d6-784859fd1c21 :steps: - 1. Create Product and Custom Yum Repo 2. Create custom tools, rhel repos and sync them 3. Create content view and publish it 4. Create activation key and add subscription 5. Register RHEL host to Satellite - 7. Generate Errata by installing outdated/older packages - 8. Check that errata applicability generated expected errata list for the given client. + 6. Generate Errata by installing outdated/older packages + 7. Check that errata applicability generated expected errata list for the given client. :expectedresults: - 1. The content host is created 2. errata count, erratum list will be generated to Satellite content host 3. All the expected errata are ready-to-be-applied on the client @@ -204,10 +202,10 @@ def test_post_scenario_errata_count_installation(self, target_sat, pre_upgrade_d 1. Recover pre_upgrade data for post_upgrade verification 2. Verify errata count has not changed on Satellite - 4. Verify the errata_ids - 5. Verify installation of errata is successfull - 6. Verify that the errata application updated packages on client - 7. Verify that all expected erratas were installed on client. + 3. Verify the errata_ids + 4. Verify installation of errata is successfull + 5. Verify that the errata application updated packages on client + 6. Verify that all expected erratas were installed on client. :expectedresults: 1. errata count and erratum list should same after Satellite upgrade diff --git a/tests/upgrades/test_hostcontent.py b/tests/upgrades/test_hostcontent.py index 54b102679b9..172039c1930 100644 --- a/tests/upgrades/test_hostcontent.py +++ b/tests/upgrades/test_hostcontent.py @@ -6,7 +6,7 @@ :CaseLevel: Acceptance -:CaseComponent: Host-Content +:CaseComponent: Hosts-Content :Team: Phoenix-subscriptions diff --git a/tests/upgrades/test_repository.py b/tests/upgrades/test_repository.py index 2119fa57816..998db385ad4 100644 --- a/tests/upgrades/test_repository.py +++ b/tests/upgrades/test_repository.py @@ -19,7 +19,12 @@ import pytest from robottelo.config import settings -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME, FAKE_4_CUSTOM_PACKAGE_NAME +from robottelo.constants import ( + DEFAULT_ARCHITECTURE, + FAKE_0_CUSTOM_PACKAGE_NAME, + FAKE_4_CUSTOM_PACKAGE_NAME, + REPOS, +) from robottelo.hosts import ContentHost UPSTREAM_USERNAME = 'rTtest123' @@ -299,3 +304,75 @@ def test_post_scenario_custom_repo_sca_toggle(self, pre_upgrade_data): result = rhel_client.execute('subscription-manager repo-override --list') assert 'enabled: 1' in result.stdout assert f'{org_name}_{product_name}_{repo_name}' in result.stdout + + +class TestScenarioLargeRepoSyncCheck: + """Scenario test to verify that large repositories can be synced without + failure after an upgrade. + + Test Steps: + + 1. Before Satellite upgrade. + 2. Enable and sync large RH repository. + 3. Upgrade Satellite. + 4. Enable and sync a second large repository. + + BZ: 2043144 + + :customerscenario: true + """ + + @pytest.mark.pre_upgrade + def test_pre_scenario_sync_large_repo( + self, target_sat, module_entitlement_manifest_org, save_test_data + ): + """This is a pre-upgrade scenario to verify that users can sync large repositories + before an upgrade + + :id: afb957dc-c509-4009-ac85-4b71b64d3c74 + + :steps: + 1. Enable a large redhat repository + 2. Sync repository and assert sync succeeds + + :expectedresults: Large Repositories should succeed when synced + """ + rh_repo_id = target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_entitlement_manifest_org.id, + product=REPOS['rhel8_bos']['product'], + repo=REPOS['rhel8_bos']['name'], + reposet=REPOS['rhel8_bos']['reposet'], + releasever=REPOS['rhel8_bos']['releasever'], + ) + repo = target_sat.api.Repository(id=rh_repo_id).read() + res = repo.sync(timeout=2000) + assert res['result'] == 'success' + save_test_data({'org_id': module_entitlement_manifest_org.id}) + + @pytest.mark.post_upgrade(depend_on=test_pre_scenario_sync_large_repo) + def test_post_scenario_sync_large_repo(self, target_sat, pre_upgrade_data): + """This is a post-upgrade scenario to verify that large repositories can be + synced after an upgrade + + :id: 7bdbb2ac-7197-4e1a-8163-5852943eb49b + + :steps: + 1. Sync large repository + 2. Upgrade satellite + 3. Sync a second large repository in that same organization + + :expectedresults: Large repositories should succeed after an upgrade + """ + org_id = pre_upgrade_data.get('org_id') + rh_repo_id = target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=org_id, + product=REPOS['rhel8_aps']['product'], + repo=REPOS['rhel8_aps']['name'], + reposet=REPOS['rhel8_aps']['reposet'], + releasever=REPOS['rhel8_aps']['releasever'], + ) + repo = target_sat.api.Repository(id=rh_repo_id).read() + res = repo.sync(timeout=4000) + assert res['result'] == 'success' diff --git a/tests/upgrades/test_satellitesync.py b/tests/upgrades/test_satellitesync.py index 5024cf93c18..dcbc7866f86 100644 --- a/tests/upgrades/test_satellitesync.py +++ b/tests/upgrades/test_satellitesync.py @@ -33,13 +33,12 @@ def test_pre_version_cv_export_import(self, module_org, target_sat, save_test_da :id: preupgrade-f19e4928-94db-4df6-8ce8-b5e4afe34258 :steps: - - 1. Create a ContentView - 2. Publish and promote the Content View - 3. Check the package count of promoted content view. + 1. Create a ContentView + 2. Publish and promote the Content View + 3. Check the package count of promoted content view. :expectedresults: Before the upgrade, Content view published and promoted, and package - count should be greater than 0. + count should be greater than 0. """ product = target_sat.api.Product(organization=module_org).create() repo = target_sat.api.Repository( diff --git a/tests/upgrades/test_syncplan.py b/tests/upgrades/test_syncplan.py index 63fdb7ee164..ba14f9de831 100644 --- a/tests/upgrades/test_syncplan.py +++ b/tests/upgrades/test_syncplan.py @@ -41,7 +41,6 @@ def test_pre_sync_plan_migration(self, request, target_sat): 3. Assign sync plan to product and sync the repo :expectedresults: Run sync plan create, get, assign and verify it should pass - """ org = target_sat.api.Organization(name=f'{request.node.name}_org').create() sync_plan = target_sat.api.SyncPlan( @@ -71,7 +70,7 @@ def test_pre_disabled_sync_plan_logic(self, request, target_sat): 5. Re enable the sync plan :expectedresults: Sync plan is created and assigned to a product. The associated recurring - logic is cancelled and then the plan is re-enabled so that it gets a new recurring logic. + logic is cancelled and then the plan is re-enabled so that it gets a new recurring logic. :BZ: 1887511 @@ -114,8 +113,7 @@ def test_post_sync_plan_migration(self, request, dependent_scenario_name, target 2. Check the all available sync_interval type update with pre-created sync_plan :expectedresults: After upgrade, the sync plan should remain the same with their all - target_sat.api and sync_interval updated with their all supported sync interval type. - + target_sat.api and sync_interval updated with their all supported sync interval type. """ pre_test_name = dependent_scenario_name org = target_sat.api.Organization().search(query={'search': f'name="{pre_test_name}_org"'})[ @@ -156,7 +154,7 @@ def test_post_disabled_sync_plan_logic(self, request, dependent_scenario_name, t 2. Check the all available sync_interval type update with pre-created sync_plan. :expectedresults: Update proceedes without any errors. After upgrade, the sync plan - should remain the same with all entities + should remain the same with all entities :BZ: 1887511 diff --git a/tests/upgrades/test_usergroup.py b/tests/upgrades/test_usergroup.py index 838a074c363..0420a8a5e8c 100644 --- a/tests/upgrades/test_usergroup.py +++ b/tests/upgrades/test_usergroup.py @@ -101,7 +101,7 @@ def test_post_verify_user_group_membership( 2. Update ldap auth. :expectedresults: After upgrade, user group membership should remain the same and LDAP - auth update should work. + auth update should work. """ ad_data = ad_data() user_group = target_sat.api.UserGroup().search(