summaryrefslogtreecommitdiff
path: root/nova/tests/functional/api/openstack/placement/gabbits/allocations-bug-1714072.yaml
blob: fa25935b6f435a2a7b5137cba9840b89be6a578d (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
# Bug 1714072 describes a situation where a resource provider is present in the
# body of an allocation, but the resources object is empty. There should be at
# least one resource class and value pair. If there is not a 400 response
# should be returned.

fixtures:
    - APIFixture

defaults:
    request_headers:
        x-auth-token: admin
        accept: application/json
        content-type: application/json
        # Default to <= 1.11 so the PUT /allocations in here that use the
        # older list-ish format continue to work.
        openstack-api-version: placement 1.11

tests:

- name: create a resource provider
  POST: /resource_providers
  data:
      name: an rp
  status: 201

- name: get resource provider
  GET: $LOCATION
  status: 200

- name: add inventory to an rp
  PUT: $RESPONSE['$.links[?rel = "inventories"].href']
  data:
      resource_provider_generation: 0
      inventories:
          VCPU:
              total: 24
          MEMORY_MB:
              total: 1024
  status: 200

- name: put a successful allocation
  PUT: /allocations/c9f0186b-64f8-44fb-b6c9-83008d8d6940
  data:
      allocations:
          - resource_provider:
                uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
            resources:
                VCPU: 1
                MEMORY_MB: 1
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 204

- name: fail with empty resources
  PUT: /allocations/c9f0186b-64f8-44fb-b6c9-83008d8d6940
  data:
      allocations:
          - resource_provider:
                uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
            resources: {}
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 400
  response_strings:
      - does not have enough properties

# The next two tests confirm that the bug identified by
# this file's name is not present in the PUT /allocations/{consumer_uuid}
# format added by microversion 1.12.

- name: put a successful dictish allocation
  PUT: /allocations/c9f0186b-64f8-44fb-b6c9-83008d8d6940
  request_headers:
      openstack-api-version: placement 1.12
  data:
      allocations:
          $HISTORY['get resource provider'].$RESPONSE['$.uuid']:
              resources:
                VCPU: 1
                MEMORY_MB: 1
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 204

- name: fail with empty resources dictish
  PUT: /allocations/c9f0186b-64f8-44fb-b6c9-83008d8d6940
  request_headers:
      openstack-api-version: placement 1.12
  data:
      allocations:
          $HISTORY['get resource provider'].$RESPONSE['$.uuid']:
              resources: {}
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 400
  response_strings:
      - does not have enough properties