Make assert_refcount skip the OBJECT REFCOUNT check with needs:debug tag (#11487)
This PR add `assert_refcount_morethan`, and modify `assert_refcount` to skip the `OBJECT REFCOUNT` check with `needs:debug` flag. Use them to modify all `OBJECT REFCOUNT` calls and also update the tests/README to be more specific. The reasoning is that some of these tests could be testing something important, and along the way also add a check for the refcount, and it could be a shame to skip the whole test just because the refcount functionality is missing or blocked. but much like the fact that some redis variants may not support DEBUG, and still we want to run the majority of the test for coverage, and just skip the digest match.
This commit is contained in:
parent
6e9724cb6a
commit
543e0daa63
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user