Skip to content

Commit f636e00

Browse files
committed
[WFLY-19337] The GitHub Action to test ejb-txn-remote-call is now working
1 parent 18f4f17 commit f636e00

File tree

14 files changed

+491
-288
lines changed

14 files changed

+491
-288
lines changed

.github/workflows/scripts/kubernetes/core/excluded-directories.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33
# microprofile-reactive-messaging-kafka
44
# Can't connect to server... I see something relating to adding a user in the README but nothing in the OpenShift tests about this so it is odd
55
ejb-remote
6-
# Some problems once the operator is installed. I haven't been able to get my go environment set up to the same version
7-
ejb-txn-remote-call
86

.github/workflows/scripts/kubernetes/core/overridable-functions.sh

Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010
# Parameters
1111
# 1 - the name of the qs directory (not the full path)
12+
#
1213
function applicationName() {
1314
echo "${1}"
1415
}
@@ -20,6 +21,7 @@ function applicationName() {
2021
#
2122
# Parameters
2223
# 1 - the name of the qs directory
24+
#
2325
function 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+
#
3538
function installPrerequisites()
3639
{
3740
application="${1}"
@@ -43,12 +46,53 @@ function installPrerequisites()
4346
#
4447
# Parameters
4548
# 1 - application name
49+
#
4650
function cleanPrerequisites()
4751
{
4852
application="${1}"
4953
echo "No prerequisites to clean for ${application}"
5054
}
5155

56+
# Trigger the custom behaviour when it comes to
57+
# provision the server and push the imagestream.
58+
# Returns
59+
# 0 - false
60+
# 1 - true
61+
#
62+
function customProvisionServer() {
63+
echo 0
64+
}
65+
66+
# Provision server and push imagestream
67+
# The current directory is the quickstart directory
68+
#
69+
# Parameters
70+
# 1 - application name
71+
# 2 - quickstart dir
72+
#
73+
function provisionServer()
74+
{
75+
echo "Nothing to do in provisionServer()..."
76+
}
77+
78+
# Trigger a custom behaviour when it comes to
79+
# setting up the environment
80+
# Returns
81+
# 0 - false
82+
# 1 - true
83+
#
84+
function customDeploy() {
85+
echo 0
86+
}
87+
88+
# Set up the environment before testing
89+
# Parameters
90+
# 1 - application name
91+
#
92+
function deploy() {
93+
echo "Nothing to do in deploy()..."
94+
}
95+
5296
# Performs the 'helm install' command.
5397
# The current directory is the quickstart directory
5498
# Parameters
@@ -61,15 +105,7 @@ function cleanPrerequisites()
61105
# * helm_install_timeout - the adjusted timeout for the helm install
62106
#
63107
function 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 "$?"
108+
echo "Nothing to do in helmInstall()..."
73109
}
74110

75111
# Commands to run once the Helm install has completed
@@ -106,10 +142,68 @@ function helmInstallFailed() {
106142
echo ""
107143
}
108144

145+
# Trigger a custom behaviour when it comes to
146+
# forward ports
147+
# Returns
148+
# 0 - false
149+
# 1 - true
150+
#
151+
function customPortForward() {
152+
echo 0
153+
}
154+
155+
# Port forward to test the quickstart
156+
# Parameters
157+
# 1 - application name
158+
#
159+
function portForward() {
160+
echo "Nothing to do in portForward()..."
161+
}
162+
163+
# Trigger a custom behaviour when it comes to
164+
# running tests
165+
# Returns
166+
# 0 - false
167+
# 1 - true
168+
#
169+
function customRunningTests() {
170+
echo 0
171+
}
172+
173+
# Running tests of the quickstart
174+
# Parameters
175+
# 1 - application name
176+
# 2 - server protocol
177+
# 3 - extra maven argument for the verify target
178+
#
179+
function runningTests() {
180+
echo "Nothing to do in portForward()..."
181+
}
182+
183+
# Trigger a custom behaviour when it comes to
184+
# running tests
185+
# Returns
186+
# 0 - false
187+
# 1 - true
188+
#
189+
function customHelmUninstall() {
190+
echo 0
191+
}
192+
193+
# Performs the 'helm uninstall' command.
194+
# Parameters
195+
# 1 - application name
196+
#
197+
function helmUninstall() {
198+
application="${1}"
199+
200+
helm uninstall "${application}" --wait --timeout=10m0s
201+
}
202+
109203
# More output when the tests have failed
110204
# Parameters
111205
# 1 - application name
112206
#
113207
function testsFailed() {
114208
echo ""
115-
}
209+
}

.github/workflows/scripts/kubernetes/core/run-quickstart-test-on-kubernetes.sh

Lines changed: 88 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -76,49 +76,71 @@ fi
7676

7777
################################################################################################
7878
# Install any pre-requisites. Function is from overridable-functions.sh
79+
7980
echo "Checking if we need to install pre-requisites"
8081
installPrerequisites "${application}"
8182

8283
################################################################################################
8384
# Provision server and push imagestream
8485

85-
echo "Building application and provisioning server image..."
86-
mvn -B package -Popenshift wildfly:image -DskipTests
87-
88-
echo "Tagging image and pushing to registry..."
89-
export root_image_name="localhost:5000/${application}"
90-
export image="${root_image_name}:latest"
91-
docker tag ${qs_dir} ${image}
92-
docker push ${image}
86+
customProvisionServer=$(customProvisionServer)
87+
if [ "0" = "${customProvisionServer}" ]; then
88+
echo "Building application and provisioning server image..."
89+
mvn -B package -Popenshift wildfly:image -DskipTests
9390

94-
################################################################################################
95-
# Helm install, waiting for the pods to come up
96-
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}"
91+
echo "Tagging image and pushing to registry..."
92+
export root_image_name="localhost:5000/${application}"
93+
export image="${root_image_name}:latest"
94+
docker tag ${qs_dir} ${image}
95+
docker push ${image}
9796

98-
additional_arguments="No additional arguments"
99-
if [ -n "${helm_set_arguments}" ]; then
100-
additional_arguments="Additional arguments: ${helm_set_arguments}"
97+
echo "Creating docker file locally and pushing to registry at localhost:5000"
98+
docker build -t "${image}" target
99+
else
100+
provisionServer "${application}" "${qs_dir}"
101101
fi
102102

103-
echo "Performing Helm install and waiting for completion.... (${additional_arguments})"
104-
# helmInstall is from overridable-functions.sh
105-
helm_install_ret=$(helmInstall "${application}" "${helm_set_arguments}")
106-
107-
# For some reason the above sometimes becomes a multi-line string. actual The exit code will be
108-
# on the last line
109-
helm_install_ret=$(echo "${helm_install_ret}"| tail -n 1)
103+
################################################################################################
110104

111-
echo "ret: ${helm_install_ret}"
112-
if [ "${helm_install_ret}" != "0" ]; then
113-
echo "Helm install failed!"
114-
echo "Dumping the application pod(s)"
115-
kubectl logs deployment/"${application}"
116-
helmInstallFailed
105+
customDeploy=$(customDeploy)
106+
if [ "0" = "${customDeploy}" ]; then
107+
# Helm install, waiting for the pods to come up
108+
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}"
109+
110+
additional_arguments="No additional arguments"
111+
if [ -n "${helm_set_arguments}" ]; then
112+
additional_arguments="Additional arguments: ${helm_set_arguments}"
113+
fi
114+
115+
echo "Performing Helm install and waiting for completion.... (${additional_arguments})"
116+
# helmInstall is from overridable-functions.sh
117+
helm_install_ret=$(helmInstall "${application}" "${helm_set_arguments}")
118+
119+
# For some reason the above sometimes becomes a multi-line string. actual The exit code will be
120+
# on the last line
121+
helm_install_ret=$(echo "${helm_install_ret}"| tail -n 1)
122+
123+
echo "ret: ${helm_install_ret}"
124+
if [ "${helm_install_ret}" != "0" ]; then
125+
echo "Helm install failed!"
126+
echo "Dumping the application pod(s)"
127+
kubectl logs deployment/"${application}"
128+
helmInstallFailed
129+
fi
130+
else
131+
deploy
117132
fi
118133

119-
kubectl port-forward service/${application} 8080:8080 &
120-
kubectl_fwd_pid=$!
121-
echo "Process ID of kubect port-forward: ${kubectl_fwd_pid}"
134+
customPortForward=$(customPortForward)
135+
if [ "0" = "${customPortForward}" ]; then
136+
nohup kubectl port-forward service/${application} 8080:8080 > /dev/null 2>&1 &
137+
kubectl_fwd_pids=$!
138+
echo "Process ID of kubect port-forward: ${kubectl_fwd_pids}"
139+
else
140+
echo "Performing Port Forward and waiting for completion...."
141+
kubectl_fwd_pids=$(portForward "${application}")
142+
echo "Process ID(s) of kubect port-forward: ${kubectl_fwd_pids}"
143+
fi
122144

123145
################################################################################################
124146
# Run any post install
@@ -130,35 +152,47 @@ runPostHelmInstallCommands
130152
echo "running the tests"
131153
pwd
132154

133-
route="localhost:8080"
134-
135-
mvnVerifyArguments="-Dserver.host=${server_protocol}://${route} "
136-
extraMvnVerifyArguments="$(getMvnVerifyExtraArguments)"
137-
if [ -n "${extraMvnVerifyArguments}" ]; then
138-
mvnVerifyArguments="${mvnVerifyArguments} ${extraMvnVerifyArguments}"
139-
fi
140-
if [ "${QS_DEBUG_TESTS}" = "1" ]; then
141-
mvnVerifyArguments="${mvnVerifyArguments} -Dmaven.failsafe.debug=true"
142-
fi
143-
144-
echo "Verify Arguments: ${mvnVerifyArguments}"
145-
146-
mvn -B verify -Pintegration-testing ${mvnVerifyArguments}
147-
148-
if [ "$?" != "0" ]; then
149-
test_status=1
150-
echo "Tests failed!"
151-
echo "Dumping the application pod(s)"
152-
kubectl logs deployment/"${application}"
153-
testsFailed
155+
customRunningTests=$(customRunningTests)
156+
if [ "0" = "${customRunningTests}" ]; then
157+
route="localhost:8080"
158+
159+
mvnVerifyArguments="-Dserver.host=${server_protocol}://${route} "
160+
extraMvnVerifyArguments="$(getMvnVerifyExtraArguments)"
161+
if [ -n "${extraMvnVerifyArguments}" ]; then
162+
mvnVerifyArguments="${mvnVerifyArguments} ${extraMvnVerifyArguments}"
163+
fi
164+
if [ "${QS_DEBUG_TESTS}" = "1" ]; then
165+
mvnVerifyArguments="${mvnVerifyArguments} -Dmaven.failsafe.debug=true"
166+
fi
167+
168+
echo "Verify Arguments: ${mvnVerifyArguments}"
169+
170+
mvn -B verify -Pintegration-testing ${mvnVerifyArguments}
171+
172+
if [ "$?" != "0" ]; then
173+
test_status=1
174+
echo "Tests failed!"
175+
echo "Dumping the application pod(s)"
176+
kubectl logs deployment/"${application}"
177+
testsFailed
178+
fi
179+
else
180+
runningTests "${application}" "${server_protocol}" "$(getMvnVerifyExtraArguments)"
181+
test_status=$?
154182
fi
155183

156-
kill -9 ${kubectl_fwd_pid}
184+
kill -9 ${kubectl_fwd_pids}
157185

158186
################################################################################################
159187
# Helm uninstall
160188
echo "Running Helm uninstall"
161-
helm uninstall "${application}" --wait --timeout=10m0s
189+
190+
customHelmUninstall=$(customHelmUninstall)
191+
if [ "0" = "${customHelmUninstall}" ]; then
192+
helm uninstall "${application}" --wait --timeout=10m0s
193+
else
194+
helmUninstall "${application}"
195+
fi
162196

163197
################################################################################################
164198
# Clean pre-requisites (cleanPrerequisites is fromm overridable-functions.sh)
@@ -187,4 +221,4 @@ end=$SECONDS
187221
duration=$((end - start))
188222
echo "${application} tests run in $(($duration / 60))m$(($duration % 60))s."
189223

190-
exit ${test_status}
224+
exit ${test_status}

0 commit comments

Comments
 (0)