Files
sysbench/tests/t/api_reports.t
Alexey Kopytov 56b473faf6 Fix GH-195: Fix JSON reporter to produce valid JSON
sysbench.report_json() now generates well-formed JSON without comma
after the last array element and with proper opening/closing brackets.
2018-04-01 13:59:00 +03:00

110 lines
3.2 KiB
Perl

########################################################################
Tests for custom report hooks
########################################################################
# Trigger one intermediate and one cumulative report
$ SB_ARGS="api_reports.lua --time=5 --report-interval=2 --verbosity=1"
########################################################################
# Default human-readable format via a custom hook
########################################################################
$ cat >api_reports.lua <<EOF
> ffi.cdef[[int usleep(unsigned int);]]
>
> function event()
> ffi.C.usleep(1000)
> end
>
> sysbench.hooks.report_intermediate = sysbench.report_default
> sysbench.hooks.report_cumulative = sysbench.report_default
> EOF
$ sysbench $SB_ARGS run
\[ 2s \] thds: 1 tps: [0-9]*\.[0-9]* qps: 0\.00 \(r\/w\/o: 0\.00\/0\.00\/0\.00\) lat \(ms,95%\): [1-9][0-9]*\.[0-9]* err\/s 0\.00 reconn\/s: 0\.00 (re)
\[ 4s \] thds: 1 tps: [0-9]*\.[0-9]* qps: 0\.00 \(r\/w\/o: 0\.00\/0\.00\/0\.00\) lat \(ms,95%\): [1-9][0-9]*\.[0-9]* err\/s 0\.00 reconn\/s: 0\.00 (re)
\[ 5s \] thds: 0 tps: [0-9]*\.[0-9]* qps: 0\.00 \(r\/w\/o: 0\.00\/0\.00\/0\.00\) lat \(ms,95%\): [1-9][0-9]*\.[0-9]* err\/s 0\.00 reconn\/s: 0\.00 (re)
########################################################################
# CSV format via a custom hook
########################################################################
$ cat >api_reports.lua <<EOF
> ffi.cdef[[int usleep(unsigned int);]]
>
> function event()
> ffi.C.usleep(1000)
> end
>
> sysbench.hooks.report_intermediate = sysbench.report_csv
> sysbench.hooks.report_cumulative = sysbench.report_csv
> EOF
$ sysbench $SB_ARGS run
2,1,[0-9]*\.[0-9]*,0\.00,0\.00,0\.00,0\.00,[1-9][0-9]*\.[0-9]*,0\.00,0\.00 (re)
4,1,[0-9]*\.[0-9]*,0\.00,0\.00,0\.00,0\.00,[1-9][0-9]*\.[0-9]*,0\.00,0\.00 (re)
5,0,[0-9]*\.[0-9]*,0\.00,0\.00,0\.00,0\.00,[1-9][0-9]*\.[0-9]*,0\.00,0\.00 (re)
########################################################################
# JSON format via a custom hook
########################################################################
$ cat >api_reports.lua <<EOF
> ffi.cdef[[int usleep(unsigned int);]]
>
> function event()
> ffi.C.usleep(1000)
> end
>
> sysbench.hooks.report_intermediate = sysbench.report_json
> sysbench.hooks.report_cumulative = sysbench.report_json
> EOF
$ sysbench $SB_ARGS run
[
{
"time": 2,
"threads": 1,
"tps": *.*, (glob)
"qps": {
"total": 0.00,
"reads": 0.00,
"writes": 0.00,
"other": 0.00
},
"latency": [1-9][0-9]*\.[0-9]*, (re)
"errors": 0.00,
"reconnects": 0.00
},
{
"time": 4,
"threads": 1,
"tps": *.*, (glob)
"qps": {
"total": 0.00,
"reads": 0.00,
"writes": 0.00,
"other": 0.00
},
"latency": [1-9][0-9]*\.[0-9]*, (re)
"errors": 0.00,
"reconnects": 0.00
}
]
[
{
"time": 5,
"threads": 0,
"tps": *.*, (glob)
"qps": {
"total": 0.00,
"reads": 0.00,
"writes": 0.00,
"other": 0.00
},
"latency": [1-9][0-9]*\.[0-9]*, (re)
"errors": 0.00,
"reconnects": 0.00
}
]