blob: 63dd4f070e9cd8bc58576bfe2f3c99a551752c5e [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
34 """
35 Test large operations.
36
37 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070038 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000039 * as a regular user
40 * TODO: same thing for cinder
41
42 """
43
Sylvain Afchain92064772014-01-16 02:45:57 +010044 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000045 def skip_checks(cls):
46 super(TestLargeOpsScenario, cls).skip_checks()
Yair Friedc1f1e832014-09-21 12:57:32 +030047 if CONF.scenario.large_ops_number < 1:
48 raise cls.skipException("large_ops_number not set to multiple "
49 "instances")
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000050
51 @classmethod
52 def setup_credentials(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010053 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000054 super(TestLargeOpsScenario, cls).setup_credentials()
55
56 @classmethod
57 def resource_setup(cls):
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010058 super(TestLargeOpsScenario, cls).resource_setup()
Yair Fried6cad1362014-11-24 17:56:56 +020059 # list of cleanup calls to be executed in reverse order
60 cls._cleanup_resources = []
61
62 @classmethod
63 def resource_cleanup(cls):
64 while cls._cleanup_resources:
65 function, args, kwargs = cls._cleanup_resources.pop(-1)
66 try:
67 function(*args, **kwargs)
Masayuki Igawabfa07602015-01-20 18:47:17 +090068 except lib_exc.NotFound:
Yair Fried6cad1362014-11-24 17:56:56 +020069 pass
70 super(TestLargeOpsScenario, cls).resource_cleanup()
71
72 @classmethod
73 def addCleanupClass(cls, function, *arguments, **keywordArguments):
74 cls._cleanup_resources.append((function, arguments, keywordArguments))
Sylvain Afchain92064772014-01-16 02:45:57 +010075
Joe Gordonb5e10cd2013-07-10 15:51:12 +000076 def _wait_for_server_status(self, status):
77 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080078 # Make sure nova list keeps working throughout the build process
79 self.servers_client.list_servers()
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000080 waiters.wait_for_server_status(self.servers_client,
81 server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000082
Joe Gordonb5e10cd2013-07-10 15:51:12 +000083 def nova_boot(self):
Ken'ichi Ohmichi6ded8df2015-03-23 02:00:19 +000084 name = data_utils.rand_name('scenario-server')
Matthew Treinish6c072292014-01-29 19:15:52 +000085 flavor_id = CONF.compute.flavor_ref
Yair Fried6cad1362014-11-24 17:56:56 +020086 # Explicitly create secgroup to avoid cleanup at the end of testcases.
87 # Since no traffic is tested, we don't need to actually add rules to
88 # secgroup
David Kranz9964b4e2015-02-06 15:45:29 -050089 secgroup = self.security_groups_client.create_security_group(
ghanshyamb610b772015-08-24 17:29:38 +090090 name='secgroup-%s' % name,
91 description='secgroup-desc-%s' % name)['security_group']
Yair Fried6cad1362014-11-24 17:56:56 +020092 self.addCleanupClass(self.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,
103 imageRef=self.image,
104 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):
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000122 self.glance_image_create()
123 self.nova_boot()
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()