Skip to content

Commit

Permalink
add tests for the Ansible Inventory provided by the Collection (#17288)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni authored Jan 10, 2025
1 parent df2303a commit 3ba05d2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/foreman/sys/test_fam.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def setup_fam(module_target_sat, module_sca_manifest, install_import_ansible_rol
f"sed -i '/test_crud/ s/pytest/$(PYTEST_COMMAND)/' {FAM_ROOT_DIR}/Makefile"
)

# Edit inventory configurations
module_target_sat.execute(
f"sed -i '/url/ s#http.*#https://localhost#' {FAM_ROOT_DIR}/tests/inventory/*.foreman.yml {FAM_ROOT_DIR}/tests/test_playbooks/vars/inventory.yml"
)
module_target_sat.execute(
f"sed -i '/inventory_use_container/ s#true#false#' {FAM_ROOT_DIR}/tests/test_playbooks/vars/inventory.yml"
)

# Upload manifest to test playbooks directory
module_target_sat.put(str(module_sca_manifest.path), str(module_sca_manifest.name))
module_target_sat.execute(
Expand Down Expand Up @@ -195,3 +203,19 @@ def test_positive_run_modules_and_roles(module_target_sat, setup_fam, ansible_mo
f'NO_COLOR=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 make --directory {FAM_ROOT_DIR} livetest_{ansible_module} PYTHON_COMMAND="python3" PYTEST_COMMAND="pytest-3.11"'
)
assert result.status == 0, f"{result.status=}\n{result.stdout=}\n{result.stderr=}"


@pytest.mark.e2e
@pytest.mark.parametrize('ansible_module', ['inventory_plugin', 'inventory_plugin_ansible'])
def test_positive_run_inventory(module_target_sat, setup_fam, ansible_module):
"""Run FAM inventory on the Satellite
:id: 6160216d-c460-437c-b440-1d283efbac70
:expectedresults: All inventories run successfully
"""
# Execute test_playbook
result = module_target_sat.execute(
f'cd {FAM_ROOT_DIR} && NO_COLOR=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest-3.11 tests/test_crud.py::test_inventory[{ansible_module}]'
)
assert result.status == 0, f"{result.status=}\n{result.stdout=}\n{result.stderr=}"

0 comments on commit 3ba05d2

Please sign in to comment.