Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightning: fix grep check in integration test #43821

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions br/tests/_utils/check_contains
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@

set -eu

if ! grep -Fq "$1" "$TEST_DIR/sql_res.$TEST_NAME.txt"; then
file_name="$TEST_DIR/sql_res.$TEST_NAME.txt"
if [ $# -gt 1 ]; then
file_name=$2
fi

if ! grep -Fq "$1" $file_name; then
echo "TEST FAILED: OUTPUT DOES NOT CONTAIN '$1'"
echo "____________________________________"
cat "$TEST_DIR/sql_res.$TEST_NAME.txt"
cat $file_name
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
exit 1
fi
9 changes: 7 additions & 2 deletions br/tests/_utils/check_not_contains
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@

set -eu

if grep -Fq -- "$1" "$TEST_DIR/sql_res.$TEST_NAME.txt"; then
file_name="$TEST_DIR/sql_res.$TEST_NAME.txt"
if [ $# -gt 1 ]; then
file_name=$2
fi

if grep -Fq -- "$1" $file_name; then
echo "TEST FAILED: OUTPUT CONTAINS '$1'"
echo "____________________________________"
cat "$TEST_DIR/sql_res.$TEST_NAME.txt"
cat $file_name
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
exit 1
fi
14 changes: 4 additions & 10 deletions br/tests/lightning_csv/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,13 @@ function run_with() {

rm -rf $TEST_DIR/lightning.log
run_with "local" "tests/$TEST_NAME/config-pause-global.toml"
grep -F 'pause pd scheduler of global scope' $TEST_DIR/lightning.log
if grep -F 'pause pd scheduler of table scope' $TEST_DIR/lightning.log; then
echo "should not contain 'table scope'"
exit 1
fi
check_contains 'pause pd scheduler of global scope' $TEST_DIR/lightning.log
check_not_contains 'pause pd scheduler of table scope' $TEST_DIR/lightning.log

rm -rf $TEST_DIR/lightning.log
run_with "local" "tests/$TEST_NAME/config.toml"
grep -F 'pause pd scheduler of table scope' $TEST_DIR/lightning.log
if grep -F 'pause pd scheduler of global scope' $TEST_DIR/lightning.log; then
echo "should not contain 'global scope'"
exit 1
fi
check_contains 'pause pd scheduler of table scope' $TEST_DIR/lightning.log
check_not_contains 'pause pd scheduler of global scope' $TEST_DIR/lightning.log

run_with "tidb" "tests/$TEST_NAME/config.toml"

Expand Down
22 changes: 11 additions & 11 deletions br/tests/lightning_error_summary/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ check_contains 'sum(k): 32'

# Verify the log contains the expected messages at the last few lines
tail -20 "$TEST_DIR/lightning-error-summary.log" > "$TEST_DIR/lightning-error-summary.tail"
grep -Fq '["tables failed to be imported"] [count=2]' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq '[-] [table=`error_summary`.`a`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq '[-] [table=`error_summary`.`c`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"
! grep -Fq '[-] [table=`error_summary`.`b`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"
check_contains '["tables failed to be imported"] [count=2]' "$TEST_DIR/lightning-error-summary.tail"
check_contains '[-] [table=`error_summary`.`a`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"
check_contains '[-] [table=`error_summary`.`c`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"
check_not_contains '[-] [table=`error_summary`.`b`] [status=checksum] [error="[Lighting:Restore:ErrChecksumMismatch]checksum mismatched' "$TEST_DIR/lightning-error-summary.tail"

# Now check the error log when the checkpoint is not cleaned.

Expand All @@ -61,10 +61,10 @@ set -e
[ "$ERRORCODE" -ne 0 ]

tail -100 "$TEST_DIR/lightning-error-summary.log" > "$TEST_DIR/lightning-error-summary.tail"
grep -Fq 'TiDB Lightning has failed last time. To prevent data loss, this run will stop now' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`a`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`c`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
! grep -Fq './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`b`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq 'checkpoint-error-destroy=all --config=...` to start from scratch' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq 'For details of this failure, read the log file' "$TEST_DIR/lightning-error-summary.tail"
grep -Fq 'PREVIOUS run' "$TEST_DIR/lightning-error-summary.tail"
check_contains 'TiDB Lightning has failed last time. To prevent data loss, this run will stop now' "$TEST_DIR/lightning-error-summary.tail"
check_contains './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`a`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
check_contains './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`c`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
check_not_contains './tidb-lightning-ctl --checkpoint-error-destroy='"'"'`error_summary`.`b`'"'"' --config=...' "$TEST_DIR/lightning-error-summary.tail"
check_contains 'checkpoint-error-destroy=all --config=...` to start from scratch' "$TEST_DIR/lightning-error-summary.tail"
check_contains 'For details of this failure, read the log file' "$TEST_DIR/lightning-error-summary.tail"
check_contains 'PREVIOUS run' "$TEST_DIR/lightning-error-summary.tail"
6 changes: 2 additions & 4 deletions br/tests/lightning_fail_fast/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ for CFG in chunk engine; do

tail -n 10 $TEST_DIR/lightning-tidb.log | grep "ERROR" | tail -n 1 | grep -Fq "Error 1062 (23000): Duplicate entry '1-1' for key 'tb.uq'"

! grep -Fq "restore file completed" $TEST_DIR/lightning-tidb.log
[ $? -eq 0 ]
check_not_contains "restore file completed" $TEST_DIR/lightning-tidb.log

! grep -Fq "restore engine completed" $TEST_DIR/lightning-tidb.log
[ $? -eq 0 ]
check_not_contains "restore engine completed" $TEST_DIR/lightning-tidb.log
done