diff --git a/pytest_fixtures/component/provision_vmware.py b/pytest_fixtures/component/provision_vmware.py index 507797ccdf..83bea95c77 100644 --- a/pytest_fixtures/component/provision_vmware.py +++ b/pytest_fixtures/component/provision_vmware.py @@ -1,6 +1,8 @@ +from broker import Broker from fauxfactory import gen_string import pytest from wrapanapi import VMWareSystem +from wrapanapi.systems.virtualcenter import VMWareVirtualMachine from robottelo.config import settings @@ -107,3 +109,21 @@ def module_vmware_image( uuid=settings.vmware.image_name, password=settings.provisioning.host_root_password, ).create() + + +@pytest.fixture +def provisioning_vmware_host(pxe_loader, vmwareclient): + """Fixture to check out blank VM on VMware""" + vm_boot_firmware = 'efi' if pxe_loader.vm_firmware == 'uefi' else 'bios' + provisioning_host = Broker( + workflow='deploy-blank-vm-vcenter', + artifacts='last', + vm_network=settings.provisioning.vlan_id, + vm_boot_firmware=vm_boot_firmware, + ).execute() + yield provisioning_host + # delete the host + vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_host['name']) + vmware_host.delete() + # check if vm is deleted from VMware + assert vmwareclient.does_vm_exist(provisioning_host['name']) is False diff --git a/tests/foreman/api/test_computeresource_vmware.py b/tests/foreman/api/test_computeresource_vmware.py index 1795ddca5a..f1dbeb4b54 100644 --- a/tests/foreman/api/test_computeresource_vmware.py +++ b/tests/foreman/api/test_computeresource_vmware.py @@ -14,6 +14,7 @@ from fauxfactory import gen_string import pytest from wait_for import wait_for +from wrapanapi.systems.virtualcenter import VMWareVirtualMachine from robottelo.config import settings @@ -124,3 +125,59 @@ def test_positive_provision_end_to_end( delay=10, ) assert host.read().build_status_label == 'Installed' + + +@pytest.mark.on_premises_provisioning +@pytest.mark.parametrize('module_provisioning_sat', ['discovery'], indirect=True) +@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) +@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version]) +@pytest.mark.tier3 +def test_positive_provision_vmware_pxe_discovery( + request, + module_provisioning_rhel_content, + module_discovery_sat, + provisioning_hostgroup, + provisioning_vmware_host, + pxe_loader, + vmwareclient, +): + """Provision a pxe-based discovered host on VMware + + :id: 29d46a87-bd6f-4963-9ed6-b3456c600779 + + :parametrized: yes + + :Setup: Provisioning and discovery should be configured + + :steps: + 1. Boot up the host to discover + 2. Provision the host + + :expectedresults: Host should be provisioned successfully + + """ + mac = provisioning_vmware_host['provisioning_nic_mac_addr'] + sat = module_discovery_sat.sat + # start the provisioning host + vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_vmware_host['name']) + vmware_host.start() + wait_for( + lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [], + timeout=1500, + delay=40, + ) + discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0] + discovered_host.hostgroup = provisioning_hostgroup + discovered_host.location = provisioning_hostgroup.location[0] + discovered_host.organization = provisioning_hostgroup.organization[0] + discovered_host.build = True + host = discovered_host.update(['hostgroup', 'build', 'location', 'organization']) + host = sat.api.Host().search(query={'search': f'name={host.name}'})[0] + request.addfinalizer(lambda: sat.provisioning_cleanup(host.name)) + wait_for( + lambda: host.read().build_status_label != 'Pending installation', + timeout=1500, + delay=10, + ) + assert host.read().build_status_label == 'Installed' + assert not sat.api.DiscoveredHost().search(query={'mac': mac})