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

fixtures:
    - APIFixture

defaults:
    request_headers:
        x-auth-token: admin
        # traits introduced in 1.6
        openstack-api-version: placement 1.6

tests:

- name: create a trait without custom namespace
  PUT: /traits/TRAIT_X
  status: 400
  response_strings:
    - 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'

- name: create a trait with invalid characters
  PUT: /traits/CUSTOM_ABC:1
  status: 400
  response_strings:
    - 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'

- name: create a trait with name exceed max characters
  PUT: /traits/CUSTOM_ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO
  status: 400
  response_strings:
    - 'The trait is invalid. A valid trait must be no longer than 255 characters, start with the prefix \"CUSTOM_\" and use following characters: \"A\"-\"Z\", \"0\"-\"9\" and \"_\"'

- name: create a trait
  PUT: /traits/CUSTOM_TRAIT_1
  status: 201
  response_headers:
    location: //traits/CUSTOM_TRAIT_1/
  response_forbidden_headers:
    - content-type
    # PUT in 1.6 version should not have cache headers
    - cache-control
    - last-modified

- name: create a trait which existed
  PUT: /traits/CUSTOM_TRAIT_1
  status: 204
  response_headers:
    location: //traits/CUSTOM_TRAIT_1/
  response_forbidden_headers:
    - content-type

- name: get a trait
  GET: /traits/CUSTOM_TRAIT_1
  status: 204
  response_forbidden_headers:
      - content-type
      # In early versions cache headers should not be present
      - cache-control
      - last-modified

- name: get a non-existed trait
  GET: /traits/NON_EXISTED
  status: 404

- name: delete a trait
  DELETE: /traits/CUSTOM_TRAIT_1
  status: 204
  response_forbidden_headers:
    - content-type
    # DELETE in any version should not have cache headers
    - cache-control
    - last-modified

- name: delete a non-existed trait
  DELETE: /traits/CUSTOM_NON_EXSITED
  status: 404

- name: try to delete standard trait
  DELETE: /traits/HW_CPU_X86_SSE
  status: 400
  response_strings:
      - Cannot delete standard trait

- name: create CUSTOM_TRAIT_1
  PUT: /traits/CUSTOM_TRAIT_1
  status: 201
  response_headers:
    location: //traits/CUSTOM_TRAIT_1/
  response_forbidden_headers:
    - content-type

- name: create CUSTOM_TRAIT_2
  PUT: /traits/CUSTOM_TRAIT_2
  status: 201
  response_headers:
    location: //traits/CUSTOM_TRAIT_2/
  response_forbidden_headers:
    - content-type

# NOTE(cdent): This simply tests that traits we know should be
# present are in the results. We can't check length here because
# the standard traits, which will grow over time, are present.
- name: list traits
  GET: /traits
  status: 200
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2
    - MISC_SHARES_VIA_AGGREGATE
    - HW_CPU_X86_SHA

- name: list traits with invalid format of name parameter
  GET: /traits?name=in_abc
  status: 400
  response_strings:
    - 'Badly formatted name parameter. Expected name query string parameter in form: ?name=[in|startswith]:[name1,name2|prefix]. Got: \"in_abc\"'

- name: list traits with name=in filter
  GET: /traits?name=in:CUSTOM_TRAIT_1,CUSTOM_TRAIT_2
  status: 200
  response_json_paths:
    $.traits.`len`: 2
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2

- name: create CUSTOM_ANOTHER_TRAIT
  PUT: /traits/CUSTOM_ANOTHER_TRAIT
  status: 201
  response_headers:
    location: //traits/CUSTOM_ANOTHER_TRAIT/
  response_forbidden_headers:
    - content-type

- name: list traits with prefix
  GET: /traits?name=startswith:CUSTOM_TRAIT
  status: 200
  response_json_paths:
    $.traits.`len`: 2
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2

- name: list traits with invalid parameters
  GET: /traits?invalid=abc
  status: 400
  response_strings:
    - "Invalid query string parameters: Additional properties are not allowed"

- name: list traits 1.14 no cache headers
  GET: /traits
  request_headers:
      openstack-api-version: placement 1.14
  response_forbidden_headers:
    - cache-control
    - last-modified

- name: list traits 1.15 has cache headers
  GET: /traits
  request_headers:
      openstack-api-version: placement 1.15
  response_headers:
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: get trait 1.14 no cache headers
  GET: /traits/CUSTOM_TRAIT_1
  request_headers:
      openstack-api-version: placement 1.14
  status: 204
  response_forbidden_headers:
    - cache-control
    - last-modified

- name: get trait 1.15 has cache headers
  GET: /traits/CUSTOM_TRAIT_1
  request_headers:
      openstack-api-version: placement 1.15
  status: 204
  response_headers:
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: put trait 1.14 no cache headers
  PUT: /traits/CUSTOM_TRAIT_1
  request_headers:
      openstack-api-version: placement 1.14
  status: 204
  response_forbidden_headers:
    - cache-control
    - last-modified

- name: put trait 1.15 has cache headers
  PUT: /traits/CUSTOM_TRAIT_1
  request_headers:
      openstack-api-version: placement 1.15
  status: 204
  response_headers:
      cache-control: no-cache
      # Does last-modified look like a legit timestamp?
      last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- 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

- name: list traits for resource provider without traits
  GET: /resource_providers/$ENVIRON['RP_UUID']/traits
  status: 200
  response_json_paths:
    $.resource_provider_generation: 0
    $.traits.`len`: 0
  response_forbidden_headers:
    # In 1.6 no cache headers
    - cache-control
    - last-modified

- name: set traits for resource provider
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    content-type: application/json
  status: 200
  data:
    traits:
        - CUSTOM_TRAIT_1
        - CUSTOM_TRAIT_2
    resource_provider_generation: 0
  response_json_paths:
    $.resource_provider_generation: 1
    $.traits.`len`: 2
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2
  response_forbidden_headers:
    # In 1.6 no cache headers
    - cache-control
    - last-modified

- name: get associated traits
  GET: /traits?associated=true
  status: 200
  response_json_paths:
    $.traits.`len`: 2
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2

- name: get associated traits with invalid value
  GET: /traits?associated=xyz
  status: 400
  response_strings:
    - 'The query parameter \"associated\" only accepts \"true\" or \"false\"'

- name: set traits for resource provider without resource provider generation
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    content-type: application/json
  status: 400
  data:
    traits:
        - CUSTOM_TRAIT_1
        - CUSTOM_TRAIT_2
  response_strings:
    - CUSTOM_TRAIT_1

- name: set traits for resource provider with conflict generation
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    content-type: application/json
  status: 409
  data:
    traits:
        - CUSTOM_TRAIT_1
    resource_provider_generation: 5
  response_strings:
    - Resource provider's generation already changed. Please update the generation and try again.

- name: set non existed traits for resource provider
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    content-type: application/json
  status: 400
  data:
    traits:
      - NON_EXISTED_TRAIT1
      - NON_EXISTED_TRAIT2
      - CUSTOM_TRAIT_1
    resource_provider_generation: 1
  response_strings:
    - No such trait
    - NON_EXISTED_TRAIT1
    - NON_EXISTED_TRAIT2

- name: set traits for non_existed resource provider
  PUT: /resource_providers/non_existed/traits
  request_headers:
    content-type: application/json
  data:
    traits:
      - CUSTOM_TRAIT_1
    resource_provider_generation: 1
  status: 404
  response_strings:
    - No resource provider with uuid non_existed found

- name: list traits for resource provider
  GET: /resource_providers/$ENVIRON['RP_UUID']/traits
  status: 200
  response_json_paths:
    $.resource_provider_generation: 1
    $.traits.`len`: 2
  response_strings:
    - CUSTOM_TRAIT_1
    - CUSTOM_TRAIT_2

- name: delete an in-use trait
  DELETE: /traits/CUSTOM_TRAIT_1
  status: 409
  response_strings:
    - The trait CUSTOM_TRAIT_1 is in use by a resource provider.

- name: list traits for non_existed resource provider
  GET: /resource_providers/non_existed/traits
  request_headers:
    content-type: application/json
  status: 404
  response_strings:
    - No resource provider with uuid non_existed found

- name: delete traits for resource provider
  DELETE: /resource_providers/$ENVIRON['RP_UUID']/traits
  status: 204
  response_forbidden_headers:
     - content-type

- name: delete traits for non_existed resource provider
  DELETE: /resource_providers/non_existed/traits
  status: 404
  response_strings:
    - No resource provider with uuid non_existed found

- name: empty traits for resource provider 1.15 has cache headers
  GET: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    openstack-api-version: placement 1.15
  response_headers:
    cache-control: no-cache
    # Does last-modified look like a legit timestamp?
    last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: update rp trait 1.14 no cache headers
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  data:
    traits:
        - CUSTOM_TRAIT_1
        - CUSTOM_TRAIT_2
    resource_provider_generation: 2
  request_headers:
    openstack-api-version: placement 1.14
    content-type: application/json
  response_forbidden_headers:
    - cache-control
    - last-modified

- name: update rp trait 1.15 has cache headers
  PUT: /resource_providers/$ENVIRON['RP_UUID']/traits
  data:
    traits:
        - CUSTOM_TRAIT_1
        - CUSTOM_TRAIT_2
    resource_provider_generation: 3
  request_headers:
    openstack-api-version: placement 1.15
    content-type: application/json
  response_headers:
    cache-control: no-cache
    # Does last-modified look like a legit timestamp?
    last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/

- name: list traits for resource provider 1.14 no cache headers
  GET: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    openstack-api-version: placement 1.14
  response_forbidden_headers:
    - cache-control
    - last-modified

- name: list traits for resource provider 1.15 has cache headers
  GET: /resource_providers/$ENVIRON['RP_UUID']/traits
  request_headers:
    openstack-api-version: placement 1.15
  response_headers:
    cache-control: no-cache
    # Does last-modified look like a legit timestamp?
    last-modified:  /^\w+, \d+ \w+ \d{4} [\d:]+ GMT$/