From dbff164e495ff39764da4c22fc367d9413b4fec5 Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Wed, 2 Oct 2024 15:49:18 +0200 Subject: [PATCH 1/5] compose dumps logs on all errors --- .../verify-compose/docker_compose.sh | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/actions/dbp-charts/verify-compose/docker_compose.sh b/.github/actions/dbp-charts/verify-compose/docker_compose.sh index 898c85d13..73b7b0a91 100755 --- a/.github/actions/dbp-charts/verify-compose/docker_compose.sh +++ b/.github/actions/dbp-charts/verify-compose/docker_compose.sh @@ -1,5 +1,25 @@ #!/bin/bash -e +containers_dump_logs_on_error() { + echo "Dumping logs for all containers" + docker-compose logs --no-color + exit 1 +} + +wait_result() { + COMPONENT=$1 + if (("${COUNTER}" < "${TIMEOUT}")); then + t1=$(date +%s) + delta=$(((t1 - t0) / 60)) + echo "$COMPONENT Started in ${delta} minutes" + else + echo "Waited ${COUNTER} seconds" + echo "$COMPONENT could not start in time." + echo "The last response code was ${response}" + containers_dump_logs_on_error + fi +} + COMPOSE_FILE=$(basename $COMPOSE_FILE_PATH) COMPOSE_PATH=$(dirname $COMPOSE_FILE_PATH) COMPOSE_BIN="docker compose" @@ -32,16 +52,7 @@ until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do COUNTER=$((COUNTER + WAIT_INTERVAL)) response=$(curl --write-out '%{http_code}' --output /dev/null --silent http://localhost:"${alf_port}"/alfresco/ || true) done -if (("${COUNTER}" < "${TIMEOUT}")); then - t1=$(date +%s) - delta=$(((t1 - t0) / 60)) - echo "Alfresco Started in ${delta} minutes" -else - echo "Waited ${COUNTER} seconds" - echo "Alfresco could not start in time." - echo "The last response code from /alfresco/ was ${response}" - exit 1 -fi +wait_result Alfresco COUNTER=0 echo "Waiting for share to start" @@ -52,16 +63,7 @@ until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do COUNTER=$((COUNTER + WAIT_INTERVAL)) response=$(curl --write-out '%{http_code}' --output /dev/null --silent http://localhost:8080/share/page || true) done -if (("${COUNTER}" < "${TIMEOUT}")); then - t1=$(date +%s) - delta=$(((t1 - t0) / 60)) - echo "Share Started in ${delta} minutes" -else - echo "Waited ${COUNTER} seconds" - echo "Share could not start in time." - echo "The last response code from /share/ was ${response}" - exit 1 -fi +wait_result Share COUNTER=0 TIMEOUT=20 @@ -73,12 +75,11 @@ until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do COUNTER=$((COUNTER + WAIT_INTERVAL)) response=$(curl --write-out '%{http_code}' --user admin:admin --output /dev/null --silent http://localhost:"${alf_port}"/alfresco/s/api/solrstats || true) done +wait_result Solr cd .. docker run -a STDOUT --volume "${PWD}"/test/postman/docker-compose:/etc/newman --network host postman/newman:5.3 run "acs-test-docker-compose-collection.json" --global-var "protocol=http" --global-var "url=localhost:8080" + retVal=$? -if [ "${retVal}" -ne 0 ]; then - # show logs - $COMPOSE_BIN logs --no-color - exit 1 -fi + +[ "${retVal}" -eq 0 ] && echo "Postman tests were successful" || containers_dump_logs_on_error From fc1a414323da61cd2a1a56a4252a6b2f3b8268cf Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Wed, 2 Oct 2024 18:00:18 +0200 Subject: [PATCH 2/5] always use compose file arg --- .../dbp-charts/verify-compose/docker_compose.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/dbp-charts/verify-compose/docker_compose.sh b/.github/actions/dbp-charts/verify-compose/docker_compose.sh index 73b7b0a91..db23875ac 100755 --- a/.github/actions/dbp-charts/verify-compose/docker_compose.sh +++ b/.github/actions/dbp-charts/verify-compose/docker_compose.sh @@ -1,8 +1,13 @@ #!/bin/bash -e +COMPOSE_FILE=$(basename $COMPOSE_FILE_PATH) +COMPOSE_PATH=$(dirname $COMPOSE_FILE_PATH) +COMPOSE_BIN="docker compose" +alf_port=8080 + containers_dump_logs_on_error() { echo "Dumping logs for all containers" - docker-compose logs --no-color + $COMPOSE_BIN -f "${COMPOSE_FILE}" logs --no-color exit 1 } @@ -20,11 +25,6 @@ wait_result() { fi } -COMPOSE_FILE=$(basename $COMPOSE_FILE_PATH) -COMPOSE_PATH=$(dirname $COMPOSE_FILE_PATH) -COMPOSE_BIN="docker compose" -alf_port=8080 - cd "$COMPOSE_PATH" || { echo "Error: docker compose dir not found" exit 1 @@ -33,7 +33,7 @@ docker info $COMPOSE_BIN version $COMPOSE_BIN -f "${COMPOSE_FILE}" config echo "Starting Alfresco in docker compose" -$COMPOSE_BIN ps +$COMPOSE_BIN -f "${COMPOSE_FILE}" ps if [ "$COMPOSE_PULL" = "true" ]; then $COMPOSE_BIN -f "${COMPOSE_FILE}" pull --quiet fi From 00ee2a2b0fce9680ddc06bd7fe244c313533c8d1 Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Wed, 2 Oct 2024 18:57:53 +0200 Subject: [PATCH 3/5] do not wait for Solr when no solr is configured --- .../verify-compose/docker_compose.sh | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/actions/dbp-charts/verify-compose/docker_compose.sh b/.github/actions/dbp-charts/verify-compose/docker_compose.sh index db23875ac..5ba25d0f3 100755 --- a/.github/actions/dbp-charts/verify-compose/docker_compose.sh +++ b/.github/actions/dbp-charts/verify-compose/docker_compose.sh @@ -65,17 +65,19 @@ until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do done wait_result Share -COUNTER=0 -TIMEOUT=20 -echo "Waiting more time for SOLR" -response=$(curl --write-out '%{http_code}' --user admin:admin --output /dev/null --silent http://localhost:"${alf_port}"/alfresco/s/api/solrstats || true) -until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do - printf '.' - sleep "${WAIT_INTERVAL}" - COUNTER=$((COUNTER + WAIT_INTERVAL)) +if [ $($COMPOSE_BIN -f "${COMPOSE_FILE}" config | yq '.services.alfresco.environment.JAVA_OPTS | contains(" -Dindex.subsystem.name=solr6")') == "true" ]; then echo "Waiting more time for SOLR" + COUNTER=0 + TIMEOUT=20 + response=$(curl --write-out '%{http_code}' --user admin:admin --output /dev/null --silent http://localhost:"${alf_port}"/alfresco/s/api/solrstats || true) -done -wait_result Solr + until [[ "200" -eq "${response}" ]] || [[ "${COUNTER}" -eq "${TIMEOUT}" ]]; do + printf '.' + sleep "${WAIT_INTERVAL}" + COUNTER=$((COUNTER + WAIT_INTERVAL)) + response=$(curl --write-out '%{http_code}' --user admin:admin --output /dev/null --silent http://localhost:"${alf_port}"/alfresco/s/api/solrstats || true) + done + wait_result Solr +fi cd .. docker run -a STDOUT --volume "${PWD}"/test/postman/docker-compose:/etc/newman --network host postman/newman:5.3 run "acs-test-docker-compose-collection.json" --global-var "protocol=http" --global-var "url=localhost:8080" From 7292cddf153f94c24e7d561f7dd40acd48f8cd2b Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Wed, 2 Oct 2024 19:11:25 +0200 Subject: [PATCH 4/5] version bump --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 2d88a61ba..4b85a6c11 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v7.1.0 +v7.1.1 From efd294fc1440ff0e9f55564da4fbe063471c8602 Mon Sep 17 00:00:00 2001 From: Alexandre Chapellon Date: Thu, 3 Oct 2024 10:52:24 +0200 Subject: [PATCH 5/5] rename function to dump logs --- .github/actions/dbp-charts/verify-compose/docker_compose.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/dbp-charts/verify-compose/docker_compose.sh b/.github/actions/dbp-charts/verify-compose/docker_compose.sh index 5ba25d0f3..493c3a991 100755 --- a/.github/actions/dbp-charts/verify-compose/docker_compose.sh +++ b/.github/actions/dbp-charts/verify-compose/docker_compose.sh @@ -5,7 +5,7 @@ COMPOSE_PATH=$(dirname $COMPOSE_FILE_PATH) COMPOSE_BIN="docker compose" alf_port=8080 -containers_dump_logs_on_error() { +dump_all_compose_logs() { echo "Dumping logs for all containers" $COMPOSE_BIN -f "${COMPOSE_FILE}" logs --no-color exit 1 @@ -21,7 +21,7 @@ wait_result() { echo "Waited ${COUNTER} seconds" echo "$COMPONENT could not start in time." echo "The last response code was ${response}" - containers_dump_logs_on_error + dump_all_compose_logs fi } @@ -84,4 +84,4 @@ docker run -a STDOUT --volume "${PWD}"/test/postman/docker-compose:/etc/newman - retVal=$? -[ "${retVal}" -eq 0 ] && echo "Postman tests were successful" || containers_dump_logs_on_error +[ "${retVal}" -eq 0 ] && echo "Postman tests were successful" || dump_all_compose_logs