From 3094eb36263e602731840ededd301ff21e7981d4 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 9 Oct 2018 15:45:58 +0800 Subject: [PATCH] Streams: add tests for aof rewrite --- tests/unit/type/stream.tcl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/unit/type/stream.tcl b/tests/unit/type/stream.tcl index 769ab5718..9acf11c74 100644 --- a/tests/unit/type/stream.tcl +++ b/tests/unit/type/stream.tcl @@ -402,3 +402,26 @@ start_server {tags {"xstream command"}} { set _ $err } {ERR no such key} } + +start_server {tags {"stream"} overrides {appendonly yes aof-use-rdb-preamble no}} { + test {Empty stream can be rewrite into AOF correctly} { + r XSTREAM CREATE mystream 0 + assert {[dict get [r xinfo stream mystream] length] == 0} + r bgrewriteaof + waitForBgrewriteaof r + r debug loadaof + assert {[dict get [r xinfo stream mystream] length] == 0} + } + + test {Stream can be rewrite into AOF correctly after XDEL lastid} { + r XADD mystream 1-1 a b + r XADD mystream 2-2 a b + assert {[dict get [r xinfo stream mystream] length] == 2} + r XDEL mystream 2-2 + r bgrewriteaof + waitForBgrewriteaof r + r debug loadaof + assert {[dict get [r xinfo stream mystream] length] == 1} + assert {[dict get [r xinfo stream mystream] last-generated-id] == "2-2"} + } +}