Skip to content

Commit

Permalink
fixture support for virt-who config cli : data_form deploy_type virtw…
Browse files Browse the repository at this point in the history
…ho_config & manifest content move
  • Loading branch information
yanpliu committed Sep 14, 2023
1 parent 59980dd commit 7d28b59
Show file tree
Hide file tree
Showing 12 changed files with 329 additions and 662 deletions.
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
'pytest_fixtures.component.templatesync',
'pytest_fixtures.component.user',
'pytest_fixtures.component.user_role',
'pytest_fixtures.component.virtwho_config',
# upgrade
'pytest_plugins.upgrade.scenario_workers',
]
Expand Down
2 changes: 1 addition & 1 deletion pytest_fixtures/component/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def module_entitlement_manifest_org(module_org, module_entitlement_manifest, mod
@pytest.fixture(scope='module')
def module_sca_manifest_org(module_org, module_sca_manifest, module_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
module_target_sat.upload_manifest(module_org.id, module_sca_manifest.content)
module_target_sat.upload_manifest(module_org.id, module_sca_manifest)
return module_org


Expand Down
177 changes: 85 additions & 92 deletions tests/foreman/virtwho/cli/test_esx.py

Large diffs are not rendered by default.

239 changes: 105 additions & 134 deletions tests/foreman/virtwho/cli/test_esx_sca.py

Large diffs are not rendered by default.

61 changes: 11 additions & 50 deletions tests/foreman/virtwho/cli/test_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,19 @@
:Upstream: No
"""
import pytest
from fauxfactory import gen_string

from robottelo.config import settings
from robottelo.utils.virtwho import deploy_configure_by_command
from robottelo.utils.virtwho import deploy_configure_by_script
from robottelo.utils.virtwho import get_configure_command
from robottelo.utils.virtwho import get_configure_file
from robottelo.utils.virtwho import get_configure_option


@pytest.fixture()
def form_data(target_sat, default_org):
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.cli.VirtWhoConfig.create(form_data)['general-information']
yield virtwho_config
target_sat.cli.VirtWhoConfig.delete({'name': virtwho_config['name']})
assert not target_sat.cli.VirtWhoConfig.exists(search=('name', form_data['name']))


class TestVirtWhoConfigforHyperv:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_cli', ['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_cli, target_sat, deploy_type_cli
):
"""Verify " hammer virt-who-config deploy & fetch"
Expand All @@ -71,20 +43,9 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
assert virtwho_config['status'] == 'No Report Yet'
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 = 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']})[
assert virtwho_config_cli['status'] == 'No Report Yet'
hypervisor_name, guest_name = deploy_type_cli
virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})[
'general-information'
]['status']
assert virt_who_instance == 'OK'
Expand All @@ -110,7 +71,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_cli, virtwho_config_cli, target_sat
):
"""Verify hypervisor_id option by hammer virt-who-config update"
Expand All @@ -125,13 +86,13 @@ def test_positive_hypervisor_id_option(
values = ['uuid', 'hostname']
for value in values:
target_sat.cli.VirtWhoConfig.update(
{'id': virtwho_config['id'], 'hypervisor-id': value}
{'id': virtwho_config_cli['id'], 'hypervisor-id': value}
)
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})
assert result['connection']['hypervisor-id'] == value
config_file = get_configure_file(virtwho_config['id'])
command = get_configure_command(virtwho_config['id'], default_org.name)
config_file = get_configure_file(virtwho_config_cli['id'])
command = get_configure_command(virtwho_config_cli['id'], default_org.name)
deploy_configure_by_command(
command, form_data['hypervisor-type'], org=default_org.label
command, form_data_cli['hypervisor-type'], org=default_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
62 changes: 11 additions & 51 deletions tests/foreman/virtwho/cli/test_hyperv_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,18 @@
:Upstream: No
"""
import pytest
from fauxfactory import gen_string

from robottelo.config import settings
from robottelo.utils.virtwho import deploy_configure_by_command
from robottelo.utils.virtwho import deploy_configure_by_script
from robottelo.utils.virtwho import get_configure_command
from robottelo.utils.virtwho import get_configure_file
from robottelo.utils.virtwho import get_configure_option


@pytest.fixture()
def form_data(target_sat, module_sca_manifest_org):
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.cli.VirtWhoConfig.create(form_data)['general-information']
yield virtwho_config
target_sat.cli.VirtWhoConfig.delete({'name': virtwho_config['name']})
assert not target_sat.cli.VirtWhoConfig.exists(search=('name', form_data['name']))


class TestVirtWhoConfigforHyperv:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_cli', ['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_cli, target_sat, deploy_type_cli
):
"""Verify " hammer virt-who-config deploy & fetch"
Expand All @@ -71,27 +42,16 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
assert virtwho_config['status'] == 'No Report Yet'
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 = target_sat.cli.VirtWhoConfig.fetch(
{'id': virtwho_config['id']}, output_format='base'
)
deploy_configure_by_script(
script, form_data['hypervisor-type'], debug=True, org=module_sca_manifest_org.label
)
virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})[
assert virtwho_config_cli['status'] == 'No Report Yet'
virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})[
'general-information'
]['status']
assert virt_who_instance == 'OK'

@pytest.mark.tier2
@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_cli, virtwho_config_cli, target_sat
):
"""Verify hypervisor_id option by hammer virt-who-config update"
Expand All @@ -105,13 +65,13 @@ def test_positive_hypervisor_id_option(
"""
for value in ['uuid', 'hostname']:
target_sat.cli.VirtWhoConfig.update(
{'id': virtwho_config['id'], 'hypervisor-id': value}
{'id': virtwho_config_cli['id'], 'hypervisor-id': value}
)
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})
assert result['connection']['hypervisor-id'] == value
config_file = get_configure_file(virtwho_config['id'])
command = get_configure_command(virtwho_config['id'], module_sca_manifest_org.name)
config_file = get_configure_file(virtwho_config_cli['id'])
command = get_configure_command(virtwho_config_cli['id'], module_sca_manifest_org.name)
deploy_configure_by_command(
command, form_data['hypervisor-type'], org=module_sca_manifest_org.label
command, form_data_cli['hypervisor-type'], org=module_sca_manifest_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
59 changes: 11 additions & 48 deletions tests/foreman/virtwho/cli/test_kubevirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,19 @@
:Upstream: No
"""
import pytest
from fauxfactory import gen_string

from robottelo.config import settings
from robottelo.utils.virtwho import deploy_configure_by_command
from robottelo.utils.virtwho import deploy_configure_by_script
from robottelo.utils.virtwho import get_configure_command
from robottelo.utils.virtwho import get_configure_file
from robottelo.utils.virtwho import get_configure_option


@pytest.fixture()
def form_data(target_sat, default_org):
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.cli.VirtWhoConfig.create(form_data)['general-information']
yield virtwho_config
target_sat.cli.VirtWhoConfig.delete({'name': virtwho_config['name']})
assert not target_sat.cli.VirtWhoConfig.exists(search=('name', form_data['name']))


class TestVirtWhoConfigforKubevirt:
@pytest.mark.tier2
@pytest.mark.parametrize('deploy_type', ['id', 'script'])
@pytest.mark.parametrize('deploy_type_cli', ['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_cli, target_sat, deploy_type_cli
):
"""Verify " hammer virt-who-config deploy & fetch"
Expand All @@ -69,20 +43,9 @@ def test_positive_deploy_configure_by_id_script(
:CaseImportance: High
"""
assert virtwho_config['status'] == 'No Report Yet'
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 = 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']})[
assert virtwho_config_cli['status'] == 'No Report Yet'
hypervisor_name, guest_name = deploy_type_cli
virt_who_instance = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})[
'general-information'
]['status']
assert virt_who_instance == 'OK'
Expand All @@ -108,7 +71,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_cli, virtwho_config_cli, target_sat
):
"""Verify hypervisor_id option by hammer virt-who-config update"
Expand All @@ -123,13 +86,13 @@ def test_positive_hypervisor_id_option(
values = ['uuid', 'hostname']
for value in values:
target_sat.cli.VirtWhoConfig.update(
{'id': virtwho_config['id'], 'hypervisor-id': value}
{'id': virtwho_config_cli['id'], 'hypervisor-id': value}
)
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config['id']})
result = target_sat.cli.VirtWhoConfig.info({'id': virtwho_config_cli['id']})
assert result['connection']['hypervisor-id'] == value
config_file = get_configure_file(virtwho_config['id'])
command = get_configure_command(virtwho_config['id'], default_org.name)
config_file = get_configure_file(virtwho_config_cli['id'])
command = get_configure_command(virtwho_config_cli['id'], default_org.name)
deploy_configure_by_command(
command, form_data['hypervisor-type'], org=default_org.label
command, form_data_cli['hypervisor-type'], org=default_org.label
)
assert get_configure_option('hypervisor_id', config_file) == value
Loading

0 comments on commit 7d28b59

Please sign in to comment.