Skip to content

Commit

Permalink
Make Glue script --profile and --junit work
Browse files Browse the repository at this point in the history
Fix Glue script --profile and --junit features does not work at the same time
TEAM-9475 - Glue script --profile and --junit features does not work at the same time
  • Loading branch information
lilyeyes committed Jul 8, 2024
1 parent 9acf690 commit 06d81e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions scripts/qesap/lib/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,14 @@ def ansible_command_sequence(configure_data_ansible, base_project, sequence, ver
ansible_cmd_seq.append({'cmd': ssh_share})
original_env = dict(os.environ)
original_env['ANSIBLE_PIPELINING'] = 'True'
ansible_callbacks = []
if profile:
original_env['ANSIBLE_CALLBACK_WHITELIST'] = 'ansible.posix.profile_tasks'
ansible_callbacks.append('ansible.posix.profile_tasks')
if junit:
original_env['ANSIBLE_CALLBACKS_ENABLED'] = 'junit'
ansible_callbacks.append('junit')
original_env['JUNIT_OUTPUT_DIR'] = junit
if len(ansible_callbacks) > 0:
original_env['ANSIBLE_CALLBACKS_ENABLED'] = ','.join(ansible_callbacks)
if 'roles_path' in configure_data_ansible:
original_env['ANSIBLE_ROLES_PATH'] = configure_data_ansible['roles_path']

Expand Down
12 changes: 12 additions & 0 deletions scripts/qesap/test/e2e/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,15 @@ ansible_logs_number=$(find . -type f -name "ansible.*.log.txt" | wc -l)
# 3 playbooks plus a log file for the initial ansible (not ansible-playbook) call
[[ $ansible_logs_number -eq 4 ]] || test_die "ansible .log.txt are not 4 files but has ${ansible_logs_number}"
rm ansible.*.log.txt

test_step "[test_4.yaml] Run Ansible with --profile"
qesap.py --verbose -b ${QESAPROOT} -c test_4.yaml ansible --profile || test_die "test_4.yaml fail on ansible"
find . -type f -name "sambuconero*.xml" -delete
rm ansible.*.log.txt

test_step "[test_4.yaml] Run Ansible with --junit"
qesap.py --verbose -b ${QESAPROOT} -c test_4.yaml ansible --junit . || test_die "test_4.yaml fail on ansible"
junit_logs_number=$(find . -type f -name "sambuconero*.xml" | wc -l)
[[ $junit_logs_number -eq 1 ]] || test_die "ansible JUNIT reports should be 1 files but are ${junit_logs_number}"
find . -type f -name "sambuconero*.xml" -delete
rm ansible.*.log.txt
4 changes: 2 additions & 2 deletions scripts/qesap/test/unit/test_qesap_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def test_ansible_profile(
"""
Test that --profile result in Ansible called with an additional env variable
ANSIBLE_CALLBACK_WHITELIST=ansible.posix.profile_tasks
ANSIBLE_CALLBACKS_ENABLED=ansible.posix.profile_tasks
"""
provider = "grilloparlante"
playbooks = {"create": ["get_cherry_wood", "made_pinocchio_head"]}
Expand All @@ -653,7 +653,7 @@ def test_ansible_profile(
calls = []
expected_env = {"MELAMPO": "cane"}
expected_env["ANSIBLE_PIPELINING"] = "True"
expected_env["ANSIBLE_CALLBACK_WHITELIST"] = "ansible.posix.profile_tasks"
expected_env["ANSIBLE_CALLBACKS_ENABLED"] = "ansible.posix.profile_tasks"
for playbook in playbook_files_list:
calls.append(mock_call_ansibleplaybook(inventory, playbook, env=expected_env))

Expand Down

0 comments on commit 06d81e7

Please sign in to comment.