Repair A1 integration tests
[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   - name: test the admission control policy status get
176     delay_before: 10 # give it a few seconds for rmr
177     request:
178       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
179       method: GET
180     response:
181       status_code: 200
182       body:
183         instance_status: "IN EFFECT"
184         has_been_deleted: False
185
186   - name: instance list 200 and contains the instance
187     request:
188       url: http://localhost:10000/a1-p/policytypes/6660666/policies
189       method: GET
190     response:
191       status_code: 200
192       body:
193         - admission_control_policy
194
195   # DELETE the instance and make sure subsequent GETs return properly
196   - name: delete the instance
197     delay_after: 4
198     request:
199       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
200       method: DELETE
201     response:
202       status_code: 202
203
204   - name: status should now be not in effect but still there
205     delay_before: 3 # give it a few seconds for rmr
206     delay_after: 8 # 3 + 11 > 10; that is, wait until t2 expires
207     request:
208       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
209       method: GET
210     response:
211       status_code: 200
212       body:
213         instance_status: "NOT IN EFFECT"
214         has_been_deleted: True
215
216   - name: instance list 200 but no instance
217     request:
218       url: http://localhost:10000/a1-p/policytypes/6660666/policies
219       method: GET
220     response:
221       status_code: 200
222       body: []
223
224   - name: cant get instance status
225     request:
226       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy/status
227       method: GET
228     response:
229       status_code: 404
230
231   - name: cant get instance
232     request:
233       url: http://localhost:10000/a1-p/policytypes/6660666/policies/admission_control_policy
234       method: GET
235     response:
236       status_code: 404
237
238   - name: delete ac type
239     request:
240       url: http://localhost:10000/a1-p/policytypes/6660666
241       method: DELETE
242     response:
243       status_code: 204
244
245   - name: cant delete again
246     request:
247       url: http://localhost:10000/a1-p/policytypes/6660666
248       method: DELETE
249     response:
250       status_code: 404
251
252   - name: cant get
253     request:
254       url: http://localhost:10000/a1-p/policytypes/6660666
255       method: DELETE
256     response:
257       status_code: 404
258
259   - name: empty type list
260     request:
261       url: http://localhost:10000/a1-p/policytypes
262       method: GET
263     response:
264       status_code: 200
265       body: []
266
267
268 ---
269
270 test_name: test the delay receiver
271
272 stages:
273
274   - name: test the delay policy type not there yet
275     request:
276       url: http://localhost:10000/a1-p/policytypes/20001
277       method: GET
278     response:
279       status_code: 404
280
281   - name: not yet in type list
282     request:
283       url: http://localhost:10000/a1-p/policytypes
284       method: GET
285     response:
286       status_code: 200
287       body: []
288
289   - name: instance list 404
290     request:
291       url: http://localhost:10000/a1-p/policytypes/20001/policies
292       method: GET
293     response:
294       status_code: 404
295
296   - name: put the type
297     request:
298       url: http://localhost:10000/a1-p/policytypes/20001
299       method: PUT
300       json:
301         name: test policy
302         description: just for testing
303         policy_type_id: 20001
304         create_schema:
305           "$schema": http://json-schema.org/draft-07/schema#
306           type: object
307           properties:
308             test:
309               type: string
310           required:
311             - test
312           additionalProperties: false
313     response:
314       status_code: 201
315
316   - name: type there now
317     request:
318       url: http://localhost:10000/a1-p/policytypes/20001
319       method: GET
320     response:
321       status_code: 200
322       body:
323         name: test policy
324         description: just for testing
325         policy_type_id: 20001
326         create_schema:
327           "$schema": http://json-schema.org/draft-07/schema#
328           type: object
329           properties:
330             test:
331               type: string
332           required:
333             - test
334           additionalProperties: false
335
336   - name: now in type list
337     request:
338       url: http://localhost:10000/a1-p/policytypes
339       method: GET
340     response:
341       status_code: 200
342       body:
343        - 20001
344
345   - name: instance list 200 but empty
346     request:
347       url: http://localhost:10000/a1-p/policytypes/20001/policies
348       method: GET
349     response:
350       status_code: 200
351       body: []
352
353   - name: test the delay policy instance get not there yet
354     request:
355       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
356       method: GET
357     response:
358       status_code: 404
359
360   - name: test the delay policy status get not there yet
361     request:
362       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
363       method: GET
364     response:
365       status_code: 404
366
367   - name: bad body for delaytest
368     request:
369       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
370       method: PUT
371       json:
372         not: "welcome"
373     response:
374       status_code: 400
375
376   - name: create delay policy instance
377     request:
378       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
379       method: PUT
380       json:
381         test: foo
382       headers:
383         content-type: application/json
384     response:
385       status_code: 202
386
387   - name: test the delay status get, not in effect yet
388     request:
389       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
390       method: GET
391     response:
392       status_code: 200
393       body:
394         instance_status: "NOT IN EFFECT"
395         has_been_deleted: False
396
397   - name: test the delay policy get
398     request:
399       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
400       method: GET
401     response:
402       status_code: 200
403       body:
404         test: foo
405
406   - name: instance list 200 and there
407     request:
408       url: http://localhost:10000/a1-p/policytypes/20001/policies
409       method: GET
410     response:
411       status_code: 200
412       body:
413        - delaytest
414
415   - name: test the delay status get
416     max_retries: 3
417     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
418     request:
419       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
420       method: GET
421     response:
422       status_code: 200
423       body:
424         instance_status: "IN EFFECT"
425         has_been_deleted: False
426
427   # DELETE the instance and make sure subsequent GETs return properly
428   - name: delete the instance
429     request:
430       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest
431       method: DELETE
432     response:
433       status_code: 202
434
435   - name: test the delay status get immediately
436     request:
437       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
438       method: GET
439     response:
440       status_code: 200
441       body:
442         instance_status: "IN EFFECT"
443         has_been_deleted: True
444
445   - name: test the delay status get after delay but before timers
446     delay_before: 7
447     request:
448       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
449       method: GET
450     response:
451       status_code: 200
452       body:
453         instance_status: "NOT IN EFFECT"
454         has_been_deleted: True
455
456   - name: test the delay status get after delay and after the timers
457     delay_before: 7
458     request:
459       url: http://localhost:10000/a1-p/policytypes/20001/policies/delaytest/status
460       method: GET
461     response:
462       status_code: 404
463
464 ---
465
466 test_name: test query
467
468 stages:
469   - name: type not there yet
470     request:
471       url: http://localhost:10000/a1-p/policytypes/1006001
472       method: GET
473     response:
474       status_code: 404
475
476   - name: put the type
477     request:
478       url: http://localhost:10000/a1-p/policytypes/1006001
479       method: PUT
480       json:
481         name: query test
482         description: test
483         policy_type_id: 1006001
484         create_schema:
485           "$schema": http://json-schema.org/draft-07/schema#
486           type: object
487           additionalProperties: false
488           properties:
489             foo:
490               type: string
491           required:
492             - foo
493     response:
494       status_code: 201
495
496   - name: type there now
497     request:
498       url: http://localhost:10000/a1-p/policytypes/1006001
499       method: GET
500     response:
501       status_code: 200
502
503   - name: instance list 200 but empty
504     request:
505       url: http://localhost:10000/a1-p/policytypes/1006001/policies
506       method: GET
507     response:
508       status_code: 200
509       body: []
510
511   - name: instance 1
512     request:
513       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt1
514       method: PUT
515       json:
516         foo: "bar1"
517       headers:
518         content-type: application/json
519     response:
520       status_code: 202
521
522   - name: instance 2
523     request:
524       url: http://localhost:10000/a1-p/policytypes/1006001/policies/qt2
525       method: PUT
526       json:
527         foo: "bar2"
528       headers:
529         content-type: application/json
530     response:
531       status_code: 202
532
533   - name: instance list
534     request:
535       url: http://localhost:10000/a1-p/policytypes/1006001/policies
536       method: GET
537     response:
538       status_code: 200
539       body: [qt1, qt2]
540
541   # after the query, a1 should send, query receiver should send back, and the policy should be in effect
542   # sometimes in kubernetes, this test takes a long time to work because of an k8s issue
543   # empirically we find that the si95 rmr finally "detects" failure after about 75 seconds, retries, and then works.
544   - name: test the query status get
545     max_retries: 100
546     delay_before: 1
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: 100
558     delay_before: 1
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