Make active defragmentation tests optional.

They failed when active defrag could not be activated because the
Jemalloc version does not include the additional APIs.
This commit is contained in:
antirez 2018-05-24 18:04:17 +02:00
parent fef42d0985
commit 98d5d3f118
2 changed files with 69 additions and 60 deletions

View File

@ -1031,9 +1031,10 @@ void configSetCommand(client *c) {
if (server.active_defrag_enabled) {
server.active_defrag_enabled = 0;
addReplyError(c,
"Active defragmentation cannot be enabled: it requires a "
"Redis server compiled with a modified Jemalloc like the "
"one shipped by default with the Redis source distribution");
"-DISABLED Active defragmentation cannot be enabled: it "
"requires a Redis server compiled with a modified Jemalloc "
"like the one shipped by default with the Redis source "
"distribution");
return;
}
#endif

View File

@ -55,16 +55,17 @@ start_server {tags {"defrag"}} {
puts "frag $frag"
}
assert {$frag >= 1.4}
r config set activedefrag yes
# wait for the active defrag to start working (decision once a second)
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
# Wait for the active defrag to start working (decision once a
# second).
wait_for_condition 50 100 {
[s active_defrag_running] ne 0
} else {
fail "defrag not started."
}
# wait for the active defrag to stop working
# Wait for the active defrag to stop working.
wait_for_condition 100 100 {
[s active_defrag_running] eq 0
} else {
@ -73,13 +74,16 @@ start_server {tags {"defrag"}} {
fail "defrag didn't stop."
}
# test the the fragmentation is lower
# Test the the fragmentation is lower.
after 120 ;# serverCron only updates the info once in 100ms
set frag [s allocator_frag_ratio]
if {$::verbose} {
puts "frag $frag"
}
assert {$frag < 1.1}
} else {
set _ ""
}
} {}
test "Active defrag big keys" {
@ -150,8 +154,9 @@ start_server {tags {"defrag"}} {
assert {$frag >= $expected_frag}
r config set latency-monitor-threshold 5
r latency reset
r config set activedefrag yes
catch {r config set activedefrag yes} e
if {![string match {DISABLED*} $e]} {
# wait for the active defrag to start working (decision once a second)
wait_for_condition 50 100 {
[s active_defrag_running] ne 0
@ -188,6 +193,9 @@ start_server {tags {"defrag"}} {
# due to high fragmentation, 10hz, and active-defrag-cycle-max set to 75,
# we expect max latency to be not much higher than 75ms
assert {$max_latency <= 80}
} else {
set _ ""
}
} {}
}
}