Merge "Merge branch 'development'"
[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/6660666
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/6660666/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/6660666
43       method: PUT
44       json:
45         name: Admission Control
46         description: various parameters to control admission of dual connection
47         policy_type_id: 6660666
48         create_schema:
49           "$schema": http://json-schema.org/draft-07/schema#
50           type: object
51           additionalProperties: false
52           properties:
53             class:
54               type: integer
55               minimum: 1
56               maximum: 256
57               description: integer id representing class to which we are applying policy
58             enforce:
59               type: boolean
60               description: Whether to enable or disable enforcement of policy on this class
61             window_length:
62               type: integer
63               minimum: 15
64               maximum: 300
65               description: Sliding window length in seconds
66             trigger_threshold:
67               type: integer
68               minimum: 1
69             blocking_rate:
70               type: number
71               minimum: 0
72               maximum: 100
73           required:
74             - class
75             - enforce
76             - window_length
77             - trigger_threshold
78             - blocking_rate
79     response:
80       status_code: 201
81
82   - name: type there now
83     request:
84       url: http://localhost:10000/a1-p/policytypes/6660666
85       method: GET
86     response:
87       status_code: 200
88
89   - name: now in type list
90     request:
91       url: http://localhost:10000/a1-p/policytypes
92       method: GET
93     response:
94       status_code: 200
95       body: [6660666]
96
97   - name: instance list 200 but empty
98     request:
99       url: http://localhost:10000/a1-p/policytypes/6660666/policies
100       method: GET
101     response:
102       status_code: 200
103       body: []
104
105   - name: test the admission control policy get not there yet
106     request:
107       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
108       method: GET
109     response:
110       status_code: 404
111
112   - name: test the admission control policy status get not there yet
113     request:
114       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
115       method: GET
116     response:
117       status_code: 404
118
119   - name: bad body for admission control policy
120     request:
121       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
122       method: PUT
123       json:
124         not: "expected"
125       headers:
126         content-type: application/json
127     response:
128       status_code: 400
129
130   - name: not a json
131     request:
132       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
133       method: PUT
134       data: "asdf"
135     response:
136       status_code: 415
137
138   # put it properly
139   - name: put the admission control policy instance
140     request:
141       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
142       method: PUT
143       json:
144         class: 12
145         enforce: true
146         window_length: 20
147         blocking_rate: 20
148         trigger_threshold: 10
149       headers:
150         content-type: application/json
151     response:
152       status_code: 202
153
154   - name: cant delete type with instances
155     delay_before: 3  # wait for the type acks to come back first
156     request:
157       url: http://localhost:10000/a1-p/policytypes/6660666
158       method: DELETE
159     response:
160       status_code: 400
161
162   - name: test the admission control policy get
163     request:
164       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
165       method: GET
166     response:
167       status_code: 200
168       body:
169         class: 12
170         enforce: true
171         window_length: 20
172         blocking_rate: 20
173         trigger_threshold: 10
174
175
176   - name: test the admission control policy status get
177     delay_before: 3 # give it a few seconds for rmr
178     request:
179       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
180       method: GET
181     response:
182       status_code: 200
183       body:
184         instance_status: "IN EFFECT"
185         has_been_deleted: False
186
187   - name: instance list 200 and contains the instance
188     request:
189       url: http://localhost:10000/a1-p/policytypes/6660666/policies
190       method: GET
191     response:
192       status_code: 200
193       body:
194         - admission_control_policy
195
196   # DELETE the instance and make sure subsequent GETs return properly
197   - name: delete the instance
198     delay_after: 4
199     request:
200       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
201       method: DELETE
202     response:
203       status_code: 202
204
205   - name: status should now be not in effect but still there
206     delay_before: 3 # give it a few seconds for rmr
207     delay_after: 8 # 3 + 11 > 10; that is, wait until t2 expires
208     request:
209       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
210       method: GET
211     response:
212       status_code: 200
213       body:
214         instance_status: "NOT IN EFFECT"
215         has_been_deleted: True
216
217   - name: instance list 200 but no instance
218     request:
219       url: http://localhost:10000/a1-p/policytypes/6660666/policies
220       method: GET
221     response:
222       status_code: 200
223       body: []
224
225   - name: cant get instance status
226     request:
227       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
228       method: GET
229     response:
230       status_code: 404
231
232   - name: cant get instance
233     request:
234       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
235       method: GET
236     response:
237       status_code: 404
238
239   - name: delete ac type
240     request:
241       url: http://localhost:10000/a1-p/policytypes/6660666
242       method: DELETE
243     response:
244       status_code: 204
245
246   - name: cant delete again
247     request:
248       url: http://localhost:10000/a1-p/policytypes/6660666
249       method: DELETE
250     response:
251       status_code: 404
252
253   - name: cant get
254     request:
255       url: http://localhost:10000/a1-p/policytypes/6660666
256       method: DELETE
257     response:
258       status_code: 404
259
260   - name: empty type list
261     request:
262       url: http://localhost:10000/a1-p/policytypes
263       method: GET
264     response:
265       status_code: 200
266       body: []
267
268
269 ---
270
271 test_name: test the delay receiver
272
273 stages:
274
275   - name: test the delay policy type not there yet
276     request:
277       url: http://localhost:10000/a1-p/policytypes/20001
278       method: GET
279     response:
280       status_code: 404
281
282   - name: not yet in type list
283     request:
284       url: http://localhost:10000/a1-p/policytypes
285       method: GET
286     response:
287       status_code: 200
288       body: []
289
290   - name: instance list 404
291     request:
292       url: http://localhost:10000/a1-p/policytypes/20001/policies
293       method: GET
294     response:
295       status_code: 404
296
297   - name: put the type
298     request:
299       url: http://localhost:10000/a1-p/policytypes/20001
300       method: PUT
301       json:
302         name: test policy
303         description: just for testing
304         policy_type_id: 20001
305         create_schema:
306           "$schema": http://json-schema.org/draft-07/schema#
307           type: object
308           properties:
309             test:
310               type: string
311           required:
312             - test
313           additionalProperties: false
314     response:
315       status_code: 201
316
317   - name: type there now
318     request:
319       url: http://localhost:10000/a1-p/policytypes/20001
320       method: GET
321     response:
322       status_code: 200
323       body:
324         name: test policy
325         description: just for testing
326         policy_type_id: 20001
327         create_schema:
328           "$schema": http://json-schema.org/draft-07/schema#
329           type: object
330           properties:
331             test:
332               type: string
333           required:
334             - test
335           additionalProperties: false
336
337   - name: now in type list
338     request:
339       url: http://localhost:10000/a1-p/policytypes
340       method: GET
341     response:
342       status_code: 200
343       body:
344        - 20001
345
346   - name: instance list 200 but empty
347     request:
348       url: http://localhost:10000/a1-p/policytypes/20001/policies
349       method: GET
350     response:
351       status_code: 200
352       body: []
353
354   - name: test the delay policy instance get not there yet
355     request:
356       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
357       method: GET
358     response:
359       status_code: 404
360
361   - name: test the delay policy status get not there yet
362     request:
363       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
364       method: GET
365     response:
366       status_code: 404
367
368   - name: bad body for delaytest
369     request:
370       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
371       method: PUT
372       json:
373         not: "welcome"
374     response:
375       status_code: 400
376
377   - name: create delay policy instance
378     request:
379       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
380       method: PUT
381       json:
382         test: foo
383       headers:
384         content-type: application/json
385     response:
386       status_code: 202
387
388   - name: test the delay status get, not in effect yet
389     request:
390       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
391       method: GET
392     response:
393       status_code: 200
394       body:
395         instance_status: "NOT IN EFFECT"
396         has_been_deleted: False
397
398   - name: test the delay policy get
399     request:
400       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
401       method: GET
402     response:
403       status_code: 200
404       body:
405         test: foo
406
407   - name: instance list 200 and there
408     request:
409       url: http://localhost:10000/a1-p/policytypes/20001/policies
410       method: GET
411     response:
412       status_code: 200
413       body:
414        - delaytest
415
416   - name: test the delay status get
417     max_retries: 3
418     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
419     request:
420       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
421       method: GET
422     response:
423       status_code: 200
424       body:
425         instance_status: "IN EFFECT"
426         has_been_deleted: False
427
428   # DELETE the instance and make sure subsequent GETs return properly
429   - name: delete the instance
430     request:
431       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
432       method: DELETE
433     response:
434       status_code: 202
435
436   - name: test the delay status get immediately
437     request:
438       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
439       method: GET
440     response:
441       status_code: 200
442       body:
443         instance_status: "IN EFFECT"
444         has_been_deleted: True
445
446   - name: test the delay status get after delay but before timers
447     delay_before: 7
448     request:
449       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
450       method: GET
451     response:
452       status_code: 200
453       body:
454         instance_status: "NOT IN EFFECT"
455         has_been_deleted: True
456
457   - name: test the delay status get after delay and after the timers
458     delay_before: 7
459     request:
460       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
461       method: GET
462     response:
463       status_code: 404
464
465 ---
466
467 test_name: test bad routing file endpoint
468
469 stages:
470
471   - name: put the type
472     request:
473       url: http://localhost:10000/a1-p/policytypes/20002
474       method: PUT
475       json:
476         name: test policy
477         description: just for testing
478         policy_type_id: 20002
479         create_schema:
480           "$schema": http://json-schema.org/draft-07/schema#
481           type: object
482           properties:
483             test:
484               type: string
485           required:
486             - test
487           additionalProperties: false
488
489   - name: create policy instance that will go to a broken routing endpoint
490     request:
491       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest
492       method: PUT
493       json:
494         test: foo
495       headers:
496         content-type: application/json
497     response:
498       status_code: 202
499
500   - name: should be no status
501     request:
502       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest/status
503       method: GET
504     response:
505       status_code: 200
506       body: []
507
508   # this one cant currently be deleted, see the comment in a1/data.py
509
510 ---
511
512 test_name: bad_requests
513
514 stages:
515
516   - name: bad type get
517     request:
518       url: http://localhost:10000/a1-p/policytypes/20666
519       method: GET
520     response:
521       status_code: 404
522
523   - name: bad instance get bad type
524     request:
525       url: http://localhost:10000/a1-p/policytypes/20666/policies/nonono
526       method: GET
527     response:
528       status_code: 404
529
530   - name: bad int range 1
531     request:
532       url: http://localhost:10000/a1-p/policytypes/0
533       method: PUT
534       json:
535         name: test policy
536         description: just for testing
537         policy_type_id: 0
538         create_schema:
539           "$schema": http://json-schema.org/draft-07/schema#
540           type: object
541     response:
542       status_code: 400
543
544   - name: bad int range 2
545     request:
546       url: http://localhost:10000/a1-p/policytypes/2147483648
547       method: PUT
548       json:
549         name: test policy
550         description: just for testing
551         policy_type_id: 2147483648
552         create_schema:
553           "$schema": http://json-schema.org/draft-07/schema#
554           type: object
555     response:
556       status_code: 400
557
558