RIC:1060: Change in PTL
[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/v2/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/v2/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/v2/policytypes
28       method: GET
29     response:
30       status_code: 200
31       json: []
32
33   - name: instance list 404
34     request:
35       url: http://localhost:10000/A1-P/v2/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/v2/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/v2/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/v2/policytypes
92       method: GET
93     response:
94       status_code: 200
95       json: [6660666]
96
97   - name: instance list 200 but empty
98     request:
99       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies
100       method: GET
101     response:
102       status_code: 200
103       json: []
104
105   - name: test the admission control policy get not there yet
106     request:
107       url: http://localhost:10000/A1-P/v2/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/v2/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/v2/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/v2/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/v2/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/v2/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/v2/policytypes/6660666/policies/admission_control_policy
165       method: GET
166     response:
167       status_code: 200
168       json:
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/v2/policytypes/6660666/policies/admission_control_policy/status
179       method: GET
180     response:
181       status_code: 200
182       json:
183         instance_status: "IN EFFECT"
184         has_been_deleted: False
185         created_at: !anyfloat
186
187   - name: instance list 200 and contains the instance
188     request:
189       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies
190       method: GET
191     response:
192       status_code: 200
193       json:
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/v2/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: 10 # 3 + 10 > 10; that is, wait until t2 expires
208     request:
209       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies/admission_control_policy/status
210       method: GET
211     response:
212       status_code: 200
213       json:
214         instance_status: "NOT IN EFFECT"
215         has_been_deleted: True
216         deleted_at: !anyfloat
217         created_at: !anyfloat
218
219   - name: instance list 200 but no instance
220     request:
221       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies
222       method: GET
223     response:
224       status_code: 200
225       json: []
226
227   - name: cant get instance status
228     request:
229       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies/admission_control_policy/status
230       method: GET
231     response:
232       status_code: 404
233
234   - name: cant get instance
235     request:
236       url: http://localhost:10000/A1-P/v2/policytypes/6660666/policies/admission_control_policy
237       method: GET
238     response:
239       status_code: 404
240
241   - name: delete ac type
242     request:
243       url: http://localhost:10000/A1-P/v2/policytypes/6660666
244       method: DELETE
245     response:
246       status_code: 204
247
248   - name: cant delete again
249     request:
250       url: http://localhost:10000/A1-P/v2/policytypes/6660666
251       method: DELETE
252     response:
253       status_code: 404
254
255   - name: cant get
256     request:
257       url: http://localhost:10000/A1-P/v2/policytypes/6660666
258       method: DELETE
259     response:
260       status_code: 404
261
262   - name: empty type list
263     request:
264       url: http://localhost:10000/A1-P/v2/policytypes
265       method: GET
266     response:
267       status_code: 200
268       json: []
269
270
271 ---
272
273 test_name: test the delay receiver
274
275 stages:
276
277   - name: test the delay policy type not there yet
278     request:
279       url: http://localhost:10000/A1-P/v2/policytypes/20001
280       method: GET
281     response:
282       status_code: 404
283
284   - name: not yet in type list
285     request:
286       url: http://localhost:10000/A1-P/v2/policytypes
287       method: GET
288     response:
289       status_code: 200
290       json: []
291
292   - name: instance list 404
293     request:
294       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies
295       method: GET
296     response:
297       status_code: 404
298
299   - name: put the type
300     request:
301       url: http://localhost:10000/A1-P/v2/policytypes/20001
302       method: PUT
303       json:
304         name: test policy
305         description: just for testing
306         policy_type_id: 20001
307         create_schema:
308           "$schema": http://json-schema.org/draft-07/schema#
309           type: object
310           properties:
311             test:
312               type: string
313           required:
314             - test
315           additionalProperties: false
316     response:
317       status_code: 201
318
319   - name: type there now
320     request:
321       url: http://localhost:10000/A1-P/v2/policytypes/20001
322       method: GET
323     response:
324       status_code: 200
325       json:
326         name: test policy
327         description: just for testing
328         policy_type_id: 20001
329         create_schema:
330           "$schema": http://json-schema.org/draft-07/schema#
331           type: object
332           properties:
333             test:
334               type: string
335           required:
336             - test
337           additionalProperties: false
338
339   - name: now in type list
340     request:
341       url: http://localhost:10000/A1-P/v2/policytypes
342       method: GET
343     response:
344       status_code: 200
345       json:
346        - 20001
347
348   - name: instance list 200 but empty
349     request:
350       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies
351       method: GET
352     response:
353       status_code: 200
354       json: []
355
356   - name: test the delay policy instance get not there yet
357     request:
358       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest
359       method: GET
360     response:
361       status_code: 404
362
363   - name: test the delay policy status get not there yet
364     request:
365       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
366       method: GET
367     response:
368       status_code: 404
369
370   - name: bad body for delaytest
371     request:
372       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest
373       method: PUT
374       json:
375         not: "welcome"
376     response:
377       status_code: 400
378
379   - name: create delay policy instance
380     request:
381       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest
382       method: PUT
383       json:
384         test: foo
385       headers:
386         content-type: application/json
387     response:
388       status_code: 202
389
390   - name: test the delay status get, not in effect yet
391     request:
392       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
393       method: GET
394     response:
395       status_code: 200
396       json:
397         instance_status: "NOT IN EFFECT"
398         has_been_deleted: False
399         created_at: !anyfloat
400
401   - name: test the delay policy get
402     request:
403       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest
404       method: GET
405     response:
406       status_code: 200
407       json:
408         test: foo
409
410   - name: instance list 200 and there
411     request:
412       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies
413       method: GET
414     response:
415       status_code: 200
416       json:
417        - delaytest
418
419   - name: test the delay status get
420     max_retries: 3
421     delay_before: 6  # give it a few seconds for rmr ; delay reciever sleeps for 5 seconds by default
422     request:
423       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
424       method: GET
425     response:
426       status_code: 200
427       json:
428         instance_status: "IN EFFECT"
429         has_been_deleted: False
430         created_at: !anyfloat
431
432   # DELETE the instance and make sure subsequent GETs return properly
433   - name: delete the instance
434     request:
435       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest
436       method: DELETE
437     response:
438       status_code: 202
439
440   - name: test the delay status get immediately
441     request:
442       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
443       method: GET
444     response:
445       status_code: 200
446       json:
447         instance_status: "IN EFFECT"
448         has_been_deleted: True
449         deleted_at: !anyfloat
450         created_at: !anyfloat
451
452   - name: test the delay status get after delay but before timers
453     delay_before: 7
454     request:
455       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
456       method: GET
457     response:
458       status_code: 200
459       json:
460         instance_status: "NOT IN EFFECT"
461         has_been_deleted: True
462         deleted_at: !anyfloat
463         created_at: !anyfloat
464
465   - name: test the delay status get after delay and after the timers
466     delay_before: 7
467     request:
468       url: http://localhost:10000/A1-P/v2/policytypes/20001/policies/delaytest/status
469       method: GET
470     response:
471       status_code: 404
472
473 ---
474
475 test_name: test query
476
477 stages:
478   - name: type not there yet
479     request:
480       url: http://localhost:10000/A1-P/v2/policytypes/1006001
481       method: GET
482     response:
483       status_code: 404
484
485   - name: put the type
486     request:
487       url: http://localhost:10000/A1-P/v2/policytypes/1006001
488       method: PUT
489       json:
490         name: query test
491         description: test
492         policy_type_id: 1006001
493         create_schema:
494           "$schema": http://json-schema.org/draft-07/schema#
495           type: object
496           additionalProperties: false
497           properties:
498             foo:
499               type: string
500           required:
501             - foo
502     response:
503       status_code: 201
504
505   - name: type there now
506     request:
507       url: http://localhost:10000/A1-P/v2/policytypes/1006001
508       method: GET
509     response:
510       status_code: 200
511
512   - name: instance list 200 but empty
513     request:
514       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies
515       method: GET
516     response:
517       status_code: 200
518       json: []
519
520   - name: instance 1
521     request:
522       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies/qt1
523       method: PUT
524       json:
525         foo: "bar1"
526       headers:
527         content-type: application/json
528     response:
529       status_code: 202
530
531   - name: instance 2
532     request:
533       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies/qt2
534       method: PUT
535       json:
536         foo: "bar2"
537       headers:
538         content-type: application/json
539     response:
540       status_code: 202
541
542   - name: instance list
543     request:
544       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies
545       method: GET
546     response:
547       status_code: 200
548       json: [qt1, qt2]
549
550   # after the query, a1 should send, query receiver should send back, and the policy should be in effect
551   # sometimes in kubernetes, this test takes a long time to work because of an k8s issue
552   # empirically we find that the si95 rmr finally "detects" failure after about 75 seconds, retries, and then works.
553   - name: test the query status get
554     max_retries: 100
555     delay_before: 1
556     request:
557       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies/qt1/status
558       method: GET
559     response:
560       status_code: 200
561       json:
562         instance_status: "IN EFFECT"
563         has_been_deleted: False
564         created_at: !anyfloat
565
566   - name: test the query status get 2
567     max_retries: 100
568     delay_before: 1
569     request:
570       url: http://localhost:10000/A1-P/v2/policytypes/1006001/policies/qt2/status
571       method: GET
572     response:
573       status_code: 200
574       json:
575         instance_status: "IN EFFECT"
576         has_been_deleted: False
577         created_at: !anyfloat
578
579 ---
580
581 test_name: test bad routing file endpoint
582
583 stages:
584
585   - name: put the type
586     request:
587       url: http://localhost:10000/A1-P/v2/policytypes/20002
588       method: PUT
589       json:
590         name: test policy
591         description: just for testing
592         policy_type_id: 20002
593         create_schema:
594           "$schema": http://json-schema.org/draft-07/schema#
595           type: object
596           properties:
597             test:
598               type: string
599           required:
600             - test
601           additionalProperties: false
602
603   - name: create policy instance that will go to a broken routing endpoint
604     request:
605       url: http://localhost:10000/A1-P/v2/policytypes/20002/policies/brokentest
606       method: PUT
607       json:
608         test: foo
609       headers:
610         content-type: application/json
611     response:
612       status_code: 202
613
614   - name: should be no status
615     request:
616       url: http://localhost:10000/A1-P/v2/policytypes/20002/policies/brokentest/status
617       method: GET
618     response:
619       status_code: 200
620       json: []
621
622   # this one cant currently be deleted, see the comment in a1/data.py
623
624 ---
625
626 test_name: bad_requests
627
628 stages:
629
630   - name: bad type get
631     request:
632       url: http://localhost:10000/A1-P/v2/policytypes/20666
633       method: GET
634     response:
635       status_code: 404
636
637   - name: bad instance get bad type
638     request:
639       url: http://localhost:10000/A1-P/v2/policytypes/20666/policies/nonono
640       method: GET
641     response:
642       status_code: 404
643
644   - name: bad int range 1
645     request:
646       url: http://localhost:10000/A1-P/v2/policytypes/0
647       method: PUT
648       json:
649         name: test policy
650         description: just for testing
651         policy_type_id: 0
652         create_schema:
653           "$schema": http://json-schema.org/draft-07/schema#
654           type: object
655     response:
656       status_code: 400
657
658   - name: bad int range 2
659     request:
660       url: http://localhost:10000/A1-P/v2/policytypes/2147483648
661       method: PUT
662       json:
663         name: test policy
664         description: just for testing
665         policy_type_id: 2147483648
666         create_schema:
667           "$schema": http://json-schema.org/draft-07/schema#
668           type: object
669     response:
670       status_code: 400