blob: e7aae1953c8541d0aa21883604924fba3321a23b [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
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040013from heat_integrationtests.scenario import scenario_base
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030014
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030015
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040016class NeutronAutoscalingTest(scenario_base.ScenarioTestsBase):
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()
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030023 if not self.conf.fixed_subnet_name:
24 raise self.skipException("No sub-network configured to test")
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040025 self.template_name = 'test_neutron_autoscaling.yaml'
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030026
27 def test_neutron_autoscaling(self):
28 """
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040029 Check autoscaling of load balancer members in Heat.
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030030
31 The alternative scenario is the following:
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040032 1. Launch a stack with a load balancer.
33 2. Check that the load balancer created
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030034 one load balancer member for stack.
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040035 3. Update stack definition: increase desired capacity of stack.
36 4. Check that number of members in load balancer was increased.
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030037 """
38
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040039 parameters = {
40 "image_id": self.conf.minimal_image_ref,
41 "capacity": "1",
Pavlo Shchelokovskyy46e5cb22015-03-23 12:01:25 +000042 "instance_type": self.conf.minimal_instance_type,
Rabi Mishraec4b03b2015-05-23 02:20:47 +053043 "fixed_subnet": self.net['subnets'][0],
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040044 }
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030045
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040046 # Launch stack
47 stack_id = self.launch_stack(
48 template_name=self.template_name,
49 parameters=parameters
50 )
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030051
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040052 # Check number of members
Sirushti Murugesan203c63a2015-04-18 23:47:38 +053053 pool_resource = self.client.resources.get(stack_id, 'test_pool')
54 pool_members = self.network_client.list_members(
55 pool_id=pool_resource.physical_resource_id)['members']
56 self.assertEqual(1, len(pool_members))
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030057
58 # Increase desired capacity and update the stack
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040059 template = self._load_template(
60 __file__, self.template_name, self.sub_dir
61 )
62 parameters["capacity"] = "2"
63 self.update_stack(
64 stack_id,
65 template=template,
66 parameters=parameters
67 )
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030068
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040069 # Check number of members
Sirushti Murugesan203c63a2015-04-18 23:47:38 +053070 pool_members = self.network_client.list_members(
71 pool_id=pool_resource.physical_resource_id)['members']
72 self.assertEqual(2, len(pool_members))