From 62c8be28ee7d15f90103f52bcf4a4c91f9ba7396 Mon Sep 17 00:00:00 2001 From: Binbin Date: Sun, 13 Feb 2022 15:52:38 +0800 Subject: Regression test for sync psync crash (#10288) Added regression tests for #10020 / #10081 / #10243. The above PRs fixed some crashes due to an asserting, see function `clientHasPendingReplies` (introduced in #9166). This commit added some tests to cover the above scenario. These tests will all fail in #9166, althought fixed not, there is value in adding these tests to cover and verify the changes. And it also can cover #8868 (verify the logs). Other changes: 1. Reduces the wait time in `waitForBgsave` and `waitForBgrewriteaof` from 1s to 50ms, which should reduce the time for some tests. 2. Improve the test infra to print context when `assert_match` fails. 3. Improve the test infra to print `$error` when `assert_error` fails. ``` Expected an error matching 'ERR*' but got 'OK' (context: type eval line 4 cmd {assert_error "ERR*" {r set a b}} proc ::test) ``` --- tests/support/test.tcl | 8 ++++---- tests/support/util.tcl | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/support') diff --git a/tests/support/test.tcl b/tests/support/test.tcl index db3a81e06..f5de12256 100644 --- a/tests/support/test.tcl +++ b/tests/support/test.tcl @@ -24,10 +24,10 @@ proc assert_no_match {pattern value} { } } -proc assert_match {pattern value} { +proc assert_match {pattern value {detail ""}} { if {![string match $pattern $value]} { set context "(context: [info frame -1])" - error "assertion:Expected '$value' to match '$pattern' $context" + error "assertion:Expected '$value' to match '$pattern' $context $detail" } } @@ -84,9 +84,9 @@ proc assert_range {value min max {detail ""}} { proc assert_error {pattern code {detail ""}} { if {[catch {uplevel 1 $code} error]} { - assert_match $pattern $error + assert_match $pattern $error $detail } else { - assert_failed "assertion:Expected an error but nothing was caught" $detail + assert_failed "Expected an error matching '$pattern' but got '$error'" $detail } } diff --git a/tests/support/util.tcl b/tests/support/util.tcl index 9d1a127ed..46c9654c8 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -89,7 +89,7 @@ proc waitForBgsave r { puts -nonewline "\nWaiting for background save to finish... " flush stdout } - after 1000 + after 50 } else { break } @@ -103,7 +103,7 @@ proc waitForBgrewriteaof r { puts -nonewline "\nWaiting for background AOF rewrite to finish... " flush stdout } - after 1000 + after 50 } else { break } -- cgit v1.2.1