summaryrefslogtreecommitdiff
path: root/test/integration/targets
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2019-08-12 16:24:28 -0400
committerGitHub <noreply@github.com>2019-08-12 16:24:28 -0400
commitc485a1b91e595234acdd2b57a5abe883c6306a35 (patch)
tree7c42dadb0891514506152b4a722b6e49b00b5769 /test/integration/targets
parent697b566971ef855d83292a7c8f954275100d6803 (diff)
downloadansible-c485a1b91e595234acdd2b57a5abe883c6306a35.tar.gz
Fix sanity tests based on newer version of shellcheck (#60423)
- change egrep to grep -E - store exit codes and check them directly - ignore SC1091
Diffstat (limited to 'test/integration/targets')
-rwxr-xr-xtest/integration/targets/blocks/runme.sh8
-rw-r--r--test/integration/targets/group/files/grouplist.sh2
-rwxr-xr-xtest/integration/targets/handlers/runme.sh24
-rwxr-xr-xtest/integration/targets/include_import/runme.sh4
-rwxr-xr-xtest/integration/targets/inventory_vmware_vm_inventory/runme.sh6
-rwxr-xr-xtest/integration/targets/pull/runme.sh4
-rw-r--r--test/integration/targets/user/files/userlist.sh2
7 files changed, 26 insertions, 24 deletions
diff --git a/test/integration/targets/blocks/runme.sh b/test/integration/targets/blocks/runme.sh
index 1c1cf546ef..3384bb9d9b 100755
--- a/test/integration/targets/blocks/runme.sh
+++ b/test/integration/targets/blocks/runme.sh
@@ -12,7 +12,7 @@ ansible-playbook -vv main.yml -i ../../inventory | tee block_test.out
env python -c \
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
<block_test.out >block_test_wo_colors.out
-[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
+[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
# cleanup the output log again, to make sure the test is clean
rm -f block_test.out block_test_wo_colors.out
# run test with free strategy and again count the completions
@@ -20,7 +20,7 @@ ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=free | tee blo
env python -c \
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
<block_test.out >block_test_wo_colors.out
-[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
+[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
# cleanup the output log again, to make sure the test is clean
rm -f block_test.out block_test_wo_colors.out
# run test with host_pinned strategy and again count the completions
@@ -28,7 +28,7 @@ ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=host_pinned |
env python -c \
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
<block_test.out >block_test_wo_colors.out
-[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
+[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
# run test that includes tasks that fail inside a block with always
rm -f block_test.out block_test_wo_colors.out
@@ -36,4 +36,4 @@ ansible-playbook -vv block_fail.yml -i ../../inventory | tee block_test.out
env python -c \
'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \
<block_test.out >block_test_wo_colors.out
-[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(egrep '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
+[ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ]
diff --git a/test/integration/targets/group/files/grouplist.sh b/test/integration/targets/group/files/grouplist.sh
index de23304412..d3129dfe86 100644
--- a/test/integration/targets/group/files/grouplist.sh
+++ b/test/integration/targets/group/files/grouplist.sh
@@ -16,5 +16,5 @@ DISTRO="$*"
if [[ "$DISTRO" == "MacOSX" ]]; then
dscl localhost -list /Local/Default/Groups
else
- egrep -v ^\# /etc/group | cut -d: -f1
+ grep -E -v ^\# /etc/group | cut -d: -f1
fi
diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh
index 03de513675..b87e342de4 100755
--- a/test/integration/targets/handlers/runme.sh
+++ b/test/integration/targets/handlers/runme.sh
@@ -15,44 +15,44 @@ ansible-playbook from_handlers.yml -i inventory.handlers -v "$@" --tags scenario
ansible-playbook test_listening_handlers.yml -i inventory.handlers -v "$@"
[ "$(ansible-playbook test_handlers.yml -i inventory.handlers -v "$@" --tags scenario2 -l A \
-| egrep -o 'RUNNING HANDLER \[test_handlers : .*?]')" = "RUNNING HANDLER [test_handlers : test handler]" ]
+| grep -E -o 'RUNNING HANDLER \[test_handlers : .*?]')" = "RUNNING HANDLER [test_handlers : test handler]" ]
# Not forcing, should only run on successful host
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags normal \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
# Forcing from command line
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags normal --force-handlers \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing from command line, should only run later tasks on unfailed hosts
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags normal --force-handlers \
-| egrep -o CALLED_TASK_. | sort | uniq | xargs)" = "CALLED_TASK_B CALLED_TASK_D CALLED_TASK_E" ]
+| grep -E -o CALLED_TASK_. | sort | uniq | xargs)" = "CALLED_TASK_B CALLED_TASK_D CALLED_TASK_E" ]
# Forcing from command line, should call handlers even if all hosts fail
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags normal --force-handlers -e fail_all=yes \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing from ansible.cfg
[ "$(ANSIBLE_FORCE_HANDLERS=true ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags normal \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing true in play
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags force_true_in_play \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing false in play, which overrides command line
[ "$(ansible-playbook test_force_handlers.yml -i inventory.handlers -v "$@" --tags force_false_in_play --force-handlers \
-| egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
+| grep -E -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
[ "$(ansible-playbook test_handlers_include.yml -i ../../inventory -v "$@" --tags playbook_include_handlers \
-| egrep -o 'RUNNING HANDLER \[.*?]')" = "RUNNING HANDLER [test handler]" ]
+| grep -E -o 'RUNNING HANDLER \[.*?]')" = "RUNNING HANDLER [test handler]" ]
[ "$(ansible-playbook test_handlers_include.yml -i ../../inventory -v "$@" --tags role_include_handlers \
-| egrep -o 'RUNNING HANDLER \[test_handlers_include : .*?]')" = "RUNNING HANDLER [test_handlers_include : test handler]" ]
+| grep -E -o 'RUNNING HANDLER \[test_handlers_include : .*?]')" = "RUNNING HANDLER [test_handlers_include : test handler]" ]
[ "$(ansible-playbook test_handlers_include_role.yml -i ../../inventory -v "$@" \
-| egrep -o 'RUNNING HANDLER \[test_handlers_include_role : .*?]')" = "RUNNING HANDLER [test_handlers_include_role : test handler]" ]
+| grep -E -o 'RUNNING HANDLER \[test_handlers_include_role : .*?]')" = "RUNNING HANDLER [test_handlers_include_role : test handler]" ]
# Notify handler listen
ansible-playbook test_handlers_listen.yml -i inventory.handlers -v "$@"
@@ -76,7 +76,7 @@ set -e
[ ! -f $output_dir/should_not_exist_B ] || (rm -f $output_dir/should_not_exist_B && exit 1)
# https://github.com/ansible/ansible/issues/47287
-[ "$(ansible-playbook test_handlers_including_task.yml -i ../../inventory -v "$@" | egrep -o 'failed=[0-9]+')" = "failed=0" ]
+[ "$(ansible-playbook test_handlers_including_task.yml -i ../../inventory -v "$@" | grep -E -o 'failed=[0-9]+')" = "failed=0" ]
# https://github.com/ansible/ansible/issues/27237
set +e
diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh
index 8ebf769531..efa0a0ae01 100755
--- a/test/integration/targets/include_import/runme.sh
+++ b/test/integration/targets/include_import/runme.sh
@@ -93,11 +93,11 @@ ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook run_once/playbook.yml "$@
# https://github.com/ansible/ansible/issues/48936
ansible-playbook -v handler_addressing/playbook.yml 2>&1 | tee test_handler_addressing.out
-test "$(egrep -c 'include handler task|ERROR! The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2
+test "$(grep -E -c 'include handler task|ERROR! The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2
# https://github.com/ansible/ansible/issues/49969
ansible-playbook -v parent_templating/playbook.yml 2>&1 | tee test_parent_templating.out
-test "$(egrep -c 'Templating the path of the parent include_tasks failed.' test_parent_templating.out)" = 0
+test "$(grep -E -c 'Templating the path of the parent include_tasks failed.' test_parent_templating.out)" = 0
# https://github.com/ansible/ansible/issues/54618
ansible-playbook test_loop_var_bleed.yaml "$@"
diff --git a/test/integration/targets/inventory_vmware_vm_inventory/runme.sh b/test/integration/targets/inventory_vmware_vm_inventory/runme.sh
index 6385b5ea10..1e43cee9c2 100755
--- a/test/integration/targets/inventory_vmware_vm_inventory/runme.sh
+++ b/test/integration/targets/inventory_vmware_vm_inventory/runme.sh
@@ -63,7 +63,8 @@ ansible-inventory -i ${VMWARE_CONFIG} --list --yaml
# Install TOML for --toml
${PYTHON} -m pip freeze | grep toml > /dev/null 2>&1
-if [ $? -ne 0 ]; then
+TOML_TEST_RESULT=$?
+if [ $TOML_TEST_RESULT -ne 0 ]; then
echo "Installing TOML package"
${PYTHON} -m pip install toml
else
@@ -72,7 +73,8 @@ fi
# Get inventory using TOML
ansible-inventory -i ${VMWARE_CONFIG} --list --toml
-if [ $? -ne 0 ]; then
+TOML_INVENTORY_LIST_RESULT=$?
+if [ $TOML_INVENTORY_LIST_RESULT -ne 0 ]; then
echo "Inventory plugin failed to list inventory host using --toml, please debug"
exit 1
fi
diff --git a/test/integration/targets/pull/runme.sh b/test/integration/targets/pull/runme.sh
index c8b6e49f75..93877b1ccb 100755
--- a/test/integration/targets/pull/runme.sh
+++ b/test/integration/targets/pull/runme.sh
@@ -35,12 +35,12 @@ function pass_tests {
fi
# test for https://github.com/ansible/ansible/issues/13681
- if egrep '127\.0\.0\.1.*ok' "${temp_log}"; then
+ if grep -E '127\.0\.0\.1.*ok' "${temp_log}"; then
echo "Found host 127.0.0.1 in output. Only localhost should be present."
exit 1
fi
# make sure one host was run
- if ! egrep 'localhost.*ok' "${temp_log}"; then
+ if ! grep -E 'localhost.*ok' "${temp_log}"; then
echo "Did not find host localhost in output."
exit 1
fi
diff --git a/test/integration/targets/user/files/userlist.sh b/test/integration/targets/user/files/userlist.sh
index c90850b33b..96a83b2073 100644
--- a/test/integration/targets/user/files/userlist.sh
+++ b/test/integration/targets/user/files/userlist.sh
@@ -16,5 +16,5 @@ DISTRO="$*"
if [[ "$DISTRO" == "MacOSX" ]]; then
dscl localhost -list /Local/Default/Users
else
- egrep -v ^\# /etc/passwd | cut -d: -f1
+ grep -E -v ^\# /etc/passwd | cut -d: -f1
fi