summaryrefslogtreecommitdiff
path: root/tests/support
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-02-13 15:52:38 +0800
committerGitHub <noreply@github.com>2022-02-13 09:52:38 +0200
commit62c8be28ee7d15f90103f52bcf4a4c91f9ba7396 (patch)
treeaf314f7d8d18fc7023a661f85c0f8b6cf7b72685 /tests/support
parent2eb9b19612db39b1bb91902c9669e28883bbbee7 (diff)
downloadredis-62c8be28ee7d15f90103f52bcf4a4c91f9ba7396.tar.gz
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) ```
Diffstat (limited to 'tests/support')
-rw-r--r--tests/support/test.tcl8
-rw-r--r--tests/support/util.tcl4
2 files changed, 6 insertions, 6 deletions
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
}