diff --git a/tests/foreman/cli/test_rhcloud_inventory.py b/tests/foreman/cli/test_rhcloud_inventory.py index 626f569a094..6c439a209e2 100644 --- a/tests/foreman/cli/test_rhcloud_inventory.py +++ b/tests/foreman/cli/test_rhcloud_inventory.py @@ -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