diff options
author | chenyang8094 <chenyang8094@users.noreply.github.com> | 2021-12-28 03:37:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-27 21:37:21 +0200 |
commit | af0b50f83a997ca3eb2e21fd9ee823ef15e12183 (patch) | |
tree | 2fbe1ee7abb832f936dc69780012fe8899f33f91 /tests/support/util.tcl | |
parent | f810510bb2f96c19b82b59222ae63941eedc9c20 (diff) | |
download | redis-af0b50f83a997ca3eb2e21fd9ee823ef15e12183.tar.gz |
Tests: don't rely on the response of MEMORY USAGE when mem_allocator is not jemalloc (#10010)
It turns out that libc malloc can return an allocation of a different size on requests of the same size.
this means that matching MEMORY USAGE of one key to another copy of the same data can fail.
Solution:
Keep running the test that calls MEMORY USAGE, but ignore the response.
We do that by introducing a new utility function to get the memory usage, which always returns 1
when the allocator is not jemalloc.
Other changes:
Some formatting for datatype2.tcl
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'tests/support/util.tcl')
-rw-r--r-- | tests/support/util.tcl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/support/util.tcl b/tests/support/util.tcl index d11841894..c4f90b29e 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -1002,3 +1002,13 @@ proc prepare_value {size} { } return $_v } + +proc memory_usage {key} { + set usage [r memory usage $key] + if {![string match {*jemalloc*} [s mem_allocator]]} { + # libc allocator can sometimes return a different size allocation for the same requested size + # this makes tests that rely on MEMORY USAGE unreliable, so instead we return a constant 1 + set usage 1 + } + return $usage +} |