Skip to content

Commit

Permalink
[WFLY-18498] microprofile-reactive-messaging-kafka Quickstart CY2023Q…
Browse files Browse the repository at this point in the history
…3 enhancements
  • Loading branch information
kabir committed Oct 18, 2023
1 parent dd968cc commit 34d276e
Show file tree
Hide file tree
Showing 25 changed files with 467 additions and 703 deletions.
3 changes: 3 additions & 0 deletions .ci/openshift-ci/build-root/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ echo "===== Environment:"
env
echo "=================="

echo "Login command:"
echo "oc login $TEST_CLUSTER_URL -u $SYSADMIN_USERNAME -p $SYSADMIN_PASSWORD --insecure-skip-tls-verify"

echo "Calling script runner....."

# Script path is relative to checkout folder
Expand Down
3 changes: 3 additions & 0 deletions .ci/openshift-ci/build-root/scripts/excluded-directories.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Quickstarts that should not be tested on OpenShift.
# One per line with no trailing spaces, and make sure to have a newline at the end
# microprofile-reactive-messaging-kafka
14 changes: 0 additions & 14 deletions .ci/openshift-ci/build-root/scripts/included-directories.txt

This file was deleted.

24 changes: 14 additions & 10 deletions .ci/openshift-ci/build-root/scripts/openshift-test-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ poll_marker_files() {

wait_marker_files() {
echo "Waiting $seconds. 'oc rsh' in and either 'touch continue' to stop waiting, or 'touch exit' to abort the test run. The latter will result in the test being reported as failed"
echo "You can log in to the cluster started by the CI to diagnose problems with the following commands"
echo "oc login $TEST_CLUSTER_URL -u $SYSADMIN_USERNAME -p $SYSADMIN_PASSWORD --insecure-skip-tls-verify"
#echo "oc get pods"
#echo "oc rsh pod/<name of pod>"

found_file=$(poll_marker_files $1)
if [ -z "${found_file}" ]; then
echo "Wait timed out - continuing"
Expand Down Expand Up @@ -112,7 +117,7 @@ getPrTouchedDirs() {
fi

IFS='/' read -ra parts <<< "${file}"
if [ "${#parts[@]}" == 1 ]; then
if [ "${#parts[@]}" == 1 ] && [ "${parts[0]}" != 'enable-wait' ] && [ "${parts[0]}" != 'continue' ] && [ "${parts[0]}" != '.gitignore' ] ; then
echo "Changed detected in ${file} which is in the root directory. All tests will need to be run."
root_dir_file_changed=1
break
Expand Down Expand Up @@ -141,10 +146,9 @@ filterDirectories() {
declare -a tmp
for fileName in "${test_directories[@]}"; do
# Quickstarts that have not been migrated yet
# TODO once everything has a quickstart_xxx_ci.yml file we can remove the included-directories check
grep -q "^${fileName}$" included-directories.txt
is_in_included_txt="$?"
if [ "${is_in_included_txt}" != "0" ] && [ ! -f "${basedir}/.github/workflows/quickstart_${fileName}_ci.yml" ]; then
grep -q "^${fileName}$" excluded-directories.txt
is_in_excluded="$?"
if [ "${is_in_excluded}" = "0" ] || [ ! -f "${basedir}/.github/workflows/quickstart_${fileName}_ci.yml" ]; then
# echo "Skipping ${fileName}!"
continue
fi
Expand All @@ -167,11 +171,6 @@ if [ -f "${basedir}/enable-wait" ]; then
wait_marker_files 3600
popd
fi
if [ -f "${basedir}/abort" ]; then
# Add ability to abort test run between quickstart runs
echo "${basedir}/abort file found. Exiting"
exit 1
fi

if [ "${JOB_TYPE}" = "presubmit" ]; then
getPrTouchedDirs
Expand Down Expand Up @@ -211,6 +210,11 @@ for fileName in "${test_directories[@]}"; do
echo "${fileName}"
else
runQuickstart "${script_directory}" "${fileName}"
if [ -f "${basedir}/abort" ]; then
# Add ability to abort test run between quickstart runs
echo "${basedir}/abort file found. Exiting"
exit 1
fi
fi
done

Expand Down
10 changes: 9 additions & 1 deletion .ci/openshift-ci/build-root/scripts/overridable-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function helmInstall() {
application="${1}"
helm_set_arguments="$2"

# '--atomic' waits until the pods are ready, and removes everything if something went wrong
# '--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
Expand Down Expand Up @@ -81,4 +81,12 @@ function getHelmSetVariablePrefix() {
function helmInstallFailed() {
# Noop - the main work is done elsewhere
echo ""
}

# More output when the tests have failed
# Parameters
# 1 - application name
#
function testsFailed() {
echo ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# These functions are 'overridable in the individual quickstarts.
# To do so create a ./qs-overrides/${qs_dir}/overridable-functions.sh and override the
# functions you need to. ${qs_dir} in this case is the same as the name of the quickstart directory
# that you want to tweak

# Installs any prerequisites before doing the Helm install.
# The current directory is the quickstart directory.
# The default is to use the quickstart directory as the name, but in some cases
# a quickstart may need to shorten the name of the application in order to control
# the length of the resources created by OpenShift
#
# Parameters
# 1 - the name of the qs directory (not the full path)
function applicationName() {
#echo "${1}"
# The fill microprofile-reactive-messaging-kafka name results in names of generated resources which are too long for
# OpenShift to handle
echo "mp-rm-qs"
}


# Installs any prerequisites before doing the Helm install.
# The current directory is the quickstart directory
#
# Parameters
# 1 - application name
function installPrerequisites()
{
application="${1}"
echo "Creating amq-streams-operator-group"

oc apply -f - <<EOF
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: amq-streams-operator-group
namespace: default
spec: {}
EOF

echo "Creating amq-streams-subscription"
oc apply -f - <<EOF
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: amq-streams-subscription
namespace: default
spec:
channel: stable
installPlanApproval: Automatic
name: amq-streams
source: redhat-operators
sourceNamespace: openshift-marketplace
startingCSV: amqstreams.v2.5.0-0
EOF


seconds=120
now=$(date +%s)
end=$(($seconds + $now))

echo "Looping for 2 minutes until the 'kafka' CRD is available "
while [ $now -lt $end ]; do
# It takes a while for the kafka CRD to be ready
sleep 5
echo "Trying to create my-cluster"
oc apply -f - <<EOF
apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: my-cluster
spec:
kafka:
replicas: 3
listeners:
- name: plain
port: 9092
type: internal
tls: false
storage:
type: ephemeral
zookeeper:
replicas: 3
storage:
type: ephemeral
entityOperator:
topicOperator: {}
EOF
if [ "$?" = "0" ]; then
break
fi
now=$(date +%s)
done

echo "Creating testing topic"
oc apply -f - <<EOF
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
name: testing
labels:
strimzi.io/cluster: my-cluster
spec:
partitions: 3
replicas: 3
EOF

# Wait for the pods to come up
seconds=900
now=$(date +%s)
end=$(($seconds + $now))

echo "Looping for 15 minutes until the Kafka cluster is ready"
while [ $now -lt $end ]; do
sleep 15
echo "Checking if pods are ready"

# Check the entity operator exists. It will have a name like my-cluster-entity-operator-<pod suffix>
# We do this check first because it takes a while to appear
oc get pods -l app.kubernetes.io/instance='my-cluster',app.kubernetes.io/name='entity-operator' | grep "my-cluster-entity-operator" || continue

# Wait 10 seconds for all pods to come up, and renter the loop if not
oc wait pod -l app.kubernetes.io/instance='my-cluster' --for=condition=Ready --timeout=10s || continue

# If we got here, everything is up, so we can proceed
break
done
}


# Cleans any prerequisites after doing the Helm uninstall.
# The current directory is the quickstart directory
#
# Parameters
# 1 - application name
function cleanPrerequisites()
{
# TODO There are a few topics created that need cleaning up

oc delete kafka my-cluster
oc delete subscription amq-streams-subscription
oc delete operatorgroup amq-streams-operator-group
oc delete deployment amq-streams-cluster-operator-v2.5.0-1
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ 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)
Expand Down Expand Up @@ -177,17 +178,14 @@ if [ "${QS_UNSIGNED_SERVER_CERT}" = "1" ]; then
truststore_properties="-Djavax.net.ssl.trustStore=${script_directory}/InstallCert/jssecacerts -Djavax.net.ssl.trustStorePassword=changeit"
fi


# I am using 'integration-test failsafe:verify' here rather than just using 'verify'. The reason for this is
# plain 'verify' gives an exit status of 0 even when the test fails.
# If I just use 'failsafe:verify' the proper exit code is returned when the test fails BUT we don't see any output of the test.
# Using 'integration-test failsafe:verify' I get the proper exit code and output
# TODO Remove arq-remote once all tests have been migrated
mvn -B integration-test failsafe:verify -Parq-remote,integration-testing -Dserver.host=https://${route} ${QS_MAVEN_REPOSITORY} ${truststore_properties}

mvn -B verify -Pintegration-testing -Dserver.host=https://${route} ${QS_MAVEN_REPOSITORY} ${truststore_properties}
if [ "$?" != "0" ]; then
test_status=1
echo "Tests failed!"
echo "Dumping the application pod(s)"
oc logs deployment/"${application}"
testsFailed
fi

################################################################################################
# Helm uninstall
echo "Running Helm uninstall"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: WildFly microprofile-reactive-messaging-kafka Quickstart CI

on:
# TEMP
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'microprofile-reactive-messaging-kafka/**'
- '.github/workflows/quickstart_ci.yml'
jobs:
call-quickstart_ci:
uses: ./.github/workflows/quickstart_ci.yml
with:
QUICKSTART_PATH: microprofile-reactive-messaging-kafka
TEST_BOOTABLE_JAR: true
# See https://issues.redhat.com/browse/WFLY-18676 for why we are excluding this on Windows for now.
MATRIX_OS: '"ubuntu-20.04"'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# This image will be moved to SmallRye at some point
docker run -d -p 9092:9092 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 quay.io/ogunalp/kafka-native:0.5.0-kafka-3.6.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ build.metadata
*.lock
*.tgz
/**/nbproject/
.ci/openshift-ci/build-root/scripts/InstallCert/jssecacerts
Loading

0 comments on commit 34d276e

Please sign in to comment.