Skip to content

Commit

Permalink
Combine discovery reboot and reboot_all test (#16572)
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Ganar <[email protected]>
  • Loading branch information
shubhamsg199 authored Oct 8, 2024
1 parent 892aa82 commit 41f203c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 44 deletions.
24 changes: 0 additions & 24 deletions pytest_fixtures/component/provision_pxe.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,6 @@ def provisioning_host(module_ssh_key_file, pxe_loader):
prov_host.blank = getattr(prov_host, 'blank', False)


@pytest.fixture
def provision_multiple_hosts(module_ssh_key_file, pxe_loader, request):
"""Fixture to check out two blank VMs"""
vlan_id = settings.provisioning.vlan_id
cd_iso = (
"" # TODO: Make this an optional fixture parameter (update vm_firmware when adding this)
)
with Broker(
workflow=settings.provisioning.provisioning_host_workflow,
host_class=ContentHost,
_count=getattr(request, 'param', 2),
target_vlan_id=vlan_id,
target_vm_firmware=pxe_loader.vm_firmware,
target_pxeless_image=cd_iso,
blank=True,
target_memory='6GiB',
auth=module_ssh_key_file,
) as hosts:
yield hosts

for prov_host in hosts:
prov_host.blank = getattr(prov_host, 'blank', False)


@pytest.fixture
def provisioning_hostgroup(
module_provisioning_sat,
Expand Down
39 changes: 19 additions & 20 deletions tests/foreman/api/test_discoveredhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def test_positive_reboot_all_pxe_hosts(
self,
module_provisioning_rhel_content,
module_discovery_sat,
provision_multiple_hosts,
provisioning_host,
provisioning_hostgroup,
pxe_loader,
):
Expand All @@ -414,33 +414,32 @@ def test_positive_reboot_all_pxe_hosts(
:parametrized: yes
:setup: Provisioning should be configured and hosts should be discovered via PXE boot.
:Setup: Provisioning should be configured and hosts should be discovered via PXE boot.
:steps: PUT /api/v2/discovered_hosts/reboot_all
:expectedresults: All discovered hosst should be rebooted successfully
:CaseImportance: Medium
:verifies: SAT-23279
:BZ: 2264195
:CaseImportance: Medium
"""
sat = module_discovery_sat.sat
for host in provision_multiple_hosts:
host.power_control(ensure=False)
mac = host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [], # noqa: B023
timeout=1500,
delay=20,
)
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
# Until BZ 2264195 is resolved, reboot_all is expected to fail
result = sat.api.DiscoveredHost().reboot_all()
assert 'Discovered hosts are rebooting now' in result['success_msg']
provisioning_host.power_control(ensure=False)
mac = provisioning_host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [],
timeout=1500,
delay=20,
)

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
result = sat.api.DiscoveredHost(id=discovered_host.id).reboot_all()
assert 'Unable to perform reboot' not in result


class TestFakeDiscoveryTests:
Expand Down

0 comments on commit 41f203c

Please sign in to comment.