This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kappnav/Issue1060-TestInstallKAppNav
Drop test setup scripts
- Loading branch information
Showing
7 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#!/bin/bash | ||
#################################################### | ||
# | ||
# setupKAppNavTestEnv.sh for Kubernetes Application Navigator | ||
# | ||
#################################################### | ||
|
||
# check if user wants help | ||
if [ "$#" -lt 5 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo "This script required 5 positional parameters" | ||
echo "Syntax: setupTestEnv.sh <platformURL> <platformUsername> <platformPassword> <platform> <dockerUsername>" | ||
echo | ||
echo "Where:" | ||
echo | ||
echo " <platformURL> specifies the target URL" | ||
echo " <platformUsername> specifies the target username" | ||
echo " <platformPassword> specifies the target password" | ||
echo " <platform> specifies one of: okd, ocp, minishift or minikube. Default is okd" | ||
echo " <dockerUsername> specifies your docker username" | ||
echo | ||
exit 0 | ||
fi | ||
|
||
# get positional parms | ||
platformURL=$1 | ||
platformUsername=$2 | ||
platformPassword=$3 | ||
platform=$4 | ||
dockerID=$5 | ||
|
||
if [ x$platform = 'xminikube' ] ; then | ||
kubectl=$(kubectl) | ||
if [ $? -ne 0 ]; then | ||
echo "Error: kubectl not found. Make sure minikube is running." | ||
echo "" | ||
exit 1 | ||
fi | ||
else | ||
# make sure to logout first, in case it already login to different platform | ||
oc logout | ||
# login to target platform | ||
echo "oc login -u $platformUsername -p $platformPassword $platformURL" | ||
oc login -u $platformUsername -p $platformPassword $platformURL | ||
if [ $? -eq 0 ]; then | ||
echo "########## OC login successfully. ##########" | ||
else | ||
echo "########## OC login failed, exiting. ##########" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# At least check if previous KAppNav already install on user namespace | ||
# If there is then uninstall first as having 2 instances install on same platform won't work well | ||
|
||
# check if KAppNav has been installed using docker id namespace | ||
./test/isDeployed.sh $dockerID | ||
if [ $? -eq 0 ]; then | ||
echo "KAppNav already installed on namespace $dockerID" | ||
echo "Uninstalling KAppNav from $dockerID namespace" | ||
kubectl delete -f ../operator/kappnav-delete-CR.yaml -n $dockerID --now | ||
kubectl delete -f ../operator/kappnav-delete.yaml -n $dockerID | ||
kubectl delete namespace $dockerID | ||
if [ $? -eq 0 ]; then | ||
echo "########## Uninstall successfully. ##########" | ||
else | ||
echo "########## Uninstall failed, exiting ##########" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# check if KAppNav has been installed on kappnav namespace | ||
# because if either AppNav or KAppNav already install on the platform you are using then thing won't work well | ||
./test/isDeployed.sh kappnav | ||
if [ $? -eq 0 ]; then | ||
echo "KAppNav already installed on namespace kappnav" | ||
echo "Uninstalling KAppNav from kappnav namespace" | ||
./uninstall.sh | ||
if [ $? -eq 0 ]; then | ||
echo "########## Uninstall successfully. ##########" | ||
else | ||
echo "########## Uninstall failed, exiting ##########" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# build kappnav | ||
echo "########## Building KAppNav ########## " | ||
./build.sh | ||
if [ $? -eq 0 ]; then | ||
echo "########## Build successfully. ##########" | ||
else | ||
echo "########## Build failed, exiting. ##########" | ||
exit 1 | ||
fi | ||
|
||
# push all images to docker hub | ||
echo "########## Pushing all KAppNav images to docker hub of $dockerID ########## " | ||
./pushimages.sh $dockerID | ||
if [ $? -eq 0 ]; then | ||
echo "########## Pushed KAppNav images successfully. ##########" | ||
else | ||
echo "########## Pushed KAppNav images failed, exiting. ##########" | ||
exit 1 | ||
fi | ||
|
||
# installing to target platform | ||
./install.sh $dockerID $platform | ||
if [ $? -eq 0 ]; then | ||
echo "########## Install successfully. ##########" | ||
else | ||
echo "########## Install failed, exiting. ##########" | ||
exit 1 | ||
fi | ||
|
||
# check to make sure KAppNav healthy | ||
./test/isKAppNavHealthy.sh kappnav 3 | ||
if [ $? -ne 0 ]; then | ||
echo "########## isKAppNavHealthy failed, exiting ##########" | ||
exit 1 | ||
fi | ||
|
||
# check to hit kappnavui url | ||
./test/isKappnavUIOK.sh kappnav $platform | ||
if [ $? -ne 0 ]; then | ||
echo "########## isKappnavUIOK failed, exiting ##########" | ||
exit 1 | ||
fi | ||
|
||
# install sample stocktrader application | ||
./test/installStocktrader.sh ../samples/stocktrader | ||
if [ $? -ne 0 ]; then | ||
echo "########## installStocktrader failed, exiting ##########" | ||
exit 1 | ||
fi | ||
|
||
# install sample bookinfo application | ||
./test/installBookinfo.sh ../samples/bookinfo | ||
if [ $? -ne 0 ]; then | ||
echo "########## installBookinfo failed, exiting ##########" | ||
exit 1 | ||
fi | ||
|
||
# test to make sure adminCenter url OK | ||
# If do not want to launch the adminCenter, do not pass in true | ||
./test/isAdminCenterUIOK.sh kappnav $platform | ||
|
||
# launch kappnav ui to do UI manual test with the test env setup | ||
# If do not want to launch the KAppNavUI, do not pass in true | ||
./test/isKappnavUIOK.sh kappnav $platform true | ||
|
||
exit 0 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
#################################################### | ||
# | ||
# installBookinfo.sh <bookinfo sample path> | ||
# | ||
#################################################### | ||
|
||
if [ "$#" -lt 1 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo Syntax: installBookinfo.sh \<bookinfo sample path\> | ||
echo "Where:" | ||
echo " <bookinfo sample path> specifies the path where bookinfo sample located" | ||
exit 1 | ||
fi | ||
|
||
bookinfoPath=$1 | ||
|
||
echo "kubectl create namespace bookinfo" | ||
kubectl create namespace bookinfo | ||
|
||
echo "kubectl apply -f $bookinfoPath -n bookinfo" | ||
kubectl apply -f $bookinfoPath -n bookinfo | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "########## Bookinfo sample application installed successfully ##########" | ||
else | ||
echo "########## Failed to install bookinfo sample application ##########" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
#################################################### | ||
# | ||
# installStocktrader.sh <stocktrader sample path> | ||
# | ||
#################################################### | ||
|
||
if [ "$#" -lt 1 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo Syntax: installStocktrader.sh \<stocktrader sample path\> | ||
echo "Where:" | ||
echo " <stocktrader sample path> specifies the path where stocktrader sample located" | ||
exit 1 | ||
fi | ||
|
||
stocktraderPath=$1 | ||
|
||
echo "kubectl create namespace stocktrader" | ||
kubectl create namespace stocktrader | ||
|
||
echo "kubectl apply -f $stocktraderPath -n stocktrader" | ||
kubectl apply -f $stocktraderPath -n stocktrader | ||
|
||
if [ $? -eq 0 ]; then | ||
# update stocktrader namespace to include all other application namespace that should show up under stock trader component view | ||
echo "kubectl annotate Application stock-trader kappnav.component.namespaces=twas,liberty,localliberty -n stocktrader --overwrite" | ||
kubectl annotate Application stock-trader kappnav.component.namespaces=twas,liberty,localliberty -n stocktrader --overwrite | ||
echo "########## Stocktrader sample application installed successfully ##########" | ||
else | ||
echo "########## Failed to install stocktrader sample application ##########" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
if [ "$#" -lt 2 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo "Syntax: isAdminCenterUIOK.sh <namespace> <platform> [true|false]" | ||
echo "Where:" | ||
echo " <namespace> specifies the namespace where AppNav is installed." | ||
echo " <platform> specifies one of: okd, ocp or minishift. Default is okd." | ||
echo " optional: [true|false] true will launch the kappnavui page." | ||
exit 1 | ||
fi | ||
|
||
namespace=$1 | ||
platform=$2 | ||
launch=$3 | ||
|
||
# test to hit Liberty adminCenter ui | ||
if [ x$platform != 'xminikube' ] ; then | ||
echo "kubectl get route -n $namespace -o=jsonpath={@.items[0].spec.host}" | ||
host=$(kubectl get route -n $namespace -o=jsonpath={@.items[0].spec.host}) | ||
if [ -z host ]; then | ||
echo "Could not retrieve kappnavui host from route. Confirm install is correct." | ||
exit 1 | ||
fi | ||
url="https://$host/adminCenter/" | ||
|
||
curl=$(curl $url --insecure >/dev/null 2>/dev/null) | ||
if [ $? -ne 0 ]; then | ||
echo "Error: $url not responding. Check that initialization is complete and successful." | ||
echo "" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "########## Liberty AdminCenter UI is OK ##########" | ||
|
||
if [ "$launch" = "true" ]; then | ||
open $url | ||
echo "########## Liberty AdminCenter UI is launched at url $url ##########" | ||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if [ "$#" -lt 1 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo Syntax: isDeployed.sh \<namespace\> | ||
echo "Where:" | ||
echo " <namespace> specifies the namespace where KAppNav is installed." | ||
exit 1 | ||
fi | ||
|
||
namespace=$1 | ||
|
||
echo "kubectl get Deployment -n $namespace --no-headers" | ||
deployments=$(kubectl get Deployment -n $namespace --no-headers) | ||
depLen=${#deployments} | ||
if [ $depLen -ne 0 ]; then | ||
echo "Already installed" | ||
exit 0 | ||
else | ||
echo "Not installed yet" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
#################################################### | ||
# | ||
# isKAppNavHealthy.sh <namespace> | ||
# | ||
#################################################### | ||
|
||
if [ "$#" -lt 1 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo Syntax: isKAppNavHealthy.sh \<namespace\> | ||
echo "Where:" | ||
echo " <namespace> specifies the namespace where AppNav is installed." | ||
exit 1 | ||
fi | ||
|
||
namespace=$1 | ||
numPods=$2 | ||
|
||
# get all KAppNav pods | ||
echo "kubectl get pods -n $namespace --no-headers -o custom-columns=NAME:.metadata.name" | ||
kappnavPods=$(kubectl get pods -n $namespace --no-headers -o custom-columns=NAME:.metadata.name) | ||
echo $kappnavPods | ||
kappnavPodsArray=( $kappnavPods ) | ||
kappnavPodsLen="${#kappnavPodsArray[@]}" | ||
|
||
# check to make sure all KAppNav pods created | ||
count=0 | ||
while [ $kappnavPodsLen -ne $numPods ] | ||
do | ||
if [ $count -eq 12 ]; then | ||
exit 1 | ||
else | ||
echo "kubectl get pods -n $namespace --no-headers -o custom-columns=NAME:.metadata.name" | ||
kappnavPods=$(kubectl get pods -n $namespace --no-headers -o custom-columns=NAME:.metadata.name) | ||
kappnavPodsArray=( $kappnavPods ) | ||
kappnavPodsLen="${#kappnavPodsArray[@]}" | ||
if [ $kappnavPodsLen -ne $numPods ]; then | ||
# check to make sure all kappnav pods created for 1 minutes at the most with 5s delay in between checking | ||
sleep 5 | ||
fi | ||
count=$((count+1)) | ||
fi | ||
done | ||
|
||
echo $kappnavPods | ||
# check all KAppNav pods until all pods status true | ||
for kappnavPod in $kappnavPods | ||
do | ||
status="false" | ||
count=0 | ||
while [ "$status" = "false" ] | ||
do | ||
# check to make sure the apps created for 10 minutes at the most with 5s delay in between checking | ||
if [ $count -eq 120 ]; then | ||
exit 1 | ||
else | ||
echo "kubectl get pods $kappnavPod -n $namespace --no-headers -o custom-columns=Ready:status.containerStatuses[0].ready" | ||
status=$(kubectl get pods $kappnavPod -n $namespace --no-headers -o custom-columns=Ready:status.containerStatuses[0].ready) | ||
if [ "$status" = "false" ]; then | ||
sleep 5 | ||
fi | ||
count=$((count+1)) | ||
fi | ||
echo "Status : $status" | ||
done | ||
done | ||
|
||
echo "########## KAppNav pods are healthy ##########" | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
if [ "$#" -lt 2 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ x$1 = x'-?' ] || [ x$1 = x'--help' ] || [ x$1 = x'help' ]; then | ||
echo "Syntax: isKappnavUIOK.sh <namespace> <platform> [true|false]" | ||
echo "Where:" | ||
echo " <namespace> specifies the namespace where KAppNav is installed." | ||
echo " <platform> specifies one of: okd, ocp or minishift. Default is okd." | ||
echo " optional: [true|false] true will launch the kappnavui page." | ||
exit 1 | ||
fi | ||
|
||
namespace=$1 | ||
platform=$2 | ||
launch=$3 | ||
|
||
# test to hit KAppNav ui | ||
if [ x$platform != 'xminikube' ] ; then | ||
echo "kubectl get route -n $namespace -o=jsonpath={@.items[0].spec.host}" | ||
host=$(kubectl get route -n $namespace -o=jsonpath={@.items[0].spec.host}) | ||
if [ -z host ]; then | ||
echo "Could not retrieve kappnavui host from route. Confirm install is correct." | ||
exit 1 | ||
fi | ||
url="https://$host/kappnav-ui/" | ||
|
||
curl=$(curl $url --insecure >/dev/null 2>/dev/null) | ||
if [ $? -ne 0 ]; then | ||
echo "Error: $url not responding. Check that initialization is complete and successful." | ||
echo "" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "########## KAppNav UI is OK ##########" | ||
|
||
if [ "$launch" = "true" ]; then | ||
open $url | ||
echo "########## KAppNav UI is launched at url $url ##########" | ||
fi | ||
|
||
|