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 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
2 changes: 1 addition & 1 deletion .github/workflows/ci-docker-hotrod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ jobs:
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

- name: Print logs from hotrod
run: docker logs example-hotrod
run: docker compose -f ./examples/hotrod/docker-compose.yml logs
if: failure()
6 changes: 3 additions & 3 deletions examples/hotrod/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: '3.7'

# To run a specific version of Jaeger, use environment variable, e.g.:
# JAEGER_VERSION=1.52 docker compose up

services:
jaeger:
image: jaegertracing/all-in-one:${JAEGER_VERSION:-latest}
image: ${REGISTRY:-}jaegertracing/all-in-one:${JAEGER_VERSION:-latest}
ports:
- "16686:16686"
- "4317:4317"
Expand All @@ -14,8 +13,9 @@ services:
- LOG_LEVEL=debug
networks:
- jaeger-example

hotrod:
image: jaegertracing/example-hotrod:${JAEGER_VERSION:-latest}
image: ${REGISTRY:-}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
Expand Down
69 changes: 60 additions & 9 deletions scripts/hotrod-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,83 @@

set -euxf -o pipefail

docker_compose_file="./examples/hotrod/docker-compose.yml"
platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"

teardown() {
echo "Tearing down..."
docker compose -f "$docker_compose_file" down
}
trap teardown EXIT

make build-examples GOOS=linux GOARCH=amd64
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
make create-baseimg

# build image locally (-l) for integration test
# Loop through each platform (separated by commas)
for platform in $(echo "$platforms" | tr ',' ' '); do
# Extract the architecture from the platform string
arch=${platform##*/} # Remove everything before the last slash
make "build-all-in-one" GOOS=linux GOARCH="${arch}"
done

# Build image locally (-l) for integration test
bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hotrod -p "${platforms}"
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one -d cmd/all-in-one -p "${platforms}" -t release

# 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}")
JAEGER_VERSION=$GITHUB_SHA REGISTRY="localhost:5000/" docker compose -f "$docker_compose_file" up -d

i=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080)" != "200" && ${i} -lt 30 ]]; do
while [[ "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080)" != "200" && $i -lt 30 ]]; do
sleep 1
i=$((i+1))
done

body=$(curl localhost:8080)
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.

response=$(curl -i -X POST "http://localhost:8080/dispatch?customer=123")
TRACE_ID=$(echo "$response" | grep -Fi "Traceresponse:" | awk '{print $2}' | cut -d '-' -f 2)

if [ -n "$TRACE_ID" ]; then
echo "TRACE_ID is not empty: $TRACE_ID"
else
echo "TRACE_ID is empty"
exit 1
fi

JAEGER_QUERY_URL="http://localhost:16686"
EXPECTED_SPANS=35
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' || echo "0"
}

# 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