Skip to content

Commit b46e405

Browse files
authored
Merge pull request #504 from Simon-Li/dev_install_test
Add a script to test installation script
2 parents 94f6eb5 + 1e9ac15 commit b46e405

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install:
2323

2424
script:
2525
- TRACE=1 ./test.sh
26+
- ./scripts/install_test.sh
2627

2728
# TBD. Suppressing for now.
2829
notifications:

scripts/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ command_exists tar
4848
if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then
4949
KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \
5050
grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/")
51+
if [ -z "$KUBEBUILDER_VERSION" ]; then
52+
echo "\nUnable to fetch the latest version tag. This may be due to network access problem"
53+
exit 0
54+
fi
5155
fi
5256

5357
KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"}

scripts/install_test.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
source ./scripts/install.sh
4+
5+
echo "Start test"
6+
7+
if [ -z "$KUBEBUILDER_VERSION" ]; then
8+
echo "\nUnable to fetch the latest version tag. Quit the test"
9+
exit 0
10+
fi
11+
12+
echo "1. Check whether $TMP_DIR folder is removed.\n"
13+
if [ -d "$TMP_DIR" ]; then
14+
echo "$TMP_DIR folder is not removed."
15+
exit 1
16+
fi
17+
echo "passed\n"
18+
19+
echo "2. Check whether $KUBEBUILDER_DIR folder exists.\n"
20+
if [ ! -d "$KUBEBUILDER_DIR" ]; then
21+
echo "$KUBEBUILDER_DIR folder is not existed."
22+
exit 1
23+
fi
24+
echo "passed\n"
25+
26+
echo "3. Check whether kubebuilder is installed properly.\n"
27+
if [ ! -x "$KUBEBUILDER_DIR/bin/kubebuilder" ]; then
28+
echo "$KUBEBUILDER_DIR/bin/kubebuilder is not existed or execute permission not granted."
29+
exit 1
30+
fi
31+
echo "passed\n"
32+
33+
echo "4. Check whether kubebuilder version is same as installed.\n"
34+
KUBEBUILDER_VERSION_FROM_BIN=$($KUBEBUILDER_DIR/bin/kubebuilder version | \
35+
sed 's/^.*KubeBuilderVersion:"\(.*\)", KubernetesVendor.*$/\1/')
36+
if [ ! "${KUBEBUILDER_VERSION_FROM_BIN}" = "${KUBEBUILDER_VERSION}" ]; then
37+
echo "kubebuilder version ${KUBEBUILDER_VERSION_FROM_BIN} mismatched from the version installed (${KUBEBUILDER_VERSION})"
38+
exit 1
39+
fi
40+
echo "passed\n"
41+
42+
echo "install test done successfully\n"
43+
exit 0

0 commit comments

Comments
 (0)