summaryrefslogtreecommitdiff
path: root/tests/t/api_reports.t
blob: 3c6827ffd1b69691ac4b0c98b09b123e6f78e562 (plain)
1
2
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
########################################################################
Tests for custom report hooks
########################################################################

# Trigger one intermediate and one cumulative report
  $ SB_ARGS="api_reports.lua --time=3 --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: *.* qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 1.* err/s 0.00 reconn/s: 0.00 (glob)
  [ 3s ] thds: 0 tps: *.* qps: 0.00 (r/w/o: 0.00/0.00/0.00) lat (ms,95%): 1.* err/s 0.00 reconn/s: 0.00 (glob)

########################################################################
# 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.00,0.00,0.00,0.00,1.*,0.00,0.00 (glob)
  3,0,*.*,0.00,0.00,0.00,0.00,1.*,0.00,0.00 (glob)

########################################################################
# 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.*, (glob)
    "errors": 0.00,
    "reconnects": 0.00
  },
  {
    "time":    3,
    "threads": 0,
    "tps": *.*, (glob)
    "qps": {
      "total": 0.00,
      "reads": 0.00,
      "writes": 0.00,
      "other": 0.00,
    },
    "latency": 1.*, (glob)
    "errors": 0.00,
    "reconnects": 0.00
  },