-
Notifications
You must be signed in to change notification settings - Fork 131
Add initial tests to validate foremanctl #20339
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1577,6 +1577,12 @@ def setup_satellite_repos(self): | |
| satellite_repo=settings.repos.satellite_repo, | ||
| satmaintenance_repo=settings.repos.satmaintenance_repo, | ||
| ) | ||
| elif settings.server.version.source == 'upstream': | ||
| self.create_custom_repos( | ||
| foreman='https://yum.theforeman.org/nightly/el9/x86_64/', | ||
| foreman_plugins='https://yum.theforeman.org/plugins/nightly/el9/x86_64/', | ||
| katello='https://yum.theforeman.org/katello/nightly/katello/el9/x86_64/', | ||
| ) | ||
| else: | ||
| # get ohsnap repofile | ||
| self.download_repofile( | ||
|
|
@@ -1955,6 +1961,55 @@ def install_satellite_or_capsule_package(self): | |
| self.enable_satellite_or_capsule_module_for_rhel8() | ||
| assert self.execute(f'dnf -y install {self.product_rpm_name}').status == 0 | ||
|
|
||
| def install_satellite_foremanctl(self, enable_fapolicyd=False, enable_fips=False): | ||
| # Enable RHEL and Satellite repos | ||
| self.register_to_cdn() | ||
| self.setup_rhel_repos() | ||
| self.setup_satellite_repos() | ||
| assert self.execute('dnf copr enable -y @theforeman/foremanctl rhel-9-x86_64').status == 0 | ||
| assert self.execute('dnf install -y foremanctl').status == 0 | ||
|
|
||
| if enable_fapolicyd: | ||
| assert self.execute('dnf -y install fapolicyd').status == 0 | ||
| assert self.execute('systemctl enable --now fapolicyd').status == 0 | ||
| assert self.execute('systemctl is-active fapolicyd').status == 0 | ||
| if enable_fips: | ||
| Broker().execute( | ||
| workflow='enable-fips', | ||
| target_vm=self.name, | ||
| ) | ||
| self.connect() | ||
| assert self.is_fips_enabled() | ||
|
|
||
| # Configure Satellite firewall to open communication | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same code is present in Maybe we should not add yet another copy, but instead make
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, will do it in a separate PR |
||
| assert ( | ||
| self.execute( | ||
sourcery-ai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| '(which firewall-cmd || dnf -y install firewalld) && systemctl enable --now firewalld' | ||
| ).status | ||
| == 0 | ||
| ), 'firewalld is not present and can\'t be installed' | ||
Gauravtalreja1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert ( | ||
| self.execute( | ||
| 'firewall-cmd --permanent --add-service RH-Satellite-6 && firewall-cmd --reload' | ||
| ).status | ||
| == 0 | ||
| ) | ||
| # Install Satellite and return result | ||
| assert ( | ||
| self.execute( | ||
| f'foremanctl deploy --foreman-initial-admin-username {settings.server.admin_username} --foreman-initial-admin-password {settings.server.admin_password}', | ||
| timeout='30m', | ||
| ).status | ||
| == 0 | ||
| ) | ||
| assert ( | ||
| self.execute( | ||
| 'foremanctl deploy --add-feature foreman-proxy --add-feature hammer' | ||
| ).status | ||
| == 0 | ||
| ) | ||
| return | ||
|
|
||
| def query_db(self, query, db='foreman', output_format='json'): | ||
| """Execute a PostgreSQL query and return the result. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,121 @@ | ||||||
| """Smoke tests to check installation health | ||||||
|
|
||||||
| :Requirement: Installation | ||||||
|
|
||||||
| :CaseAutomation: Automated | ||||||
|
|
||||||
| :CaseComponent: Installation | ||||||
|
|
||||||
| :Team: Rocket | ||||||
|
|
||||||
| :CaseImportance: Critical | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
| from broker import Broker | ||||||
| import pytest | ||||||
|
|
||||||
| from robottelo.config import settings | ||||||
| from robottelo.hosts import Satellite, get_sat_rhel_version | ||||||
|
|
||||||
| pytestmark = [pytest.mark.foremanctl, pytest.mark.build_sanity, pytest.mark.upgrade] | ||||||
|
|
||||||
| SATELLITE_SERVICES = [ | ||||||
Gauravtalreja1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| 'candlepin', | ||||||
| 'dynflow-sidekiq@orchestrator', | ||||||
| 'dynflow-sidekiq@worker', | ||||||
| 'dynflow-sidekiq@worker-hosts-queue', | ||||||
| 'foreman-proxy', | ||||||
| 'foreman', | ||||||
| 'httpd', | ||||||
| 'postgresql', | ||||||
| 'pulp-api', | ||||||
| 'pulp-content', | ||||||
| 'pulp-worker@*', | ||||||
| 'redis', | ||||||
| ] | ||||||
|
|
||||||
|
|
||||||
| def common_sat_install_assertions(satellite): | ||||||
| # no errors/failures in journald | ||||||
| result = satellite.execute( | ||||||
| r'journalctl --quiet --no-pager --boot --priority err -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"' | ||||||
| ) | ||||||
| assert not result.stdout | ||||||
| # no errors/failures in /var/log/httpd/* | ||||||
| result = satellite.execute(r'grep -iR "error" /var/log/httpd/*') | ||||||
| assert not result.stdout | ||||||
| # # no errors/failures in /var/log/candlepin/* | ||||||
| result = satellite.execute(r'grep -iR "error" /var/log/candlepin/*') | ||||||
| assert not result.stdout | ||||||
| httpd_log = satellite.execute('journalctl --unit=httpd') | ||||||
| assert 'WARNING' not in httpd_log.stdout | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(scope='module') | ||||||
| def module_sat_ready_rhel(request): | ||||||
| with Broker( | ||||||
| workflow=settings.server.deploy_workflows.os, | ||||||
| deploy_rhel_version=get_sat_rhel_version().major, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we rely directly on settings here?
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. settings.server.version.release could be stream/6.18.z, and not rhel_ver, but either we use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes, my bad. I meant I leave |
||||||
| deploy_flavor=settings.flavors.default, | ||||||
| deploy_network_type=settings.server.network_type, | ||||||
| host_class=Satellite, | ||||||
| ) as sat: | ||||||
| sat.install_satellite_foremanctl( | ||||||
| enable_fapolicyd=(request.param == 'fapolicyd'), enable_fips=(request.param == 'fips') | ||||||
| ) | ||||||
| yield sat | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.first_sanity | ||||||
| @pytest.mark.parametrize('module_sat_ready_rhel', ['default', 'fips', 'fapolicyd'], indirect=True) | ||||||
| def test_satellite_installation_with_foremanctl(module_sat_ready_rhel): | ||||||
| """Run a basic Satellite installation | ||||||
|
|
||||||
| :id: 661206f3-2eec-403c-af26-3c5cadcd5769 | ||||||
|
|
||||||
| :steps: | ||||||
| 1. Get RHEL Host | ||||||
| 2. Configure satellite repos | ||||||
| 3. Install satellite using foremanctl | ||||||
| 4. Run foremanctl deploy | ||||||
|
|
||||||
| :expectedresults: | ||||||
| 1. foremanctl deploy runs successfully | ||||||
| 2. no unexpected errors in logs | ||||||
| """ | ||||||
| common_sat_install_assertions(module_sat_ready_rhel) | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize('service', SATELLITE_SERVICES) | ||||||
| def test_positive_check_installer_service_running(service, module_sat_ready_rhel): | ||||||
| """Check if all Satellite services is running | ||||||
|
|
||||||
| :id: 5389c174-7ab1-4e9d-b2aa-66d80fd6dc5h | ||||||
|
|
||||||
| :steps: | ||||||
| 1. Verify a service is active with systemctl is-active | ||||||
|
|
||||||
| :expectedresults: All Satellite services are active | ||||||
| """ | ||||||
| is_active = module_sat_ready_rhel.execute(f'systemctl is-active {service}') | ||||||
| status = module_sat_ready_rhel.execute(f'systemctl status {service}') | ||||||
| assert is_active.status == 0, status.stdout | ||||||
|
|
||||||
|
|
||||||
| def test_positive_check_installer_hammer_ping(module_sat_ready_rhel): | ||||||
| """Check if hammer ping reports all services as ok | ||||||
|
|
||||||
| :id: 85fd4388-6d94-42f5-bed2-24be38e9f111 | ||||||
|
|
||||||
| :steps: | ||||||
| 1. Run the 'hammer ping' command on satellite. | ||||||
|
|
||||||
| :expectedresults: All services are active (running) | ||||||
| """ | ||||||
| response = module_sat_ready_rhel.api.Ping().search_json() | ||||||
| assert response['status'] == 'ok' # overall status | ||||||
| services = response['services'] | ||||||
| assert all([service['status'] == 'ok' for service in services.values()]), ( | ||||||
| 'Not all services seem to be up and running!' | ||||||
| ) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, the tests are marked with
new_installerand that sets the version source toupstream?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which packages do you want to install from the upstream repos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For setup-hammer, it needs related hammer plugins for katello and REX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you have Satellite repos enabled and can get them from there?
(Not that I'm complaining that you test upstream bits, just curious to understand which bits exactly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Satellite repos might conflict, so that's why I prefer to validate using upstream bits so its clean upstream installation until foremanctl isn't available in Satellite repos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going this route, could we use the existing property instead?
This would eliminate the need for
pytest_runtest_protocolimplementation, correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I saw is_upstream checks if satellite or satellite-capsule packages isn't present, which IMHO won't help, when we have satellite package installed(w/o satellite-installer configured) and foremanctl present.
While,
settings.server.version.sourcesetting can be used for upstream only deployments as well in future, which we don't test as of now, but it could be something we would need in future