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

Add missing pause tcl test to test_helper.tcl (#9158)

* Add keyname tags to avoid CROSSSLOT errors in external server CI
* Use new wait_for_blocked_clients_count in pause.tcl
parent 4278c45c
...@@ -70,6 +70,7 @@ set ::all_tests { ...@@ -70,6 +70,7 @@ set ::all_tests {
unit/hyperloglog unit/hyperloglog
unit/lazyfree unit/lazyfree
unit/wait unit/wait
unit/pause
unit/querybuf unit/querybuf
unit/pendingquerybuf unit/pendingquerybuf
unit/tls unit/tls
......
...@@ -15,11 +15,7 @@ start_server {tags {"pause network"}} { ...@@ -15,11 +15,7 @@ start_server {tags {"pause network"}} {
set rd [redis_deferring_client] set rd [redis_deferring_client]
$rd SET FOO BAR $rd SET FOO BAR
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s 0 blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
r client unpause r client unpause
assert_match "OK" [$rd read] assert_match "OK" [$rd read]
...@@ -33,30 +29,18 @@ start_server {tags {"pause network"}} { ...@@ -33,30 +29,18 @@ start_server {tags {"pause network"}} {
# Test that pfcount, which can replicate, is also blocked # Test that pfcount, which can replicate, is also blocked
set rd [redis_deferring_client] set rd [redis_deferring_client]
$rd PFCOUNT pause-hll $rd PFCOUNT pause-hll
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s 0 blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
# Test that publish, which adds the message to the replication # Test that publish, which adds the message to the replication
# stream is blocked. # stream is blocked.
set rd2 [redis_deferring_client] set rd2 [redis_deferring_client]
$rd2 publish foo bar $rd2 publish foo bar
wait_for_condition 50 100 { wait_for_blocked_clients_count 2 50 100
[s 0 blocked_clients] eq {2}
} else {
fail "Clients are not blocked"
}
# Test that SCRIPT LOAD, which is replicated. # Test that SCRIPT LOAD, which is replicated.
set rd3 [redis_deferring_client] set rd3 [redis_deferring_client]
$rd3 script load "return 1" $rd3 script load "return 1"
wait_for_condition 50 100 { wait_for_blocked_clients_count 3 50 100
[s 0 blocked_clients] eq {3}
} else {
fail "Clients are not blocked"
}
r client unpause r client unpause
assert_match "1" [$rd read] assert_match "1" [$rd read]
...@@ -92,11 +76,7 @@ start_server {tags {"pause network"}} { ...@@ -92,11 +76,7 @@ start_server {tags {"pause network"}} {
r client PAUSE 100000000 WRITE r client PAUSE 100000000 WRITE
assert_equal [$rd read] "QUEUED" assert_equal [$rd read] "QUEUED"
$rd EXEC $rd EXEC
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s 0 blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
r client unpause r client unpause
assert_match "OK" [$rd read] assert_match "OK" [$rd read]
$rd close $rd close
...@@ -106,12 +86,8 @@ start_server {tags {"pause network"}} { ...@@ -106,12 +86,8 @@ start_server {tags {"pause network"}} {
r client PAUSE 100000000 WRITE r client PAUSE 100000000 WRITE
set rd [redis_deferring_client] set rd [redis_deferring_client]
$rd EVAL "return 1" 0 $rd EVAL "return 1" 0
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s 0 blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
r client unpause r client unpause
assert_match "1" [$rd read] assert_match "1" [$rd read]
$rd close $rd close
...@@ -123,12 +99,8 @@ start_server {tags {"pause network"}} { ...@@ -123,12 +99,8 @@ start_server {tags {"pause network"}} {
foreach client $clients { foreach client $clients {
$client SET FOO BAR $client SET FOO BAR
} }
wait_for_condition 50 100 { wait_for_blocked_clients_count 3 50 100
[s 0 blocked_clients] eq {3}
} else {
fail "Clients are not blocked"
}
r client unpause r client unpause
foreach client $clients { foreach client $clients {
assert_match "OK" [$client read] assert_match "OK" [$client read]
...@@ -143,16 +115,16 @@ start_server {tags {"pause network"}} { ...@@ -143,16 +115,16 @@ start_server {tags {"pause network"}} {
r client unpause r client unpause
} }
test "Test both active and passive expiries are skipped during client pause" { test "Test both active and passive expires are skipped during client pause" {
set expired_keys [s 0 expired_keys] set expired_keys [s 0 expired_keys]
r multi r multi
r set foo bar PX 10 r set foo{t} bar{t} PX 10
r set bar foo PX 10 r set bar{t} foo{t} PX 10
r client PAUSE 100000000 WRITE r client PAUSE 100000000 WRITE
r exec r exec
wait_for_condition 10 100 { wait_for_condition 10 100 {
[r get foo] == {} && [r get bar] == {} [r get foo{t}] == {} && [r get bar{t}] == {}
} else { } else {
fail "Keys were never logically expired" fail "Keys were never logically expired"
} }
...@@ -163,8 +135,8 @@ start_server {tags {"pause network"}} { ...@@ -163,8 +135,8 @@ start_server {tags {"pause network"}} {
r client unpause r client unpause
# Force the keys to expire # Force the keys to expire
r get foo r get foo{t}
r get bar r get bar{t}
# Now that clients have been unpaused, expires should go through # Now that clients have been unpaused, expires should go through
assert_match [expr $expired_keys + 2] [s 0 expired_keys] assert_match [expr $expired_keys + 2] [s 0 expired_keys]
...@@ -172,23 +144,19 @@ start_server {tags {"pause network"}} { ...@@ -172,23 +144,19 @@ start_server {tags {"pause network"}} {
test "Test that client pause starts at the end of a transaction" { test "Test that client pause starts at the end of a transaction" {
r MULTI r MULTI
r SET FOO1 BAR r SET FOO1{t} BAR
r client PAUSE 100000000 WRITE r client PAUSE 100000000 WRITE
r SET FOO2 BAR r SET FOO2{t} BAR
r exec r exec
set rd [redis_deferring_client] set rd [redis_deferring_client]
$rd SET FOO3 BAR $rd SET FOO3{t} BAR
wait_for_condition 50 100 { wait_for_blocked_clients_count 1 50 100
[s 0 blocked_clients] eq {1}
} else {
fail "Clients are not blocked"
}
assert_match "BAR" [r GET FOO1] assert_match "BAR" [r GET FOO1{t}]
assert_match "BAR" [r GET FOO2] assert_match "BAR" [r GET FOO2{t}]
assert_match "" [r GET FOO3] assert_match "" [r GET FOO3{t}]
r client unpause r client unpause
assert_match "OK" [$rd read] assert_match "OK" [$rd read]
......
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