blob: 15cf13b5b0ab5c1350bb2616f9cc2bc6c510405f [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
Joe Gordon30684ef2013-10-08 17:09:09 -070028class TestLargeOpsScenario(manager.NetworkScenarioTest):
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):
42 cls.set_network_resources()
43 super(TestLargeOpsScenario, cls).setUpClass()
44
Joe Gordonb5e10cd2013-07-10 15:51:12 +000045 def _wait_for_server_status(self, status):
46 for server in self.servers:
47 self.status_timeout(
48 self.compute_client.servers, server.id, status)
49
Joe Gordonb5e10cd2013-07-10 15:51:12 +000050 def nova_boot(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090051 name = data_utils.rand_name('scenario-server-')
Joe Gordonb5e10cd2013-07-10 15:51:12 +000052 client = self.compute_client
Matthew Treinish6c072292014-01-29 19:15:52 +000053 flavor_id = CONF.compute.flavor_ref
Yair Friedeb69f3f2013-10-10 13:18:16 +030054 secgroup = self._create_security_group_nova()
Joe Gordonb5e10cd2013-07-10 15:51:12 +000055 self.servers = client.servers.create(
56 name=name, image=self.image,
57 flavor=flavor_id,
Matthew Treinish6c072292014-01-29 19:15:52 +000058 min_count=CONF.scenario.large_ops_number,
Joe Gordon30684ef2013-10-08 17:09:09 -070059 security_groups=[secgroup.name])
Joe Gordonb5e10cd2013-07-10 15:51:12 +000060 # needed because of bug 1199788
61 self.servers = [x for x in client.servers.list() if name in x.name]
Joe Gordona3219652013-10-09 15:23:11 -070062 for server in self.servers:
Matthew Treinishb7144eb2013-12-13 22:57:35 +000063 # after deleting all servers - wait for all servers to clear
64 # before cleanup continues
65 self.addCleanup(self.delete_timeout,
66 self.compute_client.servers,
67 server.id)
68 for server in self.servers:
69 self.addCleanup_with_wait(self.compute_client.servers, server.id)
Joe Gordonb5e10cd2013-07-10 15:51:12 +000070 self._wait_for_server_status('ACTIVE')
71
Joe Gordonb7f37cc2014-05-09 13:30:40 -070072 def _large_ops_scenario(self):
Matthew Treinish6c072292014-01-29 19:15:52 +000073 if CONF.scenario.large_ops_number < 1:
Joe Gordonb5e10cd2013-07-10 15:51:12 +000074 return
75 self.glance_image_create()
76 self.nova_boot()
Joe Gordonb7f37cc2014-05-09 13:30:40 -070077
78 @test.services('compute', 'image')
79 def test_large_ops_scenario_1(self):
80 self._large_ops_scenario()
81
82 @test.services('compute', 'image')
83 def test_large_ops_scenario_2(self):
84 self._large_ops_scenario()
85
86 @test.services('compute', 'image')
87 def test_large_ops_scenario_3(self):
88 self._large_ops_scenario()