summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-04-22 11:24:19 +0200
committerantirez <antirez@gmail.com>2020-04-22 11:24:19 +0200
commit58d61dd639382fc05a2516a45656ff83ebcb18ee (patch)
treeb756ef2059791a7679fd6018472b11b27546256f
parent2d1968f841277e363c14d1a2f56dd295dc49906c (diff)
downloadredis-58d61dd639382fc05a2516a45656ff83ebcb18ee.tar.gz
Tracking: NOLOOP tests.
-rw-r--r--tests/unit/tracking.tcl32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/tracking.tcl b/tests/unit/tracking.tcl
index 2058319f7..dc6cd671a 100644
--- a/tests/unit/tracking.tcl
+++ b/tests/unit/tracking.tcl
@@ -7,6 +7,9 @@ start_server {tags {"tracking"}} {
$rd1 subscribe __redis__:invalidate
$rd1 read ; # Consume the SUBSCRIBE reply.
+ # Create another client as well in order to test NOLOOP
+ set rd2 [redis_deferring_client]
+
test {Clients are able to enable tracking and redirect it} {
r CLIENT TRACKING on REDIRECT $redir
} {*OK}
@@ -62,5 +65,34 @@ start_server {tags {"tracking"}} {
assert {$keys eq {c:1234}}
}
+ test {Tracking NOLOOP mode in standard mode works} {
+ r CLIENT TRACKING off
+ r CLIENT TRACKING on REDIRECT $redir NOLOOP
+ r MGET otherkey1 loopkey otherkey2
+ $rd2 SET otherkey1 1; # We should get this
+ r SET loopkey 1 ; # We should not get this
+ $rd2 SET otherkey2 1; # We should get this
+ # Because of the internals, we know we are going to receive
+ # two separated notifications for the two different prefixes.
+ set keys1 [lsort [lindex [$rd1 read] 2]]
+ set keys2 [lsort [lindex [$rd1 read] 2]]
+ set keys [lsort [list {*}$keys1 {*}$keys2]]
+ assert {$keys eq {otherkey1 otherkey2}}
+ }
+
+ test {Tracking NOLOOP mode in BCAST mode works} {
+ r CLIENT TRACKING off
+ r CLIENT TRACKING on BCAST REDIRECT $redir NOLOOP
+ $rd2 SET otherkey1 1; # We should get this
+ r SET loopkey 1 ; # We should not get this
+ $rd2 SET otherkey2 1; # We should get this
+ # Because of the internals, we know we are going to receive
+ # two separated notifications for the two different prefixes.
+ set keys1 [lsort [lindex [$rd1 read] 2]]
+ set keys2 [lsort [lindex [$rd1 read] 2]]
+ set keys [lsort [list {*}$keys1 {*}$keys2]]
+ assert {$keys eq {otherkey1 otherkey2}}
+ }
+
$rd1 close
}