diff options
-rw-r--r-- | tests/README.md | 4 | ||||
-rw-r--r-- | tests/support/test.tcl | 13 | ||||
-rw-r--r-- | tests/unit/maxmemory.tcl | 8 | ||||
-rw-r--r-- | tests/unit/type/incr.tcl | 10 |
4 files changed, 24 insertions, 11 deletions
diff --git a/tests/README.md b/tests/README.md index 4b2251bc5..1aa98dc9f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -40,12 +40,12 @@ The following compatibility and capability tags are currently used: | `large-memory` | Test that requires more than 100mb | | `tls:skip` | Not compatible with `--tls`. | | `needs:repl` | Uses replication and needs to be able to `SYNC` from server. | -| `needs:debug` | Uses the `DEBUG` command or other debugging focused commands (like `OBJECT`). | +| `needs:debug` | Uses the `DEBUG` command or other debugging focused commands (like `OBJECT REFCOUNT`). | | `needs:pfdebug` | Uses the `PFDEBUG` command. | | `needs:config-maxmemory` | Uses `CONFIG SET` to manipulate memory limit, eviction policies, etc. | | `needs:config-resetstat` | Uses `CONFIG RESETSTAT` to reset statistics. | | `needs:reset` | Uses `RESET` to reset client connections. | -| `needs:save` | Uses `SAVE` to create an RDB file. | +| `needs:save` | Uses `SAVE` or `BGSAVE` to create an RDB file. | When using an external server (`--host` and `--port`), filtering using the `external:skip` tags is done automatically. diff --git a/tests/support/test.tcl b/tests/support/test.tcl index 34b5aad29..2fe52f475 100644 --- a/tests/support/test.tcl +++ b/tests/support/test.tcl @@ -103,10 +103,23 @@ proc assert_type {type key} { } proc assert_refcount {ref key} { + if {[lsearch $::denytags "needs:debug"] >= 0} { + return + } + set val [r object refcount $key] assert_equal $ref $val } +proc assert_refcount_morethan {key ref} { + if {[lsearch $::denytags "needs:debug"] >= 0} { + return + } + + set val [r object refcount $key] + assert_morethan $val $ref +} + # Wait for the specified condition to be true, with the specified number of # max retries and delay between retries. Otherwise the 'elsescript' is # executed. diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl index 631b3ac91..564250f2e 100644 --- a/tests/unit/maxmemory.tcl +++ b/tests/unit/maxmemory.tcl @@ -147,14 +147,14 @@ start_server {tags {"maxmemory external:skip"}} { test "Without maxmemory small integers are shared" { r config set maxmemory 0 r set a 1 - assert {[r object refcount a] > 1} + assert_refcount_morethan a 1 } 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} + assert_refcount_morethan a 1 } test "With maxmemory and LRU policy integers are not shared" { @@ -163,8 +163,8 @@ start_server {tags {"maxmemory external:skip"}} { r set a 1 r config set maxmemory-policy volatile-lru r set b 1 - assert {[r object refcount a] == 1} - assert {[r object refcount b] == 1} + assert_refcount 1 a + assert_refcount 1 b r config set maxmemory 0 } diff --git a/tests/unit/type/incr.tcl b/tests/unit/type/incr.tcl index b7446850e..7732921d9 100644 --- a/tests/unit/type/incr.tcl +++ b/tests/unit/type/incr.tcl @@ -63,18 +63,18 @@ start_server {tags {"incr"}} { test {INCR uses shared objects in the 0-9999 range} { r set foo -1 r incr foo - assert {[r object refcount foo] > 1} + assert_refcount_morethan foo 1 r set foo 9998 r incr foo - assert {[r object refcount foo] > 1} + assert_refcount_morethan foo 1 r incr foo - assert {[r object refcount foo] == 1} - } {} {needs:debug} + assert_refcount 1 foo + } test {INCR can modify objects in-place} { r set foo 20000 r incr foo - assert {[r object refcount foo] == 1} + assert_refcount 1 foo set old [lindex [split [r debug object foo]] 1] r incr foo set new [lindex [split [r debug object foo]] 1] |