Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c99f1206
Commit
c99f1206
authored
Nov 12, 2018
by
Qu Chen
Committed by
antirez
Nov 28, 2018
Browse files
Add unit test for stream XCLAIM command.
parent
edd3939b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/type/stream-cgroups.tcl
View file @
c99f1206
...
@@ -147,6 +147,54 @@ start_server {
...
@@ -147,6 +147,54 @@ start_server {
assert
{[
lindex $res 0 1 1
]
==
{
2-0
{
field1 B
}}}
assert
{[
lindex $res 0 1 1
]
==
{
2-0
{
field1 B
}}}
}
}
test
{
XCLAIM can claim PEL items from another consumer
}
{
# Add 3 items into the stream, and create a consumer group
r del mystream
set id1
[
r XADD mystream * a 1
]
set id2
[
r XADD mystream * b 2
]
set id3
[
r XADD mystream * c 3
]
r XGROUP CREATE mystream mygroup 0
# Client 1 reads item 1 from the stream without acknowledgements.
# Client 2 then claims pending item 1 from the PEL of client 1
set reply
[
r XREADGROUP GROUP mygroup client1 count 1 STREAMS mystream >
]
assert
{[
llength
[
lindex $reply 0 1 0 1
]]
== 2
}
assert
{[
lindex $reply 0 1 0 1
]
eq
{
a 1
}}
r debug sleep 0.2
set reply
[
r XCLAIM mystream mygroup client2 10 $id1
]
assert
{[
llength
[
lindex $reply 0 1
]]
== 2
}
assert
{[
lindex $reply 0 1
]
eq
{
a 1
}}
# Client 1 reads another 2 items from stream
r XREADGROUP GROUP mygroup client1 count 2 STREAMS mystream >
r debug sleep 0.2
# Delete item 2 from the stream. Now client 1 has PEL that contains
# only item 3. Try to use client 2 to claim the deleted item 2
# from the PEL of client 1, this should return nil
r XDEL mystream $id2
set reply
[
r XCLAIM mystream mygroup client2 10 $id2
]
assert
{[
llength $reply
]
== 1
}
assert_equal
""
[
lindex $reply 0
]
# Delete item 3 from the stream. Now client 1 has PEL that is empty.
# Try to use client 2 to claim the deleted item 3 from the PEL
# of client 1, this should return nil
r debug sleep 0.2
r XDEL mystream $id3
set reply
[
r XCLAIM mystream mygroup client2 10 $id3
]
assert
{[
llength $reply
]
== 1
}
assert_equal
""
[
lindex $reply 0
]
}
start_server
{}
{
start_server
{}
{
set master
[
srv -1 client
]
set master
[
srv -1 client
]
set master_host
[
srv -1 host
]
set master_host
[
srv -1 host
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment