blob: e8030c9516b1749ab7f929f7a7daa5974799c4e8 [file] [log] [blame]
Joe Gordonb5e10cd2013-07-10 15:51:12 +00001# Copyright 2013 NEC Corporation
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
Masayuki Igawa259c1132013-10-31 17:48:44 +090016from tempest.common.utils import data_utils
Matthew Treinish6c072292014-01-29 19:15:52 +000017from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040018from tempest.openstack.common import log as logging
Joe Gordonb5e10cd2013-07-10 15:51:12 +000019from tempest.scenario import manager
Matthew Treinish2153ec02013-09-09 20:57:30 +000020from tempest.test import services
Joe Gordonb5e10cd2013-07-10 15:51:12 +000021
Matthew Treinish6c072292014-01-29 19:15:52 +000022CONF = config.CONF
23
Joe Gordonb5e10cd2013-07-10 15:51:12 +000024
25LOG = logging.getLogger(__name__)
26
27
Joe Gordon30684ef2013-10-08 17:09:09 -070028class TestLargeOpsScenario(manager.NetworkScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000029
30 """
31 Test large operations.
32
33 This test below:
34 * Spin up multiple instances in one nova call
35 * as a regular user
36 * TODO: same thing for cinder
37
38 """
39
Sylvain Afchain92064772014-01-16 02:45:57 +010040 @classmethod
41 def setUpClass(cls):
42 cls.set_network_resources()
43 super(TestLargeOpsScenario, cls).setUpClass()
44
Joe Gordonb5e10cd2013-07-10 15:51:12 +000045 def _wait_for_server_status(self, status):
46 for server in self.servers:
47 self.status_timeout(
48 self.compute_client.servers, server.id, status)
49
50 def _wait_for_volume_status(self, status):
51 volume_id = self.volume.id
52 self.status_timeout(
53 self.volume_client.volumes, volume_id, status)
54
55 def _image_create(self, name, fmt, path, properties={}):
Masayuki Igawa259c1132013-10-31 17:48:44 +090056 name = data_utils.rand_name('%s-' % name)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000057 image_file = open(path, 'rb')
58 self.addCleanup(image_file.close)
59 params = {
60 'name': name,
61 'container_format': fmt,
62 'disk_format': fmt,
63 'is_public': 'True',
64 }
65 params.update(properties)
66 image = self.image_client.images.create(**params)
67 self.addCleanup(self.image_client.images.delete, image)
68 self.assertEqual("queued", image.status)
69 image.update(data=image_file)
70 return image.id
71
72 def glance_image_create(self):
Matthew Treinish6c072292014-01-29 19:15:52 +000073 aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
74 ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
75 ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
Joe Gordonb5e10cd2013-07-10 15:51:12 +000076 LOG.debug("paths: ami: %s, ari: %s, aki: %s"
77 % (ami_img_path, ari_img_path, aki_img_path))
78 kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
79 ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
80 properties = {
81 'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
82 }
83 self.image = self._image_create('scenario-ami', 'ami',
84 path=ami_img_path,
85 properties=properties)
86
87 def nova_boot(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090088 name = data_utils.rand_name('scenario-server-')
Joe Gordonb5e10cd2013-07-10 15:51:12 +000089 client = self.compute_client
Matthew Treinish6c072292014-01-29 19:15:52 +000090 flavor_id = CONF.compute.flavor_ref
Yair Friedeb69f3f2013-10-10 13:18:16 +030091 secgroup = self._create_security_group_nova()
Joe Gordonb5e10cd2013-07-10 15:51:12 +000092 self.servers = client.servers.create(
93 name=name, image=self.image,
94 flavor=flavor_id,
Matthew Treinish6c072292014-01-29 19:15:52 +000095 min_count=CONF.scenario.large_ops_number,
Joe Gordon30684ef2013-10-08 17:09:09 -070096 security_groups=[secgroup.name])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000097 # needed because of bug 1199788
98 self.servers = [x for x in client.servers.list() if name in x.name]
Joe Gordona3219652013-10-09 15:23:11 -070099 for server in self.servers:
100 self.set_resource(server.name, server)
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000101 self._wait_for_server_status('ACTIVE')
102
Matthew Treinish2153ec02013-09-09 20:57:30 +0000103 @services('compute', 'image')
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000104 def test_large_ops_scenario(self):
Matthew Treinish6c072292014-01-29 19:15:52 +0000105 if CONF.scenario.large_ops_number < 1:
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000106 return
107 self.glance_image_create()
108 self.nova_boot()