Unverified Commit c46d68d6 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix Uninitialised value error in createSparklineSequence (LATENCY GRAPH) (#11892)

This was exposed by a new LATENCY GRAPH valgrind test.
There are no security implications, fix by initializing
these members.
parent a7c9e505
...@@ -57,7 +57,10 @@ static int label_margin_top = 1; ...@@ -57,7 +57,10 @@ static int label_margin_top = 1;
struct sequence *createSparklineSequence(void) { struct sequence *createSparklineSequence(void) {
struct sequence *seq = zmalloc(sizeof(*seq)); struct sequence *seq = zmalloc(sizeof(*seq));
seq->length = 0; seq->length = 0;
seq->labels = 0;
seq->samples = NULL; seq->samples = NULL;
seq->min = 0.0f;
seq->max = 0.0f;
return seq; return seq;
} }
......
...@@ -71,6 +71,7 @@ start_server {tags {"latency-monitor needs:latency"}} { ...@@ -71,6 +71,7 @@ start_server {tags {"latency-monitor needs:latency"}} {
assert {[string length [r latency histogram blabla set get]] > 0} assert {[string length [r latency histogram blabla set get]] > 0}
} }
tags {"needs:debug"} {
test {Test latency events logging} { test {Test latency events logging} {
r debug sleep 0.3 r debug sleep 0.3
after 1100 after 1100
...@@ -78,7 +79,7 @@ start_server {tags {"latency-monitor needs:latency"}} { ...@@ -78,7 +79,7 @@ start_server {tags {"latency-monitor needs:latency"}} {
after 1100 after 1100
r debug sleep 0.5 r debug sleep 0.5
assert {[r latency history command] >= 3} assert {[r latency history command] >= 3}
} {} {needs:debug} }
test {LATENCY HISTORY output is ok} { test {LATENCY HISTORY output is ok} {
set min 250 set min 250
...@@ -106,6 +107,18 @@ start_server {tags {"latency-monitor needs:latency"}} { ...@@ -106,6 +107,18 @@ start_server {tags {"latency-monitor needs:latency"}} {
} }
} }
test {LATENCY GRAPH can output the event graph} {
set res [r latency graph command]
assert_match {*command*high*low*} $res
# These numbers are taken from the "Test latency events logging" test.
# (debug sleep 0.3) and (debug sleep 0.5), using range to prevent timing issue.
regexp "command - high (.*?) ms, low (.*?) ms" $res -> high low
assert_morethan_equal $high 500
assert_morethan_equal $low 300
}
} ;# tag
test {LATENCY of expire events are correctly collected} { test {LATENCY of expire events are correctly collected} {
r config set latency-monitor-threshold 20 r config set latency-monitor-threshold 20
r flushdb r flushdb
...@@ -124,6 +137,11 @@ start_server {tags {"latency-monitor needs:latency"}} { ...@@ -124,6 +137,11 @@ start_server {tags {"latency-monitor needs:latency"}} {
fail "key wasn't expired" fail "key wasn't expired"
} }
assert_match {*expire-cycle*} [r latency latest] assert_match {*expire-cycle*} [r latency latest]
test {LATENCY GRAPH can output the expire event graph} {
assert_match {*expire-cycle*high*low*} [r latency graph expire-cycle]
}
r config set latency-monitor-threshold 200 r config set latency-monitor-threshold 200
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment