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