Skip to content

Commit 9bd6bc4

Browse files
authored
Merge pull request #6980 from BOINC/vko_improve_integration_testing
Save logs if server testing has failed
2 parents daef5e9 + 606e7e1 commit 9bd6bc4

2 files changed

Lines changed: 95 additions & 2 deletions

File tree

.github/workflows/linux.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ jobs:
212212
213213
- name: Install dependencies for integration testing
214214
if: success() && matrix.type == 'integration-test'
215+
env:
216+
BOINC_INTEGRATION_LOG_DIR: ${{ runner.temp }}/integration-test-logs
215217
run: |
216218
sudo apt-get install ansible
217219
sudo service mysql stop
@@ -445,8 +447,43 @@ jobs:
445447

446448
- name: Execute integration-test
447449
if: success() && matrix.type == 'integration-test'
450+
env:
451+
BOINC_INTEGRATION_LOG_DIR: ${{ runner.temp }}/integration-test-logs
448452
run: ./tests/integration_test/executeTestSuite.sh
449453

454+
- name: Collect integration-test docker logs
455+
if: ${{ always() && matrix.type == 'integration-test' }}
456+
env:
457+
BOINC_INTEGRATION_LOG_DIR: ${{ runner.temp }}/integration-test-logs
458+
run: |
459+
mkdir -p "$BOINC_INTEGRATION_LOG_DIR"
460+
461+
if [ -d /tmp/boinc-server-docker ]; then
462+
cd /tmp/boinc-server-docker
463+
464+
if ! docker compose ps -a > "$BOINC_INTEGRATION_LOG_DIR/docker-compose-ps.txt" 2>&1; then
465+
echo "docker compose ps -a failed while collecting integration-test diagnostics" >> "$BOINC_INTEGRATION_LOG_DIR/docker-compose-ps.txt"
466+
fi
467+
468+
if ! docker compose logs --no-color > "$BOINC_INTEGRATION_LOG_DIR/docker-compose.log" 2>&1; then
469+
echo "docker compose logs failed while collecting integration-test diagnostics" >> "$BOINC_INTEGRATION_LOG_DIR/docker-compose.log"
470+
fi
471+
else
472+
echo "/tmp/boinc-server-docker was not created" > "$BOINC_INTEGRATION_LOG_DIR/docker-compose.log"
473+
fi
474+
475+
if ! docker ps -a > "$BOINC_INTEGRATION_LOG_DIR/docker-ps.txt" 2>&1; then
476+
echo "docker ps -a failed while collecting integration-test diagnostics" >> "$BOINC_INTEGRATION_LOG_DIR/docker-ps.txt"
477+
fi
478+
479+
- name: Upload integration-test docker logs
480+
if: ${{ always() && matrix.type == 'integration-test' }}
481+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
482+
with:
483+
name: linux_integration_test_docker_logs_${{ github.sha }}
484+
path: ${{ runner.temp }}/integration-test-logs
485+
if-no-files-found: warn
486+
450487
- name: Prepare logs on failure
451488
if: ${{ failure() }}
452489
run: python ./deploy/prepare_deployment.py logs

tests/integration_test/installTestSuite.sh

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,52 @@ fi
6464

6565
ROOTDIR=$(pwd)
6666
PREFIX=$ROOTDIR/tests/server-test
67+
BOINC_SERVER_DOCKER_DIR=/tmp/boinc-server-docker
68+
INTEGRATION_LOG_DIR=${BOINC_INTEGRATION_LOG_DIR:-${TMPDIR:-/tmp}/boinc-integration-logs}
69+
STARTUP_TIMEOUT_SECONDS=${BOINC_SERVER_STARTUP_TIMEOUT_SECONDS:-300}
70+
STARTUP_POLL_INTERVAL_SECONDS=${BOINC_SERVER_STARTUP_POLL_INTERVAL_SECONDS:-5}
71+
docker_logs_pid=""
6772
test_dir=""
73+
74+
start_docker_log_stream() {
75+
current_dir=$(pwd)
76+
77+
if [ ! -f "${BOINC_SERVER_DOCKER_DIR}/docker-compose.yml" ]; then
78+
return
79+
fi
80+
81+
mkdir -p "${INTEGRATION_LOG_DIR}"
82+
: > "${INTEGRATION_LOG_DIR}/docker-compose-live.log"
83+
84+
cd "${BOINC_SERVER_DOCKER_DIR}" || exit 1
85+
docker compose logs -f --no-color > "${INTEGRATION_LOG_DIR}/docker-compose-live.log" 2>&1 &
86+
docker_logs_pid=$!
87+
cd "${current_dir}" || exit 1
88+
}
89+
90+
stop_docker_log_stream() {
91+
if [ -n "${docker_logs_pid}" ] && kill -0 "${docker_logs_pid}" 2>/dev/null; then
92+
kill "${docker_logs_pid}"
93+
wait "${docker_logs_pid}" 2>/dev/null
94+
fi
95+
}
96+
97+
on_exit() {
98+
status=$1
99+
trap - EXIT
100+
101+
stop_docker_log_stream
102+
103+
if [ "${status}" -ne 0 ] && [ -f "${INTEGRATION_LOG_DIR}/docker-compose-live.log" ]; then
104+
echo
105+
echo "Docker compose logs (last 200 lines):"
106+
tail -n 200 "${INTEGRATION_LOG_DIR}/docker-compose-live.log"
107+
echo
108+
echo "Integration test diagnostics saved to ${INTEGRATION_LOG_DIR}"
109+
fi
110+
}
111+
112+
trap 'on_exit $?' EXIT
68113
while [[ $# -gt 0 ]]; do
69114
key="$1"
70115
case $key in
@@ -109,9 +154,20 @@ if [ $? -ne 0 ]; then exit 1; fi
109154
ansible-playbook -i hosts start.yml
110155
if [ $? -ne 0 ]; then exit 1; fi
111156

112-
until $(curl -o /dev/null -SsifL http://127.0.0.1/boincserver/index.php ); do
157+
start_docker_log_stream
158+
159+
startup_deadline=$((SECONDS + STARTUP_TIMEOUT_SECONDS))
160+
until curl -o /dev/null -SsifL http://127.0.0.1/boincserver/index.php; do
161+
if [ "${SECONDS}" -ge "${startup_deadline}" ]; then
162+
echo
163+
echo "Timed out waiting ${STARTUP_TIMEOUT_SECONDS} seconds for http://127.0.0.1/boincserver/index.php"
164+
mkdir -p "${INTEGRATION_LOG_DIR}"
165+
curl -v http://127.0.0.1/boincserver/index.php > "${INTEGRATION_LOG_DIR}/curl-startup-check.txt" 2>&1
166+
exit 1
167+
fi
113168
printf '.'
114-
sleep 5
169+
sleep "${STARTUP_POLL_INTERVAL_SECONDS}"
115170
done
171+
printf '\n'
116172

117173
cd "${ROOTDIR}" || exit 1

0 commit comments

Comments
 (0)