Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the script (from @cmoulliard) to execute rhte scenario automatically #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need also kubedb. I suggest that you add the link about how to install halkyon from the halkyon project. ... where a Halkyon operator is installed -> where a Halkyon operator is installed - see doc = link


## Additional documentation

Expand Down
119 changes: 119 additions & 0 deletions end-to-end.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF > pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.fruitstand</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Spring Boot - Demo</name>
<description>Spring Boot - Demo</description>
<packaging>pom</packaging>
<modules>
<module>fruit-backend-sb</module>
<module>fruit-client-sb</module>
</modules>
</project>
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
Comment on lines +84 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comments


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
Comment on lines +93 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comments


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment top of the README file to explain that curl or httpie (depending which one is used) must be installed.

!! Be carefull as this script will not test the endpoint to check if the output matches our expectation. Such step is part of the circleci end to end script used on halkyon operator

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