Skip to content

Commit

Permalink
Merge pull request #504 from Simon-Li/dev_install_test
Browse files Browse the repository at this point in the history
Add a script to test installation script
  • Loading branch information
k8s-ci-robot committed Dec 4, 2018
2 parents 94f6eb5 + 1e9ac15 commit b46e405
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ install:

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

# TBD. Suppressing for now.
notifications:
Expand Down
4 changes: 4 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
43 changes: 43 additions & 0 deletions scripts/install_test.sh
Original file line number Diff line number Diff line change
@@ -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 b46e405

Please sign in to comment.