-
Notifications
You must be signed in to change notification settings - Fork 51
/
test-suite-common.yaml
374 lines (372 loc) · 8.88 KB
/
test-suite-common.yaml
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
#!api-testing
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-schema.json
name: atest
api: |
{{default "http://localhost:8080" (env "SERVER")}}/api/v1
param:
suiteName: "{{randAlpha 6}}"
caseName: "{{randAlpha 6}}"
gRPCSuiteName: "{{randAlpha 6}}"
gRPCCaseName: "{{randAlpha 6}}"
store: "{{randAlpha 3}}"
server: |
{{default "http://localhost:8080" (env "SERVER")}}
items:
- name: CreateStore
before:
items:
- httpReady("{{.param.server}}/healthz", 2400)
request:
api: /stores
method: POST
body: |
{
"name": "{{.param.store}}",
"url": "{{env "target"}}",
"username": "{{default "root" (env "username")}}",
"password": "{{default "root" (env "password")}}",
"kind": {
"name": "atest-store-{{env "kind"}}"
},
"properties": [{
"key": "driver",
"value": "{{default "mysql" (env "driver")}}"
}, {
"key": "database",
"value": "{{default "atest" (env "dbname")}}"
}, {
"key": "bucket",
"value": "bucket"
}, {
"key": "region",
"value": "cn"
}, {
"key": "disablessl",
"value": "true"
}, {
"key": "targetPath",
"value": "api-testing"
}]
}
- name: createSuite
before:
items:
- sleep(3)
request:
api: /suites
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.suiteName}}",
"api": "http://localhost:8080/server.Runner"
}
- name: updateSuite
request:
api: /suites/{{.param.suiteName}}
method: PUT
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.suiteName}}",
"api": "http://localhost:8080/server.Runner",
"param": [{
"name": "name",
"value": "linuxsuren"
}]
}
- name: getSuite
request:
api: /suites/{{.param.suiteName}}
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.suiteName}}"
}
expect:
bodyFieldsExpect:
api: http://localhost:8080/server.Runner
- name: duplicateSuite
request:
api: /suites/{{.param.suiteName}}/duplicate
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"sourceSuiteName": "{{.param.suiteName}}",
"targetSuiteName": "{{.param.suiteName}}-copy"
}
- name: getDuplicatedSuite
request:
api: /suites/{{.param.suiteName}}-copy
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.suiteName}}-copy"
}
expect:
bodyFieldsExpect:
api: http://localhost:8080/server.Runner
- name: GetSuggestedAPIs
request:
api: /suggestedAPIs
body: |
{
"name": "{{.param.suiteName}}"
}
- name: createTestCase
request:
api: /suites/{{.param.suiteName}}/cases
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suiteName": "{{.param.suiteName}}",
"data": {
"name": "{{.param.caseName}}",
"request": {
"api": "/GetTestSuite",
"method": "POST",
"header": [{
"name": "X-Store-Name",
"value": "{{.param.store}}"
}]
}
}
}
- name: updateTestCase
request:
api: /suites/{{.param.suiteName}}/cases/{{.param.caseName}}
method: PUT
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suiteName": "{{.param.suiteName}}",
"data": {
"name": "{{.param.caseName}}",
"request": {
"api": "/GetTestSuite",
"method": "POST",
"header": [{
"name": "X-Store-Name",
"value": "{{.param.store}}"
}],
"body": "good"
}
}
}
- name: getTestCase
request:
api: /suites/{{.param.suiteName}}/cases/{{.param.caseName}}
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suite": "{{.param.suiteName}}",
"testcase": "{{.param.caseName}}"
}
expect:
bodyFieldsExpect:
request.body: good
- name: duplicateTestCase
request:
api: /suites/{{.param.suiteName}}/cases/{{.param.caseName}}/duplicate
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"sourceSuiteName": "{{.param.suiteName}}",
"sourceCaseName": "{{.param.caseName}}",
"targetSuiteName": "{{.param.suiteName}}",
"targetCaseName": "{{.param.caseName}}-copy"
}
- name: getDuplicatedTestCase
request:
api: /suites/{{.param.suiteName}}/cases/{{.param.caseName}}-copy
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suite": "{{.param.suiteName}}",
"testcase": "{{.param.caseName}}-copy"
}
expect:
bodyFieldsExpect:
request.body: good
- name: deleteTestCase
request:
api: /suites/{{.param.suiteName}}/cases/{{.param.caseName}}
method: DELETE
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suite": "{{.param.suiteName}}",
"testcase": "{{.param.caseName}}"
}
- name: deleteTestSuite
request:
api: /suites/{{.param.suiteName}}
method: DELETE
header:
X-Store-Name: "{{.param.store}}"
- name: createGRPCSuite
request:
api: /suites
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.gRPCSuiteName}}",
"api": "localhost:7070",
"kind": "grpc"
}
- name: createGRPCTestCase
request:
api: /suites/{{.param.gRPCSuiteName}}/cases
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suiteName": "{{.param.gRPCSuiteName}}",
"data": {
"name": "{{.param.gRPCCaseName}}",
"request": {
"api": "/server.Runner/GetSuites",
"header": [{
"key": "X-Store-Name",
"value": "{{.param.store}}"
}]
}
}
}
- name: getGRPCTestCase
request:
api: /suites/{{.param.gRPCSuiteName}}/cases/{{.param.gRPCCaseName}}
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"suite": "{{.param.gRPCSuiteName}}",
"testcase": "{{.param.gRPCCaseName}}"
}
expect:
bodyFieldsExpect:
request.header.0.value: "{{.param.store}}"
# - name: runGRPCTestCase
# request:
# api: /suites/{{.param.gRPCSuiteName}}/cases/{{.param.gRPCCaseName}}/run"
# method: POST
# header:
# X-Store-Name: "{{.param.store}}"
# body: |
# {
# "suite": "{{.param.gRPCSuiteName}}",
# "testcase": "{{.param.gRPCCaseName}}",
# "parameters": []
# }
- name: runTestSuite
request:
api: /run/suite
method: POST
header:
X-Store-Name: "{{.param.store}}"
body: |
{
"name": "{{.param.gRPCSuiteName}}"
}
- name: version
request:
api: /version
- name: popularHeaders
request:
api: /popularHeaders
expect:
verify:
- any(data.data, {.key == "Content-Type"})
- any(data.data, {.key == "Authorization"})
- name: functionsQuery
request:
api: /functions
query:
name: rand
expect:
verify:
- any(data.data, {.key == "randNumeric"})
- any(data.data, {.key == "randAlpha"})
- len(data.data) >= 8
- name: findUnknownFunction
request:
api: /functions
query:
name: "{{randAlpha 8}}"
expect:
verify:
- len(data.data) == 0
- name: listCodeGenerator
request:
api: /codeGenerators
expect:
verify:
- any(data.data, {.key == "curl"})
- len(data.data) >= 3
## Other
- name: downloadTool
request:
api: |
{{.param.server}}/get
expect:
header:
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=atest
Content-Transfer-Encoding: binary
- name: downloadExtGit
request:
api: |
{{.param.server}}/get
query:
name: atest-store-git
expect:
header:
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=atest-store-git
Content-Transfer-Encoding: binary
- name: oauth
request:
api: |
{{.param.server}}/oauth2/token
expect:
statusCode: 404
- name: debugCmdLine
request:
api: |
{{.param.server}}/debug/pprof/cmdline
- name: favicon
request:
api: |
{{ .param.server }}/favicon.ico
expect:
header:
Content-Type: image/x-icon
## metrics
- name: metrics
request:
api: |
{{.param.server}}/metrics
expect:
verify:
- indexOf(data, "atest_execution_count") != -1
- indexOf(data, "atest_execution_fail") != -1
- indexOf(data, "atest_execution_success") != -1
- indexOf(data, "atest_runners_count") != -1
- indexOf(data, "http_requests_total") != -1