From 8b41ac6afc162fbb77d79ce79a26f74629cf5977 Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 09:12:32 -0400 Subject: [PATCH 1/6] Fix test-module failing to validate args The test-module pass a wrong argument _ansible_tmp cause the validation failed. Change the argument _ansible_tmp to _ansible_tmpdir to fix this. --- hacking/test-module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacking/test-module b/hacking/test-module index c07d973fe12138..c56b8b72166626 100755 --- a/hacking/test-module +++ b/hacking/test-module @@ -125,7 +125,7 @@ def boilerplate_module(modfile, args, interpreters, check, destfile): # default selinux fs list is pass in as _ansible_selinux_special_fs arg complex_args['_ansible_selinux_special_fs'] = C.DEFAULT_SELINUX_SPECIAL_FS - complex_args['_ansible_tmp'] = C.DEFAULT_LOCAL_TMP + complex_args['_ansible_tmpdir'] = C.DEFAULT_LOCAL_TMP complex_args['_ansible_keep_remote_files'] = C.DEFAULT_KEEP_REMOTE_FILES if args.startswith("@"): From 4a186dadef2d179157bb4b9adf449980e59b28a7 Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 09:58:32 -0400 Subject: [PATCH 2/6] Add a integration test for test-module. Prior to this change, we don't have a test for test-module. This change ensure the correctness of test-module script. --- test/integration/targets/test_infra/runme.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index a0951ad2b58c1c..da73b49c3d2d8d 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -21,3 +21,5 @@ echo "rc was $APB_RC (must be non-zero)" echo "ensure playbook output shows assert/fail works (True)" echo "$PB_OUT" | grep -F "fail works (True)" || exit 1 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 + +../../../../hacking/test-module -m ../../../../lib/ansible/modules/system/ping.py From bea5b1b1962e9a3c15bba8da141227c9fde96074 Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 10:16:14 -0400 Subject: [PATCH 3/6] debug commit --- test/integration/targets/test_infra/runme.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index da73b49c3d2d8d..55b5924a2c59c4 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -22,4 +22,5 @@ echo "ensure playbook output shows assert/fail works (True)" echo "$PB_OUT" | grep -F "fail works (True)" || exit 1 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 +pwd ../../../../hacking/test-module -m ../../../../lib/ansible/modules/system/ping.py From 2ee394606743212de5bb9ba1ea993f4d2525371f Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 10:40:18 -0400 Subject: [PATCH 4/6] debug commit Prior to this change, This change --- test/integration/targets/test_infra/runme.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index 55b5924a2c59c4..c92d4acb7d1dc1 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -22,5 +22,6 @@ echo "ensure playbook output shows assert/fail works (True)" echo "$PB_OUT" | grep -F "fail works (True)" || exit 1 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 -pwd -../../../../hacking/test-module -m ../../../../lib/ansible/modules/system/ping.py + +PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py" +../../../../hacking/test-module -m "$PING_MODULE_PATH" From 5dfe91ee13832fe52b032b93759bf93ea193c785 Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 11:27:26 -0400 Subject: [PATCH 5/6] Fix the file doesn't access bug in freebsd Prior to this change, test-module will raise "No such file" error since freebsd doesn't have /usr/bin/python. --- test/integration/targets/test_infra/runme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index c92d4acb7d1dc1..bc273d2d9026b3 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -22,6 +22,6 @@ echo "ensure playbook output shows assert/fail works (True)" echo "$PB_OUT" | grep -F "fail works (True)" || exit 1 echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 - +# ensure test-module script works well PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py" -../../../../hacking/test-module -m "$PING_MODULE_PATH" +../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter=$(which python) From 87bc467548fbbfeda36d77d3fd101c5bdce81092 Mon Sep 17 00:00:00 2001 From: zhikangzhang Date: Fri, 1 Jun 2018 11:50:14 -0400 Subject: [PATCH 6/6] Improve code style Make sure runme.sh can pass the shell sanity check. --- test/integration/targets/test_infra/runme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh index bc273d2d9026b3..be3809f95bed2e 100755 --- a/test/integration/targets/test_infra/runme.sh +++ b/test/integration/targets/test_infra/runme.sh @@ -24,4 +24,4 @@ echo "$PB_OUT" | grep -F "assert works (True)" || exit 1 # ensure test-module script works well PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py" -../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter=$(which python) +../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"