Skip to content

Commit

Permalink
install.sh test
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Li committed Dec 4, 2018
1 parent 3ca15af commit 1e9ac15
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -23,6 +23,7 @@ install:


script: script:
- TRACE=1 ./test.sh - TRACE=1 ./test.sh
- ./scripts/install_test.sh


# TBD. Suppressing for now. # TBD. Suppressing for now.
notifications: notifications:
Expand Down
4 changes: 4 additions & 0 deletions scripts/install.sh
Expand Up @@ -48,6 +48,10 @@ command_exists tar
if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then
KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \ KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \
grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/") 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 fi


KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"} KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"}
Expand Down
43 changes: 43 additions & 0 deletions 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

0 comments on commit 1e9ac15

Please sign in to comment.