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