2020-10-26 02:04:59 -04:00
|
|
|
source tests/support/benchmark.tcl
|
|
|
|
|
|
|
|
|
|
|
|
proc cmdstat {cmd} {
|
|
|
|
return [cmdrstat $cmd r]
|
|
|
|
}
|
|
|
|
|
2021-09-14 12:45:06 -04:00
|
|
|
# common code to reset stats, flush the db and run redis-benchmark
|
|
|
|
proc common_bench_setup {cmd} {
|
|
|
|
r config resetstat
|
|
|
|
r flushall
|
|
|
|
if {[catch { exec {*}$cmd } error]} {
|
|
|
|
set first_line [lindex [split $error "\n"] 0]
|
|
|
|
puts [colorstr red "redis-benchmark non zero code. first line: $first_line"]
|
|
|
|
fail "redis-benchmark non zero code. first line: $first_line"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# we use this extra asserts on a simple set,get test for features like uri parsing
|
|
|
|
# and other simple flag related tests
|
|
|
|
proc default_set_get_checks {} {
|
|
|
|
assert_match {*calls=10,*} [cmdstat set]
|
|
|
|
assert_match {*calls=10,*} [cmdstat get]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat lrange]
|
|
|
|
}
|
|
|
|
|
2021-06-09 08:13:24 -04:00
|
|
|
start_server {tags {"benchmark network external:skip"}} {
|
2020-10-26 02:04:59 -04:00
|
|
|
start_server {} {
|
|
|
|
set master_host [srv 0 host]
|
|
|
|
set master_port [srv 0 port]
|
|
|
|
|
|
|
|
test {benchmark: set,get} {
|
2021-08-29 07:31:08 -04:00
|
|
|
set cmd [redisbenchmark $master_host $master_port "-c 5 -n 10 -t set,get"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
|
|
|
default_set_get_checks
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: connecting using URI set,get} {
|
|
|
|
set cmd [redisbenchmarkuri $master_host $master_port "-c 5 -n 10 -t set,get"]
|
|
|
|
common_bench_setup $cmd
|
|
|
|
default_set_get_checks
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: connecting using URI with authentication set,get} {
|
|
|
|
r config set masterauth pass
|
|
|
|
set cmd [redisbenchmarkuriuserpass $master_host $master_port "default" pass "-c 5 -n 10 -t set,get"]
|
|
|
|
common_bench_setup $cmd
|
|
|
|
default_set_get_checks
|
2020-10-26 02:04:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: full test suite} {
|
2021-08-29 07:31:08 -04:00
|
|
|
set cmd [redisbenchmark $master_host $master_port "-c 10 -n 100"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
|
|
|
|
2020-12-02 06:17:25 -05:00
|
|
|
# ping total calls are 2*issued commands per test due to PING_INLINE and PING_MBULK
|
2020-10-26 02:04:59 -04:00
|
|
|
assert_match {*calls=200,*} [cmdstat ping]
|
|
|
|
assert_match {*calls=100,*} [cmdstat set]
|
|
|
|
assert_match {*calls=100,*} [cmdstat get]
|
|
|
|
assert_match {*calls=100,*} [cmdstat incr]
|
|
|
|
# lpush total calls are 2*issued commands per test due to the lrange tests
|
|
|
|
assert_match {*calls=200,*} [cmdstat lpush]
|
|
|
|
assert_match {*calls=100,*} [cmdstat rpush]
|
|
|
|
assert_match {*calls=100,*} [cmdstat lpop]
|
|
|
|
assert_match {*calls=100,*} [cmdstat rpop]
|
|
|
|
assert_match {*calls=100,*} [cmdstat sadd]
|
|
|
|
assert_match {*calls=100,*} [cmdstat hset]
|
|
|
|
assert_match {*calls=100,*} [cmdstat spop]
|
|
|
|
assert_match {*calls=100,*} [cmdstat zadd]
|
|
|
|
assert_match {*calls=100,*} [cmdstat zpopmin]
|
|
|
|
assert_match {*calls=400,*} [cmdstat lrange]
|
|
|
|
assert_match {*calls=100,*} [cmdstat mset]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat rpoplpush]
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: multi-thread set,get} {
|
2021-08-29 07:31:08 -04:00
|
|
|
set cmd [redisbenchmark $master_host $master_port "--threads 10 -c 5 -n 10 -t set,get"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
|
|
|
default_set_get_checks
|
2020-10-26 02:04:59 -04:00
|
|
|
|
|
|
|
# ensure only one key was populated
|
|
|
|
assert_match {1} [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d]
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: pipelined full set,get} {
|
2021-08-29 07:31:08 -04:00
|
|
|
set cmd [redisbenchmark $master_host $master_port "-P 5 -c 10 -n 10010 -t set,get"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
2020-10-26 02:04:59 -04:00
|
|
|
assert_match {*calls=10010,*} [cmdstat set]
|
|
|
|
assert_match {*calls=10010,*} [cmdstat get]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat lrange]
|
|
|
|
|
|
|
|
# ensure only one key was populated
|
|
|
|
assert_match {1} [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d]
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: arbitrary command} {
|
2021-08-29 07:31:08 -04:00
|
|
|
set cmd [redisbenchmark $master_host $master_port "-c 5 -n 150 INCRBYFLOAT mykey 10.0"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
2020-10-26 02:04:59 -04:00
|
|
|
assert_match {*calls=150,*} [cmdstat incrbyfloat]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat get]
|
|
|
|
|
|
|
|
# ensure only one key was populated
|
|
|
|
assert_match {1} [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d]
|
|
|
|
}
|
|
|
|
|
|
|
|
test {benchmark: keyspace length} {
|
|
|
|
set cmd [redisbenchmark $master_host $master_port "-r 50 -t set -n 1000"]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
2020-10-26 02:04:59 -04:00
|
|
|
assert_match {*calls=1000,*} [cmdstat set]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat get]
|
|
|
|
|
|
|
|
# ensure the keyspace has the desired size
|
|
|
|
assert_match {50} [scan [regexp -inline {keys\=([\d]*)} [r info keyspace]] keys=%d]
|
|
|
|
}
|
2020-11-04 07:49:15 -05:00
|
|
|
|
|
|
|
# tls specific tests
|
|
|
|
if {$::tls} {
|
|
|
|
test {benchmark: specific tls-ciphers} {
|
|
|
|
set cmd [redisbenchmark $master_host $master_port "-r 50 -t set -n 1000 --tls-ciphers \"DEFAULT:-AES128-SHA256\""]
|
2021-09-14 12:45:06 -04:00
|
|
|
common_bench_setup $cmd
|
2020-11-04 07:49:15 -05:00
|
|
|
assert_match {*calls=1000,*} [cmdstat set]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat get]
|
|
|
|
}
|
|
|
|
|
2021-09-14 12:45:06 -04:00
|
|
|
test {benchmark: tls connecting using URI with authentication set,get} {
|
|
|
|
r config set masterauth pass
|
|
|
|
set cmd [redisbenchmarkuriuserpass $master_host $master_port "default" pass "-c 5 -n 10 -t set,get"]
|
|
|
|
common_bench_setup $cmd
|
|
|
|
default_set_get_checks
|
|
|
|
}
|
|
|
|
|
2020-11-04 07:49:15 -05:00
|
|
|
test {benchmark: specific tls-ciphersuites} {
|
|
|
|
r flushall
|
|
|
|
r config resetstat
|
|
|
|
set ciphersuites_supported 1
|
|
|
|
set cmd [redisbenchmark $master_host $master_port "-r 50 -t set -n 1000 --tls-ciphersuites \"TLS_AES_128_GCM_SHA256\""]
|
|
|
|
if {[catch { exec {*}$cmd } error]} {
|
|
|
|
set first_line [lindex [split $error "\n"] 0]
|
|
|
|
if {[string match "*Invalid option*" $first_line]} {
|
|
|
|
set ciphersuites_supported 0
|
|
|
|
if {$::verbose} {
|
|
|
|
puts "Skipping test, TLSv1.3 not supported."
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
puts [colorstr red "redis-benchmark non zero code. first line: $first_line"]
|
|
|
|
fail "redis-benchmark non zero code. first line: $first_line"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {$ciphersuites_supported} {
|
|
|
|
assert_match {*calls=1000,*} [cmdstat set]
|
|
|
|
# assert one of the non benchmarked commands is not present
|
|
|
|
assert_match {} [cmdstat get]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-26 02:04:59 -04:00
|
|
|
}
|
|
|
|
}
|