Skip to content

Commit

Permalink
Improvements to e2e logs (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Dec 20, 2024
1 parent d0ec02c commit 80caec2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
CONTAINER_SERVER: playwright_tests_server
CONTAINER_PROXY: playwright_tests_proxy
CONTAINER_RTCD: playwright_tests_rtcd
CONTAINER_OFFLOADER: playwright_tests_offloader
IMAGE_CALLS_OFFLOADER: mattermost/calls-offloader:v0.8.0
IMAGE_CALLS_RECORDER: mattermost/calls-recorder:v0.7.7
IMAGE_CALLS_TRANSCRIBER: mattermost/calls-transcriber:v0.5.0
Expand Down
3 changes: 2 additions & 1 deletion e2e/scripts/prepare-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function print_logs {
docker logs ${CONTAINER_SERVER}2
docker logs ${CONTAINER_PROXY}
docker logs ${CONTAINER_RTCD}
docker logs ${CONTAINER_OFFLOADER}
}

trap print_logs EXIT
Expand Down Expand Up @@ -55,7 +56,7 @@ docker run --rm --quiet --name "${COMPOSE_PROJECT_NAME}_curl_rtcd" --net ${DOCKE

echo "Spawning calls-offloader service with docker host access ..."
# Spawn calls offloader image as root to access local docker socket
docker run -d --quiet --user root --name "${COMPOSE_PROJECT_NAME}_callsoffloader" \
docker run -d --quiet --user root --name "${CONTAINER_OFFLOADER}" \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
--net ${DOCKER_NETWORK} \
--env "API_SECURITY_ALLOWSELFREGISTRATION=true" \
Expand Down
48 changes: 29 additions & 19 deletions e2e/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@ set -eu
set -o pipefail

function print_logs {
docker logs ${CONTAINER_SERVER}1
docker logs ${CONTAINER_SERVER}2
docker logs ${CONTAINER_PROXY}
exit_code=$?
if [[ ${exit_code} -ne 0 ]]; then
echo "Script exited with failure code ${exit_code}, printing logs..."
docker logs ${CONTAINER_SERVER}1
docker logs ${CONTAINER_SERVER}2
docker logs ${CONTAINER_PROXY}
docker logs ${CONTAINER_RTCD}
docker logs ${CONTAINER_OFFLOADER}

# Log all containers
docker ps -a

# Print transcriber job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-transcriber:master" --filter=status="exited" --format "{{.ID}}"); do
docker logs $ID
done

# Print recorder job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-recorder:master" --filter=status="exited" --format "{{.ID}}"); do
docker logs $ID
done
fi
}

trap print_logs EXIT
Expand Down Expand Up @@ -73,26 +92,17 @@ docker run -d --name playwright-e2e \

docker logs -f playwright-e2e

# Log all containers
docker ps -a

# Offloader logs
docker logs "${COMPOSE_PROJECT_NAME}_callsoffloader"

# Print transcriber job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-transcriber:master" --filter=status="exited" --format "{{.ID}}"); do
docker logs $ID
done

# Print recorder job logs in case of failure.
for ID in $(docker ps -a --filter=ancestor="calls-recorder:master" --filter=status="exited" --format "{{.ID}}"); do
docker logs $ID
done

docker cp playwright-e2e:/usr/src/calls-e2e/test-results results/test-results-${CI_NODE_INDEX}
docker cp playwright-e2e:/usr/src/calls-e2e/playwright-report results/playwright-report-${CI_NODE_INDEX}
docker cp playwright-e2e:/usr/src/calls-e2e/pw-results.json results/pw-results-${CI_NODE_INDEX}.json

## Dumping services logs to be uploaded as artifacts in case of failures.
docker logs ${CONTAINER_SERVER}1 >"${WORKSPACE}/logs/server1.log"
docker logs ${CONTAINER_SERVER}2 >"${WORKSPACE}/logs/server2.log"
docker logs ${CONTAINER_PROXY} >"${WORKSPACE}/logs/proxy.log"
docker logs ${CONTAINER_RTCD} >"${WORKSPACE}/logs/rtcd.log"
docker logs ${CONTAINER_OFFLOADER} >"${WORKSPACE}/logs/offloader.log"

## Check if we have an early failures in order to upload logs
NUM_FAILURES=0
NUM_FAILURES=$((NUM_FAILURES + $(jq '.suites[].suites[].specs[].tests[] | last(.results[]) | select(.status != "passed").status' <"${WORKSPACE}/results/pw-results-${RUN_ID}.json" | wc -l)))
Expand Down

0 comments on commit 80caec2

Please sign in to comment.