blob: 9bbfbab33101b6132cb935b99dd611a86c1a61af [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,
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040043 "fixed_subnet_name": self.conf.fixed_subnet_name,
44 }
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
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030053 members = self.network_client.list_members()
54 self.assertEqual(1, len(members["members"]))
55
56 # Increase desired capacity and update the stack
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040057 template = self._load_template(
58 __file__, self.template_name, self.sub_dir
59 )
60 parameters["capacity"] = "2"
61 self.update_stack(
62 stack_id,
63 template=template,
64 parameters=parameters
65 )
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030066
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040067 # Check number of members
kairat_kushaev0ab3d7c2015-01-27 21:48:46 +030068 upd_members = self.network_client.list_members()
Tetiana Lashchovad2f4a5a2015-02-06 13:55:34 +020069 self.assertEqual(2, len(upd_members["members"]))