
fixtures:
    - APIFixture

defaults:
    request_headers:
        x-auth-token: admin
        accept: application/json
        content-type: application/json
        # Using <= 1.11 allows the PUT /allocations/{uuid} below
        # to work with the older request form.
        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: create a resource class
  PUT: /resource_classes/CUSTOM_GOLD
  status: 201

- name: add inventory to an rp
  PUT: /resource_providers/$HISTORY['get resource provider'].$RESPONSE['$.uuid']/inventories
  data:
      resource_provider_generation: 0
      inventories:
          VCPU:
              total: 24
          CUSTOM_GOLD:
              total: 5
  status: 200

- name: allocate some of it two
  desc: this is the one that used to raise a 500
  PUT: /allocations/6d9f83db-6eb5-49f6-84b0-5d03c6aa9fc8
  data:
      allocations:
          - resource_provider:
                uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
            resources:
                DISK_GB: 5
                CUSTOM_GOLD: 1
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 409

- name: allocate some of it custom
  PUT: /allocations/6d9f83db-6eb5-49f6-84b0-5d03c6aa9fc8
  data:
      allocations:
          - resource_provider:
                uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
            resources:
                CUSTOM_GOLD: 1
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 204

- name: allocate some of it standard
  PUT: /allocations/6d9f83db-6eb5-49f6-84b0-5d03c6aa9fc8
  data:
      allocations:
          - resource_provider:
                uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
            resources:
                DISK_GB: 1
      project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
      user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
  status: 409
