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

[WFLY-19337] The GitHub Action to test ejb-txn-remote-call is now working #990

Open
wants to merge 1 commit into
base: main
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
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

104 changes: 103 additions & 1 deletion .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 Down Expand Up @@ -106,10 +150,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,50 +76,69 @@ 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
customProvisionServer=$(customProvisionServer)
if [ "0" = "${customProvisionServer}" ]; then
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}
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}
else
provisionServer "${application}" "${qs_dir}"
fi

################################################################################################
# Helm install, waiting for the pods to come up
kabir marked this conversation as resolved.
Show resolved Hide resolved
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}"
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

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
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

kubectl port-forward service/${application} 8080:8080 &
kubectl_fwd_pid=$!
echo "Process ID of kubect port-forward: ${kubectl_fwd_pid}"

################################################################################################
# Run any post install
echo "Running post Helm install commands in $(pwd)"
Expand All @@ -130,35 +149,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
Loading