blob: 71b8a7f1af32ec87e728d0afecc8c0fd04e944e7 [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.
15
Masayuki Igawa259c1132013-10-31 17:48:44 +090016from tempest.common.utils import data_utils
Matthew Treinish6c072292014-01-29 19:15:52 +000017from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040018from tempest.openstack.common import log as logging
Joe Gordonb5e10cd2013-07-10 15:51:12 +000019from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090020from tempest import test
Joe Gordonb5e10cd2013-07-10 15:51:12 +000021
Matthew Treinish6c072292014-01-29 19:15:52 +000022CONF = config.CONF
23
Joe Gordonb5e10cd2013-07-10 15:51:12 +000024
25LOG = logging.getLogger(__name__)
26
27
Ghanshyamaa4511e2014-09-08 10:37:50 +090028class TestLargeOpsScenario(manager.ScenarioTest):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000029
30 """
31 Test large operations.
32
33 This test below:
Joe Gordonfa29a622014-04-17 13:21:44 -070034 * Spin up multiple instances in one nova call, and repeat three times
Joe Gordonb5e10cd2013-07-10 15:51:12 +000035 * as a regular user
36 * TODO: same thing for cinder
37
38 """
39
Sylvain Afchain92064772014-01-16 02:45:57 +010040 @classmethod
41 def setUpClass(cls):
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")
Sylvain Afchain92064772014-01-16 02:45:57 +010045 cls.set_network_resources()
46 super(TestLargeOpsScenario, cls).setUpClass()
47
Joe Gordonb5e10cd2013-07-10 15:51:12 +000048 def _wait_for_server_status(self, status):
49 for server in self.servers:
Ghanshyamaa4511e2014-09-08 10:37:50 +090050 self.servers_client.wait_for_server_status(server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000051
Joe Gordonb5e10cd2013-07-10 15:51:12 +000052 def nova_boot(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090053 name = data_utils.rand_name('scenario-server-')
Matthew Treinish6c072292014-01-29 19:15:52 +000054 flavor_id = CONF.compute.flavor_ref
Ghanshyamaa4511e2014-09-08 10:37:50 +090055 secgroup = self._create_security_group()
56 self.servers_client.create_server(
57 name,
58 self.image,
59 flavor_id,
Matthew Treinish6c072292014-01-29 19:15:52 +000060 min_count=CONF.scenario.large_ops_number,
Ghanshyamaa4511e2014-09-08 10:37:50 +090061 security_groups=[secgroup])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000062 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +090063 params = {'name': name}
64 _, server_list = self.servers_client.list_servers(params)
65 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -070066 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +000067 # after deleting all servers - wait for all servers to clear
68 # before cleanup continues
Ghanshyamaa4511e2014-09-08 10:37:50 +090069 self.addCleanup(self.servers_client.wait_for_server_termination,
70 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +000071 for server in self.servers:
Ghanshyamaa4511e2014-09-08 10:37:50 +090072 self.addCleanup_with_wait(
73 waiter_callable=(self.servers_client.
74 wait_for_server_termination),
75 thing_id=server['id'], thing_id_param='server_id',
76 cleanup_callable=self.delete_wrapper,
77 cleanup_args=[self.servers_client.delete_server, server['id']])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000078 self._wait_for_server_status('ACTIVE')
79
Joe Gordonb7f37cc2014-05-09 13:30:40 -070080 def _large_ops_scenario(self):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000081 self.glance_image_create()
82 self.nova_boot()
Joe Gordonb7f37cc2014-05-09 13:30:40 -070083
84 @test.services('compute', 'image')
85 def test_large_ops_scenario_1(self):
86 self._large_ops_scenario()
87
88 @test.services('compute', 'image')
89 def test_large_ops_scenario_2(self):
90 self._large_ops_scenario()
91
92 @test.services('compute', 'image')
93 def test_large_ops_scenario_3(self):
94 self._large_ops_scenario()