summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2023-03-09 18:05:50 +0800
committerGitHub <noreply@github.com>2023-03-09 12:05:50 +0200
commitc46d68d6d273e7c86fd1f1d10caca4e47a3294f8 (patch)
treea8cc5e0fc98be7b914b74c2f71ef9fd3eaaa7f60 /tests/unit
parenta7c9e5053a96e66d77d243702bbadeb95c6a640d (diff)
downloadredis-c46d68d6d273e7c86fd1f1d10caca4e47a3294f8.tar.gz
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.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/latency-monitor.tcl20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/latency-monitor.tcl b/tests/unit/latency-monitor.tcl
index d592ed95b..499feceac 100644
--- a/tests/unit/latency-monitor.tcl
+++ b/tests/unit/latency-monitor.tcl
@@ -71,6 +71,7 @@ start_server {tags {"latency-monitor needs:latency"}} {
assert {[string length [r latency histogram blabla set get]] > 0}
}
+tags {"needs:debug"} {
test {Test latency events logging} {
r debug sleep 0.3
after 1100
@@ -78,7 +79,7 @@ start_server {tags {"latency-monitor needs:latency"}} {
after 1100
r debug sleep 0.5
assert {[r latency history command] >= 3}
- } {} {needs:debug}
+ }
test {LATENCY HISTORY output is ok} {
set min 250
@@ -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} {
r config set latency-monitor-threshold 20
r flushdb
@@ -124,6 +137,11 @@ start_server {tags {"latency-monitor needs:latency"}} {
fail "key wasn't expired"
}
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
}