Skip to content

Commit

Permalink
Add automation for BZ 2024175
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Talreja <[email protected]>
(cherry picked from commit 59980dd)
  • Loading branch information
Gauravtalreja1 committed Sep 12, 2023
1 parent 0d21614 commit 347991a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/foreman/api/test_provisioningtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import pytest
from fauxfactory import gen_choice
from fauxfactory import gen_integer
from fauxfactory import gen_mac
from fauxfactory import gen_string
from nailgun import client
Expand Down Expand Up @@ -474,3 +475,60 @@ def test_positive_template_subnet_with_boot_mode(
for template in pxe_templates:
rendered = host.read_template(data={'template_kind': f'{template}'})['template']
assert f'ks={ks_param}' in rendered

@pytest.mark.parametrize('module_sync_kickstart_content', [8], indirect=True)
def test_positive_template_check_aap_snippet(
self,
module_sync_kickstart_content,
module_target_sat,
module_sca_manifest_org,
module_location,
module_default_org_view,
module_lce_library,
default_architecture,
default_partitiontable,
):
"""Read the kickstart default template and verify ansible_provisioning_callback
snippet is rendered correctly
:id: 065ef48f-bec5-4535-8be7-d8527fa21564
:expectedresults: Rendered template should contain values set for AAP snippet
host parameter for respective rhel hosts.
:BZ: 2024175
:customerscenario: true
"""
aap_fqdn = 'env-aap.example.com'
template_id = gen_integer(1, 10)
extra_vars_dict = '{"package_install": "zsh"}'
config_key = gen_string('alpha')
host_params = [
{'name': 'ansible_tower_provisioning', 'value': 'true', 'parameter_type': 'boolean'},
{'name': 'ansible_tower_fqdn', 'value': aap_fqdn, 'parameter_type': 'string'},
{'name': 'ansible_host_config_key', 'value': config_key, 'parameter_type': 'string'},
{'name': 'ansible_job_template_id', 'value': template_id, 'parameter_type': 'integer'},
{'name': 'ansible_extra_vars', 'value': extra_vars_dict, 'parameter_type': 'string'},
]
host = module_target_sat.api.Host(
organization=module_sca_manifest_org,
location=module_location,
name=gen_string('alpha').lower(),
operatingsystem=module_sync_kickstart_content.os,
architecture=default_architecture,
domain=module_sync_kickstart_content.domain,
root_pass=settings.provisioning.host_root_password,
ptable=default_partitiontable,
content_facet_attributes={
'content_source_id': module_target_sat.nailgun_smart_proxy.id,
'content_view_id': module_default_org_view.id,
'lifecycle_environment_id': module_lce_library.id,
},
host_parameters_attributes=host_params,
).create()
render = host.read_template(data={'template_kind': 'provision'})['template']
assert f'https://{aap_fqdn}/api/v2/job_templates/{template_id}/callback/' in render
assert 'systemctl enable ansible-callback' in render
assert f'"host_config_key":"{config_key}"' in render
assert '{"package_install": "zsh"}' in render

0 comments on commit 347991a

Please sign in to comment.