-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathacceptance.tests
222 lines (185 loc) · 6.39 KB
/
acceptance.tests
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Tests a set of commands for an expected output
INDENT 4
############## FILTER ##############################
NAME filter match
MATCH EXACT
RUN filter -n 5 --match "(\d{3}) (\d+)" cmd/testdata/access.txt
2.3.4.1 - - [19/Aug/2019:02:26:25 +0000] "GET / HTTP/1.1" 200 546 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/98 Safari/537.4 (StatusCake)"
2.3.4.1 - - [19/Aug/2019:02:37:59 +0000] "GET / HTTP/1.1" 200 546 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/2.3.4.1 Safari/537.36"
2.3.4.1 - - [19/Aug/2019:02:37:59 +0000] "GET /favicon.ico HTTP/1.1" 404 199 "http://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/2.3.4.1 Safari/537.36"
2.3.4.1 - - [19/Aug/2019:02:38:03 +0000] "GET /mirror HTTP/1.1" 301 185 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/2.3.4.1 Safari/537.36"
2.3.4.1 - - [19/Aug/2019:02:38:03 +0000] "GET /mirror/ HTTP/1.1" 200 301 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/2.3.4.1 Safari/537.36"
STDERR
Matched: 5 / 5
END
MATCH DEFAULT
NAME filter stdin
MATCH EXACT
RUN filter --match "(\d+)" --ignore "{gt {1} 10}" -e "{multi {1} 2}" -
STDIN
hello 5
6 here
maybe 500
STDOUT
10
12
STDERR
Matched: 2 / 3 (Ignored: 1)
END
NAME filter dissect
MATCH EXACT
RUN filter -n 5 --dissect "HTTP/1.1%{} %{code} %{size}" -e "Code: {code}" cmd/testdata/access.txt
Code: 200
Code: 200
Code: 404
Code: 301
Code: 200
STDERR
Matched: 5 / 5
END
MATCH DEFAULT
NAME filter extract
RUN filter -n 5 --match "(\d{3}) (\d+)" -e "{1} {2}" cmd/testdata/access.txt
200 546
200 546
404 199
301 185
200 301
STDERR
Matched: 5 / 5
END
NAME filter error
RUN filter notafile
ERR Read errors
STDERR
Matched: 0 / 0
END
NAME filter decompress
RUN f -z cmd/testdata/log.txt.gz
this is a text file with 5
22 is the next number
5 is the last
no numbers here
empty line above
STDERR
Matched: 5 / 6 (Ignored: 1)
END
NAME filter json
RUN filter -n 5 --match "(?P<code>\d{3}) (?P<bytes>\d+)" -e "Line {line} in {src}: {#}" cmd/testdata/access.txt
Line 1 in cmd/testdata/access.txt: {"0": "200 546", "1": 200, "2": 546}
Line 2 in cmd/testdata/access.txt: {"0": "200 546", "1": 200, "2": 546}
Line 3 in cmd/testdata/access.txt: {"0": "404 199", "1": 404, "2": 199}
Line 4 in cmd/testdata/access.txt: {"0": "301 185", "1": 301, "2": 185}
Line 5 in cmd/testdata/access.txt: {"0": "200 301", "1": 200, "2": 301}
STDERR
Matched: 5 / 5
END
NAME filter json stdin
RUN filter --match "(\d+)" -e "{src}:{line} = {1}" -
STDIN
some 123
456
789
STDOUT
<stdin>:1 = 123
<stdin>:2 = 456
<stdin>:3 = 789
STDERR
Matched: 3 / 3
END
############## Histogram tests #####################
NAME histo basic
RUN histo --snapshot -m "(\d+)" -e "{bucket {1} 10}" cmd/testdata/log.txt
0 2
20 1
Matched: 3 / 6 (Groups: 2)
END
NAME histo extended
RUN histo --snapshot -m "(\d+)" -e "{bucket {1} 10}" -x cmd/testdata/log.txt
0 2 [66.7%] ██████████████████████████████████████████████████
20 1 [33.3%] █████████████████████████
Matched: 3 / 6 (Groups: 2)
END
NAME histo percent
RUN histo --percentage cmd/testdata/graph.txt
maria 19 1 [25.0%]
jill 3 1 [25.0%]
jack 93 1 [25.0%]
bob 22 1 [25.0%]
Matched: 4 / 4 (Groups: 4)
END
NAME histo percent non-1
RUN histo --percentage -m "(\w+) (\d+)" -e "{1}" -e "{2}" cmd/testdata/graph.txt
jack 93 [67.9%]
bob 22 [16.1%]
maria 19 [13.9%]
jill 3 [ 2.2%]
Matched: 4 / 4 (Groups: 4)
END
############# BARS #####################
NAME bars non-stacked
RUN bars -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{buckettime {1} year}" -e '{2}' cmd/testdata/access.txt
0 '200' 1 '301' 2 '404'
2019 ██████████████████████████████████████████████████ 47
█ 1
██▏ 2
Matched: 50 / 50
END
NAME bars stacked
RUN bars -s -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{buckettime {1} year}" -e '{2}' cmd/testdata/access.txt
0 '200' 1 '301' 2 '404'
2019 00000000000000000000000000000000000000000000000122 50
Matched: 50 / 50
END
############### Table #######################
NAME simple table
RUN table --snapshot -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{buckettime {1} year}" -e "{2}" cmd/testdata/access.txt
2019
200 47
404 2
301 1
Matched: 50 / 50 (R: 3; C: 1)
END
############## Heatmap #########################
NAME simple heatmap
RUN heatmap --snapshot -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{timeattr {time {1}} yearweek}" -e "{2}" cmd/testdata/access.txt
- 1 1 10 3 19 5 28 7 37 9 47
2019-34
200 9
301 -
404 -
Matched: 50 / 50 (R: 3; C: 1)
END
### Sparkline
NAME spark test
RUN spark -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{timeattr {time {1}} yearweek}" -e "{2}" cmd/testdata/access.txt
First 2019-342019-34 Last
200 47 █ 47
404 2 _ 2
301 1 _ 1
Matched: 50 / 50 (R: 3; C: 1)
END
### Analyze bytes sent, only looking at 200's
NAME analyze bytes sent
RUN analyze -m "(\d{3}) (\d+)" -e "{2}" -i "{neq {1} 200}" cmd/testdata/access.txt
Samples: 47
Mean: 784.5319
StdDev: 1,116.8599
Min: 251.0000
Max: 4,998.0000
Matched: 47 / 50 (Ignored: 3)
END
### Reduce http data
NAME reduce test
RUN reduce --snapshot -m "(\d{3}) (\d+)" -g "http={1}" -a "total={sumi {.} {2}}" -a "count={sumi {.} 1}" -a "avg={divi {total} {count}}" --sort "-{avg}" cmd/testdata/access.txt
http total count avg
200 36873 47 784
404 398 2 199
301 185 1 185
Matched: 50 / 50 (R: 3; C: 4)
END
################ Help and Docs ########################
NAME rare version
RUN -v
# any output is okay
END