Skip to content

Commit

Permalink
[6.16.z] Add test for VMware PXE discovery provisioning (#16229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellite-QE authored Sep 6, 2024
1 parent 17ca0f3 commit aaf66a3
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pytest_fixtures/component/provision_vmware.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
57 changes: 57 additions & 0 deletions tests/foreman/api/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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})

0 comments on commit aaf66a3

Please sign in to comment.