Mostly integration test work:
[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 query
468
469 stages:
470   - name: type not there yet
471     request:
472       url: http://localhost:10000/a1-p/policytypes/1006001
473       method: GET
474     response:
475       status_code: 404
476
477   - name: put the type
478     request:
479       url: http://localhost:10000/a1-p/policytypes/1006001
480       method: PUT
481       json:
482         name: query test
483         description: test
484         policy_type_id: 1006001
485         create_schema:
486           "$schema": http://json-schema.org/draft-07/schema#
487           type: object
488           additionalProperties: false
489           properties:
490             foo:
491               type: string
492           required:
493             - foo
494     response:
495       status_code: 201
496
497   - name: type there now
498     request:
499       url: http://localhost:10000/a1-p/policytypes/1006001
500       method: GET
501     response:
502       status_code: 200
503
504   - name: instance list 200 but empty
505     request:
506       url: http://localhost:10000/a1-p/policytypes/1006001/policies
507       method: GET
508     response:
509       status_code: 200
510       body: []
511
512   - name: instance 1
513     request:
514       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt1
515       method: PUT
516       json:
517         foo: "bar1"
518       headers:
519         content-type: application/json
520     response:
521       status_code: 202
522
523   - name: instance 2
524     request:
525       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt2
526       method: PUT
527       json:
528         foo: "bar2"
529       headers:
530         content-type: application/json
531     response:
532       status_code: 202
533
534   - name: instance list
535     request:
536       url: http://localhost:10000/a1-p/policytypes/1006001/policies
537       method: GET
538     response:
539       status_code: 200
540       body: [qt1, qt2]
541
542   # after the query, a1 should send, query receiver should send back, and the policy should be in effect
543
544   - name: test the query status get
545     max_retries: 3
546     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
547     request:
548       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt1/status
549       method: GET
550     response:
551       status_code: 200
552       body:
553         instance_status: "IN EFFECT"
554         has_been_deleted: False
555
556   - name: test the query status get 2
557     max_retries: 3
558     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
559     request:
560       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt2/status
561       method: GET
562     response:
563       status_code: 200
564       body:
565         instance_status: "IN EFFECT"
566         has_been_deleted: False
567
568 ---
569
570 test_name: test bad routing file endpoint
571
572 stages:
573
574   - name: put the type
575     request:
576       url: http://localhost:10000/a1-p/policytypes/20002
577       method: PUT
578       json:
579         name: test policy
580         description: just for testing
581         policy_type_id: 20002
582         create_schema:
583           "$schema": http://json-schema.org/draft-07/schema#
584           type: object
585           properties:
586             test:
587               type: string
588           required:
589             - test
590           additionalProperties: false
591
592   - name: create policy instance that will go to a broken routing endpoint
593     request:
594       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest
595       method: PUT
596       json:
597         test: foo
598       headers:
599         content-type: application/json
600     response:
601       status_code: 202
602
603   - name: should be no status
604     request:
605       url: http://localhost:10000/a1-p/policytypes/20002/policies/brokentest/status
606       method: GET
607     response:
608       status_code: 200
609       body: []
610
611   # this one cant currently be deleted, see the comment in a1/data.py
612
613 ---
614
615 test_name: bad_requests
616
617 stages:
618
619   - name: bad type get
620     request:
621       url: http://localhost:10000/a1-p/policytypes/20666
622       method: GET
623     response:
624       status_code: 404
625
626   - name: bad instance get bad type
627     request:
628       url: http://localhost:10000/a1-p/policytypes/20666/policies/nonono
629       method: GET
630     response:
631       status_code: 404
632
633   - name: bad int range 1
634     request:
635       url: http://localhost:10000/a1-p/policytypes/0
636       method: PUT
637       json:
638         name: test policy
639         description: just for testing
640         policy_type_id: 0
641         create_schema:
642           "$schema": http://json-schema.org/draft-07/schema#
643           type: object
644     response:
645       status_code: 400
646
647   - name: bad int range 2
648     request:
649       url: http://localhost:10000/a1-p/policytypes/2147483648
650       method: PUT
651       json:
652         name: test policy
653         description: just for testing
654         policy_type_id: 2147483648
655         create_schema:
656           "$schema": http://json-schema.org/draft-07/schema#
657           type: object
658     response:
659       status_code: 400