Skip to content

Commit

Permalink
Print server startup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Jan 26, 2025
1 parent 4cb1342 commit 7f3bf5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 38 deletions.
41 changes: 7 additions & 34 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,45 +106,18 @@ remove_all_but_latest()
docker system prune --force
}

exit_non_zero_unless_started_cleanly()
echo_warnings()
{
local -r SERVICE_NAME="${1}" # {client|server}
local -r DOCKER_LOG=$(docker logs "${CONTAINER_NAME}" 2>&1)
# Handle known warnings (eg waiting on Gem upgrade)
# local -r SHADOW_WARNING="server.rb:(.*): warning: shadowing outer local variable - filename"
# DOCKER_LOG=$(strip_known_warning "${DOCKER_LOG}" "${SHADOW_WARNING}")
local -r SERVICE_NAME="${1}"
echo
echo "Checking if ${SERVICE_NAME} started cleanly."
if [ "$(top_5)" != "$(clean_top_5)" ]; then
echo "${SERVICE_NAME} did not start cleanly: docker log..."
echo 'expected------------------'
echo "$(clean_top_5)"
echo
echo 'actual--------------------'
echo "$(top_5)"
echo
echo 'diff--------------------'
grep -Fxvf <(clean_top_5) <(top_5)
echo
exit 42
fi
}

top_5()
{
docker logs "${CONTAINER_NAME}" 2>&1 | head -5
}

clean_top_5()
{
# 1st 5 lines on Puma
local -r L1="Puma starting in single mode..."
local -r L2='* Puma version: 6.5.0 ("Sky'"'"'s Version")'
local -r L3='* Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux-musl]'
local -r L4="* Min threads: 0"
local -r L5="* Max threads: 5"
#
local -r all5="$(printf "%s\n%s\n%s\n%s\n%s" "${L1}" "${L2}" "${L3}" "${L4}" "${L5}")"
echo "${all5}"
if echo "${DOCKER_LOG}" | grep --quiet "warning" ; then
echo "Warnings in ${SERVICE_NAME} container"
echo "${DOCKER_LOG}"
fi
}

strip_known_warning()
Expand Down
10 changes: 6 additions & 4 deletions bin/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ show_help()
Use: ${MY_NAME} {server|client} [ID...]
Options:
server - only run tests from inside the server (local only)
client - only run tests from inside the client (local and CI workflow)
server - only run tests from inside the server
client - only run tests from inside the client
ID... - only run tests matching these identifiers
To see the test ID and filename as each test runs:
Expand Down Expand Up @@ -110,11 +110,13 @@ run_tests_in_container()
run_tests()
{
check_args "$@"
local -r TYPE="${1}" # {server|client}
containers_down
setup_dependent_images "$@"
create_test_data_manifests_file
docker compose --progress=plain up --no-build --wait --wait-timeout=10 "${1}"
exit_non_zero_unless_started_cleanly "${1}"
# Don't do a build here, because in CI workflow, server image is built with GitHub Action
docker compose --progress=plain up --no-build --wait --wait-timeout=10 "${TYPE}"
echo_warnings "${TYPE}"
run_tests_in_container "$@"
}

Expand Down

0 comments on commit 7f3bf5b

Please sign in to comment.