Skip to content

Enhance Kafka integration tests to support multiple Kafka versions #6400

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

Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/ci-e2e-kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
jaeger-version: [v1, v2] # Adjust if there are specific versions of Jaeger
name: kafka ${{ matrix.jaeger-version }}
jaeger-version: [v1, v2]
kafka-version: ["3.x", "2.x"]
name: kafka ${{matrix.kafka-version }} ${{ matrix.jaeger-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
Expand All @@ -31,12 +32,12 @@ jobs:
with:
go-version: 1.23.x

- name: Run Kafka integration tests
- name: Run kafka integration tests
id: test-execution
run: bash scripts/kafka-integration-test.sh -j ${{ matrix.jaeger-version }}
run: bash scripts/kafka-integration-test.sh -j ${{ matrix.jaeger-version }} -v ${{ matrix.kafka-version }}

- name: Upload coverage to codecov
uses: ./.github/actions/upload-codecov
with:
files: cover.out
flags: kafka-${{ matrix.jaeger-version }}
flags: kafka-${{ matrix.kafka-version }}-${{ matrix.jaeger-version }}
2 changes: 1 addition & 1 deletion docker-compose/kafka/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ services:
jaeger-remote-storage:
condition: service_healthy
links:
- jaeger-remote-storage
- jaeger-remote-storage
21 changes: 21 additions & 0 deletions docker-compose/kafka/v2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
zookeeper:
image: bitnami/zookeeper:3.8.4
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes

kafka:
image: bitnami/kafka:2.8.0
ports:
- "9092:9092"
environment:
- KAFKA_BROKER_ID=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_LISTENERS=PLAINTEXT://:9092
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper
3 changes: 2 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"docker-compose/elasticsearch/v6/docker-compose.yml",
"docker-compose/elasticsearch/v7/docker-compose.yml",
"docker-compose/elasticsearch/v8/docker-compose.yml",
"docker-compose/kafka-integration-test/docker-compose.yml",
"docker-compose/kafka/v2/docker-compose.yml",
"docker-compose/kafka/v3/docker-compose.yml",
"docker-compose/kafka/docker-compose.yml",
"docker-compose/monitor/docker-compose.yml",
"docker-compose/opensearch/v1/docker-compose.yml",
Expand Down
41 changes: 33 additions & 8 deletions scripts/kafka-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,63 @@

set -euf -o pipefail

compose_file="docker-compose/kafka-integration-test/docker-compose.yml"
compose_file=""
jaeger_version=""
kafka_version=""
manage_kafka="true"
success="false"

print_help() {
echo "Usage: $0 [-K] -j <jaeger_version>"
usage() {
echo "Usage: $0 [-K] -j <jaeger_version> -v <kafka_version>"
echo " -K: do not start or stop Kafka container (useful for local testing)"
echo " -j: major version of Jaeger to test (v1|v2)"
echo " -v: kafka major version (3.x|2.x)"
exit 1
}

check_arg() {
if [ ! $# -eq 3 ]; then
echo "ERROR: need exactly three arguments"
usage
fi
}

parse_args() {
while getopts "j:Kh" opt; do
while getopts "j:v:Kh" opt; do
case "${opt}" in
j)
jaeger_version=${OPTARG}
;;
v)
case ${OPTARG} in
3.x)
kafka_version="v3"
;;
2.x)
kafka_version="v2"
;;
*)
echo "Error: Invalid Kafka version. Valid options are 3.x or 2.x"
usage
;;
esac
;;
K)
manage_kafka="false"
;;
*)
print_help
usage
;;
esac
done
if [ "$jaeger_version" != "v1" ] && [ "$jaeger_version" != "v2" ]; then
if [[ "$jaeger_version" != "v1" && "$jaeger_version" != "v2" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't have objection to the change, but can you elaborate why you wanted to change it?

echo "Error: Invalid Jaeger version. Valid options are v1 or v2"
print_help
usage
fi
compose_file="docker-compose/kafka/${kafka_version}/docker-compose.yml"
}


setup_kafka() {
echo "Starting Kafka using Docker Compose..."
docker compose -f "${compose_file}" up -d kafka
Expand Down Expand Up @@ -89,7 +114,7 @@ run_integration_test() {
make jaeger-v2-storage-integration-test
else
echo "Unknown Jaeger version ${jaeger_version}."
print_help
usage
fi
}

Expand Down
Loading