blob: 91b95a8264f40224ce2ed7d249171b085d636056 [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
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010041 def resource_setup(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()
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010046 super(TestLargeOpsScenario, cls).resource_setup()
Sylvain Afchain92064772014-01-16 02:45:57 +010047
Joe Gordonb5e10cd2013-07-10 15:51:12 +000048 def _wait_for_server_status(self, status):
49 for server in self.servers:
Joe Gordon6286a6a2014-03-05 16:35:03 -080050 # Make sure nova list keeps working throughout the build process
51 self.servers_client.list_servers()
Ghanshyamaa4511e2014-09-08 10:37:50 +090052 self.servers_client.wait_for_server_status(server['id'], status)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000053
Joe Gordonb5e10cd2013-07-10 15:51:12 +000054 def nova_boot(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090055 name = data_utils.rand_name('scenario-server-')
Matthew Treinish6c072292014-01-29 19:15:52 +000056 flavor_id = CONF.compute.flavor_ref
Ghanshyamaa4511e2014-09-08 10:37:50 +090057 secgroup = self._create_security_group()
58 self.servers_client.create_server(
59 name,
60 self.image,
61 flavor_id,
Matthew Treinish6c072292014-01-29 19:15:52 +000062 min_count=CONF.scenario.large_ops_number,
Ghanshyamaa4511e2014-09-08 10:37:50 +090063 security_groups=[secgroup])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000064 # needed because of bug 1199788
Ghanshyamaa4511e2014-09-08 10:37:50 +090065 params = {'name': name}
66 _, server_list = self.servers_client.list_servers(params)
67 self.servers = server_list['servers']
Joe Gordona3219652013-10-09 15:23:11 -070068 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +000069 # after deleting all servers - wait for all servers to clear
70 # before cleanup continues
Ghanshyamaa4511e2014-09-08 10:37:50 +090071 self.addCleanup(self.servers_client.wait_for_server_termination,
72 server['id'])
Matthew Treinishb7144eb2013-12-13 22:57:35 +000073 for server in self.servers:
Ghanshyamaa4511e2014-09-08 10:37:50 +090074 self.addCleanup_with_wait(
75 waiter_callable=(self.servers_client.
76 wait_for_server_termination),
77 thing_id=server['id'], thing_id_param='server_id',
78 cleanup_callable=self.delete_wrapper,
79 cleanup_args=[self.servers_client.delete_server, server['id']])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000080 self._wait_for_server_status('ACTIVE')
81
Joe Gordonb7f37cc2014-05-09 13:30:40 -070082 def _large_ops_scenario(self):
Joe Gordonb5e10cd2013-07-10 15:51:12 +000083 self.glance_image_create()
84 self.nova_boot()
Joe Gordonb7f37cc2014-05-09 13:30:40 -070085
86 @test.services('compute', 'image')
87 def test_large_ops_scenario_1(self):
88 self._large_ops_scenario()
89
90 @test.services('compute', 'image')
91 def test_large_ops_scenario_2(self):
92 self._large_ops_scenario()
93
94 @test.services('compute', 'image')
95 def test_large_ops_scenario_3(self):
96 self._large_ops_scenario()