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

Added a docker-compose for hotrod e2e test #5740

Merged
merged 25 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
9 changes: 3 additions & 6 deletions examples/hotrod/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3.7'

# To run a specific version of Jaeger, use environment variable, e.g.:
# JAEGER_VERSION=1.52 docker compose up
# JAEGER_VERSION=1.52 docker compose up
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

services:
jaeger:
Expand All @@ -14,11 +13,9 @@ services:
- LOG_LEVEL=debug
networks:
- jaeger-example

hotrod:
image: jaegertracing/example-hotrod:${JAEGER_VERSION:-latest}
# To run the latest trunk build, find the tag at Docker Hub and use the line below
# https://hub.docker.com/r/jaegertracing/example-hotrod-snapshot/tags
#image: jaegertracing/example-hotrod-snapshot:0ab8f2fcb12ff0d10830c1ee3bb52b745522db6c
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
image: ${REGISTRY:-}jaegertracing/example-hotrod:${JAEGER_VERSION:-latest}
ports:
- "8080:8080"
- "8083:8083"
Expand Down
44 changes: 38 additions & 6 deletions scripts/hotrod-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ make build-examples GOOS=linux GOARCH=s390x
make build-examples GOOS=linux GOARCH=ppc64le
make build-examples GOOS=linux GOARCH=arm64

REPO=jaegertracing/example-hotrod
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
make prepare-docker-buildx

# build image locally (-l) for integration test
bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hotrod -p "${platforms}"

# pass --name example-hotrod so that we can do `docker logs example-hotrod` later
export CID
CID=$(docker run -d --name example-hotrod -p 8080:8080 "localhost:5000/${REPO}:${GITHUB_SHA}")
export HOTROD_IMAGE="localhost:5000/jaegertracing/example-hotrod"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
docker compose -f ./examples/hotrod/docker-compose.yml up -d

i=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080)" != "200" && ${i} -lt 30 ]]; do
Expand All @@ -28,6 +27,39 @@ if [[ $body != *"Rides On Demand"* ]]; then
echo "String \"Rides On Demand\" is not present on the index page"
exit 1
fi
docker rm -f "$CID"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

bash scripts/build-upload-a-docker-image.sh -c example-hotrod -d examples/hotrod -p "${platforms}"
Copy link
Member

Choose a reason for hiding this comment

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

this line should not have been deleted. It needs to run as the last step of the script.

curl -X POST "http://localhost:8080/dispatch?customer=123"
# Extract the logs from the docker compose service
logs=$(docker compose -f ./examples/hotrod/docker-compose.yml logs hotrod)
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

# Extract the trace_id from the logs
TRACE_ID=$(echo "$logs" | grep -oP '(?<="trace_id": ")[^"]+' | tail -n 1)
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

JAEGER_QUERY_URL="http://localhost:16686"
EXPECTED_SPANS=10 # Change this to the expected number of spans
MAX_RETRIES=30
SLEEP_INTERVAL=10

# Function to poll Jaeger for the trace
poll_jaeger() {
local trace_id=$1
local url="${JAEGER_QUERY_URL}/api/traces/${trace_id}"

curl -s "${url}" | jq '.data[0].spans | length'
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
}

# Polling loop
for ((i=1; i<=MAX_RETRIES; i++)); do
span_count=$(poll_jaeger "${TRACE_ID}")

if [[ "$span_count" -ge "$EXPECTED_SPANS" ]]; then
echo "Trace found with $span_count spans."
exit 0
fi

echo "Retry $i/$MAX_RETRIES: Trace not found or insufficient spans ($span_count/$EXPECTED_SPANS). Retrying in $SLEEP_INTERVAL seconds..."
sleep $SLEEP_INTERVAL
done

echo "Failed to find the trace with the expected number of spans within the timeout period."
exit 1
Loading