Skip to content

Commit

Permalink
[6.15.z] Integrate FAM pipeline into robottelo (SatelliteQE#14156)
Browse files Browse the repository at this point in the history
Integrate FAM pipeline into robottelo (SatelliteQE#14028)

(cherry picked from commit 7aca395)

Co-authored-by: Griffin Sullivan <[email protected]>
  • Loading branch information
2 people authored and damoore044 committed Mar 18, 2024
1 parent f9a2239 commit 66cdc9c
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 4 deletions.
119 changes: 116 additions & 3 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,9 +1924,122 @@ class Colored(Box):
"user",
]

FAM_MODULE_PATH = (
'/usr/share/ansible/collections/ansible_collections/redhat/satellite/plugins/modules'
)
FAM_TEST_PLAYBOOKS = [
"activation_keys_role",
"activation_key",
"architecture",
"auth_source_ldap",
"auth_sources_ldap_role",
"bookmark",
"compute_attribute",
"compute_profile_ovirt",
"compute_profiles_role",
"compute_profile",
"compute_resources_role",
"compute_resource",
"config_group",
"content_credentials_role",
"content_credential",
"content_export_info",
"content_export_library",
"content_export_repository",
"content_export_version",
"content_rhel_role",
"content_upload_ostree",
"content_upload",
"content_view_filter_info",
"content_view_filter_rule_info",
"content_view_filter_rule",
"content_view_filter",
"content_view_info",
"content_view_publish_role",
"content_views_role",
"content_view_version_cleanup_role",
"content_view_version_info",
"content_view_version",
"content_view",
"convert2rhel",
"discovery_rule",
"domain_info",
"domains_role",
"domain",
"external_usergroup",
"filters",
"global_parameter",
"hardware_model",
"host_collection",
"host_errata_info",
"hostgroup_info",
"hostgroups_role",
"hostgroup",
"host_info",
"host_interface_attributes",
"host_power",
"host",
"http_proxy",
"image",
"installation_medium",
"inventory_plugin_ansible",
"inventory_plugin",
"job_invocation",
"job_template",
"katello_hostgroup",
"katello_smart_proxy",
"lifecycle_environments_role",
"lifecycle_environment",
"locations_role",
"location",
"luna_hostgroup",
"manifest_role",
"module_defaults",
"operatingsystems_role",
"operatingsystem",
"organization_info",
"organizations_role",
"organization",
"os_default_template",
"partition_table",
"product",
"provisioning_templates_role",
"provisioning_template",
"puppetclasses_import",
"puppet_environment",
"realm",
"redhat_manifest",
"repositories_role",
"repository_info",
"repository_ostree",
"repository_set_info",
"repository_set",
"repository_sync",
"repository",
"resource_info",
"role",
"scap_content",
"scap_tailoring_file",
"setting_info",
"settings_role",
"setting",
"smart_class_parameter_override_value",
"smart_class_parameter",
"smart_proxy",
"status_info",
"subnet_info",
"subnets_role",
"subnet",
"subscription_info",
"subscription_manifest",
"sync_plans_role",
"sync_plan",
"templates_import",
"usergroup",
"user",
"wait_for_task",
]

FAM_ROOT_DIR = '/usr/share/ansible/collections/ansible_collections/redhat/satellite'

FAM_MODULE_PATH = f'{FAM_ROOT_DIR}/plugins/modules'

RH_SAT_ROLES = [
'activation_keys',
Expand Down
63 changes: 62 additions & 1 deletion tests/foreman/sys/test_fam.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
:Team: Platform
"""
from broker import Broker
import pytest

from robottelo.constants import FAM_MODULE_PATH, FOREMAN_ANSIBLE_MODULES, RH_SAT_ROLES
from robottelo.config import settings
from robottelo.constants import (
FAM_MODULE_PATH,
FAM_ROOT_DIR,
FAM_TEST_PLAYBOOKS,
FOREMAN_ANSIBLE_MODULES,
RH_SAT_ROLES,
)


@pytest.fixture
Expand All @@ -32,6 +40,42 @@ def sync_roles(target_sat):
target_sat.cli.Ansible.roles_delete({'id': role_id})


@pytest.fixture(scope='module')
def setup_fam(module_target_sat, module_sca_manifest):
# Execute AAP WF for FAM setup
Broker().execute(workflow='fam-test-setup', source_vm=module_target_sat.name)

# Edit Makefile to not try to rebuild the collection when tests run
module_target_sat.execute(f"sed -i '/^live/ s/$(MANIFEST)//' {FAM_ROOT_DIR}/Makefile")

# Upload manifest to test playbooks directory
module_target_sat.put(str(module_sca_manifest.path), str(module_sca_manifest.name))
module_target_sat.execute(
f'mv {module_sca_manifest.name} {FAM_ROOT_DIR}/tests/test_playbooks/data'
)

# Edit config file
config_file = f'{FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml'
module_target_sat.execute(
f'cp {FAM_ROOT_DIR}/tests/test_playbooks/vars/server.yml.example {config_file}'
)
module_target_sat.execute(
f'sed -i "s/foreman.example.com/{module_target_sat.hostname}/g" {config_file}'
)
module_target_sat.execute(
f'sed -i "s/rhsm_pool_id:.*/rhsm_pool_id: {settings.subscription.rhn_poolid}/g" {config_file}'
)
module_target_sat.execute(
f'''sed -i 's/rhsm_username:.*/rhsm_username: "{settings.subscription.rhn_username}"/g' {config_file}'''
)
module_target_sat.execute(
f'''sed -i 's|subscription_manifest_path:.*|subscription_manifest_path: "data/{module_sca_manifest.name}"|g' {config_file}'''
)
module_target_sat.execute(
f'''sed -i 's/rhsm_password:.*/rhsm_password: "{settings.subscription.rhn_password}"/g' {config_file}'''
)


@pytest.mark.pit_server
@pytest.mark.run_in_one_thread
def test_positive_ansible_modules_installation(target_sat):
Expand Down Expand Up @@ -71,3 +115,20 @@ def test_positive_import_run_roles(sync_roles, target_sat):
target_sat.cli.Host.ansible_roles_assign({'ansible-roles': roles, 'name': target_sat.hostname})
play = target_sat.cli.Host.ansible_roles_play({'name': target_sat.hostname})
assert 'Ansible roles are being played' in play[0]['message']


@pytest.mark.e2e
@pytest.mark.parametrize('ansible_module', FAM_TEST_PLAYBOOKS)
def test_positive_run_modules_and_roles(module_target_sat, setup_fam, ansible_module):
"""Run all FAM modules and roles on the Satellite
:id: b595756f-627c-44ea-b738-aa17ff5b1d39
:expectedresults: All modules and roles run successfully
"""
# Execute test_playbook
result = module_target_sat.execute(
f'export NO_COLOR=True && . ~/localenv/bin/activate && cd {FAM_ROOT_DIR} && make livetest_{ansible_module}'
)
assert 'PASSED' in result.stdout
assert result.status == 0

0 comments on commit 66cdc9c

Please sign in to comment.