99#
1010# Parameters
1111# 1 - the name of the qs directory (not the full path)
12+ #
1213function applicationName() {
1314 echo " ${1} "
1415}
@@ -20,6 +21,7 @@ function applicationName() {
2021#
2122# Parameters
2223# 1 - the name of the qs directory
24+ #
2325function namespace() {
2426 application=" ${1} "
2527 # Uncomment to make the tests run in the 'testing' namespace
@@ -32,6 +34,7 @@ function namespace() {
3234#
3335# Parameters
3436# 1 - application name
37+ #
3538function installPrerequisites()
3639{
3740 application=" ${1} "
@@ -43,12 +46,35 @@ function installPrerequisites()
4346#
4447# Parameters
4548# 1 - application name
49+ #
4650function cleanPrerequisites()
4751{
4852 application=" ${1} "
4953 echo " No prerequisites to clean for ${application} "
5054}
5155
56+ # Provision server and push imagestream
57+ # The current directory is the quickstart directory
58+ #
59+ # Parameters
60+ # 1 - application name
61+ # 2 - quickstart dir
62+ #
63+ function provisionServer()
64+ {
65+ application=" ${1} "
66+ qs_dir=" ${2} "
67+
68+ echo " Building application and provisioning server image..."
69+ mvn -B package -Popenshift wildfly:image -DskipTests
70+
71+ echo " Tagging image and pushing to registry..."
72+ export root_image_name=" localhost:5000/${application} "
73+ export image=" ${root_image_name} :latest"
74+ docker tag ${qs_dir} ${image}
75+ docker push ${image}
76+ }
77+
5278# Performs the 'helm install' command.
5379# The current directory is the quickstart directory
5480# Parameters
@@ -61,15 +87,33 @@ function cleanPrerequisites()
6187# * helm_install_timeout - the adjusted timeout for the helm install
6288#
6389function helmInstall() {
64- application=" ${1} "
65- helm_set_arguments=" $2 "
66-
67- # '--wait' waits until the pods are ready
68- # `--timeout` sets the timeout for the wait.
69- # https://helm.sh/docs/helm/helm_install/ has more details
70- # Don't quote ${helm_set_arguments} since then it fails when there are none
71- helm install " ${application} " wildfly/wildfly -f charts/helm.yaml --wait --timeout=${helm_install_timeout} ${helm_set_arguments}
72- echo " $? "
90+ application=" ${1} "
91+ helm_set_arg_prefix=" ${2} "
92+ helm_install_timeout=" ${3} "
93+
94+ # Helm install, waiting for the pods to come up
95+ helm_set_arguments=" --set ${helm_set_arg_prefix} build.enabled=false --set ${helm_set_arg_prefix} deploy.route.enabled=false --set ${helm_set_arg_prefix} image.name=${root_image_name} "
96+
97+ additional_arguments=" No additional arguments"
98+ if [ -n " ${helm_set_arguments} " ]; then
99+ additional_arguments=" Additional arguments: ${helm_set_arguments} "
100+ fi
101+
102+ echo " Performing Helm install and waiting for completion.... (${additional_arguments} )"
103+
104+ # '--wait' waits until the pods are ready
105+ # `--timeout` sets the timeout for the wait.
106+ # https://helm.sh/docs/helm/helm_install/ has more details
107+ # Don't quote ${helm_set_arguments} since then it fails when there are none
108+ helm install " ${application} " wildfly/wildfly -f charts/helm.yaml --wait --timeout=${helm_install_timeout} ${helm_set_arguments}
109+
110+ echo " ret: $? "
111+ if [ " $? " != " 0" ]; then
112+ echo " Helm install failed!"
113+ echo " Dumping the application pod(s)"
114+ kubectl logs deployment/" ${application} "
115+ helmInstallFailed
116+ fi
73117}
74118
75119# Commands to run once the Helm install has completed
@@ -106,10 +150,70 @@ function helmInstallFailed() {
106150 echo " "
107151}
108152
153+ # Port forward to test the quickstart
154+ # Parameters
155+ # 1 - application name
156+ #
157+ function portForward() {
158+ application=" ${1} "
159+
160+ kubectl port-forward service/${application} 8080:8080 &
161+ kubectl_fwd_pid=$!
162+ echo " ${kubectl_fwd_pid} "
163+ }
164+
165+ # Running tests of the quickstart
166+ # Parameters
167+ # 1 - application name
168+ # 2 - server protocol
169+ # 3 - extra maven argument for the verify target
170+ #
171+ function runningTests() {
172+ application=" ${1} "
173+ server_protocol=" ${2} "
174+ extraMvnVerifyArguments=" ${3} "
175+
176+ route=" localhost:8080"
177+
178+ mvnVerifyArguments=" -Dserver.host=${server_protocol} ://${route} "
179+ if [ -n " ${extraMvnVerifyArguments} " ]; then
180+ mvnVerifyArguments=" ${mvnVerifyArguments} ${extraMvnVerifyArguments} "
181+ fi
182+ if [ " ${QS_DEBUG_TESTS} " = " 1" ]; then
183+ mvnVerifyArguments=" ${mvnVerifyArguments} -Dmaven.failsafe.debug=true"
184+ fi
185+
186+ echo " Verify Arguments: ${mvnVerifyArguments} "
187+
188+ mvn -B verify -Pintegration-testing ${mvnVerifyArguments}
189+
190+ test_status=" $? "
191+
192+ if [ " $? " != " 0" ]; then
193+ test_status=1
194+ echo " Tests failed!"
195+ echo " Dumping the application pod(s)"
196+ kubectl logs deployment/" ${application} "
197+ testsFailed
198+ fi
199+
200+ echo " ${test_status} "
201+ }
202+
203+ # Performs the 'helm uninstall' command.
204+ # Parameters
205+ # 1 - application name
206+ #
207+ function helmUninstall() {
208+ application=" ${1} "
209+
210+ helm uninstall " ${application} " --wait --timeout=10m0s
211+ }
212+
109213# More output when the tests have failed
110214# Parameters
111215# 1 - application name
112216#
113217function testsFailed() {
114218 echo " "
115- }
219+ }
0 commit comments