summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGuy Benoish <guy.benoish@redislabs.com>2019-12-26 15:31:37 +0530
committerGuy Benoish <guy.benoish@redislabs.com>2019-12-26 15:31:37 +0530
commit1f75ce30dfdb1c8c4df8474f9580f2aff032cfb4 (patch)
tree2fa3174e9ec6d93e6af4e0802473d7be39c81f2a /tests
parent324e22accf457edc996971bc97f5474349cd7c4c (diff)
downloadredis-1f75ce30dfdb1c8c4df8474f9580f2aff032cfb4.tar.gz
Stream: Handle streamID-related edge cases
This commit solves several edge cases that are related to exhausting the streamID limits: We should correctly calculate the succeeding streamID instead of blindly incrementing 'seq' This affects both XREAD and XADD. Other (unrelated) changes: Reply with a better error message when trying to add an entry to a stream that has exhausted last_id
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/type/stream.tcl27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl
index 656bac5de..9840e3b74 100644
--- a/tests/unit/type/stream.tcl
+++ b/tests/unit/type/stream.tcl
@@ -328,6 +328,33 @@ start_server {
assert_equal [r xrevrange teststream2 1234567891245 -] {{1234567891240-0 {key1 value2}} {1234567891230-0 {key1 value1}}}
}
+
+ test {XREAD streamID edge (no-blocking)} {
+ r del x
+ r XADD x 1-1 f v
+ r XADD x 1-18446744073709551615 f v
+ r XADD x 2-1 f v
+ set res [r XREAD BLOCK 0 STREAMS x 1-18446744073709551615]
+ assert {[lindex $res 0 1 0] == {2-1 {f v}}}
+ }
+
+ test {XREAD streamID edge (blocking)} {
+ r del x
+ set rd [redis_deferring_client]
+ $rd XREAD BLOCK 0 STREAMS x 1-18446744073709551615
+ r XADD x 1-1 f v
+ r XADD x 1-18446744073709551615 f v
+ r XADD x 2-1 f v
+ set res [$rd read]
+ assert {[lindex $res 0 1 0] == {2-1 {f v}}}
+ }
+
+ test {XADD streamID edge} {
+ r del x
+ r XADD x 2577343934890-18446744073709551615 f v ;# we need the timestamp to be in the future
+ r XADD x * f2 v2
+ assert_equal [r XRANGE x - +] {{2577343934890-18446744073709551615 {f v}} {2577343934891-0 {f2 v2}}}
+ }
}
start_server {tags {"stream"} overrides {appendonly yes}} {