blob: 0e3c4049b2f7b95e616218d5e652c39d14da67a8 [file] [log] [blame]
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +03001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from heat_integrationtests.common import test
14
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030015
16class NeutronAutoscalingTest(test.HeatIntegrationTest):
Tetiana Lashchovad2f4a5a2015-02-06 13:55:34 +020017 """
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030018 The class is responsible for testing of neutron resources autoscaling.
19 """
20
21 def setUp(self):
22 super(NeutronAutoscalingTest, self).setUp()
23 self.client = self.orchestration_client
24 if not self.conf.minimal_image_ref:
25 raise self.skipException("No minimal image configured to test")
26 if not self.conf.instance_type:
27 raise self.skipException("No flavor configured to test")
28 if not self.conf.fixed_subnet_name:
29 raise self.skipException("No sub-network configured to test")
30
31 def test_neutron_autoscaling(self):
32 """
33 Check autoscaling of load balancer members in heat.
34
35 The alternative scenario is the following:
36 1. Initialize environment variables.
37 2. Create a stack with a load balancer.
38 3. Check that the load balancer created
39 one load balancer member for stack.
40 4. Update stack definition: increase desired capacity of stack.
41 5. Check that number of members in load balancer was increased.
42 """
43
44 # Init env variables
45 env = {'parameters': {"image_id": self.conf.minimal_image_ref,
46 "capacity": "1",
47 "instance_type": self.conf.instance_type,
Tetiana Lashchovad2f4a5a2015-02-06 13:55:34 +020048 "fixed_subnet_name": self.conf.fixed_subnet_name,
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030049 }}
50
Sergey Kraynevd6fa5c02015-02-13 03:03:55 -050051 template = self._load_template(__file__,
52 'test_neutron_autoscaling.yaml',
53 'templates')
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030054 # Create stack
Sergey Kraynevd6fa5c02015-02-13 03:03:55 -050055 stack_id = self.stack_create(template=template,
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030056 environment=env)
57
58 members = self.network_client.list_members()
59 self.assertEqual(1, len(members["members"]))
60
61 # Increase desired capacity and update the stack
62 env["parameters"]["capacity"] = "2"
63 self.update_stack(stack_id,
Sergey Kraynevd6fa5c02015-02-13 03:03:55 -050064 template=template,
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030065 environment=env)
66
67 upd_members = self.network_client.list_members()
Tetiana Lashchovad2f4a5a2015-02-06 13:55:34 +020068 self.assertEqual(2, len(upd_members["members"]))