blob: b549ecbd14d47dcf8a4a2d1f216f5dee95dc92b5 [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
Masayuki Igawabfa07602015-01-20 18:47:17 +090017from tempest_lib import exceptions as lib_exc
Joe Gordonb5e10cd2013-07-10 15:51:12 +000018
Peter Sabainifea219a2015-05-05 12:15:11 +020019from tempest.common import fixed_network
Fei Long Wangd39431f2015-05-14 11:30:48 +120020from tempest.common.utils import data_utils
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000021from tempest.common import waiters
Matthew Treinish6c072292014-01-29 19:15:52 +000022from tempest import config
Joe Gordonb5e10cd2013-07-10 15:51:12 +000023from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090024from tempest import test
Joe Gordonb5e10cd2013-07-10 15:51:12 +000025
Matthew Treinish6c072292014-01-29 19:15:52 +000026CONF = config.CONF
27
Joe Gordonb5e10cd2013-07-10 15:51:12 +000028
29LOG = logging.getLogger(__name__)
30
31
Ghanshyamaa4511e2014-09-08 10:37:50 +090032class TestLargeOpsScenario(manager.ScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000033
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000034 """Test large operations.
Joe Gordonb5e10cd2013-07-10 15:51:12 +000035
36 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070037 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000038 * as a regular user
39 * TODO: same thing for cinder
40
41 """
42
Sylvain Afchain92064772014-01-16 02:45:57 +010043 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000044 def skip_checks(cls):
45 super(TestLargeOpsScenario, cls).skip_checks()
Yair Friedc1f1e832014-09-21 12:57:32 +030046 if CONF.scenario.large_ops_number < 1:
47 raise cls.skipException("large_ops_number not set to multiple "
48 "instances")
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000049
50 @classmethod
51 def setup_credentials(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010052 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000053 super(TestLargeOpsScenario, cls).setup_credentials()
54
55 @classmethod
56 def resource_setup(cls):
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010057 super(TestLargeOpsScenario, cls).resource_setup()
Yair Fried6cad1362014-11-24 17:56:56 +020058 # list of cleanup calls to be executed in reverse order
59 cls._cleanup_resources = []
60
61 @classmethod
62 def resource_cleanup(cls):
63 while cls._cleanup_resources:
64 function, args, kwargs = cls._cleanup_resources.pop(-1)
65 try:
66 function(*args, **kwargs)
Masayuki Igawabfa07602015-01-20 18:47:17 +090067 except lib_exc.NotFound:
Yair Fried6cad1362014-11-24 17:56:56 +020068 pass
69 super(TestLargeOpsScenario, cls).resource_cleanup()
70
71 @classmethod
72 def addCleanupClass(cls, function, *arguments, **keywordArguments):
73 cls._cleanup_resources.append((function, arguments, keywordArguments))
Sylvain Afchain92064772014-01-16 02:45:57 +010074
Joe Gordonb5e10cd2013-07-10 15:51:12 +000075 def _wait_for_server_status(self, status):
76 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080077 # Make sure nova list keeps working throughout the build process
78 self.servers_client.list_servers()
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000079 waiters.wait_for_server_status(self.servers_client,
80 server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000081
Jordan Pittier1e443ec2015-11-20 16:15:58 +010082 def nova_boot(self, image):
Ken'ichi Ohmichi6ded8df2015-03-23 02:00:19 +000083 name = data_utils.rand_name('scenario-server')
Matthew Treinish6c072292014-01-29 19:15:52 +000084 flavor_id = CONF.compute.flavor_ref
Yair Fried6cad1362014-11-24 17:56:56 +020085 # Explicitly create secgroup to avoid cleanup at the end of testcases.
86 # Since no traffic is tested, we don't need to actually add rules to
87 # secgroup
John Warrenf2345512015-12-10 13:39:30 -050088 secgroup = self.compute_security_groups_client.create_security_group(
ghanshyamb610b772015-08-24 17:29:38 +090089 name='secgroup-%s' % name,
90 description='secgroup-desc-%s' % name)['security_group']
John Warrenf2345512015-12-10 13:39:30 -050091 self.addCleanupClass(
92 self.compute_security_groups_client.delete_security_group,
93 secgroup['id'])
Peter Sabainifea219a2015-05-05 12:15:11 +020094 create_kwargs = {
95 'min_count': CONF.scenario.large_ops_number,
96 'security_groups': [{'name': secgroup['name']}]
97 }
98 network = self.get_tenant_network()
99 create_kwargs = fixed_network.set_networks_kwarg(network,
100 create_kwargs)
Ghanshyamaa4511e2014-09-08 10:37:50 +0900101 self.servers_client.create_server(
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +0000102 name=name,
Jordan Pittier1e443ec2015-11-20 16:15:58 +0100103 imageRef=image,
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +0000104 flavorRef=flavor_id,
Peter Sabainifea219a2015-05-05 12:15:11 +0200105 **create_kwargs)
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000106 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +0900107 params = {'name': name}
Ken'ichi Ohmichicbc26a82015-07-03 08:18:04 +0000108 server_list = self.servers_client.list_servers(**params)
Ghanshyamaa4511e2014-09-08 10:37:50 +0900109 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -0700110 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000111 # after deleting all servers - wait for all servers to clear
112 # before cleanup continues
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000113 self.addCleanupClass(waiters.wait_for_server_termination,
114 self.servers_client,
Yair Fried6cad1362014-11-24 17:56:56 +0200115 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000116 for server in self.servers:
Yair Fried6cad1362014-11-24 17:56:56 +0200117 self.addCleanupClass(self.servers_client.delete_server,
118 server['id'])
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000119 self._wait_for_server_status('ACTIVE')
120
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700121 def _large_ops_scenario(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +0100122 image = self.glance_image_create()
123 self.nova_boot(image)
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700124
Chris Hoge7579c1a2015-02-26 14:12:15 -0800125 @test.idempotent_id('14ba0e78-2ed9-4d17-9659-a48f4756ecb3')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700126 @test.services('compute', 'image')
127 def test_large_ops_scenario_1(self):
128 self._large_ops_scenario()
129
Chris Hoge7579c1a2015-02-26 14:12:15 -0800130 @test.idempotent_id('b9b79b88-32aa-42db-8f8f-dcc8f4b4ccfe')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700131 @test.services('compute', 'image')
132 def test_large_ops_scenario_2(self):
133 self._large_ops_scenario()
134
Chris Hoge7579c1a2015-02-26 14:12:15 -0800135 @test.idempotent_id('3aab7e82-2de3-419a-9da1-9f3a070668fb')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700136 @test.services('compute', 'image')
137 def test_large_ops_scenario_3(self):
138 self._large_ops_scenario()