-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run v2 e2e integration tests for Kafka (#5782)
## Description of the changes - Update v2 e2e integration tests scripts for kafka - Update v2 gh workflows for kafka ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: joeyyy09 <menteharshith@gmail.com> Signed-off-by: Yuri Shkuro <github@ysh.us> Co-authored-by: Yuri Shkuro <github@ysh.us>
- Loading branch information
1 parent
a8e98d9
commit a1fe858
Showing
5 changed files
with
132 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,100 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -euf -o pipefail | ||
|
||
export STORAGE=kafka | ||
compose_file="docker-compose/kafka-integration-test/docker-compose.yml" | ||
echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}" | ||
|
||
# Check if the -k parameter is provided and start Kafka if it was | ||
if [ "$1" == "-k" ]; then | ||
echo "Starting Kafka using Docker Compose..." | ||
docker compose -f "${compose_file}" up -d kafka | ||
echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}" | ||
fi | ||
jaeger_version="" | ||
manage_kafka="true" | ||
|
||
print_help() { | ||
echo "Usage: $0 [-K] -j <jaeger_version>" | ||
echo " -K: do not start or stop Kafka container (useful for local testing)" | ||
echo " -j: major version of Jaeger to test (v1|v2)" | ||
exit 1 | ||
} | ||
|
||
parse_args() { | ||
while getopts "j:Kh" opt; do | ||
case "${opt}" in | ||
j) | ||
jaeger_version=${OPTARG} | ||
;; | ||
K) | ||
manage_kafka="false" | ||
;; | ||
*) | ||
print_help | ||
;; | ||
esac | ||
done | ||
if [ "$jaeger_version" != "v1" ] && [ "$jaeger_version" != "v2" ]; then | ||
echo "Error: Invalid Jaeger version. Valid options are v1 or v2" | ||
print_help | ||
fi | ||
} | ||
|
||
setup_kafka() { | ||
echo "Starting Kafka using Docker Compose..." | ||
docker compose -f "${compose_file}" up -d kafka | ||
} | ||
|
||
teardown_kafka() { | ||
echo "Stopping Kafka..." | ||
docker compose -f "${compose_file}" down | ||
} | ||
|
||
# Check if Kafka is ready by attempting to list topics | ||
is_kafka_ready() { | ||
docker compose -f "${compose_file}" \ | ||
exec kafka /opt/bitnami/kafka/bin/kafka-topics.sh \ | ||
--list \ | ||
--bootstrap-server localhost:9092 \ | ||
>/dev/null 2>&1 | ||
docker compose -f "${compose_file}" \ | ||
exec kafka /opt/bitnami/kafka/bin/kafka-topics.sh \ | ||
--list \ | ||
--bootstrap-server localhost:9092 \ | ||
>/dev/null 2>&1 | ||
} | ||
|
||
# Set the timeout in seconds | ||
timeout=180 | ||
# Set the interval between checks in seconds | ||
interval=5 | ||
# Calculate the end time | ||
end_time=$((SECONDS + timeout)) | ||
wait_for_kafka() { | ||
local timeout=180 | ||
local interval=5 | ||
local end_time=$((SECONDS + timeout)) | ||
|
||
while [ $SECONDS -lt $end_time ]; do | ||
while [ $SECONDS -lt $end_time ]; do | ||
if is_kafka_ready; then | ||
break | ||
return | ||
fi | ||
echo "Kafka broker not ready, waiting ${interval} seconds" | ||
sleep $interval | ||
done | ||
done | ||
|
||
if ! is_kafka_ready; then | ||
echo "Timed out waiting for Kafka to start" | ||
exit 1 | ||
fi | ||
echo "Timed out waiting for Kafka to start" | ||
exit 1 | ||
} | ||
|
||
run_integration_test() { | ||
export STORAGE=kafka | ||
if [ "${jaeger_version}" = "v1" ]; then | ||
make storage-integration-test | ||
elif [ "${jaeger_version}" = "v2" ]; then | ||
make jaeger-v2-storage-integration-test | ||
else | ||
echo "Unknown Jaeger version ${jaeger_version}." | ||
print_help | ||
fi | ||
} | ||
|
||
main() { | ||
parse_args "$@" | ||
|
||
echo "Executing Kafka integration test for version $2" | ||
set -x | ||
|
||
if [[ "$manage_kafka" == "true" ]]; then | ||
setup_kafka | ||
trap 'teardown_kafka' EXIT | ||
fi | ||
wait_for_kafka | ||
|
||
run_integration_test | ||
} | ||
|
||
make storage-integration-test | ||
main "$@" |