Last active
August 25, 2020 16:23
-
-
Save felipou/acd4469dffbfe02740dfe7465ee60b72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Existing tests | |
test "BRPOPLPUSH with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd brpoplpush blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal {foo bar} [r lrange target 0 -1] | |
} | |
test "BRPOPRPUSH with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd brpoprpush blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal {bar foo} [r lrange target 0 -1] | |
} | |
test "BLPOPLPUSH with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd blpoplpush blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal {foo bar} [r lrange target 0 -1] | |
} | |
test "BLPOPRPUSH with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd blpoprpush blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal {bar foo} [r lrange target 0 -1] | |
} | |
# Option 1 | |
foreach popdir {r l} { | |
foreach {pushdir a b} {r bar foo l foo bar} { | |
set cmd b${popdir}pop${pushdir}push | |
test "[string toupper $cmd] with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd $cmd blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal "$a $b" [r lrange target 0 -1] | |
} | |
} | |
} | |
# Option 2 | |
foreach {cmd a b} {brpoplpush foo bar brpoprpush bar foo blpoplpush foo bar blpoprpush bar foo} { | |
test "[string toupper $cmd] with zero timeout should block indefinitely" { | |
set rd [redis_deferring_client] | |
r del blist target | |
r rpush target bar | |
$rd $cmd blist target 0 | |
wait_for_condition 100 10 { | |
[s blocked_clients] == 1 | |
} else { | |
fail "Timeout waiting for blocked clients" | |
} | |
r rpush blist foo | |
assert_equal foo [$rd read] | |
assert_equal "$a $b" [r lrange target 0 -1] | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment