From 79ef8f729abd819075467588ea3a5853ec8e50fa Mon Sep 17 00:00:00 2001 From: juniartisu Date: Wed, 19 Feb 2020 11:33:44 -0600 Subject: [PATCH 1/4] Issue1060: drop test setup scripts --- setupKAppNavTestEnv.sh | 171 ++++++++++++++++++ test/installBookinfo.sh | 19 ++ test/installLibertyInContainer.sh | 19 ++ test/installStocktrader.sh | 21 +++ test/isAdminCenterUIOK.sh | 39 ++++ test/isDeployed.sh | 19 ++ test/isKAppNavHealthy.sh | 69 +++++++ test/isKappnavUIOK.sh | 39 ++++ .../kappnav-websphere-liberty.yaml | 81 +++++++++ 9 files changed, 477 insertions(+) create mode 100755 setupKAppNavTestEnv.sh create mode 100755 test/installBookinfo.sh create mode 100755 test/installLibertyInContainer.sh create mode 100755 test/installStocktrader.sh create mode 100755 test/isAdminCenterUIOK.sh create mode 100755 test/isDeployed.sh create mode 100755 test/isKAppNavHealthy.sh create mode 100755 test/isKappnavUIOK.sh create mode 100644 test/twas-liberty/kappnav-websphere-liberty.yaml diff --git a/setupKAppNavTestEnv.sh b/setupKAppNavTestEnv.sh new file mode 100755 index 0000000..5601611 --- /dev/null +++ b/setupKAppNavTestEnv.sh @@ -0,0 +1,171 @@ +#!/bin/bash +#################################################### +# +# setupTestEnv.sh for 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 "================================================================" + echo "===> Note: this script is for use for IBM Development only! <===" + echo "================================================================" + echo "This script required 5 positional parameters" + echo "Syntax: setupTestEnv.sh " + echo + echo "Where:" + echo + echo " specifies the target URL" + echo " specifies the target username" + echo " specifies the target password" + echo " specifies one of: okd, ocp, minishift or minikube. Default is okd" + echo " 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 + rc=$? + if [ $rc -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 +rc=$? +if [ $rc -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 +rc=$? +if [ $rc -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 +rc=$? +if [ $rc -eq 0 ]; then + echo "########## Install successfully. ##########" +else + echo "########## Install failed, exiting. ##########" + exit 1 +fi + +# check to make sure KAppNav healthy +./test/isKAppNavHealthy.sh kappnav +if [ $rc -ne 0 ]; then + exit 1 +fi + +# check to hit kappnavui url +./test/isKappnavUIOK.sh kappnav $platform +if [ $rc -ne 0 ]; then + exit 1 +fi + +# install sample stocktrader application +./test/installStocktrader.sh kappnav +if [ $rc -ne 0 ]; then + exit 1 +fi + +# install sample bookinfo application +./test/installBookinfo.sh kappnav +if [ $rc -ne 0 ]; then + exit 1 +fi + +# install websphere liberty in container +./test/installLibertyInContainer.sh kappnav +if [ $rc -ne 0 ]; then + 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 + + + + + + + + + + + diff --git a/test/installBookinfo.sh b/test/installBookinfo.sh new file mode 100755 index 0000000..c3f88b0 --- /dev/null +++ b/test/installBookinfo.sh @@ -0,0 +1,19 @@ +isKAppNav=$1 + +echo "kubectl create namespace bookinfo" +kubectl create namespace bookinfo + +if [ x$isKAppNav == 'x' ]; then + echo "kubectl apply -f tmpbuild/samples/bookinfo -n bookinfo" + kubectl apply -f tmpbuild/samples/bookinfo -n bookinfo +else + echo "kubectl apply -f ../../samples/bookinfo -n bookinfo" + kubectl apply -f ../samples/bookinfo -n bookinfo +fi + +if [ $? -eq 0 ]; then + echo "########## Bookinfo sample application installed successfully ##########" +else + echo "########## Failed to install bookinfo sample application ##########" + exit 1 +fi diff --git a/test/installLibertyInContainer.sh b/test/installLibertyInContainer.sh new file mode 100755 index 0000000..e6b75b2 --- /dev/null +++ b/test/installLibertyInContainer.sh @@ -0,0 +1,19 @@ +isKAppNav=$1 + +echo "kubectl create namespace localliberty" +kubectl create namespace localliberty + +if [ x$isKAppNav == 'x' ]; then + echo "kubectl apply -f tmpbuild/test/twas-liberty/kappnav-websphere-liberty -n localliberty" + kubectl apply -f tmpbuild/test/twas-liberty/kappnav-websphere-liberty.yaml -n localliberty +else + echo "kubectl apply -f ../test/twas-liberty/kappnav-websphere-liberty -n localliberty" + kubectl apply -f test/twas-liberty/kappnav-websphere-liberty.yaml -n localliberty +fi + +if [ $? -eq 0 ]; then + echo "########## WebSphere Liberty in container installed successfully ##########" +else + echo "########## Failed to install WebSphere Liberty in container ##########" + exit 1 +fi diff --git a/test/installStocktrader.sh b/test/installStocktrader.sh new file mode 100755 index 0000000..25741cc --- /dev/null +++ b/test/installStocktrader.sh @@ -0,0 +1,21 @@ +isKAppNav=$1 + +echo "kubectl create namespace stocktrader" +kubectl create namespace stocktrader + +if [ x$isKAppNav == 'x' ]; then + echo "kubectl apply -f tmpbuild/samples/stocktrader -n stocktrader" + kubectl apply -f tmpbuild/samples/stocktrader -n stocktrader +else + echo "kubectl apply -f ../../samples/stocktrader -n stocktrader" + kubectl apply -f ../samples/stocktrader -n stocktrader +fi + +if [ $? -eq 0 ]; then + 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 \ No newline at end of file diff --git a/test/isAdminCenterUIOK.sh b/test/isAdminCenterUIOK.sh new file mode 100755 index 0000000..66097b8 --- /dev/null +++ b/test/isAdminCenterUIOK.sh @@ -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 [true|false]" + echo "Where:" + echo " specifies the namespace where AppNav is installed." + echo " 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 + + diff --git a/test/isDeployed.sh b/test/isDeployed.sh new file mode 100755 index 0000000..8c2de90 --- /dev/null +++ b/test/isDeployed.sh @@ -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 \ + echo "Where:" + echo " 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 diff --git a/test/isKAppNavHealthy.sh b/test/isKAppNavHealthy.sh new file mode 100755 index 0000000..03c4f7e --- /dev/null +++ b/test/isKAppNavHealthy.sh @@ -0,0 +1,69 @@ +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 \ + echo "Where:" + echo " specifies the namespace where AppNav is installed." + exit 1 +fi + +namespace=$1 + +# 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 4 KAppNav pods created +count=0 +numPods=4 +if [ x$namespace == x'kappnav' ]; then + numPods=3 +fi + +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 + if [ $count -eq 60 ]; 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 + # check to make sure the apps created for 5 minutes at the most with 5s delay in between checking + sleep 5 + fi + count=$((count+1)) + fi + echo "Status : $status" + done +done + +echo "########## KAppNav pods are healthy ##########" + + + + + diff --git a/test/isKappnavUIOK.sh b/test/isKappnavUIOK.sh new file mode 100755 index 0000000..209143b --- /dev/null +++ b/test/isKappnavUIOK.sh @@ -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 [true|false]" + echo "Where:" + echo " specifies the namespace where KAppNav is installed." + echo " 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 + + diff --git a/test/twas-liberty/kappnav-websphere-liberty.yaml b/test/twas-liberty/kappnav-websphere-liberty.yaml new file mode 100644 index 0000000..6904f17 --- /dev/null +++ b/test/twas-liberty/kappnav-websphere-liberty.yaml @@ -0,0 +1,81 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + annotations: + kappnav.subkind: liberty + name: websphere-liberty + labels: + app: websphere-liberty + app.kubernetes.io/component: websphere-liberty + app.kubernetes.io/instance: websphere-liberty + app.kubernetes.io/part-of: websphere-liberty + kappnav.actions.admincenter: admincenter + solution: stock-trader +spec: + selector: + matchLabels: + app: websphere-liberty + template: + metadata: + labels: + app: websphere-liberty + deploymentconfig: websphere-liberty + spec: + containers: + - name: websphere-liberty + ports: + - containerPort: 9100 + protocol: TCP + - containerPort: 9500 + protocol: TCP + image: docker.io/juniarti/websphere-liberty-admincenter:latest + imagePullPolicy: Always + restartPolicy: Always + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + schedulerName: default-scheduler + +--- + +kind: Service +apiVersion: v1 +metadata: + name: websphere-liberty + labels: + app: websphere-liberty +spec: + ports: + - name: 9100-tcp + protocol: TCP + port: 9100 + targetPort: 9100 + - name: 9500-tcp + protocol: TCP + port: 9500 + targetPort: 9500 + selector: + app: websphere-liberty + deploymentconfig: websphere-liberty + type: ClusterIP + +--- + +kind: Route +apiVersion: route.openshift.io/v1 +metadata: + name: websphere-liberty + labels: + app: websphere-liberty +spec: + to: + kind: Service + name: websphere-liberty + weight: 100 + port: + targetPort: 9500-tcp + tls: + termination: passthrough + wildcardPolicy: None + + + \ No newline at end of file From ad8a43712365d2729195e11b20c5f7a85bead505 Mon Sep 17 00:00:00 2001 From: juniartisu Date: Wed, 19 Feb 2020 15:27:10 -0600 Subject: [PATCH 2/4] increase the pod ready check to 10 minutes --- setupKAppNavTestEnv.sh | 24 ++++++++++-------------- test/isKAppNavHealthy.sh | 4 ++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/setupKAppNavTestEnv.sh b/setupKAppNavTestEnv.sh index 5601611..0863f1f 100755 --- a/setupKAppNavTestEnv.sh +++ b/setupKAppNavTestEnv.sh @@ -1,7 +1,7 @@ #!/bin/bash #################################################### # -# setupTestEnv.sh for Application Navigator +# setupKAppNavTestEnv.sh for Kubernetes Application Navigator # #################################################### @@ -44,8 +44,7 @@ else # login to target platform echo "oc login -u $platformUsername -p $platformPassword $platformURL" oc login -u $platformUsername -p $platformPassword $platformURL - rc=$? - if [ $rc -eq 0 ]; then + if [ $? -eq 0 ]; then echo "########## OC login successfully. ##########" else echo "########## OC login failed, exiting. ##########" @@ -90,8 +89,7 @@ fi # build kappnav echo "########## Building KAppNav ########## " ./build.sh -rc=$? -if [ $rc -eq 0 ]; then +if [ $? -eq 0 ]; then echo "########## Build successfully. ##########" else echo "########## Build failed, exiting. ##########" @@ -101,8 +99,7 @@ fi # push all images to docker hub echo "########## Pushing all KAppNav images to docker hub of $dockerID ########## " ./pushimages.sh $dockerID -rc=$? -if [ $rc -eq 0 ]; then +if [ $? -eq 0 ]; then echo "########## Pushed KAppNav images successfully. ##########" else echo "########## Pushed KAppNav images failed, exiting. ##########" @@ -111,8 +108,7 @@ fi # installing to target platform ./install.sh $dockerID $platform -rc=$? -if [ $rc -eq 0 ]; then +if [ $? -eq 0 ]; then echo "########## Install successfully. ##########" else echo "########## Install failed, exiting. ##########" @@ -121,31 +117,31 @@ fi # check to make sure KAppNav healthy ./test/isKAppNavHealthy.sh kappnav -if [ $rc -ne 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi # check to hit kappnavui url ./test/isKappnavUIOK.sh kappnav $platform -if [ $rc -ne 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi # install sample stocktrader application ./test/installStocktrader.sh kappnav -if [ $rc -ne 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi # install sample bookinfo application ./test/installBookinfo.sh kappnav -if [ $rc -ne 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi # install websphere liberty in container ./test/installLibertyInContainer.sh kappnav -if [ $rc -ne 0 ]; then +if [ $? -ne 0 ]; then exit 1 fi diff --git a/test/isKAppNavHealthy.sh b/test/isKAppNavHealthy.sh index 03c4f7e..50e1073 100755 --- a/test/isKAppNavHealthy.sh +++ b/test/isKAppNavHealthy.sh @@ -46,13 +46,13 @@ do count=0 while [ "$status" = "false" ] do - if [ $count -eq 60 ]; then + # 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 - # check to make sure the apps created for 5 minutes at the most with 5s delay in between checking sleep 5 fi count=$((count+1)) From 67de0ec650c145d2efc39a61d178a1317149a5cc Mon Sep 17 00:00:00 2001 From: juniartisu Date: Wed, 19 Feb 2020 20:24:24 -0600 Subject: [PATCH 3/4] add error msg on exit --- setupKAppNavTestEnv.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setupKAppNavTestEnv.sh b/setupKAppNavTestEnv.sh index 0863f1f..5da1916 100755 --- a/setupKAppNavTestEnv.sh +++ b/setupKAppNavTestEnv.sh @@ -118,30 +118,35 @@ fi # check to make sure KAppNav healthy ./test/isKAppNavHealthy.sh kappnav 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 kappnav if [ $? -ne 0 ]; then + echo "########## installStocktrader failed, exiting ##########" exit 1 fi # install sample bookinfo application ./test/installBookinfo.sh kappnav if [ $? -ne 0 ]; then + echo "########## installBookinfo failed, exiting ##########" exit 1 fi # install websphere liberty in container ./test/installLibertyInContainer.sh kappnav if [ $? -ne 0 ]; then + echo "########## installLibertyInContainer failed, exiting ##########" exit 1 fi From 88d83b161cca6ae8469c84a40c8a2c414d2e7775 Mon Sep 17 00:00:00 2001 From: juniartisu Date: Fri, 21 Feb 2020 15:50:30 -0600 Subject: [PATCH 4/4] code review update --- setupKAppNavTestEnv.sh | 16 +--- test/installBookinfo.sh | 25 ++++-- test/installLibertyInContainer.sh | 19 ----- test/installStocktrader.sh | 26 ++++-- test/isKAppNavHealthy.sh | 15 ++-- .../kappnav-websphere-liberty.yaml | 81 ------------------- 6 files changed, 47 insertions(+), 135 deletions(-) delete mode 100755 test/installLibertyInContainer.sh delete mode 100644 test/twas-liberty/kappnav-websphere-liberty.yaml diff --git a/setupKAppNavTestEnv.sh b/setupKAppNavTestEnv.sh index 5da1916..0ee1ba9 100755 --- a/setupKAppNavTestEnv.sh +++ b/setupKAppNavTestEnv.sh @@ -7,9 +7,6 @@ # 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 "================================================================" - echo "===> Note: this script is for use for IBM Development only! <===" - echo "================================================================" echo "This script required 5 positional parameters" echo "Syntax: setupTestEnv.sh " echo @@ -116,7 +113,7 @@ else fi # check to make sure KAppNav healthy -./test/isKAppNavHealthy.sh kappnav +./test/isKAppNavHealthy.sh kappnav 3 if [ $? -ne 0 ]; then echo "########## isKAppNavHealthy failed, exiting ##########" exit 1 @@ -130,26 +127,19 @@ if [ $? -ne 0 ]; then fi # install sample stocktrader application -./test/installStocktrader.sh kappnav +./test/installStocktrader.sh ../samples/stocktrader if [ $? -ne 0 ]; then echo "########## installStocktrader failed, exiting ##########" exit 1 fi # install sample bookinfo application -./test/installBookinfo.sh kappnav +./test/installBookinfo.sh ../samples/bookinfo if [ $? -ne 0 ]; then echo "########## installBookinfo failed, exiting ##########" exit 1 fi -# install websphere liberty in container -./test/installLibertyInContainer.sh kappnav -if [ $? -ne 0 ]; then - echo "########## installLibertyInContainer 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 diff --git a/test/installBookinfo.sh b/test/installBookinfo.sh index c3f88b0..48bcc6d 100755 --- a/test/installBookinfo.sh +++ b/test/installBookinfo.sh @@ -1,15 +1,24 @@ -isKAppNav=$1 +#!/bin/bash +#################################################### +# +# installBookinfo.sh +# +#################################################### + +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 \ + echo "Where:" + echo " specifies the path where bookinfo sample located" + exit 1 +fi + +bookinfoPath=$1 echo "kubectl create namespace bookinfo" kubectl create namespace bookinfo -if [ x$isKAppNav == 'x' ]; then - echo "kubectl apply -f tmpbuild/samples/bookinfo -n bookinfo" - kubectl apply -f tmpbuild/samples/bookinfo -n bookinfo -else - echo "kubectl apply -f ../../samples/bookinfo -n bookinfo" - kubectl apply -f ../samples/bookinfo -n bookinfo -fi +echo "kubectl apply -f $bookinfoPath -n bookinfo" +kubectl apply -f $bookinfoPath -n bookinfo if [ $? -eq 0 ]; then echo "########## Bookinfo sample application installed successfully ##########" diff --git a/test/installLibertyInContainer.sh b/test/installLibertyInContainer.sh deleted file mode 100755 index e6b75b2..0000000 --- a/test/installLibertyInContainer.sh +++ /dev/null @@ -1,19 +0,0 @@ -isKAppNav=$1 - -echo "kubectl create namespace localliberty" -kubectl create namespace localliberty - -if [ x$isKAppNav == 'x' ]; then - echo "kubectl apply -f tmpbuild/test/twas-liberty/kappnav-websphere-liberty -n localliberty" - kubectl apply -f tmpbuild/test/twas-liberty/kappnav-websphere-liberty.yaml -n localliberty -else - echo "kubectl apply -f ../test/twas-liberty/kappnav-websphere-liberty -n localliberty" - kubectl apply -f test/twas-liberty/kappnav-websphere-liberty.yaml -n localliberty -fi - -if [ $? -eq 0 ]; then - echo "########## WebSphere Liberty in container installed successfully ##########" -else - echo "########## Failed to install WebSphere Liberty in container ##########" - exit 1 -fi diff --git a/test/installStocktrader.sh b/test/installStocktrader.sh index 25741cc..17ef9c0 100755 --- a/test/installStocktrader.sh +++ b/test/installStocktrader.sh @@ -1,17 +1,27 @@ -isKAppNav=$1 +#!/bin/bash +#################################################### +# +# installStocktrader.sh +# +#################################################### + +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 \ + echo "Where:" + echo " specifies the path where stocktrader sample located" + exit 1 +fi + +stocktraderPath=$1 echo "kubectl create namespace stocktrader" kubectl create namespace stocktrader -if [ x$isKAppNav == 'x' ]; then - echo "kubectl apply -f tmpbuild/samples/stocktrader -n stocktrader" - kubectl apply -f tmpbuild/samples/stocktrader -n stocktrader -else - echo "kubectl apply -f ../../samples/stocktrader -n stocktrader" - kubectl apply -f ../samples/stocktrader -n stocktrader -fi +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 ##########" diff --git a/test/isKAppNavHealthy.sh b/test/isKAppNavHealthy.sh index 50e1073..31d2a82 100755 --- a/test/isKAppNavHealthy.sh +++ b/test/isKAppNavHealthy.sh @@ -1,3 +1,10 @@ +#!/bin/bash +#################################################### +# +# isKAppNavHealthy.sh +# +#################################################### + 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 \ echo "Where:" @@ -6,6 +13,7 @@ if [ "$#" -lt 1 ] || [ x$1 = 'x' ] || [ x$1 = x'?' ] || [ x$1 = x'--?' ] || [ fi namespace=$1 +numPods=$2 # get all KAppNav pods echo "kubectl get pods -n $namespace --no-headers -o custom-columns=NAME:.metadata.name" @@ -14,13 +22,8 @@ echo $kappnavPods kappnavPodsArray=( $kappnavPods ) kappnavPodsLen="${#kappnavPodsArray[@]}" -# check to make sure all 4 KAppNav pods created +# check to make sure all KAppNav pods created count=0 -numPods=4 -if [ x$namespace == x'kappnav' ]; then - numPods=3 -fi - while [ $kappnavPodsLen -ne $numPods ] do if [ $count -eq 12 ]; then diff --git a/test/twas-liberty/kappnav-websphere-liberty.yaml b/test/twas-liberty/kappnav-websphere-liberty.yaml deleted file mode 100644 index 6904f17..0000000 --- a/test/twas-liberty/kappnav-websphere-liberty.yaml +++ /dev/null @@ -1,81 +0,0 @@ -kind: Deployment -apiVersion: apps/v1 -metadata: - annotations: - kappnav.subkind: liberty - name: websphere-liberty - labels: - app: websphere-liberty - app.kubernetes.io/component: websphere-liberty - app.kubernetes.io/instance: websphere-liberty - app.kubernetes.io/part-of: websphere-liberty - kappnav.actions.admincenter: admincenter - solution: stock-trader -spec: - selector: - matchLabels: - app: websphere-liberty - template: - metadata: - labels: - app: websphere-liberty - deploymentconfig: websphere-liberty - spec: - containers: - - name: websphere-liberty - ports: - - containerPort: 9100 - protocol: TCP - - containerPort: 9500 - protocol: TCP - image: docker.io/juniarti/websphere-liberty-admincenter:latest - imagePullPolicy: Always - restartPolicy: Always - terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - schedulerName: default-scheduler - ---- - -kind: Service -apiVersion: v1 -metadata: - name: websphere-liberty - labels: - app: websphere-liberty -spec: - ports: - - name: 9100-tcp - protocol: TCP - port: 9100 - targetPort: 9100 - - name: 9500-tcp - protocol: TCP - port: 9500 - targetPort: 9500 - selector: - app: websphere-liberty - deploymentconfig: websphere-liberty - type: ClusterIP - ---- - -kind: Route -apiVersion: route.openshift.io/v1 -metadata: - name: websphere-liberty - labels: - app: websphere-liberty -spec: - to: - kind: Service - name: websphere-liberty - weight: 100 - port: - targetPort: 9500-tcp - tls: - termination: passthrough - wildcardPolicy: None - - - \ No newline at end of file