From 46f6fef00ee971550eb7d7463816f2d1346778d4 Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Tue, 9 Dec 2025 04:31:20 -0500 Subject: [PATCH] Remove RHcloud report assertion (#20230) * Remove rhcloud report assertion * fix common assertions in rhcloud tests (cherry picked from commit 8ec8fa1c4a0738dc9ad3cf2efcdf4885116a5d55) --- tests/foreman/cli/test_rhcloud_inventory.py | 4 -- tests/foreman/ui/test_rhcloud_inventory.py | 47 ++++++++++++++++----- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/tests/foreman/cli/test_rhcloud_inventory.py b/tests/foreman/cli/test_rhcloud_inventory.py index b5954ef3e71..4f4a2e6ddd6 100644 --- a/tests/foreman/cli/test_rhcloud_inventory.py +++ b/tests/foreman/cli/test_rhcloud_inventory.py @@ -542,10 +542,6 @@ def generate_report(rhcloud_manifest_org, module_target_sat, disconnected=False) ) assert task_output[0].result == "success" - report_log = module_target_sat.api.Organization(id=org.id).rh_cloud_fetch_last_report_log() - expected = 'Check the Uploading tab for report uploading status' - assert expected in report_log['output'] - def test_positive_config_on_sat_without_network_protocol(module_target_sat, module_sca_manifest): """Test cloud connector configuration on Satellite without explicit network protocol. diff --git a/tests/foreman/ui/test_rhcloud_inventory.py b/tests/foreman/ui/test_rhcloud_inventory.py index c22ed4f6dc5..9079d3ffa30 100644 --- a/tests/foreman/ui/test_rhcloud_inventory.py +++ b/tests/foreman/ui/test_rhcloud_inventory.py @@ -13,6 +13,8 @@ """ from datetime import UTC, datetime, timedelta +import os +import tempfile import pytest from wait_for import wait_for @@ -57,22 +59,26 @@ def common_assertion( ): """Function to perform common assertions""" local_file_data = get_local_file_data(report_path) - upload_success_msg = ( - f'Done: /var/lib/foreman/red_hat_inventory/uploads/report_for_{org.id}.tar.xz' - ) upload_error_messages = ['NSS error', 'Permission denied'] - assert ( - 'Check the Uploading tab for report uploading status' - in inventory_data['generating']['terminal'] - ) if subscription_connection_enabled: + # Only check upload-related assertions when connection is enabled + upload_success_msg = 'Uploaded file moved to done/ folder' + assert ( + 'Check the Uploading tab for report uploading status' + in inventory_data['generating']['terminal'] + ) assert upload_success_msg in inventory_data['uploading']['terminal'] - assert 'x-rh-insights-request-id' in inventory_data['uploading']['terminal'].lower() for error_msg in upload_error_messages: assert error_msg not in inventory_data['uploading']['terminal'] - # There is no uploaded report with subscription_connection_enabled set to false + # Verify uploaded report checksum matches assert local_file_data['checksum'] == get_remote_report_checksum(satellite, org.id) + else: + # When connection disabled, just verify report was generated + assert ( + f'Generated /var/lib/foreman/red_hat_inventory/generated_reports/report_for_{org.id}.tar.xz' + in inventory_data['generating']['terminal'] + ) assert local_file_data['size'] > 0 assert local_file_data['extractable'] @@ -150,7 +156,28 @@ def test_rhcloud_inventory_e2e( silent_failure=True, handle_exception=True, ) - report_path = session.cloudinventory.download_report(org.name) + # Get report based on subscription_connection_enabled setting + if subscription_setting: + # When enabled, download via UI + report_path = session.cloudinventory.download_report(org.name) + else: + # When disabled, get from filesystem + remote_report_path = ( + f'/var/lib/foreman/red_hat_inventory/generated_reports/report_for_{org.id}.tar.xz' + ) + + # Verify file exists on Satellite + result = module_target_sat.execute(f'test -f {remote_report_path}') + assert result.status == 0, f"Report file not found at {remote_report_path}" + + # Copy report from Satellite to local temp location + temp_dir = tempfile.mkdtemp() + local_report_name = f'report_for_{org.id}.tar.xz' + report_path = os.path.join(temp_dir, local_report_name) + + # Download the file from satellite + module_target_sat.get(remote_path=remote_report_path, local_path=report_path) + inventory_data = session.cloudinventory.read(org.name) # Verify that generated archive is valid. common_assertion(report_path, inventory_data, org, module_target_sat, subscription_setting)