From d76ed2921f264d50fa4cdb54b0d7d3aaefebf9a1 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 10 Dec 2024 11:49:07 +0100 Subject: [PATCH] Provide better error output for test_satellite_installation (#17105) (cherry picked from commit c170b84214e2ce4928af4ca744a64df6c37ee607) --- pytest_fixtures/core/sat_cap_factory.py | 28 ++++++++++++----------- tests/foreman/installer/test_installer.py | 10 ++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index ff9fd39438..6329c00f8f 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -372,19 +372,18 @@ def installer_satellite(request): # enable satellite repos for repo in sat.SATELLITE_CDN_REPOS.values(): sat.enable_repo(repo, force=True) + elif settings.server.version.source == 'nightly': + sat.create_custom_repos( + satellite_repo=settings.repos.satellite_repo, + satmaintenance_repo=settings.repos.satmaintenance_repo, + ) else: - if settings.server.version.source == 'nightly': - sat.create_custom_repos( - satellite_repo=settings.repos.satellite_repo, - satmaintenance_repo=settings.repos.satmaintenance_repo, - ) - else: - # get ohsnap repofile - sat.download_repofile( - product='satellite', - release=settings.server.version.release, - snap=settings.server.version.snap, - ) + # get ohsnap repofile + sat.download_repofile( + product='satellite', + release=settings.server.version.release, + snap=settings.server.version.snap, + ) if settings.robottelo.rhel_source == "internal": # disable rhel repos from cdn @@ -394,7 +393,7 @@ def installer_satellite(request): sat.install_satellite_or_capsule_package() # Install Satellite - sat.execute( + installer_result = sat.execute( InstallerCommand( installer_args=[ 'scenario satellite', @@ -403,6 +402,9 @@ def installer_satellite(request): ).get_command(), timeout='30m', ) + # exit code 0 means no changes, 2 means changes were applied succesfully + assert installer_result.status in (0, 2), installer_result.stdout + sat.enable_satellite_ipv6_http_proxy() if 'sanity' in request.config.option.markexpr: configure_nailgun() diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index 8fb215b7bf..a85129bfe5 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -1323,22 +1323,22 @@ def common_sat_install_assertions(satellite): result = satellite.execute( r'journalctl --quiet --no-pager --boot --priority err -u "dynflow-sidekiq*" -u "foreman-proxy" -u "foreman" -u "httpd" -u "postgresql" -u "pulpcore-api" -u "pulpcore-content" -u "pulpcore-worker*" -u "redis" -u "tomcat"' ) - assert len(result.stdout) == 0 + assert not result.stdout # no errors in /var/log/foreman/production.log result = satellite.execute(r'grep --context=100 -E "\[E\|" /var/log/foreman/production.log') if not is_open('SAT-21086'): - assert len(result.stdout) == 0 + assert not result.stdout # no errors/failures in /var/log/foreman-installer/satellite.log result = satellite.execute( r'grep "\[ERROR" --context=100 /var/log/foreman-installer/satellite.log' ) - assert len(result.stdout) == 0 + assert not result.stdout # no errors/failures in /var/log/httpd/* result = satellite.execute(r'grep -iR "error" /var/log/httpd/*') - assert len(result.stdout) == 0 + assert not result.stdout # no errors/failures in /var/log/candlepin/* result = satellite.execute(r'grep -iR "error" /var/log/candlepin/*') - assert len(result.stdout) == 0 + assert not result.stdout httpd_log = satellite.execute('journalctl --unit=httpd') assert "WARNING" not in httpd_log.stdout