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

[CC Automation] Test for Scheduled insights sync job #16913

Open
wants to merge 2 commits into
base: master
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
36 changes: 36 additions & 0 deletions tests/foreman/api/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,39 @@ 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
Copy link
Contributor

@LadislavVasina1 LadislavVasina1 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColeHiggins2 add a blank line here so that the sphinx is satisfied, you can check it locally using make test-docstrings

Suggested change
:id: 59f66062-2865-4cca-82bb-8d0501fd40f1
:id: 59f66062-2865-4cca-82bb-8d0501fd40f1

Otherwise seems good to me!

: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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColeHiggins2 Could we define/name some constant for this so we know what it means?
Maybe in robottelo/constants/__init__.py something like

INSIGHT_SYNC_STATUS = Box(OK = 2, FAIL = 3, UNKNOWN = 42)

and use it globally? (I've seen it at more places already)

assert task_output[0].output['host_statuses']['sync'] == INSIGHT_SYNC_STATUS.OK

I think @toledo would know the valid statuses, he could help here.

(I used Box coz I like . syntax, but could be dict or anything.)

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
Loading