Skip to content

Commit

Permalink
[WFLY-19337] The GitHub Action to test ejb-txn-remote-call is now wor…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
jmfinelli committed Dec 20, 2024
1 parent 75d24ed commit e8d8dce
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
# microprofile-reactive-messaging-kafka
# 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
ejb-remote
# Some problems once the operator is installed. I haven't been able to get my go environment set up to the same version
ejb-txn-remote-call

114 changes: 104 additions & 10 deletions .github/workflows/scripts/kubernetes/core/overridable-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
# Parameters
# 1 - the name of the qs directory (not the full path)
#
function applicationName() {
echo "${1}"
}
Expand All @@ -20,6 +21,7 @@ function applicationName() {
#
# Parameters
# 1 - the name of the qs directory
#
function namespace() {
application="${1}"
# Uncomment to make the tests run in the 'testing' namespace
Expand All @@ -32,6 +34,7 @@ function namespace() {
#
# Parameters
# 1 - application name
#
function installPrerequisites()
{
application="${1}"
Expand All @@ -43,12 +46,53 @@ function installPrerequisites()
#
# Parameters
# 1 - application name
#
function cleanPrerequisites()
{
application="${1}"
echo "No prerequisites to clean for ${application}"
}

# Trigger the custom behaviour when it comes to
# provision the server and push the imagestream.
# Returns
# 0 - false
# 1 - true
#
function customProvisionServer() {
echo 0
}

# Provision server and push imagestream
# The current directory is the quickstart directory
#
# Parameters
# 1 - application name
# 2 - quickstart dir
#
function provisionServer()
{
echo "Nothing to do in provisionServer()..."
}

# Trigger a custom behaviour when it comes to
# setting up the environment
# Returns
# 0 - false
# 1 - true
#
function customDeploy() {
echo 0
}

# Set up the environment before testing
# Parameters
# 1 - application name
#
function deploy() {
echo "Nothing to do in deploy()..."
}

# Performs the 'helm install' command.
# The current directory is the quickstart directory
# Parameters
Expand All @@ -61,15 +105,7 @@ function cleanPrerequisites()
# * helm_install_timeout - the adjusted timeout for the helm install
#
function helmInstall() {
application="${1}"
helm_set_arguments="$2"

# '--wait' waits until the pods are ready
# `--timeout` sets the timeout for the wait.
# https://helm.sh/docs/helm/helm_install/ has more details
# Don't quote ${helm_set_arguments} since then it fails when there are none
helm install "${application}" wildfly/wildfly -f charts/helm.yaml --wait --timeout=${helm_install_timeout} ${helm_set_arguments}
echo "$?"
echo "Nothing to do in helmInstall()..."
}

# Commands to run once the Helm install has completed
Expand Down Expand Up @@ -106,10 +142,68 @@ function helmInstallFailed() {
echo ""
}

# Trigger a custom behaviour when it comes to
# forward ports
# Returns
# 0 - false
# 1 - true
#
function customPortForward() {
echo 0
}

# Port forward to test the quickstart
# Parameters
# 1 - application name
#
function portForward() {
echo "Nothing to do in portForward()..."
}

# Trigger a custom behaviour when it comes to
# running tests
# Returns
# 0 - false
# 1 - true
#
function customRunningTests() {
echo 0
}

# Running tests of the quickstart
# Parameters
# 1 - application name
# 2 - server protocol
# 3 - extra maven argument for the verify target
#
function runningTests() {
echo "Nothing to do in portForward()..."
}

# Trigger a custom behaviour when it comes to
# running tests
# Returns
# 0 - false
# 1 - true
#
function customHelmUninstall() {
echo 0
}

# Performs the 'helm uninstall' command.
# Parameters
# 1 - application name
#
function helmUninstall() {
application="${1}"

helm uninstall "${application}" --wait --timeout=10m0s
}

# More output when the tests have failed
# Parameters
# 1 - application name
#
function testsFailed() {
echo ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,71 @@ fi

################################################################################################
# Install any pre-requisites. Function is from overridable-functions.sh

echo "Checking if we need to install pre-requisites"
installPrerequisites "${application}"

################################################################################################
# Provision server and push imagestream

echo "Building application and provisioning server image..."
mvn -B package -Popenshift wildfly:image -DskipTests

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

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

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

echo "Performing Helm install and waiting for completion.... (${additional_arguments})"
# helmInstall is from overridable-functions.sh
helm_install_ret=$(helmInstall "${application}" "${helm_set_arguments}")

# For some reason the above sometimes becomes a multi-line string. actual The exit code will be
# on the last line
helm_install_ret=$(echo "${helm_install_ret}"| tail -n 1)
################################################################################################

echo "ret: ${helm_install_ret}"
if [ "${helm_install_ret}" != "0" ]; then
echo "Helm install failed!"
echo "Dumping the application pod(s)"
kubectl logs deployment/"${application}"
helmInstallFailed
customDeploy=$(customDeploy)
if [ "0" = "${customDeploy}" ]; then
# Helm install, waiting for the pods to come up
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}"

additional_arguments="No additional arguments"
if [ -n "${helm_set_arguments}" ]; then
additional_arguments="Additional arguments: ${helm_set_arguments}"
fi

echo "Performing Helm install and waiting for completion.... (${additional_arguments})"
# helmInstall is from overridable-functions.sh
helm_install_ret=$(helmInstall "${application}" "${helm_set_arguments}")

# For some reason the above sometimes becomes a multi-line string. actual The exit code will be
# on the last line
helm_install_ret=$(echo "${helm_install_ret}"| tail -n 1)

echo "ret: ${helm_install_ret}"
if [ "${helm_install_ret}" != "0" ]; then
echo "Helm install failed!"
echo "Dumping the application pod(s)"
kubectl logs deployment/"${application}"
helmInstallFailed
fi
else
deploy
fi

kubectl port-forward service/${application} 8080:8080 &
kubectl_fwd_pid=$!
echo "Process ID of kubect port-forward: ${kubectl_fwd_pid}"
customPortForward=$(customPortForward)
if [ "0" = "${customPortForward}" ]; then
nohup kubectl port-forward service/${application} 8080:8080 > /dev/null 2>&1 &
kubectl_fwd_pids=$!
echo "Process ID of kubect port-forward: ${kubectl_fwd_pids}"
else
echo "Performing Port Forward and waiting for completion...."
kubectl_fwd_pids=$(portForward "${application}")
echo "Process ID(s) of kubect port-forward: ${kubectl_fwd_pids}"
fi

################################################################################################
# Run any post install
Expand All @@ -130,35 +152,47 @@ runPostHelmInstallCommands
echo "running the tests"
pwd

route="localhost:8080"

mvnVerifyArguments="-Dserver.host=${server_protocol}://${route} "
extraMvnVerifyArguments="$(getMvnVerifyExtraArguments)"
if [ -n "${extraMvnVerifyArguments}" ]; then
mvnVerifyArguments="${mvnVerifyArguments} ${extraMvnVerifyArguments}"
fi
if [ "${QS_DEBUG_TESTS}" = "1" ]; then
mvnVerifyArguments="${mvnVerifyArguments} -Dmaven.failsafe.debug=true"
fi

echo "Verify Arguments: ${mvnVerifyArguments}"

mvn -B verify -Pintegration-testing ${mvnVerifyArguments}

if [ "$?" != "0" ]; then
test_status=1
echo "Tests failed!"
echo "Dumping the application pod(s)"
kubectl logs deployment/"${application}"
testsFailed
customRunningTests=$(customRunningTests)
if [ "0" = "${customRunningTests}" ]; then
route="localhost:8080"

mvnVerifyArguments="-Dserver.host=${server_protocol}://${route} "
extraMvnVerifyArguments="$(getMvnVerifyExtraArguments)"
if [ -n "${extraMvnVerifyArguments}" ]; then
mvnVerifyArguments="${mvnVerifyArguments} ${extraMvnVerifyArguments}"
fi
if [ "${QS_DEBUG_TESTS}" = "1" ]; then
mvnVerifyArguments="${mvnVerifyArguments} -Dmaven.failsafe.debug=true"
fi

echo "Verify Arguments: ${mvnVerifyArguments}"

mvn -B verify -Pintegration-testing ${mvnVerifyArguments}

if [ "$?" != "0" ]; then
test_status=1
echo "Tests failed!"
echo "Dumping the application pod(s)"
kubectl logs deployment/"${application}"
testsFailed
fi
else
runningTests "${application}" "${server_protocol}" "$(getMvnVerifyExtraArguments)"
test_status=$?
fi

kill -9 ${kubectl_fwd_pid}
kill -9 ${kubectl_fwd_pids}

################################################################################################
# Helm uninstall
echo "Running Helm uninstall"
helm uninstall "${application}" --wait --timeout=10m0s

customHelmUninstall=$(customHelmUninstall)
if [ "0" = "${customHelmUninstall}" ]; then
helm uninstall "${application}" --wait --timeout=10m0s
else
helmUninstall "${application}"
fi

################################################################################################
# Clean pre-requisites (cleanPrerequisites is fromm overridable-functions.sh)
Expand Down
Loading

0 comments on commit e8d8dce

Please sign in to comment.