summaryrefslogtreecommitdiff
path: root/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml
blob: caf9c2f8763d92ceddf2666b1cc5277e76d31775 (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

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: non admin forbidden non json
  GET: /resource_providers
  request_headers:
      x-auth-token: user
      accept: text/plain
  status: 403
  response_strings:
      - admin required

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

# 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

- 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'

- 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: 201

- 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: 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: 201
  response_headers:
      location: //resource_providers/[a-f0-9-]+/
  response_forbidden_headers:
      - content-type

- 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: 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: 201

- 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

- 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: 201
  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