Skip to content

Commit

Permalink
Remove double Ansible logs
Browse files Browse the repository at this point in the history
Remove doubled log debug from Ansible in case of PASS
  • Loading branch information
mpagot committed Jun 5, 2024
1 parent 57bd87f commit 23efbb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 1 addition & 4 deletions scripts/qesap/lib/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,7 @@ def cmd_ansible(configure_data, base_project, dryrun, verbose, destroy=False, pr
else:
ret, out = lib.process_manager.subprocess_run(**command)
log.debug("Ansible process return ret:%d", ret)
if ret == 0:
for out_line in out:
log.debug("> %s", out_line)
else:
if ret != 0:
log.error("command:%s returned non zero %d", command, ret)
return Status(ret)
return Status("ok")
15 changes: 11 additions & 4 deletions scripts/qesap/test/e2e/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "#######################################################################"
test_step "Configure has to fail with empty yaml"
set +e
qesap.py --verbose -b ${QESAPROOT} -c test_1.yaml configure
rc=$?;echo "1"; [[ $rc -ne 0 ]] || test_die "Should exit with zero rc but is rc:$rc"
rc=$?; [[ $rc -ne 0 ]] || test_die "Should exit with zero rc but is rc:$rc"
set -e

test_step "Minimal configure only with Terraform"
Expand Down Expand Up @@ -155,7 +155,7 @@ test_step "[test_5.yaml] test verbosity for terraform PASS"
rm terraform.*.log.txt
set +e
qesap.py -b ${QESAPROOT} -c test_5.yaml terraform |& tee "${QESAPROOT}/test_5_terraform.txt"
qesap.py --verbose -b ${QESAPROOT} -c test_5.yaml configure |& tee "${QESAPROOT}/test_5_terraform_verbose.txt"
qesap.py --verbose -b ${QESAPROOT} -c test_5.yaml terraform |& tee "${QESAPROOT}/test_5_terraform_verbose.txt"
grep -qE "^DEBUG" "${QESAPROOT}/test_5_terraform_verbose.txt"
rc=$?; [[ $rc -eq 0 ]] || test_die "rc:$rc in verbose mode there should be some DEBUG"

Expand All @@ -178,6 +178,13 @@ echo "### ###"
echo "### A N S I B L E ###"
echo "### ###"
echo "#######################################################################"
test_step "[test_4.yaml] Run Ansible without inventory"
rm "${TEST_PROVIDER}/inventory.yaml" || echo "No old inventory to remove"
set +e
qesap.py --verbose -b ${QESAPROOT} -c test_4.yaml ansible
rc=$?; [[ $rc -ne 0 ]] || test_die "qesap.py ansible has to fail without inventory.yaml but rc:$rc"
set -e

test_step "[test_3.yaml] Run Ansible with no playbooks"
# Keep in mind that test_3.yaml has no playbooks at all
touch "${TEST_PROVIDER}/inventory.yaml"
Expand Down Expand Up @@ -211,7 +218,7 @@ grep -qE "^INFO" "${QESAPROOT}/test_4_ansible_pass_verbose.txt"
rc=$?; [[ $rc -eq 0 ]] || test_die "rc:$rc in verbose mode there should be some INFO"

occurrence=$(grep -E "TASK \[Say hello\]" "${QESAPROOT}/test_4_ansible_pass_verbose.txt" | wc -l)
[[ $occurrence -eq 1 ]] || echo "Some Ansible stdout lines are repeated ${occurrence} in place of exactly 1"
[[ $occurrence -eq 1 ]] || test_die "Some Ansible stdout lines are repeated ${occurrence} times in place of exactly 1"
set -e
rm "${QESAPROOT}/test_4_ansible_pass.txt"
rm "${QESAPROOT}/test_4_ansible_pass_verbose.txt"
rm "${QESAPROOT}/test_4_ansible_pass_verbose.txt"

0 comments on commit 23efbb5

Please sign in to comment.