Skip to content

Commit

Permalink
fix five Data structure tcl bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxianrong committed Mar 18, 2024
1 parent cacd576 commit b490e8e
Show file tree
Hide file tree
Showing 13 changed files with 1,371 additions and 314 deletions.
4 changes: 3 additions & 1 deletion tests/test_helper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ set ::all_tests {
unit/scan
unit/multi
unit/quit
unit/type/list
unit/pubsub
unit/slowlog
unit/maxmemory
unit/bitops
unit/hyperloglog
unit/type
unit/acl
unit/type/geo
unit/type/list
unit/type/list-2
unit/type/list-3
unit/type/set
unit/type/zset
unit/type/string
unit/type/hash
unit/type/stream
# unit/expire
# unit/protocol
# unit/other
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/hyperloglog.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ start_server {tags {"hll"}} {
set res
} {5 10}

# This parameter is not available in Pika
# test {HyperLogLogs are promote from sparse to dense} {
# r del hll
# r config set hll-sparse-max-bytes 3000
Expand All @@ -59,6 +60,7 @@ start_server {tags {"hll"}} {
# }
# }

# Pika does not support the pfdebug command
# test {HyperLogLog sparse encoding stress test} {
# for {set x 0} {$x < 1000} {incr x} {
# r del hll1 hll2
Expand All @@ -74,7 +76,7 @@ start_server {tags {"hll"}} {
# r pfadd hll2 {*}$elements
# assert {[r pfdebug encoding hll1] eq {sparse}}
# assert {[r pfdebug encoding hll2] eq {dense}}
# Cardinality estimated should match exactly.
# # Cardinality estimated should match exactly.
# assert {[r pfcount hll1] eq [r pfcount hll2]}
# }
# }
Expand Down Expand Up @@ -224,13 +226,14 @@ start_server {tags {"hll"}} {
# }
# }

# Pika does not support the pfdebug command
# test {PFDEBUG GETREG returns the HyperLogLog raw registers} {
# r del hll
# r pfadd hll 1 2 3
# llength [r pfdebug getreg hll]
# } {16384}


# Pika does not support the pfdebug command
# test {PFDEBUG GETREG returns the HyperLogLog raw registers} {
# r del hll
# r pfadd hll 1 2 3
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/maxmemory.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ start_server {tags {"maxmemory"}} {
# The current maxmemory command does not support config set and policy.
# For a complete list of commands, refer to the wiki: https://github.com/OpenAtomFoundation/pika/wiki/pika-%E5%B7%AE%E5%BC%82%E5%8C%96%E5%91%BD%E4%BB%A4

# This parameter is not available in Pika
# test "Without maxmemory small integers are shared" {
# r config set maxmemory 0
# r set a 1
# assert {[r object refcount a] > 1}
# }

# This parameter is not available in Pika
# test "With maxmemory and non-LRU policy integers are still shared" {
# r config set maxmemory 1073741824
# r config set maxmemory-policy allkeys-random
# r set a 1
# assert {[r object refcount a] > 1}
# }

# This parameter is not available in Pika
# test "With maxmemory and LRU policy integers are not shared" {
# r config set maxmemory 1073741824
# r config set maxmemory-policy allkeys-lru
Expand All @@ -31,6 +34,7 @@ start_server {tags {"maxmemory"}} {
# r config set maxmemory 0
# }

# This parameter is not available in Pika
# foreach policy {
# allkeys-random allkeys-lru volatile-lru volatile-random volatile-ttl
# } {
Expand Down Expand Up @@ -63,6 +67,7 @@ start_server {tags {"maxmemory"}} {
# }
# }

# This parameter is not available in Pika
# foreach policy {
# allkeys-random allkeys-lru volatile-lru volatile-random volatile-ttl
# } {
Expand Down Expand Up @@ -105,6 +110,7 @@ start_server {tags {"maxmemory"}} {
# }
# }

# This parameter is not available in Pika
# foreach policy {
# volatile-lru volatile-random volatile-ttl
# } {
Expand Down
172 changes: 92 additions & 80 deletions tests/unit/multi.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ start_server {tags {"multi"}} {
list [r exists foo1] [r exists foo2]
} {0 0}

# This parameter is not available in Pika
# test {EXEC fails if there are errors while queueing commands #2} {
# set rd [redis_deferring_client]
# r del foo1 foo2
Expand All @@ -74,25 +75,26 @@ start_server {tags {"multi"}} {
# list [r exists foo1] [r exists foo2]
# } {0 0}

# test {If EXEC aborts, the client MULTI state is cleared} {
# r del foo1 foo2
# r multi
# r set foo1 bar1
# catch {r non-existing-command}
# r set foo2 bar2
# catch {r exec} e
# assert_match {EXECABORT*} $e
# r ping
# } {PONG}
test {If EXEC aborts, the client MULTI state is cleared} {
r del foo1 foo2
r multi
r set foo1 bar1
catch {r non-existing-command}
r set foo2 bar2
catch {r exec} e
assert_match {EXECABORT*} $e
r ping
} {PONG}

# test {EXEC works on WATCHed key not modified} {
# r watch x y z
# r watch k
# r multi
# r ping
# r exec
# } {PONG}
test {EXEC works on WATCHed key not modified} {
r watch x y z
r watch k
r multi
r ping
r exec
} {PONG}

# bug need fix
# test {EXEC fail on WATCHed key modified (1 key of 1 watched)} {
# r set x 30
# r watch x
Expand All @@ -102,6 +104,7 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# bug need fix
# test {EXEC fail on WATCHed key modified (1 key of 5 watched)} {
# r set x 30
# r watch a b x k z
Expand All @@ -111,6 +114,7 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# bug need fix
# test {EXEC fail on WATCHed key modified by SORT with STORE even if the result is empty} {
# r flushdb
# r lpush foo barsync"
Expand All @@ -121,45 +125,46 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# test {After successful EXEC key is no longer watched} {
# r set x 30
# r watch x
# r multi
# r ping
# r exec
# r set x 40
# r multi
# r ping
# r exec
# } {PONG}
test {After successful EXEC key is no longer watched} {
r set x 30
r watch x
r multi
r ping
r exec
r set x 40
r multi
r ping
r exec
} {PONG}

# test {After failed EXEC key is no longer watched} {
# r set x 30
# r watch x
# r set x 40
# r multi
# r ping
# r exec
# r set x 40
# r multi
# r ping
# r exec
# } {PONG}
test {After failed EXEC key is no longer watched} {
r set x 30
r watch x
r set x 40
r multi
r ping
r exec
r set x 40
r multi
r ping
r exec
} {PONG}

# test {It is possible to UNWATCH} {
# r set x 30
# r watch x
# r set x 40
# r unwatch
# r multi
# r ping
# r exec
# } {PONG}
test {It is possible to UNWATCH} {
r set x 30
r watch x
r set x 40
r unwatch
r multi
r ping
r exec
} {PONG}

test {UNWATCH when there is nothing watched works as expected} {
r unwatch
} {OK}

# bug need fix
# test {FLUSHALL is able to touch the watched keys} {
# r set x 30
# r watch x
Expand All @@ -169,15 +174,16 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# test {FLUSHALL does not touch non affected keys} {
# r del x
# r watch x
# r flushall
# r multi
# r ping
# r exec
# } {PONG}
test {FLUSHALL does not touch non affected keys} {
r del x
r watch x
r flushall
r multi
r ping
r exec
} {PONG}

# bug need fix
# test {FLUSHDB is able to touch the watched keys} {
# r set x 30
# r watch x
Expand All @@ -187,15 +193,16 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# test {FLUSHDB does not touch non affected keys} {
# r del x
# r watch x
# r flushdb
# r multi
# r ping
# r exec
# } {PONG}
test {FLUSHDB does not touch non affected keys} {
r del x
r watch x
r flushdb
r multi
r ping
r exec
} {PONG}

# bug need fix
# test {WATCH is able to remember the DB a key belongs to} {
# r select 5
# r set x 30
Expand All @@ -211,6 +218,7 @@ start_server {tags {"multi"}} {
# set res
# } {PONG}

# bug need fix
# test {WATCH will consider touched keys target of EXPIRE} {
# r del x
# r set x foo
Expand All @@ -221,16 +229,16 @@ start_server {tags {"multi"}} {
# r exec
# } {}

# test {WATCH will not consider touched expired keys} {
# r del x
# r set x foo
# r expire x 1
# r watch x
# after 1100
# r multi
# r ping
# r exec
# } {PONG}
test {WATCH will not consider touched expired keys} {
r del x
r set x foo
r expire x 1
r watch x
after 1100
r multi
r ping
r exec
} {PONG}

test {DISCARD should clear the WATCH dirty flag on the client} {
r watch x
Expand All @@ -253,6 +261,7 @@ start_server {tags {"multi"}} {
r exec
} {11}

# Pika does not support the sync command
# test {MULTI / EXEC is propagated correctly (single write command)} {
# set repl [attach_to_replication_stream]
# r multi
Expand All @@ -265,8 +274,9 @@ start_server {tags {"multi"}} {
# {exec}
# }
# close_replication_stream $repl
# }
#
# }

# Pika does not support the sync command
# test {MULTI / EXEC is propagated correctly (empty transaction)} {
# set repl [attach_to_replication_stream]
# r multi
Expand All @@ -278,7 +288,8 @@ start_server {tags {"multi"}} {
# }
# close_replication_stream $repl
# }
#

# Pika does not support the sync command
# test {MULTI / EXEC is propagated correctly (read-only commands)} {
# r set foo value1
# set repl [attach_to_replication_stream]
Expand All @@ -292,9 +303,10 @@ start_server {tags {"multi"}} {
# }
# close_replication_stream $repl
# }
#

# Pika does not support the sync command
# test {MULTI / EXEC is propagated correctly (write command, no effect)} {
# r del bar foo bar
# r del bar foo bar
# set repl [attach_to_replication_stream]
# r multi
# r del foo
Expand Down
Loading

0 comments on commit b490e8e

Please sign in to comment.