|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +OUTER_LOOP_TEST_NAMESPACE='outer-loop-test' |
| 4 | + |
| 5 | +mkdir outer-loop-test-dir |
| 6 | +cd outer-loop-test-dir |
| 7 | + |
| 8 | +echo -e "\n> Clone application-stack-intro project" |
| 9 | +git clone https://github.com/OpenLiberty/application-stack-intro.git |
| 10 | +cd application-stack-intro |
| 11 | + |
| 12 | +echo -e "\n> Copy Dockerfile" |
| 13 | +cp ../../generated/Dockerfile Dockerfile |
| 14 | + |
| 15 | +echo -e "\n> Copy app-deploy.yaml" |
| 16 | +cp ../../templates/outer-loop/app-deploy.yaml app-deploy.yaml |
| 17 | + |
| 18 | +echo -e "\n> Create new odo project" |
| 19 | +odo project create ${OUTER_LOOP_TEST_NAMESPACE} |
| 20 | + |
| 21 | +### This is only needed if the Minikube driver is "docker". As of now, we are using diver=none or "bare metal" |
| 22 | +### which allows Minikube to use the local docker registry |
| 23 | +#echo -e "\n Use the Minikube image registry" |
| 24 | +#eval $(minikube docker-env) |
| 25 | + |
| 26 | +echo -e "\n> Build Docker image" |
| 27 | +sed -i '/COPY --from=compile/a RUN true' Dockerfile |
| 28 | +docker build -t outerloop/application-stack-intro:1.0 . |
| 29 | + |
| 30 | +echo -e "\n> Replace variables in app-deploy.yaml" |
| 31 | +sed -i 's/{{\.PORT}}/9080/g' app-deploy.yaml |
| 32 | +sed -i 's/{{\.COMPONENT_NAME}}/my-ol-deployment/g' app-deploy.yaml |
| 33 | +sed -i 's/{{\.CONTAINER_IMAGE}}/outerloop\/application-stack-intro:1\.0/g' app-deploy.yaml |
| 34 | + |
| 35 | +echo -e "\n> Install Open Liberty Operator" |
| 36 | +kubectl apply -f https://raw.githubusercontent.com/OpenLiberty/open-liberty-operator/master/deploy/releases/0.7.0/openliberty-app-crd.yaml |
| 37 | +curl -L https://raw.githubusercontent.com/OpenLiberty/open-liberty-operator/master/deploy/releases/0.7.0/openliberty-app-operator.yaml \ |
| 38 | + | sed -e "s/OPEN_LIBERTY_WATCH_NAMESPACE/${OUTER_LOOP_TEST_NAMESPACE}/" \ |
| 39 | + | kubectl apply -n ${OUTER_LOOP_TEST_NAMESPACE} -f - |
| 40 | + |
| 41 | +echo -e "\n> Wait for operator pod to start" |
| 42 | +count=1 |
| 43 | +while [[ $(kubectl get pods -l name=open-liberty-operator -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" && $count -lt 20 ]]; do |
| 44 | + kubectl get pods |
| 45 | + echo "waiting for operator pod" && sleep 3; |
| 46 | + count=`expr $count + 1` |
| 47 | +done |
| 48 | +if [ $count -eq 20 ]; then |
| 49 | + echo "Timed out waiting for operator pod to start" |
| 50 | + kubectl describe pods -l name=open-liberty-operator |
| 51 | + exit 12 |
| 52 | +fi |
| 53 | + |
| 54 | +echo -e "\n> Deploy image" |
| 55 | +cat app-deploy.yaml |
| 56 | +kubectl apply -f app-deploy.yaml |
| 57 | + |
| 58 | +echo -e "\n> Wait for pod to start" |
| 59 | +count=1 |
| 60 | +while [[ $(kubectl get pods -l app.kubernetes.io/name=my-ol-deployment -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" && $count -lt 20 ]]; do |
| 61 | + kubectl get pods |
| 62 | + echo "waiting for pod" && sleep 3; |
| 63 | + count=`expr $count + 1` |
| 64 | +done |
| 65 | +if [ $count -eq 20 ]; then |
| 66 | + echo "Timed out waiting for pod to start" |
| 67 | + kubectl describe pods -l app.kubernetes.io/name=my-ol-deployment |
| 68 | + exit 12 |
| 69 | +fi |
| 70 | + |
| 71 | +echo -e "\n> Test liveness endpoint" |
| 72 | +livenessResults=$(curl http://my-ol-deployment.$(minikube ip).nip.io/health/live) |
| 73 | +if echo $livenessResults | grep -qF '{"checks":[{"data":{},"name":"SampleLivenessCheck","status":"UP"}],"status":"UP"}'; then |
| 74 | + |
| 75 | + echo "Liveness check passed!" |
| 76 | +else |
| 77 | + echo "Liveness check failed. Liveness endpoint returned: " |
| 78 | + echo $livenessResults |
| 79 | + exit 12 |
| 80 | +fi |
| 81 | + |
| 82 | +echo -e "\n> Test readiness endpoint" |
| 83 | +readinessResults=$(curl http://my-ol-deployment.$(minikube ip).nip.io/health/ready) |
| 84 | +if echo $readinessResults | grep -qF '{"checks":[{"data":{},"name":"SampleReadinessCheck","status":"UP"}],"status":"UP"}'; then |
| 85 | + |
| 86 | + echo "Readiness check passed!" |
| 87 | +else |
| 88 | + echo "Readiness check failed! Readiness endpoint returned: " |
| 89 | + echo $readinessResults |
| 90 | + exit 12 |
| 91 | +fi |
| 92 | + |
| 93 | +echo -e "\n> Test REST endpoint" |
| 94 | +restResults=$(curl http://my-ol-deployment.$(minikube ip).nip.io/health/live) |
| 95 | +if ! echo $restResults | grep -qF 'Hello! Welcome to Open Liberty'; then |
| 96 | + |
| 97 | + echo "REST endpoint check passed!" |
| 98 | +else |
| 99 | + echo "REST endpoint check failed. REST endpoint returned: " |
| 100 | + echo $restResults |
| 101 | + exit 12 |
| 102 | +fi |
0 commit comments