From 4ae4d3b61d8a7713e51d9d8116efdfd2e93cc427 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 14 Nov 2023 17:30:01 -0600 Subject: [PATCH] Print docker container logs in webapp test. (#649) --- .../cerc-nextjs-base/scripts/start-serving-app.sh | 9 ++------- tests/webapp-test/run-webapp-test.sh | 12 ++++++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh index aec65f29..bf35bcdb 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh @@ -39,17 +39,12 @@ if [ "$CERC_NEXTJS_SKIP_GENERATE" != "true" ]; then count=0 generate_done="false" - while [ $count -lt $CERC_MAX_GENERATE_TIME ]; do + while [ $count -lt $CERC_MAX_GENERATE_TIME ] && [ "$generate_done" == "false" ]; do sleep 1 + count=$((count + 1)) grep 'rendered as static HTML' gen.out > /dev/null if [ $? -eq 0 ]; then generate_done="true" - ps -ef | grep 'node' | grep 'next' | grep 'generate' >/dev/null - if [ $? -ne 0 ]; then - break - fi - else - count=$((count + 1)) fi done diff --git a/tests/webapp-test/run-webapp-test.sh b/tests/webapp-test/run-webapp-test.sh index d32e0eba..5db382f8 100755 --- a/tests/webapp-test/run-webapp-test.sh +++ b/tests/webapp-test/run-webapp-test.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -e + if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi + # Dump environment variables for debugging echo "Environment variables:" env @@ -28,16 +30,18 @@ CHECK="SPECIAL_01234567890_TEST_STRING" set +e -CONTAINER_ID=$(docker run -p 3000:3000 -d cerc/test-progressive-web-app:local) +CONTAINER_ID=$(docker run -p 3000:3000 -d -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG cerc/test-progressive-web-app:local) sleep 3 -wget -O test.before -m http://localhost:3000 +wget -t 7 -O test.before -m http://localhost:3000 +docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID -CONTAINER_ID=$(docker run -p 3000:3000 -e CERC_WEBAPP_DEBUG=$CHECK -d cerc/test-progressive-web-app:local) +CONTAINER_ID=$(docker run -p 3000:3000 -e CERC_WEBAPP_DEBUG=$CHECK -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG -d cerc/test-progressive-web-app:local) sleep 3 -wget -O test.after -m http://localhost:3000 +wget -t 7 -O test.after -m http://localhost:3000 +docker logs $CONTAINER_ID docker remove -f $CONTAINER_ID echo "###########################################################################"