Skip to content

Commit 06df80d

Browse files
committed
Improve replica test debugging
- Print log excerpt on failure - Upload full log artifacts on failure
1 parent 9fee640 commit 06df80d

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

.github/workflows/replica-tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ jobs:
2828
- name: Run tests
2929
run: script/docker-gh-ost-replica-tests run
3030

31+
- name: Set artifact name
32+
if: failure()
33+
run: |
34+
ARTIFACT_NAME=$(echo "${{ matrix.image }}" | tr '/:' '-')
35+
echo "ARTIFACT_NAME=test-logs-${ARTIFACT_NAME}" >> $GITHUB_ENV
36+
37+
- name: Upload test logs on failure
38+
if: failure()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ env.ARTIFACT_NAME }}
42+
path: /tmp/gh-ost-test.*
43+
retention-days: 7
44+
3145
- name: Teardown environment
3246
if: always()
3347
run: script/docker-gh-ost-replica-tests down

localtests/test.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ verify_master_and_replica() {
107107
fi
108108
}
109109

110-
exec_cmd() {
111-
echo "$@"
112-
command "$@" 1>$test_logfile 2>&1
113-
return $?
114-
}
115-
116110
echo_dot() {
117111
echo -n "."
118112
}
@@ -225,7 +219,7 @@ test_single() {
225219
cat $tests_path/$test_name/create.sql
226220
return 1
227221
fi
228-
222+
229223
if [ -f $tests_path/$test_name/before.sql ]; then
230224
gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/before.sql
231225
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test < $tests_path/$test_name/before.sql
@@ -310,7 +304,7 @@ test_single() {
310304
echo_dot
311305
echo $cmd >$exec_command_file
312306
echo_dot
313-
bash $exec_command_file 1>$test_logfile 2>&1
307+
bash $exec_command_file >$test_logfile 2>&1
314308

315309
execution_result=$?
316310
cleanup
@@ -332,7 +326,10 @@ test_single() {
332326
if [ -f $tests_path/$test_name/expect_failure ]; then
333327
if [ $execution_result -eq 0 ]; then
334328
echo
335-
echo "ERROR $test_name execution was expected to exit on error but did not. cat $test_logfile"
329+
echo "ERROR $test_name execution was expected to exit on error but did not."
330+
echo "=== Last 50 lines of $test_logfile ==="
331+
tail -n 50 $test_logfile
332+
echo "=== End log excerpt ==="
336333
return 1
337334
fi
338335
if [ -s $tests_path/$test_name/expect_failure ]; then
@@ -342,7 +339,10 @@ test_single() {
342339
return 0
343340
fi
344341
echo
345-
echo "ERROR $test_name execution was expected to exit with error message '${expected_error_message}' but did not. cat $test_logfile"
342+
echo "ERROR $test_name execution was expected to exit with error message '${expected_error_message}' but did not."
343+
echo "=== Last 50 lines of $test_logfile ==="
344+
tail -n 50 $test_logfile
345+
echo "=== End log excerpt ==="
346346
return 1
347347
fi
348348
# 'expect_failure' file has no content. We generally agree that the failure is correct

0 commit comments

Comments
 (0)