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.15.z] [Customer Case] Adding test for syncing inventory with missing ip #16600

Open
wants to merge 1 commit into
base: 6.15.z
Choose a base branch
from
Open
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
69 changes: 69 additions & 0 deletions tests/foreman/cli/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,75 @@ def test_positive_sync_inventory_status(
assert task_output[0].output['host_statuses']['disconnect'] == 0


@pytest.mark.tier3
def test_positive_sync_inventory_status_missing_host_ip(
rhcloud_manifest_org,
rhcloud_registered_hosts,
module_target_sat,
):
"""Sync inventory status via foreman-rake commands with missing IP.

:id: 372c03df-038b-49fb-a509-bb28edf178f3

:steps:

1. Create a vm and register to insights within org having manifest.
2. Remove IP from host.
3. Sync inventory status for specific organization.
# export organization_id=1
# /usr/sbin/foreman-rake rh_cloud_inventory:sync


:expectedresults: Inventory status is successfully synced for satellite host with missing IP.

:Verifies: SAT-24805

:customerscenario: true
"""
org = rhcloud_manifest_org
cmd = f'organization_id={org.id} foreman-rake rh_cloud_inventory:sync'
success_msg = f"Synchronized inventory for organization '{org.name}'"
timestamp = datetime.utcnow().strftime('%Y-%m-%d %H:%M')
rhcloud_host = module_target_sat.cli.Host.info({'name': rhcloud_registered_hosts[0].hostname})[
'id'
]
update_ip = module_target_sat.execute(
f'echo "Host.find({rhcloud_host}).update(ip: nil)" | foreman-rake console'
)
assert 'true' in update_ip.stdout
result = module_target_sat.execute(cmd)
assert result.status == 0
assert success_msg in result.stdout
# Check task details
wait_for(
lambda: module_target_sat.api.ForemanTask()
.search(
query={
'search': f'{inventory_sync_task} and started_at >= "{timestamp}"',
'per_page': 'all',
}
)[0]
.result
== 'success',
timeout=400,
delay=15,
silent_failure=True,
handle_exception=True,
)
task_output = module_target_sat.api.ForemanTask().search(
query={'search': f'{inventory_sync_task} and started_at >= "{timestamp}"'}
)
host_status = None
for task in task_output:
if task.input.get("organization_ids") is None:
continue
if str(task.input.get("organization_ids")[0]) == str(org.id):
host_status = task.output
break
assert host_status['host_statuses']['sync'] == 2
assert host_status['host_statuses']['disconnect'] == 0


@pytest.mark.stubbed
def test_max_org_size_variable():
"""Verify that if organization had more hosts than specified by max_org_size variable
Expand Down
Loading