Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Jul 19, 2024
1 parent 6f855c4 commit e1fb84c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci-docker-hotrod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ jobs:
- name: Export BRANCH variable
uses: ./.github/actions/setup-branch

- name: Install tools
run: make install-ci

- uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0

- name: Define BUILD_FLAGS var if running on a Pull Request
run: |
case ${GITHUB_EVENT_NAME} in
pull_request)
echo "BUILD_FLAGS=-l -D -p linux/amd64" >> ${GITHUB_ENV}
echo "BUILD_FLAGS=-l -p linux/amd64" >> ${GITHUB_ENV}
;;
*)
echo "BUILD_FLAGS=" >> ${GITHUB_ENV}
Expand Down
33 changes: 15 additions & 18 deletions scripts/hotrod-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -euxf -o pipefail

print_help() {
echo "Usage: $0 [-l] [-D] [-p platforms] [-h]"
echo "-D: Disable building of images with debugger"
echo "-h: Print help"
echo "-l: Enable local-only mode that only pushes images to local registry"
echo "-p: Comma-separated list of platforms to build for (default: all supported)"
Expand All @@ -13,7 +12,7 @@ print_help() {

docker_compose_file="./examples/hotrod/docker-compose.yml"
platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
BINARY='example-hotrod'
current_platform="$(go env GOOS)/$(go env GOARCH)"
LOCAL_FLAG=''

while getopts "lp:h" opt; do
Expand All @@ -25,7 +24,7 @@ while getopts "lp:h" opt; do
p)
platforms=${OPTARG}
;;
?)
h)
print_help
;;
esac
Expand All @@ -37,26 +36,24 @@ teardown() {
}
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

make prepare-docker-buildx
make create-baseimg

# Loop through each platform (separated by commas)
# Build hotrod binary for each target platform (separated by commas)
for platform in $(echo "$platforms" | tr ',' ' '); do
# Extract the operating system from the platform string
os=${platform%%/*} #remove everything after the last slash
# Extract the architecture from the platform string
arch=${platform##*/} # Remove everything before the last slash
make "build-all-in-one" GOOS="${os}" GOARCH="${arch}"
make build-examples GOOS="${os}" GOARCH="${arch}"
done

# Build image locally (-l) for integration test
bash scripts/build-upload-a-docker-image.sh -l -c ${BINARY} -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
# Build hotrod image locally (-l) for integration test
bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hotrod -p "${current_platform}"

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

JAEGER_VERSION=$GITHUB_SHA REGISTRY="localhost:5000/" docker compose -f "$docker_compose_file" up -d

Expand Down Expand Up @@ -85,17 +82,16 @@ fi
JAEGER_QUERY_URL="http://localhost:16686"
EXPECTED_SPANS=35
MAX_RETRIES=30
SLEEP_INTERVAL=10
SLEEP_INTERVAL=3

# 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
# Poll Jaeger until trace with desired number of spans is loaded or we timeout.
span_count=0
for ((i=1; i<=MAX_RETRIES; i++)); do
span_count=$(poll_jaeger "${TRACE_ID}")
Expand All @@ -114,5 +110,6 @@ if [[ "$span_count" -lt "$EXPECTED_SPANS" ]]; then
exit 1
fi

# Ensure the image is published after successful test (maybe with -l flag if on a pull request)
bash scripts/build-upload-a-docker-image.sh ${LOCAL_FLAG} -c example-hotrod -d examples/hotrod -p "${platforms}"
# Ensure the image is published after successful test (maybe with -l flag if on a pull request).
# This is where all those multi-platform binaries we built earlier are utilized.
bash scripts/build-upload-a-docker-image.sh ${LOCAL_FLAG} -c example-hotrod -d examples/hotrod -p "${platforms}" -t release

0 comments on commit e1fb84c

Please sign in to comment.