Skip to content

Commit

Permalink
Add tests for Facts component
Browse files Browse the repository at this point in the history
  • Loading branch information
shweta83 committed May 2, 2024
1 parent ddd6cca commit 2d710c5
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion tests/foreman/cli/test_fact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:CaseImportance: Critical
"""
from fauxfactory import gen_string
from fauxfactory import gen_ipaddr, gen_mac, gen_string
import pytest

pytestmark = [pytest.mark.tier1]
Expand Down Expand Up @@ -60,3 +60,38 @@ def test_negative_list_by_name(module_target_sat):
assert (
module_target_sat.cli.Fact().list(options={'search': f'fact={gen_string("alpha")}'}) == []
)


@pytest.mark.no_containers
def test_positive_update_client_facts(
module_target_sat, rhel8_contenthost, module_org, module_location, module_activation_key
):
"""Update client facts and verify the facts are updated on Satellite.
:id: ea94ccb7-a125-4be3-932a-bfcb035d3604
:steps:
1. Add another interface to the host.
2. Update the facts on the Satellite.
3. Verify that the facts are updated on the Satellite.
:expectedresults: Facts are successfully updated on the Satellite.
"""
client = rhel8_contenthost
mac_address = gen_mac(multicast=False)
ip = gen_ipaddr()
# Create eth1 interface on the host
add_interface_command = f'ip link add eth1 type dummy;ifconfig eth1 hw ether {mac_address};ip addr add {ip}/24 brd + dev eth1 label eth1:1;ip link set dev eth1 up'
result = client.execute(add_interface_command)
assert result.status == 0
command = module_target_sat.api.RegistrationCommand(
organization=module_org,
location=module_location,
activation_keys=[module_activation_key.name],
update_packages=True,
remote_execution_interface='eth1',
).create()
result = client.execute(command)
assert result.status == 0, f'Failed to register host: {result.stderr}'
facts = module_target_sat.cli.Fact().list()
assert ip in facts

0 comments on commit 2d710c5

Please sign in to comment.