X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/28d1ee2cda01bccdd2424f8fdbb4a924de37eaa3..9bd0e097aa19b697757cdb73dd447e2c6f4960c6:/tests/unit/type/hash.tcl diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 950805d1..fa52afd1 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -397,7 +397,7 @@ start_server {tags {"hash"}} { } {b} foreach size {10 512} { - test "Hash fuzzing - $size fields" { + test "Hash fuzzing #1 - $size fields" { for {set times 0} {$times < 10} {incr times} { catch {unset hash} array set hash {} @@ -418,5 +418,53 @@ start_server {tags {"hash"}} { assert_equal [array size hash] [r hlen hash] } } + + test "Hash fuzzing #2 - $size fields" { + for {set times 0} {$times < 10} {incr times} { + catch {unset hash} + array set hash {} + r del hash + + # Create + for {set j 0} {$j < $size} {incr j} { + randpath { + set field [randomValue] + set value [randomValue] + r hset hash $field $value + set hash($field) $value + } { + set field [randomSignedInt 512] + set value [randomSignedInt 512] + r hset hash $field $value + set hash($field) $value + } { + randpath { + set field [randomValue] + } { + set field [randomSignedInt 512] + } + r hdel hash $field + unset -nocomplain hash($field) + } + } + + # Verify + foreach {k v} [array get hash] { + assert_equal $v [r hget hash $k] + } + assert_equal [array size hash] [r hlen hash] + } + } + } + + test {Stress test the hash ziplist -> hashtable encoding conversion} { + r config set hash-max-ziplist-entries 32 + for {set j 0} {$j < 100} {incr j} { + r del myhash + for {set i 0} {$i < 64} {incr i} { + r hset myhash [randomValue] [randomValue] + } + assert {[r object encoding myhash] eq {hashtable}} + } } }