blob: 25e2dab36527614858af3c3a602abdaff2fab535 [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 Treinishf4a9b0f2013-07-26 16:58:26 -040017from tempest.openstack.common import log as logging
Joe Gordonb5e10cd2013-07-10 15:51:12 +000018from tempest.scenario import manager
Matthew Treinish2153ec02013-09-09 20:57:30 +000019from tempest.test import services
Joe Gordonb5e10cd2013-07-10 15:51:12 +000020
21
22LOG = logging.getLogger(__name__)
23
24
Joe Gordon30684ef2013-10-08 17:09:09 -070025class TestLargeOpsScenario(manager.NetworkScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000026
27 """
28 Test large operations.
29
30 This test below:
31 * Spin up multiple instances in one nova call
32 * as a regular user
33 * TODO: same thing for cinder
34
35 """
36
Sylvain Afchain92064772014-01-16 02:45:57 +010037 @classmethod
38 def setUpClass(cls):
39 cls.set_network_resources()
40 super(TestLargeOpsScenario, cls).setUpClass()
41
Joe Gordonb5e10cd2013-07-10 15:51:12 +000042 def _wait_for_server_status(self, status):
43 for server in self.servers:
44 self.status_timeout(
45 self.compute_client.servers, server.id, status)
46
47 def _wait_for_volume_status(self, status):
48 volume_id = self.volume.id
49 self.status_timeout(
50 self.volume_client.volumes, volume_id, status)
51
52 def _image_create(self, name, fmt, path, properties={}):
Masayuki Igawa259c1132013-10-31 17:48:44 +090053 name = data_utils.rand_name('%s-' % name)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000054 image_file = open(path, 'rb')
55 self.addCleanup(image_file.close)
56 params = {
57 'name': name,
58 'container_format': fmt,
59 'disk_format': fmt,
60 'is_public': 'True',
61 }
62 params.update(properties)
63 image = self.image_client.images.create(**params)
64 self.addCleanup(self.image_client.images.delete, image)
65 self.assertEqual("queued", image.status)
66 image.update(data=image_file)
67 return image.id
68
69 def glance_image_create(self):
70 aki_img_path = self.config.scenario.img_dir + "/" + \
71 self.config.scenario.aki_img_file
72 ari_img_path = self.config.scenario.img_dir + "/" + \
73 self.config.scenario.ari_img_file
74 ami_img_path = self.config.scenario.img_dir + "/" + \
75 self.config.scenario.ami_img_file
76 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
90 flavor_id = self.config.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,
Joe Gordon30684ef2013-10-08 17:09:09 -070095 min_count=self.config.scenario.large_ops_number,
96 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):
105 if self.config.scenario.large_ops_number < 1:
106 return
107 self.glance_image_create()
108 self.nova_boot()