blob: 3449aba2b95b9602db69788bb1acbe7961d10f34 [file] [log] [blame]
Ken'ichi Ohmichi3cf16272017-04-25 11:49:18 -07001# Copyright 2012 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import testtools
17
18from tempest.api.compute import base
19from tempest.common.utils.linux import remote_client
20from tempest import config
21from tempest.lib.common.utils import data_utils
22from tempest.lib import decorators
23
24CONF = config.CONF
25
26
27class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
28 disk_config = 'AUTO'
29
30 @classmethod
31 def setup_credentials(cls):
32 cls.prepare_instance_network()
33 super(ServersWithSpecificFlavorTestJSON, cls).setup_credentials()
34
35 @classmethod
36 def setup_clients(cls):
37 super(ServersWithSpecificFlavorTestJSON, cls).setup_clients()
38 cls.client = cls.servers_client
39
40 @classmethod
41 def resource_setup(cls):
42 cls.set_validation_resources()
43
44 super(ServersWithSpecificFlavorTestJSON, cls).resource_setup()
45
46 @decorators.idempotent_id('b3c7bcfc-bb5b-4e22-b517-c7f686b802ca')
47 @testtools.skipUnless(CONF.validation.run_validation,
48 'Instance validation tests are disabled.')
49 def test_verify_created_server_ephemeral_disk(self):
50 # Verify that the ephemeral disk is created when creating server
51 flavor_base = self.flavors_client.show_flavor(
52 self.flavor_ref)['flavor']
53
54 def create_flavor_with_ephemeral(ephem_disk):
55 name = 'flavor_with_ephemeral_%s' % ephem_disk
56 flavor_name = data_utils.rand_name(name)
57
58 ram = flavor_base['ram']
59 vcpus = flavor_base['vcpus']
60 disk = flavor_base['disk']
61
62 # Create a flavor with ephemeral disk
63 flavor = self.create_flavor(name=flavor_name, ram=ram, vcpus=vcpus,
64 disk=disk, ephemeral=ephem_disk)
65 return flavor['id']
66
67 flavor_with_eph_disk_id = create_flavor_with_ephemeral(ephem_disk=1)
68 flavor_no_eph_disk_id = create_flavor_with_ephemeral(ephem_disk=0)
69
70 admin_pass = self.image_ssh_password
71
72 server_no_eph_disk = self.create_test_server(
73 validatable=True,
74 wait_until='ACTIVE',
75 adminPass=admin_pass,
76 flavor=flavor_no_eph_disk_id)
77
78 # Get partition number of server without ephemeral disk.
79 server_no_eph_disk = self.client.show_server(
80 server_no_eph_disk['id'])['server']
81 linux_client = remote_client.RemoteClient(
82 self.get_server_ip(server_no_eph_disk),
83 self.ssh_user,
84 admin_pass,
85 self.validation_resources['keypair']['private_key'],
86 server=server_no_eph_disk,
87 servers_client=self.client)
88 disks_num = len(linux_client.get_disks().split('\n'))
89
90 # Explicit server deletion necessary for Juno compatibility
91 self.client.delete_server(server_no_eph_disk['id'])
92
93 server_with_eph_disk = self.create_test_server(
94 validatable=True,
95 wait_until='ACTIVE',
96 adminPass=admin_pass,
97 flavor=flavor_with_eph_disk_id)
98
99 server_with_eph_disk = self.client.show_server(
100 server_with_eph_disk['id'])['server']
101 linux_client = remote_client.RemoteClient(
102 self.get_server_ip(server_with_eph_disk),
103 self.ssh_user,
104 admin_pass,
105 self.validation_resources['keypair']['private_key'],
106 server=server_with_eph_disk,
107 servers_client=self.client)
108 disks_num_eph = len(linux_client.get_disks().split('\n'))
109 self.assertEqual(disks_num + 1, disks_num_eph)