From d395ca100af45f7f869070c1bfa6db2f574705e8 Mon Sep 17 00:00:00 2001 From: aurea munoz Date: Fri, 4 Oct 2019 15:41:42 +0200 Subject: [PATCH] feat: add the script (from @cmoulliard) to execute rhte scenario automatically --- README.md | 3 ++ end-to-end.sh | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 end-to-end.sh diff --git a/README.md b/README.md index 9d92df7..57e7a94 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,9 @@ kubectl get ingress/hello-world Copy/paste the address displayed within the terminal in a browser and say Hello world 😉 +## Tests + +The script `end-to-end.sh` allows to execute automatically a test end to end given a valid connection to an Openshift cluster where a Halkyon operator is installed. ## Additional documentation diff --git a/end-to-end.sh b/end-to-end.sh new file mode 100644 index 0000000..ddd9384 --- /dev/null +++ b/end-to-end.sh @@ -0,0 +1,119 @@ +oc new-project test + +cd ~/Temp +echo "########################" +echo "#### Create Test project at this path: $(pwd)" +echo "########################" +mkdir test && cd test + +echo "########################" +echo "#### Create Pom parent file" +echo "########################" +cat < pom.xml + + + 4.0.0 + me.fruitstand + parent + 1.0.0-SNAPSHOT + Spring Boot - Demo + Spring Boot - Demo + pom + + fruit-backend-sb + fruit-client-sb + + +EOF + +echo "########################" +echo "#### Scaffold projects" +echo "########################" + +hal component spring-boot \ + -i fruit-backend-sb \ + -g me.fruitsand \ + -p me.fruitsand.demo \ + -s 2.1.6.RELEASE \ + -t crud \ + -v 1.0.0-SNAPSHOT \ + --supported=false \ + fruit-backend-sb + + hal component spring-boot \ + -i fruit-client-sb \ + -g me.fruitsand \ + -p me.fruitsand.demo \ + -s 2.1.6.RELEASE \ + -t client \ + -v 1.0.0-SNAPSHOT \ + --supported=false \ + fruit-client-sb + +echo "########################" +echo "#### Maven package" +echo "########################" +mvn package -f fruit-client-sb +mvn package -f fruit-backend-sb -Pkubernetes + +echo "########################" +echo "#### Create component" +echo "########################" +hal component create -c fruit-client-sb +hal component create -c fruit-backend-sb + +echo "########################" +echo "#### Create Capability" +echo "########################" +hal capability create -n postgres-db -g database -t postgres -v 10 -p DB_NAME=sample-db -p DB_PASSWORD=admin -p DB_USER=admin +sleep 15s + +echo "########################" +echo "#### Link" +echo "########################" +hal link create -n backend-to-db -t fruit-backend-sb -s postgres-db-config +hal link create -n client-to-backend -t fruit-client-sb -e KUBERNETES_ENDPOINT_FRUIT=http://fruit-backend-sb:8080/api/fruits + +echo "########################" +echo "#### Push" +echo "########################" +sleep 60s + +hal component push -c fruit-client-sb +# PROJECT=fruit-client-sb +# NAMESPACE=test +# POD_ID=$(oc get pod -lapp=$PROJECT -n $NAMESPACE -o name | awk -F '/' '{print $2}') +# oc cp $PROJECT/pom.xml $POD_ID:/usr/src/ -n $NAMESPACE +# oc cp $PROJECT/src $POD_ID:/usr/src/ -n $NAMESPACE +# oc exec $POD_ID -n $NAMESPACE /var/lib/supervisord/bin/supervisord ctl start build +# oc exec $POD_ID -n $NAMESPACE /var/lib/supervisord/bin/supervisord ctl start run + +hal component push -c fruit-backend-sb +# PROJECT=fruit-backend-sb +# NAMESPACE=test +# POD_ID=$(oc get pod -lapp=$PROJECT -n $NAMESPACE -o name | awk -F '/' '{print $2}') +# oc cp $PROJECT/pom.xml $POD_ID:/usr/src/ -n $NAMESPACE +# oc cp $PROJECT/src $POD_ID:/usr/src/ -n $NAMESPACE +# oc exec $POD_ID -n $NAMESPACE /var/lib/supervisord/bin/supervisord ctl start build +# oc exec $POD_ID -n $NAMESPACE /var/lib/supervisord/bin/supervisord ctl start run + +echo "########################" +echo "#### Wait and call endpoint" +echo "########################" +sleep 120s +BACKEND_URL=$(oc get routes/fruit-backend-sb --template={{.spec.host}}) +http -s solarized POST "http://${BACKEND_URL}/api/fruits" name=Orange +http -s solarized POST "http://${BACKEND_URL}/api/fruits" name=Banana +http -s solarized POST "http://${BACKEND_URL}/api/fruits" name=Pineapple +http -s solarized POST "http://${BACKEND_URL}/api/fruits" name=Apple +http -s solarized POST "http://${BACKEND_URL}/api/fruits" name=Pear + +FRONTEND_URL=$(oc get routes/fruit-client-sb --template={{.spec.host}}) +http "http://${FRONTEND_URL}/api/client" -s solarized + +echo "########################" +echo "#### Delete" +echo "########################" +oc delete all --all -n test +cd .. && rm -rf test \ No newline at end of file