summaryrefslogtreecommitdiff
path: root/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml
blob: c550e80dca4efe5594282af25a0583e51b7989e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775

fixtures:
    - APIFixture

defaults:
    request_headers:
        x-auth-token: admin
        accept: application/json
        openstack-api-version: placement latest

tests:

- name: what is at resource providers
  GET: /resource_providers
  request_headers:
      # microversion 1.15 for cache headers
      openstack-api-version: placement 1.15
  response_json_paths:
      $.resource_providers: []
  response_headers:
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: non admin forbidden
  GET: /resource_providers
  request_headers:
      x-auth-token: user
      accept: application/json
  status: 403
  response_json_paths:
      $.errors[0].title: Forbidden

- name: route not found non json
  GET: /moo
  request_headers:
      accept: text/plain
  status: 404
  response_strings:
      - The resource could not be found

- name: post new resource provider - old microversion
  POST: /resource_providers
  request_headers:
    content-type: application/json
    openstack-api-version: placement 1.19
  data:
      name: $ENVIRON['RP_NAME']
      uuid: $ENVIRON['RP_UUID']
  status: 201
  response_headers:
      location: //resource_providers/[a-f0-9-]+/
  response_forbidden_headers:
      - content-type

- name: delete it
  DELETE: $LOCATION
  status: 204

- name: post new resource provider - new microversion
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: $ENVIRON['RP_NAME']
      uuid: $ENVIRON['RP_UUID']
  status: 200
  response_headers:
      location: //resource_providers/[a-f0-9-]+/
  response_json_paths:
      $.uuid: $ENVIRON['RP_UUID']
      $.name: $ENVIRON['RP_NAME']
      $.parent_provider_uuid: null
      $.generation: 0
      $.links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages

# On this one, don't test for which field was a duplicate because
# that depends on how the database reports columns.
- name: try to create same all again
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: $ENVIRON['RP_NAME']
      uuid: $ENVIRON['RP_UUID']
  status: 409
  response_strings:
      - Conflicting resource provider
  response_json_paths:
      $.errors[0].title: Conflict

- name: try to create same name again
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: $ENVIRON['RP_NAME']
      uuid: ada30fb5-566d-4fe1-b43b-28a9e988790c
  status: 409
  response_strings:
      - "Conflicting resource provider name: $ENVIRON['RP_NAME'] already exists"
  response_json_paths:
      $.errors[0].title: Conflict
      $.errors[0].code: placement.duplicate_name

- name: confirm the correct post
  GET: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
      openstack-api-version: placement 1.15
  response_headers:
      content-type: application/json
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/
  response_json_paths:
      $.uuid: $ENVIRON['RP_UUID']
      $.name: $ENVIRON['RP_NAME']
      $.parent_provider_uuid: null
      $.generation: 0
      $.links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages

- name: get resource provider works with no accept
  GET: /resource_providers/$ENVIRON['RP_UUID']
  response_headers:
      content-type: /application/json/
  response_json_paths:
      $.uuid: $ENVIRON['RP_UUID']

- name: get non-existing resource provider
  GET: /resource_providers/d67370b5-4dc0-470d-a4fa-85e8e89abc6c
  status: 404
  response_strings:
      - No resource provider with uuid d67370b5-4dc0-470d-a4fa-85e8e89abc6c found
  response_json_paths:
      $.errors[0].title: Not Found

- name: list one resource providers
  GET: /resource_providers
  request_headers:
      openstack-api-version: placement 1.15
  response_json_paths:
      $.resource_providers.`len`: 1
      $.resource_providers[0].uuid: $ENVIRON['RP_UUID']
      $.resource_providers[0].name: $ENVIRON['RP_NAME']
      $.resource_providers[0].generation: 0
      $.resource_providers[0].parent_provider_uuid: null
      $.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
  response_headers:
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: filter out all resource providers by name
  GET: /resource_providers?name=flubblebubble
  response_json_paths:
      $.resource_providers.`len`: 0

- name: filter out all resource providers by uuid
  GET: /resource_providers?uuid=d67370b5-4dc0-470d-a4fa-85e8e89abc6c
  response_json_paths:
      $.resource_providers.`len`: 0

- name: list one resource provider filtering by name
  GET: /resource_providers?name=$ENVIRON['RP_NAME']
  response_json_paths:
      $.resource_providers.`len`: 1
      $.resource_providers[0].uuid: $ENVIRON['RP_UUID']
      $.resource_providers[0].name: $ENVIRON['RP_NAME']
      $.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages

- name: list resource providers filtering by invalid uuid
  GET: /resource_providers?uuid=spameggs
  status: 400
  response_strings:
      - 'Invalid query string parameters'
  response_json_paths:
      $.errors[0].title: Bad Request

- name: list resource providers providing an invalid filter
  GET: /resource_providers?spam=eggs
  status: 400
  response_strings:
      - 'Invalid query string parameters'
  response_json_paths:
      $.errors[0].title: Bad Request

- name: list one resource provider filtering by uuid with allocations link
  GET: /resource_providers?uuid=$ENVIRON['RP_UUID']
  request_headers:
      openstack-api-version: placement 1.11
  response_json_paths:
      $.resource_providers.`len`: 1
      $.resource_providers[0].uuid: $ENVIRON['RP_UUID']
      $.resource_providers[0].name: $ENVIRON['RP_NAME']
      $.resource_providers[0].links.`len`: 6
      $.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
      $.resource_providers[0].links[?rel = "allocations"].href: /resource_providers/$ENVIRON['RP_UUID']/allocations

- name: list one resource provider filtering by uuid no allocations link
  GET: /resource_providers?uuid=$ENVIRON['RP_UUID']
  request_headers:
      openstack-api-version: placement 1.10
  response_json_paths:
      $.resource_providers.`len`: 1
      $.resource_providers[0].uuid: $ENVIRON['RP_UUID']
      $.resource_providers[0].name: $ENVIRON['RP_NAME']
      $.resource_providers[0].links.`len`: 5
      $.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
      $.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
      $.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages

- name: update a resource provider's name
  PUT: /resource_providers/$RESPONSE['$.resource_providers[0].uuid']
  request_headers:
      content-type: application/json
      openstack-api-version: placement 1.15
  data:
      name: new name
  status: 200
  response_headers:
      content-type: /application/json/
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/
  response_forbidden_headers:
      - location
  response_json_paths:
      $.generation: 0
      $.name: new name
      $.uuid: $ENVIRON['RP_UUID']
      $.links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']

- name: check the name from that update
  GET: $LAST_URL
  response_json_paths:
      $.name: new name

- name: update a provider poorly
  PUT: $LAST_URL
  request_headers:
      content-type: application/json
  data:
      badfield: new name
  status: 400
  response_strings:
      - 'JSON does not validate'
  response_json_paths:
      $.errors[0].title: Bad Request

# This section of tests validate nested resource provider relationships and
# constraints. We attempt to set the parent provider UUID for the primary
# resource provider to a UUID value of a provider we have not yet created and
# expect a failure. We then create that parent provider record and attempt to
# set the same parent provider UUID without also setting the root provider UUID
# to the same value, with an expected failure. Finally, we set the primary
# provider's root AND parent to the new provider UUID and verify success.

- name: test POST microversion limits nested providers
  POST: /resource_providers
  request_headers:
      openstack-api-version: placement 1.13
      content-type: application/json
  data:
      name: child
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'JSON does not validate'

- name: test PUT microversion limits nested providers
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      openstack-api-version: placement 1.13
      content-type: application/json
  data:
      name: child
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'JSON does not validate'

- name: fail trying to set a root provider UUID
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'JSON does not validate'

- name: fail trying to self-parent
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: child
      uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
      parent_provider_uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'parent provider UUID cannot be same as UUID'
      - 'Unable to create resource provider \"child\", $ENVIRON["ALT_PARENT_PROVIDER_UUID"]:'

- name: update a parent provider UUID to non-existing provider
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      name: parent
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'parent provider UUID does not exist'

- name: now create the parent provider
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: parent
      uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 200
  response_json_paths:
      $.uuid: $ENVIRON['PARENT_PROVIDER_UUID']
      $.name: parent
      $.parent_provider_uuid: null
      $.generation: 0

- name: get provider with old microversion no root provider UUID field
  GET: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
  request_headers:
      openstack-api-version: placement 1.13
      content-type: application/json
  response_json_paths:
      $.`len`: 4
      name: parent
  status: 200

- name: get provider has root provider UUID field
  GET: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
  request_headers:
      content-type: application/json
  response_json_paths:
      $.`len`: 6
      name: parent
      root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
      parent_provider_uuid: null
  status: 200

- name: update a parent
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      name: child
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 200

- name: get provider has new parent and root provider UUID field
  GET: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  response_json_paths:
      name: child
      root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 200

- name: fail trying to un-parent
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      name: child
      parent_provider_uuid: null
  status: 400
  response_strings:
      - 'un-parenting a provider is not currently allowed'

- name: 409 conflict while trying to delete parent with existing child
  DELETE: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
  status: 409
  response_strings:
      - "Unable to delete parent resource provider
       $ENVIRON['PARENT_PROVIDER_UUID']: It has child resource providers."
  response_json_paths:
      $.errors[0].code: placement.resource_provider.cannot_delete_parent

- name: list all resource providers in a tree that does not exist
  GET: /resource_providers?in_tree=$ENVIRON['ALT_PARENT_PROVIDER_UUID']
  response_json_paths:
      $.resource_providers.`len`: 0

- name: list all resource providers in a tree with multiple providers in tree
  GET: /resource_providers?in_tree=$ENVIRON['RP_UUID']
  response_json_paths:
      $.resource_providers.`len`: 2
      # Verify that we have both the parent and child in the list
      $.resource_providers[?uuid="$ENVIRON['PARENT_PROVIDER_UUID']"].root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
      $.resource_providers[?uuid="$ENVIRON['RP_UUID']"].root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']

- name: create a new parent provider
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: altwparent
      uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
  status: 200
  response_headers:
      location: //resource_providers/[a-f0-9-]+/
  response_json_paths:
      $.uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
      $.name: altwparent

- name: list all resource providers in a tree
  GET: /resource_providers?in_tree=$ENVIRON['ALT_PARENT_PROVIDER_UUID']
  response_json_paths:
      $.resource_providers.`len`: 1
      $.resource_providers[?uuid="$ENVIRON['ALT_PARENT_PROVIDER_UUID']"].root_provider_uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']

- name: filter providers by traits none of them have
  GET: /resource_providers?required=HW_CPU_X86_SGX,HW_CPU_X86_SHA
  response_json_paths:
      $.resource_providers.`len`: 0

- name: add traits to a provider
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    content-type: application/json
  data:
      resource_provider_generation: 0
      traits: ['HW_CPU_X86_SGX', 'STORAGE_DISK_SSD']

- name: add traits to another provider
  PUT: /resource_providers/$ENVIRON['ALT_PARENT_PROVIDER_UUID']/traits
  request_headers:
    content-type: application/json
  data:
      resource_provider_generation: 0
      traits: ['MISC_SHARES_VIA_AGGREGATE', 'STORAGE_DISK_SSD']

- name: filter providers with multiple traits where no provider has all of them
  GET: /resource_providers?required=HW_CPU_X86_SGX,MISC_SHARES_VIA_AGGREGATE
  response_json_paths:
      $.resource_providers.`len`: 0

- name: filter providers with a trait some of them have
  GET: /resource_providers?required=STORAGE_DISK_SSD
  response_json_paths:
      $.resource_providers.`len`: 2
      # Don't really care about the root UUID - just validating that the providers present are the ones we expected
      $.resource_providers[?uuid="$ENVIRON['ALT_PARENT_PROVIDER_UUID']"].root_provider_uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
      $.resource_providers[?uuid="$ENVIRON['RP_UUID']"].root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']

- name: list providers with 'required' parameter filters cumulatively with in_tree
  GET: /resource_providers?required=STORAGE_DISK_SSD&in_tree=$ENVIRON['RP_UUID']
  response_json_paths:
      $.resource_providers.`len`: 1
      # Only RP_UUID satisfies both the tree and trait constraint
      $.resource_providers[?uuid="$ENVIRON['RP_UUID']"].root_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']

- name: list providers for full count
  GET: /resource_providers
  response_json_paths:
      $.resource_providers.`len`: 3

- name: list providers forbidden 1.22
  GET: /resource_providers?required=!STORAGE_DISK_SSD
  response_json_paths:
      $.resource_providers.`len`: 1

- name: confirm forbidden trait not there
  GET: /resource_providers/$RESPONSE['$.resource_providers[0].uuid']/traits
  response_json_paths:
      $.traits: []

- name: list providers forbidden 1.21
  GET: /resource_providers?required=!STORAGE_DISK_SSD
  request_headers:
      openstack-api-version: placement 1.21
  status: 400
  response_strings:
      - "Invalid query string parameters: Expected 'required' parameter value of the form: HW_CPU_X86_VMX,CUSTOM_MAGIC. Got: !STORAGE_DISK_SSD"

- name: list providers forbidden again
  GET: /resource_providers?required=!MISC_SHARES_VIA_AGGREGATE
  response_json_paths:
      $.resource_providers.`len`: 2

- name: mixed required and forbidden
  GET: /resource_providers?required=!HW_CPU_X86_SGX,STORAGE_DISK_SSD
  response_json_paths:
      $.resource_providers.`len`: 1

- name: confirm mixed required and forbidden
  GET: /resource_providers/$RESPONSE['$.resource_providers[0].uuid']/traits
  response_json_paths:
      $.traits.`sorted`: ['MISC_SHARES_VIA_AGGREGATE', 'STORAGE_DISK_SSD']

- name: multiple forbidden
  GET: /resource_providers?required=!MISC_SHARES_VIA_AGGREGATE,!HW_CPU_X86_SGX
  response_json_paths:
      $.resource_providers.`len`: 1

- name: confirm multiple forbidden
  GET: /resource_providers/$RESPONSE['$.resource_providers[0].uuid']/traits
  response_json_paths:
      $.traits: []

- name: forbidden no apply
  GET: /resource_providers?required=!HW_CPU_X86_VMX
  response_json_paths:
      $.resource_providers.`len`: 3

- name: create some inventory
  PUT: /resource_providers/$ENVIRON['ALT_PARENT_PROVIDER_UUID']/inventories
  request_headers:
      content-type: application/json
  data:
      resource_provider_generation: 1
      inventories:
        IPV4_ADDRESS:
          total: 253
        DISK_GB:
          total: 1024
  status: 200
  response_json_paths:
      $.resource_provider_generation: 2
      $.inventories.IPV4_ADDRESS.total: 253
      $.inventories.IPV4_ADDRESS.reserved: 0
      $.inventories.DISK_GB.total: 1024
      $.inventories.DISK_GB.allocation_ratio: 1.0

- name: list providers with 'required' parameter filters cumulatively with resources
  GET: /resource_providers?required=STORAGE_DISK_SSD&resources=IPV4_ADDRESS:10
  response_json_paths:
      $.resource_providers.`len`: 1
      # Only ALT_PARENT_PROVIDER_UUID satisfies both the tree and trait constraint
      $.resource_providers[?uuid="$ENVIRON['ALT_PARENT_PROVIDER_UUID']"].root_provider_uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']

- name: invalid 'required' parameter - blank
  GET: /resource_providers?required=
  status: 400
  response_strings:
      - "Invalid query string parameters: Expected 'required' parameter value of the form: HW_CPU_X86_VMX,!CUSTOM_MAGIC."
  response_json_paths:
      $.errors[0].title: Bad Request

- name: invalid 'required' parameter 1.21
  GET: /resource_providers?required=
  request_headers:
      openstack-api-version: placement 1.21
  status: 400
  response_strings:
      - "Invalid query string parameters: Expected 'required' parameter value of the form: HW_CPU_X86_VMX,CUSTOM_MAGIC."
  response_json_paths:
      $.errors[0].title: Bad Request

- name: invalid 'required' parameter - contains an empty trait name
  GET: /resource_providers?required=STORAGE_DISK_SSD,,MISC_SHARES_VIA_AGGREGATE
  status: 400
  response_strings:
      - "Invalid query string parameters: Expected 'required' parameter value of the form: HW_CPU_X86_VMX,!CUSTOM_MAGIC."
  response_json_paths:
      $.errors[0].title: Bad Request

- name: invalid 'required' parameter - contains a nonexistent trait
  GET: /resource_providers?required=STORAGE_DISK_SSD,BOGUS_TRAIT,MISC_SHARES_VIA_AGGREGATE
  status: 400
  response_strings:
      - "No such trait(s): BOGUS_TRAIT."
  response_json_paths:
      $.errors[0].title: Bad Request

- name: schema validation fails with 'required' parameter on old microversion
  request_headers:
      openstack-api-version: placement 1.17
  GET: /resource_providers?required=HW_CPU_X86_SGX,MISC_SHARES_VIA_AGGREGATE
  status: 400
  response_strings:
      - Additional properties are not allowed
  response_json_paths:
      $.errors[0].title: Bad Request

- name: fail trying to re-parent to a different provider
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      name: child
      parent_provider_uuid: $ENVIRON['ALT_PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 're-parenting a provider is not currently allowed'

- name: create a new provider
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: cow
  status: 200

- name: try to rename that provider to existing name
  PUT: $LOCATION
  request_headers:
      content-type: application/json
  data:
      name: child
  status: 409
  response_json_paths:
      $.errors[0].title: Conflict
      $.errors[0].code: placement.duplicate_name

- name: fail to put that provider with uuid
  PUT: $LAST_URL
  request_headers:
      content-type: application/json
  data:
      name: second new name
      uuid: 7d4275fc-8b40-4995-85e2-74fcec2cb3b6
  status: 400
  response_strings:
      - Additional properties are not allowed
  response_json_paths:
      $.errors[0].title: Bad Request

- name: delete resource provider
  DELETE: $LAST_URL
  status: 204

- name: 404 on deleted provider
  DELETE: $LAST_URL
  status: 404
  response_json_paths:
      $.errors[0].title: Not Found

- name: fail to get a provider
  GET: /resource_providers/random_sauce
  status: 404
  response_json_paths:
      $.errors[0].title: Not Found

- name: delete non-existing resource provider
  DELETE: /resource_providers/d67370b5-4dc0-470d-a4fa-85e8e89abc6c
  status: 404
  response_strings:
      - No resource provider with uuid d67370b5-4dc0-470d-a4fa-85e8e89abc6c found for delete
  response_json_paths:
      $.errors[0].title: Not Found

- name: post resource provider no uuid
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: a name
  status: 200
  response_headers:
      location: //resource_providers/[a-f0-9-]+/

- name: post malformed json as json
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data: '{"foo": }'
  status: 400
  response_strings:
      - 'Malformed JSON:'
  response_json_paths:
      $.errors[0].title: Bad Request

- name: post bad uuid in resource provider
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: my bad rp
      uuid: this is not a uuid
  status: 400
  response_strings:
      - "Failed validating 'format'"
  response_json_paths:
      $.errors[0].title: Bad Request

- name: try to create resource provider with name exceed max characters
  POST: /resource_providers
  request_headers:
      content-type: application/json
  data:
      name: &name_exceeds_max_length_check This is a long text of 201 charactersssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
  status: 400
  response_strings:
      - "Failed validating 'maxLength'"
  response_json_paths:
      $.errors[0].title: Bad Request

- name: try to update resource provider with name exceed max characters
  PUT: /resource_providers/$ENVIRON['RP_UUID']
  request_headers:
      content-type: application/json
  data:
      name: *name_exceeds_max_length_check
  status: 400
  response_strings:
      - "Failed validating 'maxLength'"
  response_json_paths:
      $.errors[0].title: Bad Request

- name: confirm no cache-control headers before 1.15
  GET: /resource_providers
  request_headers:
      openstack-api-version: placement 1.14
  response_forbidden_headers:
      - cache-control
      - last-modified

- name: fail updating a parent to itself
  PUT: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
  request_headers:
      content-type: application/json
  data:
      name: parent
      parent_provider_uuid: $ENVIRON['PARENT_PROVIDER_UUID']
  status: 400
  response_strings:
      - 'creating loop in the provider tree is not allowed.'

- name: fail updating the parent to point to its child
  PUT: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
  request_headers:
      content-type: application/json
  data:
      name: parent
      parent_provider_uuid: $ENVIRON['RP_UUID']
  status: 400
  response_strings:
      - 'creating loop in the provider tree is not allowed.'

- name: create a resource provider with dashed uuid
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: rp with dashed uuid
      uuid: 2290d4af-9e6e-400b-9d65-1ee01376f71a
  status: 200
  response_headers:
      location: //resource_providers/[a-f0-9-]+/

- name: try to create with the same uuid but without dashes
  POST: /resource_providers
  request_headers:
    content-type: application/json
  data:
      name: rp with dashless uuid
      uuid: 2290d4af9e6e400b9d651ee01376f71a
  status: 409
  response_strings:
      - "Conflicting resource provider uuid: 2290d4af-9e6e-400b-9d65-1ee01376f71a already exists"
  response_json_paths:
      $.errors[0].title: Conflict