]> git.saurik.com Git - redis.git/blob - tests/unit/slowlog.tcl
Tests modified to account for INFO fields renaming.
[redis.git] / tests / unit / slowlog.tcl
1 start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
2 test {SLOWLOG - check that it starts with an empty log} {
3 r slowlog len
4 } {0}
5
6 test {SLOWLOG - only logs commands taking more time than specified} {
7 r config set slowlog-log-slower-than 100000
8 r ping
9 assert_equal [r slowlog len] 0
10 r debug sleep 0.2
11 assert_equal [r slowlog len] 1
12 }
13
14 test {SLOWLOG - max entries is correctly handled} {
15 r config set slowlog-log-slower-than 0
16 r config set slowlog-max-len 10
17 for {set i 0} {$i < 100} {incr i} {
18 r ping
19 }
20 r slowlog len
21 } {10}
22
23 test {SLOWLOG - GET optional argument to limit output len works} {
24 llength [r slowlog get 5]
25 } {5}
26
27 test {SLOWLOG - RESET subcommand works} {
28 r config set slowlog-log-slower-than 100000
29 r slowlog reset
30 r slowlog len
31 } {0}
32
33 test {SLOWLOG - logged entry sanity check} {
34 r debug sleep 0.2
35 set e [lindex [r slowlog get] 0]
36 assert_equal [llength $e] 4
37 assert_equal [lindex $e 0] 105
38 assert_equal [expr {[lindex $e 2] > 100000}] 1
39 assert_equal [lindex $e 3] {debug sleep 0.2}
40 }
41
42 test {SLOWLOG - commands with too many arguments are trimmed} {
43 r config set slowlog-log-slower-than 0
44 r slowlog reset
45 r sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
46 set e [lindex [r slowlog get] 0]
47 lindex $e 3
48 } {sadd set 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 {... (2 more arguments)}}
49
50 test {SLOWLOG - too long arguments are trimmed} {
51 r config set slowlog-log-slower-than 0
52 r slowlog reset
53 set arg [string repeat A 129]
54 r sadd set foo $arg
55 set e [lindex [r slowlog get] 0]
56 lindex $e 3
57 } {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}}
58 }