Tests: fix new defrag test to be skipped when not supported ()

Additionally the older defrag tests are using an obsolete way to check
if the defragger is suuported (the error no longer contains "DISABLED").
this doesn't usually makes a difference since these tests are completely
skipped if the allocator is not jemalloc, but that would fail if the
allocator is a jemalloc that doesn't support defrag.
This commit is contained in:
Oran Agra 2020-12-14 11:13:46 +02:00 committed by GitHub
parent 1e301ff83e
commit 7d9b09adaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 32 deletions
tests/unit

@ -63,7 +63,7 @@ start_server {tags {"defrag"} overrides {appendonly yes auto-aof-rewrite-percent
r config set maxmemory 110mb ;# prevent further eviction (not to fail the digest test)
set digest [r debug digest]
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
if {[r config get activedefrag] eq "activedefrag yes"} {
# Wait for the active defrag to start working (decision once a
# second).
wait_for_condition 50 100 {
@ -236,7 +236,7 @@ start_server {tags {"defrag"} overrides {appendonly yes auto-aof-rewrite-percent
set digest [r debug digest]
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
if {[r config get activedefrag] eq "activedefrag yes"} {
# wait for the active defrag to start working (decision once a second)
wait_for_condition 50 100 {
[s active_defrag_running] ne 0
@ -332,7 +332,7 @@ start_server {tags {"defrag"} overrides {appendonly yes auto-aof-rewrite-percent
set digest [r debug digest]
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
if {[r config get activedefrag] eq "activedefrag yes"} {
# wait for the active defrag to start working (decision once a second)
wait_for_condition 50 100 {
[s active_defrag_running] ne 0
@ -452,7 +452,7 @@ start_server {tags {"defrag"} overrides {appendonly yes auto-aof-rewrite-percent
set digest [r debug digest]
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
if {[r config get activedefrag] eq "activedefrag yes"} {
# wait for the active defrag to start working (decision once a second)
wait_for_condition 50 100 {
[s active_defrag_running] ne 0

@ -3,14 +3,16 @@ set testmodule [file normalize tests/modules/defragtest.so]
start_server {tags {"modules"} overrides {{save ""}}} {
r module load $testmodule 10000
r config set hz 100
test {Module defrag: simple key defrag works} {
r frag.create key1 1 1000 0
r config set active-defrag-ignore-bytes 1
r config set active-defrag-threshold-lower 0
r config set active-defrag-cycle-min 99
r config set activedefrag yes
# try to enable active defrag, it will fail if redis was compiled without it
catch {r config set activedefrag yes} e
if {[r config get activedefrag] eq "activedefrag yes"} {
test {Module defrag: simple key defrag works} {
r frag.create key1 1 1000 0
after 2000
set info [r info defragtest_stats]
@ -40,4 +42,5 @@ start_server {tags {"modules"} overrides {{save ""}}} {
set info [r info defragtest_stats]
assert {[getInfoProperty $info defragtest_global_attempts] > 0}
}
}
}