diff --git a/.travis.yml b/.travis.yml index 6d9867a1a1..7bba7bef86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ install: script: - TRACE=1 ./test.sh +- ./scripts/install_test.sh # TBD. Suppressing for now. notifications: diff --git a/scripts/install.sh b/scripts/install.sh index f75273df6e..4d2ddb5b05 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -48,6 +48,10 @@ command_exists tar if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \ grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/") + if [ -z "$KUBEBUILDER_VERSION" ]; then + echo "\nUnable to fetch the latest version tag. This may be due to network access problem" + exit 0 + fi fi KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"} diff --git a/scripts/install_test.sh b/scripts/install_test.sh new file mode 100755 index 0000000000..91ec0b8e51 --- /dev/null +++ b/scripts/install_test.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +source ./scripts/install.sh + +echo "Start test" + +if [ -z "$KUBEBUILDER_VERSION" ]; then + echo "\nUnable to fetch the latest version tag. Quit the test" + exit 0 +fi + +echo "1. Check whether $TMP_DIR folder is removed.\n" +if [ -d "$TMP_DIR" ]; then + echo "$TMP_DIR folder is not removed." + exit 1 +fi +echo "passed\n" + +echo "2. Check whether $KUBEBUILDER_DIR folder exists.\n" +if [ ! -d "$KUBEBUILDER_DIR" ]; then + echo "$KUBEBUILDER_DIR folder is not existed." + exit 1 +fi +echo "passed\n" + +echo "3. Check whether kubebuilder is installed properly.\n" +if [ ! -x "$KUBEBUILDER_DIR/bin/kubebuilder" ]; then + echo "$KUBEBUILDER_DIR/bin/kubebuilder is not existed or execute permission not granted." + exit 1 +fi +echo "passed\n" + +echo "4. Check whether kubebuilder version is same as installed.\n" +KUBEBUILDER_VERSION_FROM_BIN=$($KUBEBUILDER_DIR/bin/kubebuilder version | \ + sed 's/^.*KubeBuilderVersion:"\(.*\)", KubernetesVendor.*$/\1/') +if [ ! "${KUBEBUILDER_VERSION_FROM_BIN}" = "${KUBEBUILDER_VERSION}" ]; then + echo "kubebuilder version ${KUBEBUILDER_VERSION_FROM_BIN} mismatched from the version installed (${KUBEBUILDER_VERSION})" + exit 1 +fi +echo "passed\n" + +echo "install test done successfully\n" +exit 0