From 717a3f721dcdd0f4a026beaf7c24f4abbc2103d2 Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Wed, 13 Nov 2024 15:24:38 -0500 Subject: [PATCH] test for scheduling insights sync --- tests/foreman/api/test_rhcloud_inventory.py | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/foreman/api/test_rhcloud_inventory.py b/tests/foreman/api/test_rhcloud_inventory.py index d624be1f680..59a6c31f3ed 100644 --- a/tests/foreman/api/test_rhcloud_inventory.py +++ b/tests/foreman/api/test_rhcloud_inventory.py @@ -289,3 +289,38 @@ def test_include_parameter_tags_setting( if tag['key'] == 'host_collection': assert tag['value'] == f'"{host_col_name}"' break + + +@pytest.mark.e2e +@pytest.mark.tier3 +def test_rhcloud_scheduled_insights_sync( + rhcloud_manifest_org, + rhcloud_registered_hosts, + module_target_sat, +): + """Verify that triggering the InsightsScheduledSync job in Satellite succeeds with no errors + :id: 59f66062-2865-4cca-82bb-8d0501fd40f1 + :steps: + 1. Prepare machine and upload its data to Insights + 2. Sync inventory status using RH Cloud plugin api + 3. Trigger the InsightsScheduledSync job manually + 4. Assert job succeeds + :expectedresults: + 1. Manually triggering the InsightsScheduledSync job succeeds with no errors. + :Verifies: SAT-22626 + :CaseAutomation: Automated + """ + org = rhcloud_manifest_org + virtual_host, baremetal_host = rhcloud_registered_hosts + # Generate report + module_target_sat.generate_inventory_report(org) + # Sync inventory status + inventory_sync = module_target_sat.sync_inventory_status(org) + task_output = module_target_sat.api.ForemanTask().search( + query={'search': f'id = {inventory_sync["task"]["id"]}'} + ) + assert task_output[0].output['host_statuses']['sync'] == 2 + result = module_target_sat.execute("foreman-rake console SATELLITE_RH_CLOUD_REQUESTS_DELAY=0 <<< 'ForemanTasks.sync_task(InsightsCloud::Async::InsightsScheduledSync)'" + ) + assert 'success' in result.stdout + assert result.status == 0