Skip to content

Commit ba92ee5

Browse files
committed
Improve replica test debugging
- Print log excerpt on failure - Upload full log artifacts on failure - Clearly separate tests in log file
1 parent 9fee640 commit ba92ee5

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/replica-tests.yml

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

31+
- name: Upload test logs on failure
32+
if: failure()
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: test-logs-${{ matrix.image }}
36+
path: /tmp/gh-ost-test.*
37+
retention-days: 7
38+
3139
- name: Teardown environment
3240
if: always()
3341
run: script/docker-gh-ost-replica-tests down

localtests/test.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ test_single() {
225225
cat $tests_path/$test_name/create.sql
226226
return 1
227227
fi
228-
228+
229229
if [ -f $tests_path/$test_name/before.sql ]; then
230230
gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/before.sql
231231
gh-ost-test-mysql-replica --default-character-set=utf8mb4 test < $tests_path/$test_name/before.sql
@@ -310,7 +310,13 @@ test_single() {
310310
echo_dot
311311
echo $cmd >$exec_command_file
312312
echo_dot
313-
bash $exec_command_file 1>$test_logfile 2>&1
313+
{
314+
echo "==============================================================================="
315+
echo "TEST: $test_name"
316+
echo "TIME: $(date '+%Y-%m-%d %H:%M:%S')"
317+
echo "==============================================================================="
318+
} >$test_logfile 2>&1
319+
bash $exec_command_file >$test_logfile 2>&1
314320

315321
execution_result=$?
316322
cleanup
@@ -332,7 +338,10 @@ test_single() {
332338
if [ -f $tests_path/$test_name/expect_failure ]; then
333339
if [ $execution_result -eq 0 ]; then
334340
echo
335-
echo "ERROR $test_name execution was expected to exit on error but did not. cat $test_logfile"
341+
echo "ERROR $test_name execution was expected to exit on error but did not."
342+
echo "=== Last 50 lines of $test_logfile ==="
343+
tail -n 50 $test_logfile
344+
echo "=== End log excerpt ==="
336345
return 1
337346
fi
338347
if [ -s $tests_path/$test_name/expect_failure ]; then
@@ -342,7 +351,10 @@ test_single() {
342351
return 0
343352
fi
344353
echo
345-
echo "ERROR $test_name execution was expected to exit with error message '${expected_error_message}' but did not. cat $test_logfile"
354+
echo "ERROR $test_name execution was expected to exit with error message '${expected_error_message}' but did not."
355+
echo "=== Last 50 lines of $test_logfile ==="
356+
tail -n 50 $test_logfile
357+
echo "=== End log excerpt ==="
346358
return 1
347359
fi
348360
# 'expect_failure' file has no content. We generally agree that the failure is correct

0 commit comments

Comments
 (0)