diff options
author | Mohamed Ashiq Liyazudeen <mliyazud@redhat.com> | 2017-05-08 21:08:09 +0530 |
---|---|---|
committer | Mohamed Ashiq Liyazudeen <mliyazud@redhat.com> | 2017-05-08 22:39:07 +0530 |
commit | ec2d37cd987c6aafc7d0d71ab6c2643487d8ef92 (patch) | |
tree | 9d6137f38a97b149c4ef75878745ddd26095e2b2 /tests/shelltest | |
parent | e63a97ed1b464975c9df07ea07dec3b136fa034a (diff) | |
download | gluster-ec2d37cd987c6aafc7d0d71ab6c2643487d8ef92.tar.gz gluster-ec2d37cd987c6aafc7d0d71ab6c2643487d8ef92.tar.bz2 gluster-ec2d37cd987c6aafc7d0d71ab6c2643487d8ef92.tar.xz gluster-ec2d37cd987c6aafc7d0d71ab6c2643487d8ef92.zip |
Unit Test to check the shell script and Dockerfile lint. Travis.ci intergrated.
Refer: https://github.com/projectatomic/dockerfile_lint
Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com>
Diffstat (limited to 'tests/shelltest')
-rw-r--r-- | tests/shelltest/Makefile | 2 | ||||
-rwxr-xr-x | tests/shelltest/run.sh | 12 | ||||
-rwxr-xr-x | tests/shelltest/test_gluster_container_basic.sh | 47 |
3 files changed, 61 insertions, 0 deletions
diff --git a/tests/shelltest/Makefile b/tests/shelltest/Makefile new file mode 100644 index 0000000..13cf414 --- /dev/null +++ b/tests/shelltest/Makefile @@ -0,0 +1,2 @@ +test: + ./run.sh diff --git a/tests/shelltest/run.sh b/tests/shelltest/run.sh new file mode 100755 index 0000000..b82b810 --- /dev/null +++ b/tests/shelltest/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SCRIPT_DIR=$(cd $(dirname $0); pwd) + +echo "running tests in ${SCRIPT_DIR}" + +for test in ${SCRIPT_DIR}/test_*.sh ; do + $test + if [ $? -ne 0 ]; then + exit 1 + fi +done diff --git a/tests/shelltest/test_gluster_container_basic.sh b/tests/shelltest/test_gluster_container_basic.sh new file mode 100755 index 0000000..8d139ca --- /dev/null +++ b/tests/shelltest/test_gluster_container_basic.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +SCRIPT_DIR=$(cd $(dirname ${0}); pwd) +TESTS_DIR="${SCRIPT_DIR}/.." +INC_DIR="${TESTS_DIR}/common" +BASE_DIR="${SCRIPT_DIR}/../.." + +GK_DEPLOY="${DEPLOY_DIR}/" + +source "${INC_DIR}/subunit.sh" + + +test_syntax() { + local file="${1}" + bash -n ${file} +} + +test_shellcheck() { + local file="${1}" + if ! which shellcheck ; then + echo "ShellCheck not found: skipping..." + return 0 + fi + + shellcheck -s bash -e SC2181 ${file} +} + +failed=0 + +testit "test script syntax ${BASE_DIR}/CentOS/gluster-setup.sh" \ + test_syntax ${BASE_DIR}/CentOS/gluster-setup.sh \ + || ((failed++)) + +testit "test shellcheck ${BASE_DIR}/CentOS/gluster-setup.sh" \ + test_shellcheck ${BASE_DIR}/CentOS/gluster-setup.sh \ + || ((failed++)) + +testit "test script syntax ${BASE_DIR}/gluster-object/CentOS/docker-gluster-swift/update_gluster_vol.sh" \ + test_syntax ${BASE_DIR}/gluster-object/CentOS/docker-gluster-swift/update_gluster_vol.sh \ + || ((failed++)) + +testit "test shellcheck ${BASE_DIR}/gluster-object/CentOS/docker-gluster-swift/update_gluster_vol.sh" \ + test_shellcheck ${BASE_DIR}/gluster-object/CentOS/docker-gluster-swift/update_gluster_vol.sh \ + || ((failed++)) + + +testok $0 ${failed} |