summaryrefslogtreecommitdiff
path: root/tempest/api/compute/servers/test_multiple_create.py
blob: b464c45f5b1235e316c6ad0d1ca29b8fbd634ac0 (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
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from tempest.api.compute import base
from tempest.common import compute
from tempest.common import waiters
from tempest.lib import decorators


class MultipleCreateTestJSON(base.BaseV2ComputeTest):
    """Test creating multiple servers in one request"""
    create_default_network = True

    @decorators.idempotent_id('61e03386-89c3-449c-9bb1-a06f423fd9d1')
    def test_multiple_create(self):
        """Test creating multiple servers in one request

        Creating server with min_count=2, 2 servers will be created.
        """
        tenant_network = self.get_tenant_network()
        body, servers = compute.create_test_server(
            self.os_primary,
            wait_until='ACTIVE',
            min_count=2,
            tenant_network=tenant_network)

        for server in servers:
            self.addCleanup(waiters.wait_for_server_termination,
                            self.servers_client,
                            server['id'])

        for server in servers:
            self.addCleanup(self.servers_client.delete_server, server['id'])

        # NOTE(maurosr): do status response check and also make sure that
        # reservation_id is not in the response body when the request send
        # contains return_reservation_id=False
        self.assertNotIn('reservation_id', body)
        self.assertEqual(2, len(servers))

    @decorators.idempotent_id('864777fb-2f1e-44e3-b5b9-3eb6fa84f2f7')
    def test_multiple_create_with_reservation_return(self):
        """Test creating multiple servers with return_reservation_id=True

        Creating multiple servers with return_reservation_id=True,
        reservation_id will be returned.
        """

        body = self.create_test_server(wait_until='ACTIVE',
                                       min_count=1,
                                       max_count=2,
                                       return_reservation_id=True)
        self.assertIn('reservation_id', body)