Threading pt3:
[ric-plt/a1.git] / integration_tests / test_a1.tavern.yaml
1 # test_a1.tavern.yaml
2
3 test_name: test healthcheck
4
5 stages:
6   - name: test the a1 healthcheck
7     request:
8       url: http://localhost:10000/a1-p/healthcheck
9       method: GET
10     response:
11       status_code: 200
12
13 ---
14
15 test_name: test admission control
16
17 stages:
18   - name: type not there yet
19     request:
20       url: http://localhost:10000/a1-p/policytypes/20000
21       method: GET
22     response:
23       status_code: 404
24
25   - name: type list empty
26     request:
27       url: http://localhost:10000/a1-p/policytypes
28       method: GET
29     response:
30       status_code: 200
31       body: []
32
33   - name: instance list 404
34     request:
35       url: http://localhost:10000/a1-p/policytypes/20000/policies
36       method: GET
37     response:
38       status_code: 404
39
40   - name: put the type
41     request:
42       url: http://localhost:10000/a1-p/policytypes/20000
43       method: PUT
44       json:
45         name: Admission Control
46         description: various parameters to control admission of dual connection
47         policy_type_id: 20000
48         create_schema:
49           "$schema": http://json-schema.org/draft-07/schema#
50           type: object
51           properties:
52             enforce:
53               type: boolean
54               default: true
55             window_length:
56               type: integer
57               default: 1
58               minimum: 1
59               maximum: 60
60               description: Sliding window length (in minutes)
61             blocking_rate:
62               type: number
63               default: 10
64               minimum: 1
65               maximum: 100
66               description: "% Connections to block"
67             trigger_threshold:
68               type: integer
69               default: 10
70               minimum: 1
71               description: Minimum number of events in window to trigger blocking
72           required:
73             - enforce
74             - blocking_rate
75             - trigger_threshold
76             - window_length
77           additionalProperties: false
78     response:
79       status_code: 201
80
81   - name: type there now
82     request:
83       url: http://localhost:10000/a1-p/policytypes/20000
84       method: GET
85     response:
86       status_code: 200
87
88   - name: now in type list
89     request:
90       url: http://localhost:10000/a1-p/policytypes
91       method: GET
92     response:
93       status_code: 200
94       body: [20000]
95
96   - name: instance list 200 but empty
97     request:
98       url: http://localhost:10000/a1-p/policytypes/20000/policies
99       method: GET
100     response:
101       status_code: 200
102       body: []
103
104   - name: test the admission control policy get not there yet
105     request:
106       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
107       method: GET
108     response:
109       status_code: 404
110
111   - name: test the admission control policy status get not there yet
112     request:
113       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy/status
114       method: GET
115     response:
116       status_code: 404
117
118   - name: bad body for admission control policy
119     request:
120       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
121       method: PUT
122       json:
123         not: "expected"
124       headers:
125         content-type: application/json
126     response:
127       status_code: 400
128
129   - name: not a json
130     request:
131       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
132       method: PUT
133       data: "asdf"
134     response:
135       status_code: 415
136
137   # put it properly
138   - name: put the admission control policy instance
139     request:
140       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
141       method: PUT
142       json:
143         enforce: true
144         window_length: 10
145         blocking_rate: 20
146         trigger_threshold: 10
147       headers:
148         content-type: application/json
149     response:
150       status_code: 202
151
152   - name: cant delete type with instances
153     delay_before: 3  # wait for the type acks to come back first
154     request:
155       url: http://localhost:10000/a1-p/policytypes/20000
156       method: DELETE
157     response:
158       status_code: 400
159
160   - name: test the admission control policy get
161     request:
162       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
163       method: GET
164     response:
165       status_code: 200
166       body:
167         enforce: true
168         window_length: 10
169         blocking_rate: 20
170         trigger_threshold: 10
171
172   - name: test the admission control policy status get
173     delay_before: 3 # give it a few seconds for rmr
174     request:
175       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy/status
176       method: GET
177     response:
178       status_code: 200
179       # tavern doesn't yet let you check string statuses!!!
180
181   - name: instance list 200 and contains the instance
182     request:
183       url: http://localhost:10000/a1-p/policytypes/20000/policies
184       method: GET
185     response:
186       status_code: 200
187       body:
188         - admission_control_policy
189
190   # DELETE the instance and make sure subsequent GETs return properly
191   - name: delete the instance
192     delay_after: 3 # give it a few seconds for rmr
193     request:
194       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
195       method: DELETE
196     response:
197       status_code: 202
198
199   - name: instance list 200 but no instance
200     request:
201       url: http://localhost:10000/a1-p/policytypes/20000/policies
202       method: GET
203     response:
204       status_code: 200
205       body: []
206
207   - name: cant get instance status
208     request:
209       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy/status
210       method: GET
211     response:
212       status_code: 404
213
214   - name: cant get instance
215     request:
216       url: http://localhost:10000/a1-p/policytypes/20000/policies/admission_control_policy
217       method: GET
218     response:
219       status_code: 404
220
221   - name: delete ac type
222     request:
223       url: http://localhost:10000/a1-p/policytypes/20000
224       method: DELETE
225     response:
226       status_code: 204
227
228   - name: cant delete again
229     request:
230       url: http://localhost:10000/a1-p/policytypes/20000
231       method: DELETE
232     response:
233       status_code: 404
234
235   - name: cant get
236     request:
237       url: http://localhost:10000/a1-p/policytypes/20000
238       method: DELETE
239     response:
240       status_code: 404
241
242   - name: empty type list
243     request:
244       url: http://localhost:10000/a1-p/policytypes
245       method: GET
246     response:
247       status_code: 200
248       body: []
249
250
251 ---
252
253 test_name: test the delay receiver
254
255 stages:
256
257   - name: test the delay policy type not there yet
258     request:
259       url: http://localhost:10000/a1-p/policytypes/20001
260       method: GET
261     response:
262       status_code: 404
263
264   - name: not yet in type list
265     request:
266       url: http://localhost:10000/a1-p/policytypes
267       method: GET
268     response:
269       status_code: 200
270       body: []
271
272   - name: instance list 404
273     request:
274       url: http://localhost:10000/a1-p/policytypes/20001/policies
275       method: GET
276     response:
277       status_code: 404
278
279   - name: put the type
280     request:
281       url: http://localhost:10000/a1-p/policytypes/20001
282       method: PUT
283       json:
284         name: test policy
285         description: just for testing
286         policy_type_id: 20001
287         create_schema:
288           "$schema": http://json-schema.org/draft-07/schema#
289           type: object
290           properties:
291             test:
292               type: string
293           required:
294             - test
295           additionalProperties: false
296     response:
297       status_code: 201
298
299   - name: type there now
300     request:
301       url: http://localhost:10000/a1-p/policytypes/20001
302       method: GET
303     response:
304       status_code: 200
305       body:
306         name: test policy
307         description: just for testing
308         policy_type_id: 20001
309         create_schema:
310           "$schema": http://json-schema.org/draft-07/schema#
311           type: object
312           properties:
313             test:
314               type: string
315           required:
316             - test
317           additionalProperties: false
318
319   - name: now in type list
320     request:
321       url: http://localhost:10000/a1-p/policytypes
322       method: GET
323     response:
324       status_code: 200
325       body:
326        - 20001
327
328   - name: instance list 200 but empty
329     request:
330       url: http://localhost:10000/a1-p/policytypes/20001/policies
331       method: GET
332     response:
333       status_code: 200
334       body: []
335
336   - name: test the delay policy instance get not there yet
337     request:
338       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
339       method: GET
340     response:
341       status_code: 404
342
343   - name: test the delay policy status get not there yet
344     request:
345       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
346       method: GET
347     response:
348       status_code: 404
349
350   - name: bad body for delaytest
351     request:
352       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
353       method: PUT
354       json:
355         not: "welcome"
356     response:
357       status_code: 400
358
359   - name: create delay policy instance
360     request:
361       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
362       method: PUT
363       json:
364         test: foo
365       headers:
366         content-type: application/json
367     response:
368       status_code: 202
369
370   - name: test the delay policy get
371     request:
372       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
373       method: GET
374     response:
375       status_code: 200
376       body:
377         test: foo
378
379   - name: test the delay status get
380     max_retries: 3
381     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
382     request:
383       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
384       method: GET
385     response:
386       status_code: 200
387       # tavern doesn't let you check non json yet!
388
389   - name: instance list 200 and there
390     request:
391       url: http://localhost:10000/a1-p/policytypes/20001/policies
392       method: GET
393     response:
394       status_code: 200
395       body:
396        - delaytest
397
398 ---
399
400 test_name: test bad routing file endpoint
401
402 stages:
403
404   - name: put the type
405     request:
406       url: http://localhost:10000/a1-p/policytypes/20002
407       method: PUT
408       json:
409         name: test policy
410         description: just for testing
411         policy_type_id: 20002
412         create_schema:
413           "$schema": http://json-schema.org/draft-07/schema#
414           type: object
415           properties:
416             test:
417               type: string
418           required:
419             - test
420           additionalProperties: false
421
422   - name: create policy instance that will go to a broken routing endpoint
423     request:
424       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest
425       method: PUT
426       json:
427         test: foo
428       headers:
429         content-type: application/json
430     response:
431       status_code: 202
432
433   - name: should be no status
434     request:
435       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest/status
436       method: GET
437     response:
438       status_code: 200
439       body: []
440
441   # this one cant currently be deleted, see the comment in a1/data.py
442
443 ---
444
445 test_name: bad_requests
446
447 stages:
448
449   - name: bad type get
450     request:
451       url: http://localhost:10000/a1-p/policytypes/20666
452       method: GET
453     response:
454       status_code: 404
455
456   - name: bad instance get bad type
457     request:
458       url: http://localhost:10000/a1-p/policytypes/20666/policies/nonono
459       method: GET
460     response:
461       status_code: 404
462
463   - name: bad int range 1
464     request:
465       url: http://localhost:10000/a1-p/policytypes/19999
466       method: PUT
467       json:
468         name: test policy
469         description: just for testing
470         policy_type_id: 19999
471         create_schema:
472           "$schema": http://json-schema.org/draft-07/schema#
473           type: object
474     response:
475       status_code: 400
476
477   - name: bad int range 2
478     request:
479       url: http://localhost:10000/a1-p/policytypes/21024
480       method: PUT
481       json:
482         name: test policy
483         description: just for testing
484         policy_type_id: 21024
485         create_schema:
486           "$schema": http://json-schema.org/draft-07/schema#
487           type: object
488     response:
489       status_code: 400
490
491