Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redis
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
What's new
5
Snippets
Groups
Projects
gitlab-org
build
omnibus-mirror
redis
Commits
8ea7a3ee
Commit
8ea7a3ee
authored
5 years ago
by
antirez
Browse files
Options
Downloads
Patches
Plain Diff
Tracking: first set of tests for the feature.
parent
47177c9e
Branches
csc2
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/tracking.tcl
+66
-0
66 additions, 0 deletions
tests/unit/tracking.tcl
with
66 additions
and
0 deletions
tests/unit/tracking.tcl
0 → 100644
+
66
−
0
View file @
8ea7a3ee
start_server
{
tags
{
"tracking"
}}
{
# Create a deferred client we'll use to redirect invalidation
# messages to.
set rd1
[
redis_deferring_client
]
$rd1 client id
set redir
[
$rd1
read
]
$rd1 subscribe __redis__:invalidate
$rd1 read
;
# Consume the SUBSCRIBE reply.
test
{
Clients are able to enable tracking and redirect it
}
{
r CLIENT TRACKING on REDIRECT $redir
}
{
*OK
}
test
{
The other connection is able to get invalidations
}
{
r SET a 1
r GET a
r INCR a
r INCR b
;
# This key should not be notified, since it wasn't fetched.
set keys
[
lindex
[
$rd1
read
]
2
]
assert
{[
llength $keys
]
== 1
}
assert
{[
lindex $keys 0
]
eq
{
a
}}
}
test
{
The client is now able to disable tracking
}
{
# Make sure to add a few more keys in the tracking list
# so that we can check for leaks, as a side effect.
r MGET a b c d e f g
r CLIENT TRACKING off
}
test
{
Clients can enable the BCAST mode with the empty prefix
}
{
r CLIENT TRACKING on BCAST REDIRECT $redir
}
{
*OK*
}
test
{
The connection gets invalidation messages about all the keys
}
{
r MSET a 1 b 2 c 3
set keys
[
lsort
[
lindex
[
$rd1
read
]
2
]]
assert
{
$keys
eq
{
a b c
}}
}
test
{
Clients can enable the BCAST mode with prefixes
}
{
r CLIENT TRACKING off
r CLIENT TRACKING on BCAST REDIRECT $redir PREFIX a: PREFIX b:
r MULTI
r INCR a:1
r INCR a:2
r INCR b:1
r INCR b:2
r EXEC
# 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
{
a:1 a:2 b:1 b:2
}}
}
test
{
Adding prefixes to BCAST mode works
}
{
r CLIENT TRACKING on BCAST REDIRECT $redir PREFIX c:
r INCR c:1234
set keys
[
lsort
[
lindex
[
$rd1
read
]
2
]]
assert
{
$keys
eq
{
c:1234
}}
}
$rd1 close
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment