-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathacceptance.tests
More file actions
323 lines (273 loc) · 9.57 KB
/
Copy pathacceptance.tests
File metadata and controls
323 lines (273 loc) · 9.57 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# 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
NAME filter match
RUN filter --match "(\d{3}) (\d+)" cmd/testdata/access.txt cmd/testdata/access.txt cmd/testdata/access.txt cmd/testdata/access.txt
STDERR
Matched: 200 / 200
END
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
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 line-file
RUN filter -n 5 --match "(\d{3}) (\d+)" -e "{src}:{line} {1}" cmd/testdata/access.txt
cmd/testdata/access.txt:1 200
cmd/testdata/access.txt:2 200
cmd/testdata/access.txt:3 404
cmd/testdata/access.txt:4 301
cmd/testdata/access.txt:5 200
STDERR
Matched: 5 / 5
END
NAME search for lines
RUN search -n 5 -e "{1}" "(\d{3}) (\d+)" cmd/testdata/access.txt
cmd/testdata/access.txt 1: 200
cmd/testdata/access.txt 2: 200
cmd/testdata/access.txt 3: 404
cmd/testdata/access.txt 4: 301
cmd/testdata/access.txt 5: 200
STDERR
Read : 1 file(s) (9.22 KB)
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 inline key
RUN bars -k -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{buckettime {1} year}" -e "{2}" cmd/testdata/access.txt
2019 200 ██████████████████████████████████████████████████ 47
301 █ 1
404 ██▏ 2
Matched: 50 / 50
END
NAME bars inline key no sub
RUN bars -k -m "\[(.+?)\].* (\d{3}) (\d+)" -e "{buckettime {1} year}" cmd/testdata/access.txt
2019 ██████████████████████████████████████████████████ 50
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 #################################
### 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 ###############################
NAME empty reduce
RUN reduce --snapshot -m "(\d{3}) (\d+)" cmd/testdata/access.txt
Matched: 50 / 50
END
### Reduce with no group
NAME simple reduce
RUN reduce --snapshot -m "(\d{3}) (\d+)" -a "total={sumi {.} {2}}" -a "count={sumi {.} 1}" -a "avg={divi {total} {count}}" --sort "-{avg}" cmd/testdata/access.txt
total: 37456
count: 50
avg : 749
Matched: 50 / 50
END
NAME simple reduce with formatters
RUN reduce --snapshot -m "(\d{3}) (\d+)" -a "total={sumi {.} {2}}" -a "count={sumi {.} 1}" -a "avg={divi {total} {count}}" --sort "-{avg}" --fmt "val: {0}" --fmt total=bytesize cmd/testdata/access.txt
total: 37 KB
count: val: 50
avg : val: 749
Matched: 50 / 50
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
### Reduce with formatters
NAME reduce formatters
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}" --fmt "{! [0]*10}" --fmt total=bytesize cmd/testdata/access.txt
http total count avg
200 36 KB 470 7840
404 398 B 20 1990
301 185 B 10 1850
Matched: 50 / 50 (R: 3; C: 4)
END
### Reduce with formatters fail
NAME reduce failure
RUN reduce -m "(\d{3}) (\d+)" -g "http={1}" -a "total={sumi {.} {2}}" -a "count={sumi {.} 1}" -a "avg={divi {total} {count}}" --sort "-{avg}" --fmt "{!" cmd/testdata/access.txt
ERR exited code 2
END
################ Help and Docs ########################
NAME rare version
MATCH regex
RUN -v
rare(?:.test) version (.+), (.+); regex: re2
END
NAME walk
GOOS linux
MATCH regex
RUN walk -R --include *.sh docs/
docs/install.sh
STDERR
Found 1 path\(s\), (.+) excluded
END
NAME walk windows
GOOS windows
MATCH regex
RUN walk -R --include *.sh docs/
docs\install.sh
STDERR
Found 1 path\(s\), (.+) excluded
END