|
| 1 | +"""Smoke tests to check installation health |
| 2 | +
|
| 3 | +:Requirement: Installation |
| 4 | +
|
| 5 | +:CaseAutomation: Automated |
| 6 | +
|
| 7 | +:CaseComponent: Installation |
| 8 | +
|
| 9 | +:Team: Rocket |
| 10 | +
|
| 11 | +:CaseImportance: Critical |
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | +from broker import Broker |
| 16 | +import pytest |
| 17 | + |
| 18 | +from robottelo.config import settings |
| 19 | +from robottelo.hosts import Satellite |
| 20 | +from robottelo.utils.issue_handlers import is_open |
| 21 | + |
| 22 | +pytestmark = [pytest.mark.foremanctl, pytest.mark.build_sanity, pytest.mark.upgrade] |
| 23 | + |
| 24 | +SATELLITE_SERVICES = [ |
| 25 | + 'candlepin', |
| 26 | + 'dynflow-sidekiq@orchestrator', |
| 27 | + 'dynflow-sidekiq@worker', |
| 28 | + 'dynflow-sidekiq@worker-hosts-queue', |
| 29 | + 'foreman-proxy', |
| 30 | + 'foreman', |
| 31 | + 'httpd', |
| 32 | + 'postgresql', |
| 33 | + 'pulp-api', |
| 34 | + 'pulp-content', |
| 35 | + 'pulp-worker@*', |
| 36 | + 'redis', |
| 37 | +] |
| 38 | + |
| 39 | + |
| 40 | +def common_sat_install_assertions(satellite): |
| 41 | + # no errors/failures in journald |
| 42 | + result = satellite.execute( |
| 43 | + r'journalctl --quiet --no-pager --boot --grep ERROR -u "dynflow-sidekiq*" -u "foreman-proxy" -u "foreman" -u "httpd" -u "postgresql" -u "pulp-api" -u "pulp-content" -u "pulp-worker*" -u "redis" -u "candlepin"' |
| 44 | + ) |
| 45 | + if is_open('SAT-21086'): |
| 46 | + assert not list(filter(lambda x: 'PG::' not in x, result.stdout.splitlines())) |
| 47 | + else: |
| 48 | + assert not result.stdout |
| 49 | + # no errors/failures in /var/log/httpd/* |
| 50 | + result = satellite.execute(r'grep -iR "error" /var/log/httpd/*') |
| 51 | + assert not result.stdout |
| 52 | + httpd_log = satellite.execute('journalctl --unit=httpd') |
| 53 | + assert 'WARNING' not in httpd_log.stdout |
| 54 | + |
| 55 | + |
| 56 | +@pytest.fixture(scope='module') |
| 57 | +def module_sat_ready_rhel(request): |
| 58 | + with Broker( |
| 59 | + workflow=settings.server.deploy_workflows.os, |
| 60 | + deploy_rhel_version=settings.server.version.rhel_version, |
| 61 | + deploy_flavor=settings.flavors.default, |
| 62 | + deploy_network_type=settings.server.network_type, |
| 63 | + host_class=Satellite, |
| 64 | + ) as sat: |
| 65 | + sat.install_satellite_foremanctl( |
| 66 | + enable_fapolicyd=(request.param == 'fapolicyd'), enable_fips=(request.param == 'fips') |
| 67 | + ) |
| 68 | + yield sat |
| 69 | + |
| 70 | + |
| 71 | +@pytest.mark.first_sanity |
| 72 | +@pytest.mark.parametrize('module_sat_ready_rhel', ['default'], indirect=True) |
| 73 | +def test_satellite_installation_with_foremanctl(module_sat_ready_rhel): |
| 74 | + """Run a basic Satellite installation |
| 75 | +
|
| 76 | + :id: 661206f3-2eec-403c-af26-3c5cadcd5769 |
| 77 | +
|
| 78 | + :steps: |
| 79 | + 1. Get RHEL Host |
| 80 | + 2. Configure satellite repos |
| 81 | + 3. Install satellite using foremanctl |
| 82 | + 4. Run foremanctl deploy |
| 83 | +
|
| 84 | + :expectedresults: |
| 85 | + 1. foremanctl deploy runs successfully |
| 86 | + 2. no unexpected errors in logs |
| 87 | + """ |
| 88 | + common_sat_install_assertions(module_sat_ready_rhel) |
| 89 | + |
| 90 | + |
| 91 | +@pytest.mark.parametrize('module_sat_ready_rhel', ['default'], indirect=True) |
| 92 | +@pytest.mark.parametrize('service', SATELLITE_SERVICES) |
| 93 | +def test_positive_check_installer_service_running(service, module_sat_ready_rhel): |
| 94 | + """Check if all Satellite services is running |
| 95 | +
|
| 96 | + :id: 5389c174-7ab1-4e9d-b2aa-66d80fd6dc5h |
| 97 | +
|
| 98 | + :steps: |
| 99 | + 1. Verify a service is active with systemctl is-active |
| 100 | +
|
| 101 | + :expectedresults: All Satellite services are active |
| 102 | + """ |
| 103 | + is_active = module_sat_ready_rhel.execute(f'systemctl is-active {service}') |
| 104 | + status = module_sat_ready_rhel.execute(f'systemctl status {service}') |
| 105 | + assert is_active.status == 0, status.stdout |
| 106 | + |
| 107 | + |
| 108 | +@pytest.mark.parametrize('module_sat_ready_rhel', ['default'], indirect=True) |
| 109 | +def test_positive_check_installer_hammer_ping(module_sat_ready_rhel): |
| 110 | + """Check if hammer ping reports all services as ok |
| 111 | +
|
| 112 | + :id: 85fd4388-6d94-42f5-bed2-24be38e9f111 |
| 113 | +
|
| 114 | + :steps: |
| 115 | + 1. Run the 'hammer ping' command on satellite. |
| 116 | +
|
| 117 | + :expectedresults: All services are active (running) |
| 118 | + """ |
| 119 | + # check status reported by hammer ping command |
| 120 | + result = module_sat_ready_rhel.execute('hammer ping') |
| 121 | + assert result.status == 0 |
| 122 | + for line in result.stdout.split('\n'): |
| 123 | + if 'Status' in line: |
| 124 | + assert 'ok' in line |
0 commit comments