Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.14.z] Modify VMware tests to run on VMware8 #13998

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions conf/vmware.yaml.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
VMWARE:
# VMware to be added as a compute resource
# VCENTER: vmware vcenter URL
VCENTER:
VCENTER7:
HOSTNAME:
HYPERVISOR:
# mac_address: Mac address of the vm_name
MAC_ADDRESS:
VCENTER8:
HOSTNAME:
HYPERVISOR:
# mac_address: Mac address of the vm_name
MAC_ADDRESS:
# USERNAME: Login for vmware
USERNAME:
# PASSWORD: Password for vmware
Expand All @@ -14,10 +23,6 @@ VMWARE:
DATASTORE:
# VM_NAME: Name of VM to power On/Off & delete
VM_NAME:
# MAC_ADDRESS: Mac address of the vm
MAC_ADDRESS:
# HYPERVISOR: IP address or hostname of the hypervisor
HYPERVISOR:
# VMware Compute resource image data
# IMAGE_OS: Operating system of the image
IMAGE_OS:
Expand Down
13 changes: 11 additions & 2 deletions pytest_fixtures/component/provision_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
from robottelo.config import settings


@pytest.fixture
def vmware(request):
versions = {
'vmware7': settings.vmware.vcenter7,
'vmware8': settings.vmware.vcenter8,
}
return versions[getattr(request, 'param', 'vmware8')]


@pytest.fixture(scope='module')
def module_vmware_cr(module_provisioning_sat, module_sca_manifest_org, module_location):
def module_vmware_cr(module_provisioning_sat, module_sca_manifest_org, module_location, vmware):
vmware_cr = module_provisioning_sat.sat.api.VMWareComputeResource(
name=gen_string('alpha'),
provider='Vmware',
url=settings.vmware.vcenter,
url=vmware.hostname,
user=settings.vmware.username,
password=settings.vmware.password,
datacenter=settings.vmware.datacenter,
Expand Down
11 changes: 7 additions & 4 deletions tests/foreman/cli/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
@pytest.mark.tier1
@pytest.mark.e2e
@pytest.mark.upgrade
def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location, vmware):
"""Create, Read, Update and Delete VMware compute resources

:id: 96faae3f-bc64-4147-a9fc-09c858e0a68f
Expand All @@ -43,7 +44,7 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location):
'organization-ids': module_org.id,
'location-ids': module_location.id,
'provider': FOREMAN_PROVIDERS['vmware'],
'server': settings.vmware.vcenter,
'server': vmware.hostname,
'user': settings.vmware.username,
'password': settings.vmware.password,
'datacenter': settings.vmware.datacenter,
Expand All @@ -52,7 +53,7 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location):
assert vmware_cr['name'] == cr_name
assert vmware_cr['locations'][0] == module_location.name
assert vmware_cr['organizations'][0] == module_org.name
assert vmware_cr['server'] == settings.vmware.vcenter
assert vmware_cr['server'] == vmware.hostname
assert vmware_cr['datacenter'] == settings.vmware.datacenter
# List
target_sat.cli.ComputeResource.list({'search': f'name="{cr_name}"'})
Expand All @@ -76,6 +77,7 @@ def test_positive_vmware_cr_end_to_end(target_sat, module_org, module_location):
@pytest.mark.e2e
@pytest.mark.on_premises_provisioning
@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True)
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True)
@pytest.mark.parametrize('provision_method', ['build', 'bootdisk'])
@pytest.mark.rhel_ver_match('[^6]')
Expand All @@ -90,6 +92,7 @@ def test_positive_provision_end_to_end(
module_vmware_cr,
module_vmware_hostgroup,
provision_method,
vmware,
):
"""Provision a host on vmware compute resource with
the help of hostgroup.
Expand Down Expand Up @@ -137,7 +140,7 @@ def test_positive_provision_end_to_end(
assert hostname == host['name']
# check if vm is created on vmware
vmware = VMWareSystem(
hostname=settings.vmware.vcenter,
hostname=vmware.hostname,
username=settings.vmware.username,
password=settings.vmware.password,
)
Expand Down
43 changes: 25 additions & 18 deletions tests/foreman/ui/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def _get_normalized_size(size):
return f'{size} {suffixes[suffix_index]}'


def _get_vmware_datastore_summary_string(data_store_name=settings.vmware.datastore):
def _get_vmware_datastore_summary_string(data_store_name=settings.vmware.datastore, vmware=None):
"""Return the datastore string summary for data_store_name

For "Local-Ironforge" datastore the string looks Like:

"Local-Ironforge (free: 1.66 TB, prov: 2.29 TB, total: 2.72 TB)"
"""
system = VMWareSystem(
hostname=settings.vmware.vcenter,
hostname=vmware.hostname,
username=settings.vmware.username,
password=settings.vmware.password,
)
Expand All @@ -81,7 +81,8 @@ def _get_vmware_datastore_summary_string(data_store_name=settings.vmware.datasto


@pytest.mark.tier1
def test_positive_end_to_end(session, module_org, module_location):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_end_to_end(session, module_org, module_location, vmware):
"""Perform end to end testing for compute resource VMware component.

:id: 47fc9e77-5b22-46b4-a76c-3217434fde2f
Expand All @@ -102,7 +103,7 @@ def test_positive_end_to_end(session, module_org, module_location):
'name': cr_name,
'description': description,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand Down Expand Up @@ -152,7 +153,8 @@ def test_positive_end_to_end(session, module_org, module_location):


@pytest.mark.tier2
def test_positive_retrieve_virtual_machine_list(session):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_retrieve_virtual_machine_list(session, vmware):
"""List the virtual machine list from vmware compute resource

:id: 21ade57a-0caa-4144-9c46-c8e22f33414e
Expand All @@ -173,7 +175,7 @@ def test_positive_retrieve_virtual_machine_list(session):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand All @@ -187,7 +189,8 @@ def test_positive_retrieve_virtual_machine_list(session):

@pytest.mark.e2e
@pytest.mark.tier2
def test_positive_image_end_to_end(session, target_sat):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_image_end_to_end(session, target_sat, vmware):
"""Perform end to end testing for compute resource VMware component image.

:id: 6b7949ef-c684-40aa-b181-11f8d4cd39c6
Expand All @@ -204,7 +207,7 @@ def test_positive_image_end_to_end(session, target_sat):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand Down Expand Up @@ -245,7 +248,8 @@ def test_positive_image_end_to_end(session, target_sat):

@pytest.mark.tier2
@pytest.mark.run_in_one_thread
def test_positive_resource_vm_power_management(session):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_resource_vm_power_management(session, vmware):
"""Read current VMware Compute Resource virtual machine power status and
change it to opposite one

Expand All @@ -260,7 +264,7 @@ def test_positive_resource_vm_power_management(session):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand All @@ -287,7 +291,8 @@ def test_positive_resource_vm_power_management(session):


@pytest.mark.tier2
def test_positive_select_vmware_custom_profile_guest_os_rhel7(session):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_select_vmware_custom_profile_guest_os_rhel7(session, vmware):
"""Select custom default (3-Large) compute profile guest OS RHEL7.

:id: 24f7bb5f-2aaf-48cb-9a56-d2d0713dfe3d
Expand Down Expand Up @@ -316,7 +321,7 @@ def test_positive_select_vmware_custom_profile_guest_os_rhel7(session):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand All @@ -331,7 +336,8 @@ def test_positive_select_vmware_custom_profile_guest_os_rhel7(session):


@pytest.mark.tier2
def test_positive_access_vmware_with_custom_profile(session):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_access_vmware_with_custom_profile(session, vmware):
"""Associate custom default (3-Large) compute profile

:id: 751ef765-5091-4322-a0d9-0c9c73009cc4
Expand All @@ -350,7 +356,7 @@ def test_positive_access_vmware_with_custom_profile(session):
with provided values.
"""
cr_name = gen_string('alpha')
data_store_summary_string = _get_vmware_datastore_summary_string()
data_store_summary_string = _get_vmware_datastore_summary_string(vmware=vmware)
cr_profile_data = dict(
cpus='2',
cores_per_socket='2',
Expand Down Expand Up @@ -412,7 +418,7 @@ def test_positive_access_vmware_with_custom_profile(session):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand Down Expand Up @@ -461,7 +467,8 @@ def test_positive_access_vmware_with_custom_profile(session):


@pytest.mark.tier2
def test_positive_virt_card(session, target_sat, module_location, module_org):
@pytest.mark.parametrize('vmware', ['vmware7', 'vmware8'], indirect=True)
def test_positive_virt_card(session, target_sat, module_location, module_org, vmware):
"""Check to see that the Virtualization card appears for an imported VM

:id: 0502d5a6-64c1-422f-a9ba-ac7c2ee7bad2
Expand Down Expand Up @@ -524,7 +531,7 @@ def test_positive_virt_card(session, target_sat, module_location, module_org):
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'provider_content.vcenter': settings.vmware.vcenter,
'provider_content.vcenter': vmware.hostname,
'provider_content.user': settings.vmware.username,
'provider_content.password': settings.vmware.password,
'provider_content.datacenter.value': settings.vmware.datacenter,
Expand Down Expand Up @@ -562,7 +569,7 @@ def test_positive_virt_card(session, target_sat, module_location, module_org):
assert virt_card['cluster'] == settings.vmware.cluster
assert virt_card['memory'] == '5 GB'
assert 'public_ip_address' in virt_card
assert virt_card['mac_address'] == settings.vmware.mac_address
assert virt_card['mac_address'] == vmware.mac_address
assert virt_card['cpus'] == '1'
if 'disk_label' in virt_card:
assert virt_card['disk_label'] == 'Hard disk 1'
Expand Down
Loading