diff --git a/pytest_fixtures/component/provision_libvirt.py b/pytest_fixtures/component/provision_libvirt.py index 82f06ac86d9..2ee34f98629 100644 --- a/pytest_fixtures/component/provision_libvirt.py +++ b/pytest_fixtures/component/provision_libvirt.py @@ -1,15 +1,24 @@ # Compute resource - Libvirt entities +from box import Box from fauxfactory import gen_string import pytest from robottelo.config import settings from robottelo.constants import COMPUTE_PROFILE_SMALL, FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL -LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname + +@pytest.fixture(scope='module') +def libvirt(request): + versions = { + 'libvirt9': settings.libvirt.hostname.libvirt9, + 'libvirt10': settings.libvirt.hostname.libvirt10, + } + default = versions[getattr(request, 'param', 'libvirt9')] + return Box(fqdn=default, url=LIBVIRT_RESOURCE_URL % default) @pytest.fixture(scope='module') -def module_cr_libvirt(module_target_sat, module_org, module_location): +def module_cr_libvirt(module_target_sat, module_org, module_location, libvirt): """Create a Libvirt compute resource for the module.""" return module_target_sat.api.LibvirtComputeResource( name=gen_string('alpha'), @@ -17,7 +26,7 @@ def module_cr_libvirt(module_target_sat, module_org, module_location): display_type='VNC', organization=[module_org], location=[module_location], - url=LIBVIRT_URL, + url=libvirt.url, ).create() @@ -27,9 +36,9 @@ def module_libvirt_image(module_target_sat, module_cr_libvirt): @pytest.fixture(scope='module') -def module_libvirt_provisioning_sat(module_provisioning_sat): +def module_libvirt_provisioning_sat(module_provisioning_sat, libvirt): # Configure Libvirt CR for provisioning - module_provisioning_sat.sat.configure_libvirt_cr() + module_provisioning_sat.sat.configure_libvirt_cr(server_fqdn=libvirt.fqdn) return module_provisioning_sat diff --git a/tests/foreman/api/test_computeresource_libvirt.py b/tests/foreman/api/test_computeresource_libvirt.py index 4515a4639e6..f1249aabfb9 100644 --- a/tests/foreman/api/test_computeresource_libvirt.py +++ b/tests/foreman/api/test_computeresource_libvirt.py @@ -22,7 +22,7 @@ from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL +from robottelo.constants import FOREMAN_PROVIDERS from robottelo.hosts import ContentHost from robottelo.utils.datafactory import ( invalid_values_list, @@ -32,11 +32,10 @@ pytestmark = [pytest.mark.skip_if_not_set('libvirt')] -LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname - @pytest.mark.e2e -def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location): +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) +def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location, libvirt): """CRUD compute resource libvirt :id: 1e545c56-2f53-44c1-a17e-38c83f8fe0c2 @@ -74,7 +73,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location cr.name = new_name cr.description = new_description cr.display_type = new_display_type - cr.url = LIBVIRT_URL + cr.url = libvirt.url cr.organization = [new_org] cr.location = [new_loc] cr.update(['name', 'description', 'display_type', 'url', 'organization', 'location']) @@ -84,7 +83,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location assert updated_cr.name == new_name assert updated_cr.description == new_description assert updated_cr.display_type == new_display_type - assert updated_cr.url == LIBVIRT_URL + assert updated_cr.url == libvirt.url assert updated_cr.organization[0].id == new_org.id assert updated_cr.location[0].id == new_loc.id # DELETE @@ -96,7 +95,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location @pytest.mark.parametrize('name', **parametrized(valid_data_list())) def test_positive_create_with_name_description( - name, request, module_target_sat, module_org, module_location + name, request, module_target_sat, module_org, module_location, libvirt ): """Create compute resources with different names and descriptions @@ -113,14 +112,14 @@ def test_positive_create_with_name_description( description=name, organization=[module_org], location=[module_location], - url=LIBVIRT_URL, + url=libvirt.url, ).create() request.addfinalizer(compresource.delete) assert compresource.name == name assert compresource.description == name -def test_positive_create_with_orgs_and_locs(request, module_target_sat): +def test_positive_create_with_orgs_and_locs(request, module_target_sat, libvirt): """Create a compute resource with multiple organizations and locations :id: c6c6c6f7-50ca-4f38-8126-eb95359d7cbb @@ -133,7 +132,7 @@ def test_positive_create_with_orgs_and_locs(request, module_target_sat): orgs = [module_target_sat.api.Organization().create() for _ in range(2)] locs = [module_target_sat.api.Location(organization=[org]).create() for org in orgs] compresource = module_target_sat.api.LibvirtComputeResource( - location=locs, organization=orgs, url=LIBVIRT_URL + location=locs, organization=orgs, url=libvirt.url ).create() request.addfinalizer(compresource.delete) assert {org.name for org in orgs} == {org.read().name for org in compresource.organization} @@ -141,7 +140,9 @@ def test_positive_create_with_orgs_and_locs(request, module_target_sat): @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) -def test_negative_create_with_invalid_name(name, module_target_sat, module_org, module_location): +def test_negative_create_with_invalid_name( + name, module_target_sat, module_org, module_location, libvirt +): """Attempt to create compute resources with invalid names :id: f73bf838-3ffd-46d3-869c-81b334b47b13 @@ -157,11 +158,13 @@ def test_negative_create_with_invalid_name(name, module_target_sat, module_org, name=name, organization=[module_org], location=[module_location], - url=LIBVIRT_URL, + url=libvirt.url, ).create() -def test_negative_create_with_same_name(request, module_target_sat, module_org, module_location): +def test_negative_create_with_same_name( + request, module_target_sat, module_org, module_location, libvirt +): """Attempt to create a compute resource with already existing name :id: 9376e25c-2aa8-4d99-83aa-2eec160c030e @@ -172,7 +175,7 @@ def test_negative_create_with_same_name(request, module_target_sat, module_org, """ name = gen_string('alphanumeric') cr = module_target_sat.api.LibvirtComputeResource( - location=[module_location], name=name, organization=[module_org], url=LIBVIRT_URL + location=[module_location], name=name, organization=[module_org], url=libvirt.url ).create() request.addfinalizer(cr.delete) assert cr.name == name @@ -181,7 +184,7 @@ def test_negative_create_with_same_name(request, module_target_sat, module_org, name=name, organization=[module_org], location=[module_location], - url=LIBVIRT_URL, + url=libvirt.url, ).create() @@ -205,7 +208,7 @@ def test_negative_create_with_url(module_target_sat, module_org, module_location @pytest.mark.parametrize('new_name', **parametrized(invalid_values_list())) def test_negative_update_invalid_name( - request, module_target_sat, module_org, module_location, new_name + request, module_target_sat, module_org, module_location, new_name, libvirt ): """Attempt to update compute resource with invalid names @@ -219,7 +222,7 @@ def test_negative_update_invalid_name( """ name = gen_string('alphanumeric') compresource = module_target_sat.api.LibvirtComputeResource( - location=[module_location], name=name, organization=[module_org], url=LIBVIRT_URL + location=[module_location], name=name, organization=[module_org], url=libvirt.url ).create() request.addfinalizer(compresource.delete) compresource.name = new_name @@ -228,7 +231,9 @@ def test_negative_update_invalid_name( assert compresource.read().name == name -def test_negative_update_same_name(request, module_target_sat, module_org, module_location): +def test_negative_update_same_name( + request, module_target_sat, module_org, module_location, libvirt +): """Attempt to update a compute resource with already existing name :id: 4d7c5eb0-b8cb-414f-aa10-fe464a164ab4 @@ -239,11 +244,11 @@ def test_negative_update_same_name(request, module_target_sat, module_org, modul """ name = gen_string('alphanumeric') compresource = module_target_sat.api.LibvirtComputeResource( - location=[module_location], name=name, organization=[module_org], url=LIBVIRT_URL + location=[module_location], name=name, organization=[module_org], url=libvirt.url ).create() request.addfinalizer(compresource.delete) new_compresource = module_target_sat.api.LibvirtComputeResource( - location=[module_location], organization=[module_org], url=LIBVIRT_URL + location=[module_location], organization=[module_org], url=libvirt.url ).create() request.addfinalizer(new_compresource.delete) new_compresource.name = name @@ -253,7 +258,7 @@ def test_negative_update_same_name(request, module_target_sat, module_org, modul @pytest.mark.parametrize('url', **parametrized({'random': gen_string('alpha'), 'empty': ''})) -def test_negative_update_url(url, request, module_target_sat, module_org, module_location): +def test_negative_update_url(url, request, module_target_sat, module_org, module_location, libvirt): """Attempt to update a compute resource with invalid url :id: b5256090-2ceb-4976-b54e-60d60419fe50 @@ -265,7 +270,7 @@ def test_negative_update_url(url, request, module_target_sat, module_org, module :parametrized: yes """ compresource = module_target_sat.api.LibvirtComputeResource( - location=[module_location], organization=[module_org], url=LIBVIRT_URL + location=[module_location], organization=[module_org], url=libvirt.url ).create() request.addfinalizer(compresource.delete) compresource.url = url @@ -279,9 +284,11 @@ def test_negative_update_url(url, request, module_target_sat, module_org, module @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi', 'secureboot'], indirect=True) @pytest.mark.rhel_ver_list('[9, 10]') +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_provision_end_to_end( request, setting_update, + libvirt, module_provisioning_rhel_content, module_libvirt_provisioning_sat, configure_secureboot_provisioning, @@ -315,7 +322,7 @@ def test_positive_provision_end_to_end( display_type='VNC', organization=[module_sca_manifest_org], location=[module_location], - url=LIBVIRT_URL, + url=libvirt.url, ).create() request.addfinalizer(libvirt_cr.delete) assert libvirt_cr.name == cr_name @@ -358,7 +365,7 @@ def test_positive_provision_end_to_end( assert host.name == f'{host_name}.{module_libvirt_provisioning_sat.domain.name}' # Check on Libvirt, if VM exists result = sat.execute( - f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + f'su foreman -s /bin/bash -c "virsh -c {libvirt.url} list --state-running"' ) assert host_name in result.stdout # check the build status diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index cd3bbfd7357..74d6ca1d1af 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -36,13 +36,11 @@ from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL +from robottelo.constants import FOREMAN_PROVIDERS from robottelo.exceptions import CLIReturnCodeError from robottelo.hosts import ContentHost from robottelo.utils.datafactory import parametrized -LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname - def valid_name_desc_data(): """Random data for valid name and description""" @@ -101,14 +99,10 @@ def invalid_update_data(): } -@pytest.fixture(scope="module") -def libvirt_url(): - return LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname - - @pytest.mark.e2e @pytest.mark.upgrade -def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location, libvirt_url): +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) +def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location, libvirt): """CRUD compute resource libvirt :id: a2f99c0e-53b6-435d-9b59-c6cbbcabca1e @@ -125,7 +119,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location { 'name': name, 'provider': 'Libvirt', - 'url': libvirt_url, + 'url': libvirt.url, 'description': desc, 'location-ids': module_location.id, 'organization-ids': module_org.id, @@ -134,7 +128,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location assert cr['name'] == name assert cr['provider'] == provider assert cr['description'] == desc - assert cr['url'] == libvirt_url + assert cr['url'] == libvirt.url assert cr['locations'][0] == module_location.name assert cr['organizations'][0] == module_org.name # UPDATE @@ -156,7 +150,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location assert cr_read['name'] == new_name assert cr_read['description'] == new_desc assert cr_read['provider'] == provider - assert cr_read['url'] == libvirt_url + assert cr_read['url'] == libvirt.url assert cr_read['locations'][0] == new_loc['name'] assert cr_read['organizations'][0] == new_org['name'] # LIST @@ -172,7 +166,7 @@ def test_positive_crud_libvirt_cr(module_target_sat, module_org, module_location @pytest.mark.upgrade @pytest.mark.parametrize('options', **parametrized(valid_name_desc_data())) -def test_positive_create_with_libvirt(libvirt_url, options, target_sat): +def test_positive_create_with_libvirt(options, target_sat): """Test Compute Resource create :id: adc6f4f8-6420-4044-89d1-c69e0bfeeab9 @@ -193,7 +187,7 @@ def test_positive_create_with_libvirt(libvirt_url, options, target_sat): ) -def test_positive_create_with_locs(libvirt_url, module_target_sat): +def test_positive_create_with_locs(libvirt, module_target_sat): """Create Compute Resource with multiple locations :id: f665c586-39bf-480a-a0fc-81d9e1eb7c54 @@ -209,7 +203,7 @@ def test_positive_create_with_locs(libvirt_url, module_target_sat): { 'location-ids': [location['id'] for location in locations], 'provider': FOREMAN_PROVIDERS['libvirt'], - 'url': libvirt_url, + 'url': libvirt.url, } ) assert len(comp_resource['locations']) == locations_amount @@ -221,7 +215,7 @@ def test_positive_create_with_locs(libvirt_url, module_target_sat): @pytest.mark.parametrize('options', **parametrized(invalid_create_data())) -def test_negative_create_with_name_url(libvirt_url, options, target_sat): +def test_negative_create_with_name_url(options, target_sat): """Compute Resource negative create with invalid values :id: cd432ff3-b3b9-49cd-9a16-ed00d81679dd @@ -240,7 +234,7 @@ def test_negative_create_with_name_url(libvirt_url, options, target_sat): ) -def test_negative_create_with_same_name(libvirt_url, module_target_sat): +def test_negative_create_with_same_name(libvirt, module_target_sat): """Compute Resource negative create with the same name :id: ddb5c45b-1ea3-46d0-b248-56c0388d2e4b @@ -250,7 +244,7 @@ def test_negative_create_with_same_name(libvirt_url, module_target_sat): :CaseImportance: High """ comp_res = module_target_sat.cli_factory.compute_resource( - {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url} + {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt.url} ) with pytest.raises(CLIReturnCodeError): module_target_sat.cli.ComputeResource.create( @@ -266,7 +260,7 @@ def test_negative_create_with_same_name(libvirt_url, module_target_sat): @pytest.mark.parametrize('options', **parametrized(valid_update_data())) -def test_positive_update_name(libvirt_url, options, module_target_sat): +def test_positive_update_name(libvirt, options, module_target_sat): """Compute Resource positive update :id: 213d7f04-4c54-4985-8ca0-d2a1a9e3b305 @@ -278,7 +272,7 @@ def test_positive_update_name(libvirt_url, options, module_target_sat): :parametrized: yes """ comp_res = module_target_sat.cli_factory.compute_resource( - {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url} + {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt.url} ) options.update({'name': comp_res['name']}) # update Compute Resource @@ -295,7 +289,7 @@ def test_positive_update_name(libvirt_url, options, module_target_sat): @pytest.mark.parametrize('options', **parametrized(invalid_update_data())) -def test_negative_update(libvirt_url, options, module_target_sat): +def test_negative_update(libvirt, options, module_target_sat): """Compute Resource negative update :id: e7aa9b39-dd01-4f65-8e89-ff5a6f4ee0e3 @@ -307,7 +301,7 @@ def test_negative_update(libvirt_url, options, module_target_sat): :parametrized: yes """ comp_res = module_target_sat.cli_factory.compute_resource( - {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt_url} + {'provider': FOREMAN_PROVIDERS['libvirt'], 'url': libvirt.url} ) with pytest.raises(CLIReturnCodeError): module_target_sat.cli.ComputeResource.update(dict({'name': comp_res['name']}, **options)) @@ -320,9 +314,7 @@ def test_negative_update(libvirt_url, options, module_target_sat): @pytest.mark.parametrize('set_console_password', ['true', 'false']) -def test_positive_create_with_console_password_and_name( - libvirt_url, set_console_password, module_target_sat -): +def test_positive_create_with_console_password_and_name(set_console_password, module_target_sat): """Create a compute resource with ``--set-console-password``. :id: 5b4c838a-0265-4c71-a73d-305fecbe508a @@ -338,7 +330,7 @@ def test_positive_create_with_console_password_and_name( module_target_sat.cli.ComputeResource.create( { 'name': gen_string('utf8'), - 'provider': 'Libvirt', + 'provider': FOREMAN_PROVIDERS['libvirt'], 'set-console-password': set_console_password, 'url': gen_url(), } @@ -346,7 +338,7 @@ def test_positive_create_with_console_password_and_name( @pytest.mark.parametrize('set_console_password', ['true', 'false']) -def test_positive_update_console_password(libvirt_url, set_console_password, module_target_sat): +def test_positive_update_console_password(set_console_password, module_target_sat): """Update a compute resource with ``--set-console-password``. :id: ef09351e-dcd3-4b4f-8d3b-995e9e5873b3 @@ -361,7 +353,7 @@ def test_positive_update_console_password(libvirt_url, set_console_password, mod """ cr_name = gen_string('utf8') module_target_sat.cli.ComputeResource.create( - {'name': cr_name, 'provider': 'Libvirt', 'url': gen_url()} + {'name': cr_name, 'provider': FOREMAN_PROVIDERS['libvirt'], 'url': gen_url()} ) module_target_sat.cli.ComputeResource.update( {'name': cr_name, 'set-console-password': set_console_password} @@ -373,10 +365,12 @@ def test_positive_update_console_password(libvirt_url, set_console_password, mod @pytest.mark.rhel_ver_match('[7]') @pytest.mark.parametrize('pxe_loader', ['uefi', 'secureboot'], indirect=True) @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_provision_end_to_end( request, pxe_loader, setting_update, + libvirt, module_libvirt_provisioning_sat, module_sca_manifest_org, module_location, @@ -413,7 +407,7 @@ def test_positive_provision_end_to_end( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'url': LIBVIRT_URL, + 'url': libvirt.url, 'organizations': module_sca_manifest_org.name, 'locations': module_location.name, } @@ -445,7 +439,7 @@ def test_positive_provision_end_to_end( host_info = sat.cli.Host.info({'name': hostname}) # Check on Libvirt, if VM exists result = sat.execute( - f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + f'su foreman -s /bin/bash -c "virsh -c {libvirt.url} list --state-running"' ) assert hostname in result.stdout @@ -486,8 +480,9 @@ def test_negative_create_libvirt_with_url(module_location, module_org, module_ta ) +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_crud_image_libvirt_with_name( - request, module_location, module_org, module_target_sat, module_os + request, module_location, module_org, module_target_sat, module_os, libvirt ): """Create, Read, Update and Delete images on the libvirt compute resource @@ -504,12 +499,12 @@ def test_positive_crud_image_libvirt_with_name( :expectedresults: Image should be created, list, updated and deleted in Libvirt CR """ cr_name = gen_string('alpha') - module_target_sat.configure_libvirt_cr() + module_target_sat.configure_libvirt_cr(server_fqdn=libvirt.fqdn) comp_res = module_target_sat.cli_factory.compute_resource( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'url': LIBVIRT_URL, + 'url': libvirt.url, 'organizations': module_org.name, 'locations': module_location.name, } @@ -586,7 +581,7 @@ def test_negative_add_image_libvirt_with_invalid_uuid(): def test_negative_add_image_libvirt_with_invalid_name( - module_location, module_org, module_target_sat, module_os + module_location, module_org, module_target_sat, module_os, libvirt ): """Attempt to add invalid image name to the libvirt compute resource @@ -604,7 +599,7 @@ def test_negative_add_image_libvirt_with_invalid_name( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'url': LIBVIRT_URL, + 'url': libvirt.url, 'organizations': module_org.name, 'locations': module_location.name, } diff --git a/tests/foreman/cli/test_organization.py b/tests/foreman/cli/test_organization.py index 052da53d234..1a6cbcae56d 100644 --- a/tests/foreman/cli/test_organization.py +++ b/tests/foreman/cli/test_organization.py @@ -15,7 +15,6 @@ from fauxfactory import gen_string import pytest -from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError from robottelo.utils.datafactory import ( @@ -261,7 +260,7 @@ def test_positive_add_and_remove_hostgroups(module_org, module_target_sat): @pytest.mark.skip_if_not_set('libvirt') @pytest.mark.upgrade -def test_positive_add_and_remove_compute_resources(module_org, module_target_sat): +def test_positive_add_and_remove_compute_resources(module_org, module_target_sat, libvirt): """Add and remove a compute resource from organization :id: 415c14ab-f879-4ed8-9ba7-8af4ada2e277 @@ -278,7 +277,7 @@ def test_positive_add_and_remove_compute_resources(module_org, module_target_sat module_target_sat.cli_factory.compute_resource( { 'provider': FOREMAN_PROVIDERS['libvirt'], - 'url': f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', + 'url': libvirt.url, }, ) for _ in range(0, 2) diff --git a/tests/foreman/endtoend/test_api_endtoend.py b/tests/foreman/endtoend/test_api_endtoend.py index 03a90ab4b77..a692f1144d0 100644 --- a/tests/foreman/endtoend/test_api_endtoend.py +++ b/tests/foreman/endtoend/test_api_endtoend.py @@ -1053,7 +1053,9 @@ def test_positive_find_admin_user(self, class_target_sat): @pytest.mark.skipif( (not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url' ) - def test_positive_end_to_end(self, function_sca_manifest, target_sat, rhel_contenthost): + def test_positive_end_to_end( + self, function_sca_manifest, target_sat, rhel_contenthost, libvirt + ): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions @@ -1190,7 +1192,7 @@ def test_positive_end_to_end(self, function_sca_manifest, target_sat, rhel_conte # step 2.14: Create a new libvirt compute resource target_sat.api.LibvirtComputeResource( server_config=user_cfg, - url=f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', + url=libvirt.url, ).create() # step 2.15: Create a new subnet diff --git a/tests/foreman/endtoend/test_cli_endtoend.py b/tests/foreman/endtoend/test_cli_endtoend.py index 2c70939f0bc..0ab1b139752 100644 --- a/tests/foreman/endtoend/test_cli_endtoend.py +++ b/tests/foreman/endtoend/test_cli_endtoend.py @@ -62,7 +62,7 @@ def test_positive_cli_find_admin_user(module_target_sat): @pytest.mark.e2e @pytest.mark.upgrade @pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url') -def test_positive_cli_end_to_end(function_sca_manifest, target_sat, rhel_contenthost): +def test_positive_cli_end_to_end(function_sca_manifest, target_sat, rhel_contenthost, libvirt): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions @@ -271,7 +271,7 @@ def test_positive_cli_end_to_end(function_sca_manifest, target_sat, rhel_content { 'name': gen_alphanumeric(), 'provider': 'Libvirt', - 'url': f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', + 'url': libvirt.url, }, ) diff --git a/tests/foreman/ui/test_computeresource_libvirt.py b/tests/foreman/ui/test_computeresource_libvirt.py index 2ba63fa8e84..603bfb73406 100644 --- a/tests/foreman/ui/test_computeresource_libvirt.py +++ b/tests/foreman/ui/test_computeresource_libvirt.py @@ -22,17 +22,15 @@ from robottelo.constants import ( COMPUTE_PROFILE_SMALL, FOREMAN_PROVIDERS, - LIBVIRT_RESOURCE_URL, ) from robottelo.hosts import ContentHost pytestmark = [pytest.mark.skip_if_not_set('libvirt')] -LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname - @pytest.mark.e2e -def test_positive_end_to_end(session, module_target_sat, module_org, module_location): +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) +def test_positive_end_to_end(session, module_target_sat, module_org, module_location, libvirt): """Perform end to end testing for compute resource Libvirt component. :id: 7ef925ac-5aec-4e9d-b786-328a9b219c01 @@ -51,14 +49,14 @@ def test_positive_end_to_end(session, module_target_sat, module_org, module_loca new_loc = module_target_sat.api.Location().create() display_type = choice(('VNC', 'SPICE')) console_passwords = choice((True, False)) - module_target_sat.configure_libvirt_cr() + module_target_sat.configure_libvirt_cr(server_fqdn=libvirt.fqdn) with session: session.computeresource.create( { 'name': cr_name, 'description': cr_description, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'provider_content.url': LIBVIRT_URL, + 'provider_content.url': libvirt.url, 'provider_content.display_type': display_type, 'provider_content.console_passwords': console_passwords, 'organizations.resources.assigned': [module_org.name], @@ -68,7 +66,7 @@ def test_positive_end_to_end(session, module_target_sat, module_org, module_loca cr_values = session.computeresource.read(cr_name) assert cr_values['name'] == cr_name assert cr_values['description'] == cr_description - assert cr_values['provider_content']['url'] == LIBVIRT_URL + assert cr_values['provider_content']['url'] == libvirt.url assert cr_values['provider_content']['display_type'] == display_type assert cr_values['provider_content']['console_passwords'] == console_passwords assert cr_values['organizations']['resources']['assigned'] == [module_org.name] @@ -122,9 +120,11 @@ def test_positive_end_to_end(session, module_target_sat, module_org, module_loca @pytest.mark.rhel_ver_match('[8]') @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) @pytest.mark.parametrize('pxe_loader', ['uefi', 'secureboot'], indirect=True) +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_provision_end_to_end( request, pxe_loader, + libvirt, setting_update, module_sca_manifest_org, module_location, @@ -150,7 +150,7 @@ def test_positive_provision_end_to_end( hostname = gen_string('alpha').lower() cr = sat.api.LibvirtComputeResource( provider=FOREMAN_PROVIDERS['libvirt'], - url=LIBVIRT_URL, + url=libvirt.url, display_type='VNC', location=[module_location], organization=[module_sca_manifest_org], @@ -185,7 +185,7 @@ def test_positive_provision_end_to_end( # Check on Libvirt, if VM exists result = sat.execute( - f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + f'su foreman -s /bin/bash -c "virsh -c {libvirt.url} list --state-running"' ) assert hostname in result.stdout # Wait for provisioning to complete and report status back to Satellite @@ -214,8 +214,9 @@ def test_positive_provision_end_to_end( @pytest.mark.e2e +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_image_end_to_end( - request, session, target_sat, module_target_sat, module_org, module_location + request, session, target_sat, module_target_sat, module_org, module_location, libvirt ): """Perform end to end testing for compute resource libvirt component image. @@ -240,14 +241,14 @@ def test_positive_image_end_to_end( display_type = choice(('VNC', 'SPICE')) console_passwords = choice((True, False)) image_user_data = choice((False, True)) - module_target_sat.configure_libvirt_cr() + module_target_sat.configure_libvirt_cr(server_fqdn=libvirt.fqdn) with session: session.computeresource.create( { 'name': cr_name, 'description': cr_description, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'provider_content.url': LIBVIRT_URL, + 'provider_content.url': libvirt.url, 'provider_content.display_type': display_type, 'provider_content.console_passwords': console_passwords, 'organizations.resources.assigned': [module_org.name], @@ -295,7 +296,7 @@ def _finalize(): def test_positive_associate_with_custom_profile( - request, session, target_sat, module_target_sat, module_org, module_location + request, session, target_sat, module_target_sat, module_org, module_location, libvirt ): """Associate custom default (1-Small) compute profile to libvirt compute resource. @@ -320,14 +321,14 @@ def test_positive_associate_with_custom_profile( 'network': 'br-420', # hardcoding network here as this test won't be doing actual provisioning 'nic_type': 'virtio', } - module_target_sat.configure_libvirt_cr() + module_target_sat.configure_libvirt_cr(server_fqdn=libvirt.fqdn) with session: session.computeresource.create( { 'name': cr_name, 'description': cr_description, 'provider': FOREMAN_PROVIDERS['libvirt'], - 'provider_content.url': LIBVIRT_URL, + 'provider_content.url': libvirt.url, 'provider_content.display_type': display_type, 'provider_content.console_passwords': console_passwords, 'organizations.resources.assigned': [module_org.name], @@ -393,9 +394,11 @@ def test_positive_associate_with_custom_profile_with_template(): @pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) @pytest.mark.rhel_ver_list('[10]') +@pytest.mark.parametrize('libvirt', ['libvirt9', 'libvirt10'], indirect=True) def test_positive_image_provision_end_to_end( request, session, + libvirt, setting_update, module_provisioning_rhel_content, module_libvirt_provisioning_sat, @@ -450,13 +453,12 @@ def test_positive_image_provision_end_to_end( @request.addfinalizer def _finalize(): - # Cleanup: Delete the image and compute resource after test execution. sat.provisioning_cleanup(host_fqdn) cr = sat.api.LibvirtComputeResource().search( - query={'search': f'name={module_cr_libvirt.id}'} + query={'search': f'name={module_cr_libvirt.name}'} ) - sat.api.Image(id=image.id, compute_resource=module_cr_libvirt.id).delete() if cr: + sat.api.Image(id=image.id, compute_resource=cr[0].id).delete() sat.api.LibvirtComputeResource(id=cr[0].id).delete() # Begin UI session to create and manage the host @@ -484,7 +486,7 @@ def _finalize(): # Verify the VM was successfully created and is running on the Libvirt hypervisor result = sat.execute( - f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + f'su foreman -s /bin/bash -c "virsh -c {libvirt.url} list --state-running"' ) assert hostname in result.stdout, f"VM '{hostname}' not found in running VMs on hypervisor" @@ -519,4 +521,4 @@ def _finalize(): # Verify SecureBoot is enabled using mokutil command assert ( 'SecureBoot enabled' in provisioning_host.execute('mokutil --sb-state').stdout - ), "SecureBoot is not enabled on the provisioned host" + ), 'SecureBoot is not enabled on the provisioned host' diff --git a/tests/foreman/ui/test_location.py b/tests/foreman/ui/test_location.py index d91303bcc87..8c49df57f65 100644 --- a/tests/foreman/ui/test_location.py +++ b/tests/foreman/ui/test_location.py @@ -15,8 +15,7 @@ from fauxfactory import gen_ipaddr, gen_string import pytest -from robottelo.config import settings -from robottelo.constants import ANY_CONTEXT, INSTALL_MEDIUM_URL, LIBVIRT_RESOURCE_URL +from robottelo.constants import ANY_CONTEXT, INSTALL_MEDIUM_URL @pytest.mark.e2e @@ -172,15 +171,14 @@ def test_positive_add_org_hostgroup_template(session, target_sat): @pytest.mark.skip_if_not_set('libvirt') -def test_positive_update_compresource(session, target_sat): +def test_positive_update_compresource(session, target_sat, libvirt): """Add/Remove compute resource from/to location :id: 1d24414a-666d-490d-89b9-cd0704684cdd :expectedresults: compute resource is added and removed from the location """ - url = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname - resource = target_sat.api.LibvirtComputeResource(url=url).create() + resource = target_sat.api.LibvirtComputeResource(url=libvirt.url).create() resource_name = resource.name + ' (Libvirt)' loc = target_sat.api.Location().create() with session: diff --git a/tests/foreman/ui/test_organization.py b/tests/foreman/ui/test_organization.py index c75d03195a3..00a3d608f5f 100644 --- a/tests/foreman/ui/test_organization.py +++ b/tests/foreman/ui/test_organization.py @@ -16,7 +16,7 @@ import pytest from robottelo.config import settings -from robottelo.constants import ANY_CONTEXT, DEFAULT_ORG, INSTALL_MEDIUM_URL, LIBVIRT_RESOURCE_URL +from robottelo.constants import ANY_CONTEXT, DEFAULT_ORG, INSTALL_MEDIUM_URL from robottelo.logging import logger CUSTOM_REPO_ERRATA_ID = settings.repos.yum_0.errata[0] @@ -216,15 +216,14 @@ def test_positive_create_with_all_users(session, module_target_sat): @pytest.mark.skip_if_not_set('libvirt') -def test_positive_update_compresource(session, module_target_sat): +def test_positive_update_compresource(session, module_target_sat, libvirt): """Add/Remove compute resource from/to organization. :id: a49349b9-4637-4ef6-b65b-bd3eccb5a12a :expectedresults: Compute resource is added and then removed. """ - url = f'{LIBVIRT_RESOURCE_URL}{settings.libvirt.libvirt_hostname}' - resource = module_target_sat.api.LibvirtComputeResource(url=url).create() + resource = module_target_sat.api.LibvirtComputeResource(url=libvirt.url).create() resource_name = resource.name + ' (Libvirt)' org = module_target_sat.api.Organization().create() with session: