diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index 39e68087f1f..069eefc969a 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -68,8 +68,9 @@ def delete_host(form_data, target_sat): @pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforEsx: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -82,67 +83,19 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config.status == 'unknown' - 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 - ) - 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} + 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 ) - 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'}]} + 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, ) - 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: 166ec4f8-e3fa-4555-9acb-1a5d693a42bb - - :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, - ) virt_who_instance = ( target_sat.api.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] diff --git a/tests/foreman/virtwho/api/test_hyperv.py b/tests/foreman/virtwho/api/test_hyperv.py index a2af53b39c0..084975d00a3 100644 --- a/tests/foreman/virtwho/api/test_hyperv.py +++ b/tests/foreman/virtwho/api/test_hyperv.py @@ -55,8 +55,9 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforHyperv: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -69,67 +70,19 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config.status == 'unknown' - 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 - ) - 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} + 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 ) - 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'}]} + 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, ) - 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: 2c58b131-5d68-41d2-b804-4548f998ab5f - - :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, - ) virt_who_instance = ( target_sat.api.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] diff --git a/tests/foreman/virtwho/api/test_kubevirt.py b/tests/foreman/virtwho/api/test_kubevirt.py index 059fdab7f21..0ff6ade433d 100644 --- a/tests/foreman/virtwho/api/test_kubevirt.py +++ b/tests/foreman/virtwho/api/test_kubevirt.py @@ -53,18 +53,19 @@ def virtwho_config(form_data, target_sat): @pytest.fixture(autouse=True) -def clean_host(form_data, target_sat): +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('clean_host') +@pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforKubevirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -77,10 +78,19 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config.status == 'unknown' - 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 - ) + 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] diff --git a/tests/foreman/virtwho/api/test_libvirt.py b/tests/foreman/virtwho/api/test_libvirt.py index 976a8e424a0..b1f105938e5 100644 --- a/tests/foreman/virtwho/api/test_libvirt.py +++ b/tests/foreman/virtwho/api/test_libvirt.py @@ -54,8 +54,9 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforLibvirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -68,67 +69,19 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config.status == 'unknown' - 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 - ) - 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} + 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 ) - 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'}]} + 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, ) - 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: 9668b900-0d2f-42ae-b2f8-523ca292b2bd - - :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, - ) virt_who_instance = ( target_sat.api.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] diff --git a/tests/foreman/virtwho/api/test_nutanix.py b/tests/foreman/virtwho/api/test_nutanix.py index bdf393c88c2..147c6246d1e 100644 --- a/tests/foreman/virtwho/api/test_nutanix.py +++ b/tests/foreman/virtwho/api/test_nutanix.py @@ -59,18 +59,19 @@ def virtwho_config(form_data, target_sat): @pytest.fixture(autouse=True) -def clean_host(form_data, target_sat): +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('clean_host') +@pytest.mark.usefixtures('delete_host') class TestVirtWhoConfigforNutanix: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify "POST /foreman_virt_who_configure/api/v2/configs" @@ -83,71 +84,19 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config.status == 'unknown' - 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 - ) - 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, - settings.virtwho.sku.vdc_physical, - 'NORMAL', - ), - ( - guest_name, - settings.virtwho.sku.vdc_virtual, - 'STACK_DERIVED', - ), - ] - for hostname, sku, type in hosts: - host = target_sat.api.Host().search(query={'search': hostname})[0].read_json() - subscriptions = target_sat.api.Organization(id=default_org.id).subscriptions()[ - 'results' - ] - for item in subscriptions: - if item['type'] == type and item['product_id'] == sku: - vdc_id = item['id'] - if ( - 'hypervisor' in item - and hypervisor_name.lower() in item['hypervisor']['name'] - ): - break - target_sat.api.HostSubscription(host=host['id']).add_subscriptions( - data={'subscriptions': [{'id': vdc_id, 'quantity': 'Automatic'}]} + 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, ) - 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: 7aabfa3e-0ec0-44a3-8b7c-b67476318c2c - - :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, - ) virt_who_instance = ( target_sat.api.VirtWhoConfig() .search(query={'search': f'name={virtwho_config.name}'})[0] diff --git a/tests/foreman/virtwho/cli/test_esx.py b/tests/foreman/virtwho/cli/test_esx.py index dec037c6058..613f69acf0f 100644 --- a/tests/foreman/virtwho/cli/test_esx.py +++ b/tests/foreman/virtwho/cli/test_esx.py @@ -64,8 +64,9 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforEsx: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): """Verify " hammer virt-who-config deploy" @@ -78,61 +79,18 @@ def test_positive_deploy_configure_by_id( :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' - 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 - ) - virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ - 'general-information' - ]['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} + 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 ) - 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 - result = target_sat.cli.Host.subscription_attach( - {'host-id': host['id'], 'subscription-id': vdc_id} + elif deploy_type == "script": + script = target_sat.cli.VirtWhoConfig.fetch( + {'id': virtwho_config['id']}, output_format='base' + ) + hypervisor_name, guest_name = deploy_configure_by_script( + script, form_data['hypervisor-type'], debug=True, org=default_org.label ) - assert result.strip() == 'Subscription attached to the host successfully.' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify " hammer virt-who-config fetch" - - :id: 6aaffaeb-aaf2-42cf-b0dc-ca41a53d42a6 - - :expectedresults: Config can be created, fetch and deploy - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config['status'] == 'No Report Yet' - script = target_sat.cli.VirtWhoConfig.fetch( - {'id': virtwho_config['id']}, output_format='base' - ) - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor-type'], debug=True, org=default_org.label - ) virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] diff --git a/tests/foreman/virtwho/cli/test_esx_sca.py b/tests/foreman/virtwho/cli/test_esx_sca.py index 4a6625d1659..c82520b30fc 100644 --- a/tests/foreman/virtwho/cli/test_esx_sca.py +++ b/tests/foreman/virtwho/cli/test_esx_sca.py @@ -67,11 +67,13 @@ class TestVirtWhoConfigforEsx: def test_positive_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify "hammer virt-who-config deploy" + """Verify "hammer virt-who-config deploy & fetch" :id: 04f2cef8-c88e-4a21-9d2f-c17238eea308 - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration diff --git a/tests/foreman/virtwho/cli/test_hyperv.py b/tests/foreman/virtwho/cli/test_hyperv.py index 3696554af50..6ccb39c6bd2 100644 --- a/tests/foreman/virtwho/cli/test_hyperv.py +++ b/tests/foreman/virtwho/cli/test_hyperv.py @@ -55,69 +55,35 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforHyperv: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: 7cc0ad4f-e185-4d63-a2f5-1cb0245faa6c - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' - 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 - ) - virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ - 'general-information' - ]['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} + 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 ) - 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 - result = target_sat.cli.Host.subscription_attach( - {'host-id': host['id'], 'subscription-id': vdc_id} + elif deploy_type == "script": + script = target_sat.cli.VirtWhoConfig.fetch( + {'id': virtwho_config['id']}, output_format='base' + ) + hypervisor_name, guest_name = deploy_configure_by_script( + script, form_data['hypervisor-type'], debug=True, org=default_org.label ) - assert result.strip() == 'Subscription attached to the host successfully.' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify " hammer virt-who-config fetch" - - :id: 22dc8068-c843-4ca0-acbe-0b2aef8ece31 - - :expectedresults: Config can be created, fetch and deploy - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config['status'] == 'No Report Yet' - script = target_sat.cli.VirtWhoConfig.fetch( - {'id': virtwho_config['id']}, output_format='base' - ) - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor-type'], debug=True, org=default_org.label - ) virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] diff --git a/tests/foreman/virtwho/cli/test_hyperv_sca.py b/tests/foreman/virtwho/cli/test_hyperv_sca.py index 4fa1c0d3ee5..715ec1eafa1 100644 --- a/tests/foreman/virtwho/cli/test_hyperv_sca.py +++ b/tests/foreman/virtwho/cli/test_hyperv_sca.py @@ -59,11 +59,13 @@ class TestVirtWhoConfigforHyperv: def test_positive_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: ba51dd0e-39da-4afd-b7e1-d470082024ba - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration diff --git a/tests/foreman/virtwho/cli/test_kubevirt.py b/tests/foreman/virtwho/cli/test_kubevirt.py index 8ab1fa93e5c..32d1a75416b 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt.py +++ b/tests/foreman/virtwho/cli/test_kubevirt.py @@ -53,69 +53,35 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforKubevirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: d0b109f5-2699-43e4-a6cd-d682204d97a7 - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' - 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 - ) - virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ - 'general-information' - ]['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} + 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 ) - 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 - result = target_sat.cli.Host.subscription_attach( - {'host-id': host['id'], 'subscription-id': vdc_id} + elif deploy_type == "script": + script = target_sat.cli.VirtWhoConfig.fetch( + {'id': virtwho_config['id']}, output_format='base' + ) + hypervisor_name, guest_name = deploy_configure_by_script( + script, form_data['hypervisor-type'], debug=True, org=default_org.label ) - assert result.strip() == 'Subscription attached to the host successfully.' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify " hammer virt-who-config fetch" - - :id: 273df8e0-5ef5-47d9-9567-543157be7dd8 - - :expectedresults: Config can be created, fetch and deploy - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config['status'] == 'No Report Yet' - script = target_sat.cli.VirtWhoConfig.fetch( - {'id': virtwho_config['id']}, output_format='base' - ) - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor-type'], debug=True, org=default_org.label - ) virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] diff --git a/tests/foreman/virtwho/cli/test_kubevirt_sca.py b/tests/foreman/virtwho/cli/test_kubevirt_sca.py index a22d69513e9..4c86aa21f51 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/cli/test_kubevirt_sca.py @@ -55,11 +55,13 @@ class TestVirtWhoConfigforKubevirt: def test_positive_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: e0162dba-a50f-4356-9dc2-c928a1bed15c - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration diff --git a/tests/foreman/virtwho/cli/test_libvirt.py b/tests/foreman/virtwho/cli/test_libvirt.py index d8d2f7b2c19..59508ba74a7 100644 --- a/tests/foreman/virtwho/cli/test_libvirt.py +++ b/tests/foreman/virtwho/cli/test_libvirt.py @@ -54,69 +54,35 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforLibvirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: e66bf88a-bd4e-409a-91a8-bc5e005d95dd - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' - 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 - ) - virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ - 'general-information' - ]['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} + 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 ) - 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 - result = target_sat.cli.Host.subscription_attach( - {'host-id': host['id'], 'subscription-id': vdc_id} + elif deploy_type == "script": + script = target_sat.cli.VirtWhoConfig.fetch( + {'id': virtwho_config['id']}, output_format='base' + ) + hypervisor_name, guest_name = deploy_configure_by_script( + script, form_data['hypervisor-type'], debug=True, org=default_org.label ) - assert result.strip() == 'Subscription attached to the host successfully.' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify " hammer virt-who-config fetch" - - :id: bd5c52ab-3dbd-4cf1-9837-b8eb6233f1cd - - :expectedresults: Config can be created, fetch and deploy - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config['status'] == 'No Report Yet' - script = target_sat.cli.VirtWhoConfig.fetch( - {'id': virtwho_config['id']}, output_format='base' - ) - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor-type'], debug=True, org=default_org.label - ) virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] diff --git a/tests/foreman/virtwho/cli/test_libvirt_sca.py b/tests/foreman/virtwho/cli/test_libvirt_sca.py index a4d0c4d287d..02550772ca6 100644 --- a/tests/foreman/virtwho/cli/test_libvirt_sca.py +++ b/tests/foreman/virtwho/cli/test_libvirt_sca.py @@ -56,11 +56,13 @@ class TestVirtWhoConfigforLibvirt: def test_positive_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify " hammer virt-who-config deploy" + """Verify " hammer virt-who-config deploy & fetch" :id: 53143fc3-97e0-4403-8114-4d7f20fde98e - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration diff --git a/tests/foreman/virtwho/cli/test_nutanix.py b/tests/foreman/virtwho/cli/test_nutanix.py index e312f98fc86..10599c55c00 100644 --- a/tests/foreman/virtwho/cli/test_nutanix.py +++ b/tests/foreman/virtwho/cli/test_nutanix.py @@ -59,69 +59,35 @@ def virtwho_config(form_data, target_sat): class TestVirtWhoConfigforNutanix: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id( - self, default_org, form_data, virtwho_config, target_sat + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify "hammer virt-who-config deploy" + """Verify "hammer virt-who-config deploy & fetch" :id: 129d8e57-b4fc-4d95-ad33-5aa6ec6fb146 - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration :CaseImportance: High """ assert virtwho_config['status'] == 'No Report Yet' - 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 - ) - virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ - 'general-information' - ]['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} + 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 ) - 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 - result = target_sat.cli.Host.subscription_attach( - {'host-id': host['id'], 'subscription-id': vdc_id} + elif deploy_type == "script": + script = target_sat.cli.VirtWhoConfig.fetch( + {'id': virtwho_config['id']}, output_format='base' + ) + hypervisor_name, guest_name = deploy_configure_by_script( + script, form_data['hypervisor-type'], debug=True, org=default_org.label ) - assert result.strip() == 'Subscription attached to the host successfully.' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, form_data, virtwho_config, target_sat - ): - """Verify "hammer virt-who-config fetch" - - :id: d707fac0-f2b1-4493-b083-cf1edc231691 - - :expectedresults: Config can be created, fetch and deploy - - :CaseLevel: Integration - - :CaseImportance: High - """ - assert virtwho_config['status'] == 'No Report Yet' - script = target_sat.cli.VirtWhoConfig.fetch( - {'id': virtwho_config['id']}, output_format='base' - ) - hypervisor_name, guest_name = deploy_configure_by_script( - script, form_data['hypervisor-type'], debug=True, org=default_org.label - ) virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[ 'general-information' ]['status'] diff --git a/tests/foreman/virtwho/cli/test_nutanix_sca.py b/tests/foreman/virtwho/cli/test_nutanix_sca.py index 84db5ce8733..b18a82cd670 100644 --- a/tests/foreman/virtwho/cli/test_nutanix_sca.py +++ b/tests/foreman/virtwho/cli/test_nutanix_sca.py @@ -60,11 +60,13 @@ class TestVirtWhoConfigforNutanix: def test_positive_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, virtwho_config, target_sat, deploy_type ): - """Verify "hammer virt-who-config deploy" + """Verify "hammer virt-who-config deploy & fetch" :id: 71750104-b436-4ad4-9b6b-6f0fe8c3ee4c - :expectedresults: Config can be created and deployed + :expectedresults: + 1. Config can be created and deployed + 2. Config can be created, fetch and deploy :CaseLevel: Integration @@ -120,13 +122,14 @@ def test_positive_hypervisor_id_option( def test_positive_prism_central_deploy_configure_by_id_script( self, module_sca_manifest_org, form_data, target_sat, deploy_type ): - """Verify "hammer virt-who-config deploy" on nutanix prism central mode + """Verify "hammer virt-who-config deploy & fetch" on nutanix prism central mode :id: 96fd691f-5b62-469c-adc7-f2739ddf4a62 :expectedresults: 1. Config can be created and deployed 2. The prism_central has been set in /etc/virt-who.d/vir-who.conf file + 3. Config can be created, fetch and deploy :CaseLevel: Integration diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index ae69655e3e2..8a49ba6250f 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -67,23 +67,26 @@ def virtwho_config(form_data, target_sat, session): @pytest.fixture(autouse=True) -def clean_host(form_data, target_sat): +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('clean_host') +@pytest.mark.usefixtures('delete_host') class TestVirtwhoConfigforEsx: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, session, form_data): - """Verify configure created and deployed with id. + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, virtwho_config, session, form_data, deploy_type + ): + """Verify configure created and deployed with id|script. :id: 44f93ec8-a59a-42a4-ab30-edc554b022b2 :expectedresults: - 1. Config can be created and deployed by command + 1. Config can be created and deployed by command|script 2. No error msg in /var/log/rhsm/rhsm.log 3. Report is sent to satellite 4. Virtual sku can be generated and attached @@ -95,50 +98,30 @@ def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, sess """ name = form_data['name'] values = session.virtwho_configure.read(name) - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) + 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'] 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' - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, virtwho_config, session, form_data - ): - """Verify configure created and deployed with script. - - :id: d64332fb-a6e0-4864-9f8b-2406223fcdcc - - :expectedresults: - 1. Config can be created and deployed by script - 2. No error msg in /var/log/rhsm/rhsm.log - 3. Report is sent to satellite - 4. Virtual sku can be generated and attached - 5. Config can be deleted - - :CaseLevel: Integration - - :CaseImportance: High - """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - 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.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + == 'Unsubscribed hypervisor' ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = 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' session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + assert ( + 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' diff --git a/tests/foreman/virtwho/ui/test_hyperv.py b/tests/foreman/virtwho/ui/test_hyperv.py index dad6a6121d0..e6dafffd15a 100644 --- a/tests/foreman/virtwho/ui/test_hyperv.py +++ b/tests/foreman/virtwho/ui/test_hyperv.py @@ -55,13 +55,16 @@ def virtwho_config(form_data, target_sat, session): class TestVirtwhoConfigforHyperv: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, session, form_data): + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, virtwho_config, session, form_data, deploy_type + ): """Verify configure created and deployed with id. :id: c8913398-c5c6-4f2c-bc53-0bbfb158b762 :expectedresults: - 1. Config can be created and deployed by command + 1. Config can be created and deployed by command/script 2. No error msg in /var/log/rhsm/rhsm.log 3. Report is sent to satellite 4. Virtual sku can be generated and attached @@ -73,50 +76,30 @@ def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, sess """ name = form_data['name'] values = session.virtwho_configure.read(name) - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) + 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'] 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' - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, virtwho_config, session, form_data - ): - """Verify configure created and deployed with script. - - :id: b0401417-3a6e-4a54-b8e8-22d290813da3 - - :expectedresults: - 1. Config can be created and deployed by script - 2. No error msg in /var/log/rhsm/rhsm.log - 3. Report is sent to satellite - 4. Virtual sku can be generated and attached - 5. Config can be deleted - - :CaseLevel: Integration - - :CaseImportance: High - """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - 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.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + == 'Unsubscribed hypervisor' ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = 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' session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + assert ( + 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' diff --git a/tests/foreman/virtwho/ui/test_kubevirt.py b/tests/foreman/virtwho/ui/test_kubevirt.py index 57d7f278e03..20c5e6170e3 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt.py +++ b/tests/foreman/virtwho/ui/test_kubevirt.py @@ -53,13 +53,16 @@ def virtwho_config(form_data, target_sat, session): class TestVirtwhoConfigforKubevirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, session, form_data): + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, virtwho_config, session, form_data, deploy_type + ): """Verify configure created and deployed with id. :id: 7b2a1b08-f33c-44f4-ad2e-317b6c44b938 :expectedresults: - 1. Config can be created and deployed by command + 1. Config can be created and deployed by command/script 2. No error msg in /var/log/rhsm/rhsm.log 3. Report is sent to satellite 4. Virtual sku can be generated and attached @@ -71,50 +74,30 @@ def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, sess """ name = form_data['name'] values = session.virtwho_configure.read(name) - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) + 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'] 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' - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, virtwho_config, session, form_data - ): - """Verify configure created and deployed with script. - - :id: b3903ccb-04cc-4867-b7ed-d5053d2bfe03 - - :expectedresults: - 1. Config can be created and deployed by script - 2. No error msg in /var/log/rhsm/rhsm.log - 3. Report is sent to satellite - 4. Virtual sku can be generated and attached - 5. Config can be deleted - - :CaseLevel: Integration - - :CaseImportance: High - """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - 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.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + == 'Unsubscribed hypervisor' ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = 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' session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + assert ( + 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' diff --git a/tests/foreman/virtwho/ui/test_libvirt.py b/tests/foreman/virtwho/ui/test_libvirt.py index f75db53cc20..cd90836beb4 100644 --- a/tests/foreman/virtwho/ui/test_libvirt.py +++ b/tests/foreman/virtwho/ui/test_libvirt.py @@ -54,13 +54,16 @@ def virtwho_config(form_data, target_sat, session): class TestVirtwhoConfigforLibvirt: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, session, form_data): + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, virtwho_config, session, form_data, deploy_type + ): """Verify configure created and deployed with id. :id: ae37ea79-f99c-4511-ace9-a7de26d6db40 :expectedresults: - 1. Config can be created and deployed by command + 1. Config can be created and deployed by command/script 2. No error msg in /var/log/rhsm/rhsm.log 3. Report is sent to satellite 4. Virtual sku can be generated and attached @@ -72,50 +75,30 @@ def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, sess """ name = form_data['name'] values = session.virtwho_configure.read(name) - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) + 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'] 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' - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, virtwho_config, session, form_data - ): - """Verify configure created and deployed with script. - - :id: 3655a501-ab05-4724-945a-7f6e6878091d - - :expectedresults: - 1. Config can be created and deployed by script - 2. No error msg in /var/log/rhsm/rhsm.log - 3. Report is sent to satellite - 4. Virtual sku can be generated and attached - 5. Config can be deleted - - :CaseLevel: Integration - - :CaseImportance: High - """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - 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.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + == 'Unsubscribed hypervisor' ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = 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' session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + assert ( + 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' diff --git a/tests/foreman/virtwho/ui/test_nutanix.py b/tests/foreman/virtwho/ui/test_nutanix.py index fca28223f50..35c1db88385 100644 --- a/tests/foreman/virtwho/ui/test_nutanix.py +++ b/tests/foreman/virtwho/ui/test_nutanix.py @@ -59,7 +59,10 @@ def virtwho_config(form_data, target_sat, session): class TestVirtwhoConfigforNutanix: @pytest.mark.tier2 - def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, session, form_data): + @pytest.mark.parametrize('deploy_type', ['id', 'script']) + def test_positive_deploy_configure_by_id_script( + self, default_org, virtwho_config, session, form_data, deploy_type + ): """Verify configure created and deployed with id. :id: becea4d0-db4e-4a85-93d2-d40e86da0e2f @@ -77,50 +80,30 @@ def test_positive_deploy_configure_by_id(self, default_org, virtwho_config, sess """ name = form_data['name'] values = session.virtwho_configure.read(name) - command = values['deploy']['command'] - hypervisor_name, guest_name = deploy_configure_by_command( - command, form_data['hypervisor_type'], debug=True, org=default_org.label - ) + 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'] 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' - session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) - assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' - session.contenthost.add_subscription(guest_name, vdc_virtual) - assert session.contenthost.search(guest_name)[0]['Subscription Status'] == 'green' - - @pytest.mark.tier2 - def test_positive_deploy_configure_by_script( - self, default_org, virtwho_config, session, form_data - ): - """Verify configure created and deployed with script. - - :id: 1c1b19c9-988c-4b86-a2b2-658fded10ccb - - :expectedresults: - 1. Config can be created and deployed by script - 2. No error msg in /var/log/rhsm/rhsm.log - 3. Report is sent to satellite - 4. Virtual sku can be generated and attached - 5. Config can be deleted - - :CaseLevel: Integration - - :CaseImportance: High - """ - name = form_data['name'] - values = session.virtwho_configure.read(name) - 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.contenthost.read_legacy_ui(hypervisor_display_name)['subscriptions']['status'] + == 'Unsubscribed hypervisor' ) - assert session.virtwho_configure.search(name)[0]['Status'] == 'ok' - hypervisor_display_name = 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' session.contenthost.add_subscription(hypervisor_display_name, vdc_physical) assert session.contenthost.search(hypervisor_name)[0]['Subscription Status'] == 'green' + assert ( + 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'