Unverified Commit a7c9e505 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix test and improve assert_replication_stream print the whole stream (#11793)

This PR has two parts:

1. Fix flaky test case, the previous tests set a lot of volatile keys,
it injects an unexpected DEL command into the replication stream during
the later test, causing it to fail. Add a flushall to avoid it.

2. Improve assert_replication_stream, now it can print the whole stream
rather than just the failing line.
parent 312654d5
......@@ -24,9 +24,11 @@ proc assert_no_match {pattern value} {
}
}
proc assert_match {pattern value {detail ""}} {
proc assert_match {pattern value {detail ""} {context ""}} {
if {![string match $pattern $value]} {
set context "(context: [info frame -1])"
if {$context eq ""} {
set context "(context: [info frame -1])"
}
error "assertion:Expected '$value' to match '$pattern' $context $detail"
}
}
......
......@@ -857,9 +857,22 @@ proc read_from_replication_stream {s} {
}
proc assert_replication_stream {s patterns} {
set errors 0
set values_list {}
set patterns_list {}
for {set j 0} {$j < [llength $patterns]} {incr j} {
assert_match [lindex $patterns $j] [read_from_replication_stream $s]
set pattern [lindex $patterns $j]
lappend patterns_list $pattern
set value [read_from_replication_stream $s]
lappend values_list $value
if {![string match $pattern $value]} { incr errors }
}
if {$errors == 0} { return }
set context [info frame -1]
close_replication_stream $s ;# for fast exit
assert_match $patterns_list $values_list "" $context
}
proc close_replication_stream {s} {
......
......@@ -628,6 +628,9 @@ start_server {tags {"expire"}} {
} {-1} {needs:debug}
test {GETEX propagate as to replica as PERSIST, DEL, or nothing} {
# In the above tests, many keys with random expiration times are set, flush
# the DBs to avoid active expiry kicking in and messing the replication streams.
r flushall
set repl [attach_to_replication_stream]
r set foo bar EX 100
r getex foo PERSIST
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment