blob: 0789c21415fbe0e9a88907dc536d40fe471a76df [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.
Matthew Treinish01472ff2015-02-20 17:26:52 -050015
Doug Hellmann583ce2c2015-03-11 14:55:46 +000016from oslo_log import log as logging
Matthew Treinish01472ff2015-02-20 17:26:52 -050017from tempest_lib.common.utils import data_utils
Masayuki Igawabfa07602015-01-20 18:47:17 +090018from tempest_lib import exceptions as lib_exc
Joe Gordonb5e10cd2013-07-10 15:51:12 +000019
Matthew Treinish6c072292014-01-29 19:15:52 +000020from tempest import config
Joe Gordonb5e10cd2013-07-10 15:51:12 +000021from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090022from tempest import test
Joe Gordonb5e10cd2013-07-10 15:51:12 +000023
Matthew Treinish6c072292014-01-29 19:15:52 +000024CONF = config.CONF
25
Joe Gordonb5e10cd2013-07-10 15:51:12 +000026
27LOG = logging.getLogger(__name__)
28
29
Ghanshyamaa4511e2014-09-08 10:37:50 +090030class TestLargeOpsScenario(manager.ScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000031
32 """
33 Test large operations.
34
35 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070036 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000037 * as a regular user
38 * TODO: same thing for cinder
39
40 """
41
Sylvain Afchain92064772014-01-16 02:45:57 +010042 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000043 def skip_checks(cls):
44 super(TestLargeOpsScenario, cls).skip_checks()
Yair Friedc1f1e832014-09-21 12:57:32 +030045 if CONF.scenario.large_ops_number < 1:
46 raise cls.skipException("large_ops_number not set to multiple "
47 "instances")
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000048
49 @classmethod
50 def setup_credentials(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010051 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000052 super(TestLargeOpsScenario, cls).setup_credentials()
53
54 @classmethod
55 def resource_setup(cls):
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010056 super(TestLargeOpsScenario, cls).resource_setup()
Yair Fried6cad1362014-11-24 17:56:56 +020057 # list of cleanup calls to be executed in reverse order
58 cls._cleanup_resources = []
59
60 @classmethod
61 def resource_cleanup(cls):
62 while cls._cleanup_resources:
63 function, args, kwargs = cls._cleanup_resources.pop(-1)
64 try:
65 function(*args, **kwargs)
Masayuki Igawabfa07602015-01-20 18:47:17 +090066 except lib_exc.NotFound:
Yair Fried6cad1362014-11-24 17:56:56 +020067 pass
68 super(TestLargeOpsScenario, cls).resource_cleanup()
69
70 @classmethod
71 def addCleanupClass(cls, function, *arguments, **keywordArguments):
72 cls._cleanup_resources.append((function, arguments, keywordArguments))
Sylvain Afchain92064772014-01-16 02:45:57 +010073
Joe Gordonb5e10cd2013-07-10 15:51:12 +000074 def _wait_for_server_status(self, status):
75 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080076 # Make sure nova list keeps working throughout the build process
77 self.servers_client.list_servers()
Ghanshyamaa4511e2014-09-08 10:37:50 +090078 self.servers_client.wait_for_server_status(server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000079
Joe Gordonb5e10cd2013-07-10 15:51:12 +000080 def nova_boot(self):
Ken'ichi Ohmichi6ded8df2015-03-23 02:00:19 +000081 name = data_utils.rand_name('scenario-server')
Matthew Treinish6c072292014-01-29 19:15:52 +000082 flavor_id = CONF.compute.flavor_ref
Yair Fried6cad1362014-11-24 17:56:56 +020083 # Explicitly create secgroup to avoid cleanup at the end of testcases.
84 # Since no traffic is tested, we don't need to actually add rules to
85 # secgroup
David Kranz9964b4e2015-02-06 15:45:29 -050086 secgroup = self.security_groups_client.create_security_group(
Yair Fried6cad1362014-11-24 17:56:56 +020087 'secgroup-%s' % name, 'secgroup-desc-%s' % name)
88 self.addCleanupClass(self.security_groups_client.delete_security_group,
89 secgroup['id'])
90
Ghanshyamaa4511e2014-09-08 10:37:50 +090091 self.servers_client.create_server(
92 name,
93 self.image,
94 flavor_id,
Matthew Treinish6c072292014-01-29 19:15:52 +000095 min_count=CONF.scenario.large_ops_number,
Ken'ichi Ohmichi1b3461e2014-12-02 03:41:07 +000096 security_groups=[{'name': secgroup['name']}])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000097 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +090098 params = {'name': name}
David Kranzae99b9a2015-02-16 13:37:01 -050099 server_list = self.servers_client.list_servers(params)
Ghanshyamaa4511e2014-09-08 10:37:50 +0900100 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -0700101 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000102 # after deleting all servers - wait for all servers to clear
103 # before cleanup continues
Yair Fried6cad1362014-11-24 17:56:56 +0200104 self.addCleanupClass(self.servers_client.
105 wait_for_server_termination,
106 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000107 for server in self.servers:
Yair Fried6cad1362014-11-24 17:56:56 +0200108 self.addCleanupClass(self.servers_client.delete_server,
109 server['id'])
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000110 self._wait_for_server_status('ACTIVE')
111
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700112 def _large_ops_scenario(self):
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000113 self.glance_image_create()
114 self.nova_boot()
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700115
Chris Hoge7579c1a2015-02-26 14:12:15 -0800116 @test.idempotent_id('14ba0e78-2ed9-4d17-9659-a48f4756ecb3')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700117 @test.services('compute', 'image')
118 def test_large_ops_scenario_1(self):
119 self._large_ops_scenario()
120
Chris Hoge7579c1a2015-02-26 14:12:15 -0800121 @test.idempotent_id('b9b79b88-32aa-42db-8f8f-dcc8f4b4ccfe')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700122 @test.services('compute', 'image')
123 def test_large_ops_scenario_2(self):
124 self._large_ops_scenario()
125
Chris Hoge7579c1a2015-02-26 14:12:15 -0800126 @test.idempotent_id('3aab7e82-2de3-419a-9da1-9f3a070668fb')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700127 @test.services('compute', 'image')
128 def test_large_ops_scenario_3(self):
129 self._large_ops_scenario()