blob: 9ed831cf20757c3477ed8896c30c8ed817b384eb [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
Peter Sabainifea219a2015-05-05 12:15:11 +020016from tempest.common import fixed_network
Fei Long Wangd39431f2015-05-14 11:30:48 +120017from tempest.common.utils import data_utils
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000018from tempest.common import waiters
Matthew Treinish6c072292014-01-29 19:15:52 +000019from tempest import config
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050020from tempest.lib import exceptions as lib_exc
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
Ghanshyamaa4511e2014-09-08 10:37:50 +090027class TestLargeOpsScenario(manager.ScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000028
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000029 """Test large operations.
Joe Gordonb5e10cd2013-07-10 15:51:12 +000030
31 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070032 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000033 * as a regular user
34 * TODO: same thing for cinder
35
36 """
37
Sylvain Afchain92064772014-01-16 02:45:57 +010038 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000039 def skip_checks(cls):
40 super(TestLargeOpsScenario, cls).skip_checks()
Yair Friedc1f1e832014-09-21 12:57:32 +030041 if CONF.scenario.large_ops_number < 1:
42 raise cls.skipException("large_ops_number not set to multiple "
43 "instances")
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000044
45 @classmethod
46 def setup_credentials(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010047 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000048 super(TestLargeOpsScenario, cls).setup_credentials()
49
50 @classmethod
51 def resource_setup(cls):
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010052 super(TestLargeOpsScenario, cls).resource_setup()
Yair Fried6cad1362014-11-24 17:56:56 +020053 # list of cleanup calls to be executed in reverse order
54 cls._cleanup_resources = []
55
56 @classmethod
57 def resource_cleanup(cls):
58 while cls._cleanup_resources:
59 function, args, kwargs = cls._cleanup_resources.pop(-1)
60 try:
61 function(*args, **kwargs)
Masayuki Igawabfa07602015-01-20 18:47:17 +090062 except lib_exc.NotFound:
Yair Fried6cad1362014-11-24 17:56:56 +020063 pass
64 super(TestLargeOpsScenario, cls).resource_cleanup()
65
66 @classmethod
67 def addCleanupClass(cls, function, *arguments, **keywordArguments):
68 cls._cleanup_resources.append((function, arguments, keywordArguments))
Sylvain Afchain92064772014-01-16 02:45:57 +010069
Joe Gordonb5e10cd2013-07-10 15:51:12 +000070 def _wait_for_server_status(self, status):
71 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080072 # Make sure nova list keeps working throughout the build process
73 self.servers_client.list_servers()
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000074 waiters.wait_for_server_status(self.servers_client,
75 server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000076
Jordan Pittier1e443ec2015-11-20 16:15:58 +010077 def nova_boot(self, image):
Ken'ichi Ohmichi6ded8df2015-03-23 02:00:19 +000078 name = data_utils.rand_name('scenario-server')
Matthew Treinish6c072292014-01-29 19:15:52 +000079 flavor_id = CONF.compute.flavor_ref
Yair Fried6cad1362014-11-24 17:56:56 +020080 # Explicitly create secgroup to avoid cleanup at the end of testcases.
81 # Since no traffic is tested, we don't need to actually add rules to
82 # secgroup
John Warrenf2345512015-12-10 13:39:30 -050083 secgroup = self.compute_security_groups_client.create_security_group(
ghanshyamb610b772015-08-24 17:29:38 +090084 name='secgroup-%s' % name,
85 description='secgroup-desc-%s' % name)['security_group']
John Warrenf2345512015-12-10 13:39:30 -050086 self.addCleanupClass(
87 self.compute_security_groups_client.delete_security_group,
88 secgroup['id'])
Peter Sabainifea219a2015-05-05 12:15:11 +020089 create_kwargs = {
90 'min_count': CONF.scenario.large_ops_number,
91 'security_groups': [{'name': secgroup['name']}]
92 }
93 network = self.get_tenant_network()
94 create_kwargs = fixed_network.set_networks_kwarg(network,
95 create_kwargs)
Ghanshyamaa4511e2014-09-08 10:37:50 +090096 self.servers_client.create_server(
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +000097 name=name,
Jordan Pittier1e443ec2015-11-20 16:15:58 +010098 imageRef=image,
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +000099 flavorRef=flavor_id,
Peter Sabainifea219a2015-05-05 12:15:11 +0200100 **create_kwargs)
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000101 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +0900102 params = {'name': name}
Ken'ichi Ohmichicbc26a82015-07-03 08:18:04 +0000103 server_list = self.servers_client.list_servers(**params)
Ghanshyamaa4511e2014-09-08 10:37:50 +0900104 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -0700105 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000106 # after deleting all servers - wait for all servers to clear
107 # before cleanup continues
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000108 self.addCleanupClass(waiters.wait_for_server_termination,
109 self.servers_client,
Yair Fried6cad1362014-11-24 17:56:56 +0200110 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000111 for server in self.servers:
Yair Fried6cad1362014-11-24 17:56:56 +0200112 self.addCleanupClass(self.servers_client.delete_server,
113 server['id'])
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000114 self._wait_for_server_status('ACTIVE')
115
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700116 def _large_ops_scenario(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +0100117 image = self.glance_image_create()
118 self.nova_boot(image)
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700119
Chris Hoge7579c1a2015-02-26 14:12:15 -0800120 @test.idempotent_id('14ba0e78-2ed9-4d17-9659-a48f4756ecb3')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700121 @test.services('compute', 'image')
122 def test_large_ops_scenario_1(self):
123 self._large_ops_scenario()
124
Chris Hoge7579c1a2015-02-26 14:12:15 -0800125 @test.idempotent_id('b9b79b88-32aa-42db-8f8f-dcc8f4b4ccfe')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700126 @test.services('compute', 'image')
127 def test_large_ops_scenario_2(self):
128 self._large_ops_scenario()
129
Chris Hoge7579c1a2015-02-26 14:12:15 -0800130 @test.idempotent_id('3aab7e82-2de3-419a-9da1-9f3a070668fb')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700131 @test.services('compute', 'image')
132 def test_large_ops_scenario_3(self):
133 self._large_ops_scenario()