blob: 402077f3a28f0b7c407d0eecb1b28bfaba853226 [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
Masayuki Igawabfa07602015-01-20 18:47:17 +090016from tempest_lib import exceptions as lib_exc
Joe Gordonb5e10cd2013-07-10 15:51:12 +000017
Peter Sabainifea219a2015-05-05 12:15:11 +020018from tempest.common import fixed_network
Fei Long Wangd39431f2015-05-14 11:30:48 +120019from tempest.common.utils import data_utils
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000020from tempest.common import waiters
Matthew Treinish6c072292014-01-29 19:15:52 +000021from tempest import config
Joe Gordonb5e10cd2013-07-10 15:51:12 +000022from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090023from tempest import test
Joe Gordonb5e10cd2013-07-10 15:51:12 +000024
Matthew Treinish6c072292014-01-29 19:15:52 +000025CONF = config.CONF
26
Joe Gordonb5e10cd2013-07-10 15:51:12 +000027
Ghanshyamaa4511e2014-09-08 10:37:50 +090028class TestLargeOpsScenario(manager.ScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000029
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000030 """Test large operations.
Joe Gordonb5e10cd2013-07-10 15:51:12 +000031
32 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070033 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000034 * as a regular user
35 * TODO: same thing for cinder
36
37 """
38
Sylvain Afchain92064772014-01-16 02:45:57 +010039 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000040 def skip_checks(cls):
41 super(TestLargeOpsScenario, cls).skip_checks()
Yair Friedc1f1e832014-09-21 12:57:32 +030042 if CONF.scenario.large_ops_number < 1:
43 raise cls.skipException("large_ops_number not set to multiple "
44 "instances")
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000045
46 @classmethod
47 def setup_credentials(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010048 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000049 super(TestLargeOpsScenario, cls).setup_credentials()
50
51 @classmethod
52 def resource_setup(cls):
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010053 super(TestLargeOpsScenario, cls).resource_setup()
Yair Fried6cad1362014-11-24 17:56:56 +020054 # list of cleanup calls to be executed in reverse order
55 cls._cleanup_resources = []
56
57 @classmethod
58 def resource_cleanup(cls):
59 while cls._cleanup_resources:
60 function, args, kwargs = cls._cleanup_resources.pop(-1)
61 try:
62 function(*args, **kwargs)
Masayuki Igawabfa07602015-01-20 18:47:17 +090063 except lib_exc.NotFound:
Yair Fried6cad1362014-11-24 17:56:56 +020064 pass
65 super(TestLargeOpsScenario, cls).resource_cleanup()
66
67 @classmethod
68 def addCleanupClass(cls, function, *arguments, **keywordArguments):
69 cls._cleanup_resources.append((function, arguments, keywordArguments))
Sylvain Afchain92064772014-01-16 02:45:57 +010070
Joe Gordonb5e10cd2013-07-10 15:51:12 +000071 def _wait_for_server_status(self, status):
72 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080073 # Make sure nova list keeps working throughout the build process
74 self.servers_client.list_servers()
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000075 waiters.wait_for_server_status(self.servers_client,
76 server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000077
Jordan Pittier1e443ec2015-11-20 16:15:58 +010078 def nova_boot(self, image):
Ken'ichi Ohmichi6ded8df2015-03-23 02:00:19 +000079 name = data_utils.rand_name('scenario-server')
Matthew Treinish6c072292014-01-29 19:15:52 +000080 flavor_id = CONF.compute.flavor_ref
Yair Fried6cad1362014-11-24 17:56:56 +020081 # Explicitly create secgroup to avoid cleanup at the end of testcases.
82 # Since no traffic is tested, we don't need to actually add rules to
83 # secgroup
John Warrenf2345512015-12-10 13:39:30 -050084 secgroup = self.compute_security_groups_client.create_security_group(
ghanshyamb610b772015-08-24 17:29:38 +090085 name='secgroup-%s' % name,
86 description='secgroup-desc-%s' % name)['security_group']
John Warrenf2345512015-12-10 13:39:30 -050087 self.addCleanupClass(
88 self.compute_security_groups_client.delete_security_group,
89 secgroup['id'])
Peter Sabainifea219a2015-05-05 12:15:11 +020090 create_kwargs = {
91 'min_count': CONF.scenario.large_ops_number,
92 'security_groups': [{'name': secgroup['name']}]
93 }
94 network = self.get_tenant_network()
95 create_kwargs = fixed_network.set_networks_kwarg(network,
96 create_kwargs)
Ghanshyamaa4511e2014-09-08 10:37:50 +090097 self.servers_client.create_server(
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +000098 name=name,
Jordan Pittier1e443ec2015-11-20 16:15:58 +010099 imageRef=image,
Ken'ichi Ohmichif2d436e2015-09-03 01:13:16 +0000100 flavorRef=flavor_id,
Peter Sabainifea219a2015-05-05 12:15:11 +0200101 **create_kwargs)
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000102 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +0900103 params = {'name': name}
Ken'ichi Ohmichicbc26a82015-07-03 08:18:04 +0000104 server_list = self.servers_client.list_servers(**params)
Ghanshyamaa4511e2014-09-08 10:37:50 +0900105 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -0700106 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000107 # after deleting all servers - wait for all servers to clear
108 # before cleanup continues
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000109 self.addCleanupClass(waiters.wait_for_server_termination,
110 self.servers_client,
Yair Fried6cad1362014-11-24 17:56:56 +0200111 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +0000112 for server in self.servers:
Yair Fried6cad1362014-11-24 17:56:56 +0200113 self.addCleanupClass(self.servers_client.delete_server,
114 server['id'])
Joe Gordonb5e10cd2013-07-10 15:51:12 +0000115 self._wait_for_server_status('ACTIVE')
116
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700117 def _large_ops_scenario(self):
Jordan Pittier1e443ec2015-11-20 16:15:58 +0100118 image = self.glance_image_create()
119 self.nova_boot(image)
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700120
Chris Hoge7579c1a2015-02-26 14:12:15 -0800121 @test.idempotent_id('14ba0e78-2ed9-4d17-9659-a48f4756ecb3')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700122 @test.services('compute', 'image')
123 def test_large_ops_scenario_1(self):
124 self._large_ops_scenario()
125
Chris Hoge7579c1a2015-02-26 14:12:15 -0800126 @test.idempotent_id('b9b79b88-32aa-42db-8f8f-dcc8f4b4ccfe')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700127 @test.services('compute', 'image')
128 def test_large_ops_scenario_2(self):
129 self._large_ops_scenario()
130
Chris Hoge7579c1a2015-02-26 14:12:15 -0800131 @test.idempotent_id('3aab7e82-2de3-419a-9da1-9f3a070668fb')
Joe Gordonb7f37cc2014-05-09 13:30:40 -0700132 @test.services('compute', 'image')
133 def test_large_ops_scenario_3(self):
134 self._large_ops_scenario()