Skip to content

Commit

Permalink
Integrate FAM pipeline into robottelo
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffin-Sullivan committed Feb 9, 2024
1 parent 15f49ed commit b7f1d3d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
6 changes: 3 additions & 3 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1885,9 +1885,9 @@ class Colored(Box):
"user",
]

FAM_MODULE_PATH = (
'/usr/share/ansible/collections/ansible_collections/redhat/satellite/plugins/modules'
)
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
69 changes: 68 additions & 1 deletion tests/foreman/sys/test_fam.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@
: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,
FOREMAN_ANSIBLE_MODULES,
RH_SAT_ROLES,
)

TEST_ROLES_LIST = [f'{role}_role' for role in RH_SAT_ROLES]


@pytest.fixture
Expand All @@ -32,6 +41,48 @@ 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(f'{module_sca_manifest.path}', f'{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}.zip"|g' {config_file}'''
)
module_target_sat.execute(
f'''sed -i 's/rhsm_password:.*/rhsm_password: "{settings.subscription.rhn_password}"/g' {config_file}'''
)

# Handle color output formatting
module_target_sat.execute('export ANSIBLE_NOCOLOR=True && export PY_COLORS=0')
module_target_sat.execute(
f"sed -i 's/pytest -vv/pytest -v --color=no /g' {FAM_ROOT_DIR}/Makefile"
)


@pytest.mark.pit_server
@pytest.mark.run_in_one_thread
def test_positive_ansible_modules_installation(target_sat):
Expand Down Expand Up @@ -71,3 +122,19 @@ 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', FOREMAN_ANSIBLE_MODULES + TEST_ROLES_LIST)
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'. ~/localenv/bin/activate && cd {FAM_ROOT_DIR} && make livetest_{ansible_module}'
)
assert 'PASSED' in result.stdout

0 comments on commit b7f1d3d

Please sign in to comment.