kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 1 | # 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 Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 13 | from heat_integrationtests.scenario import scenario_base |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 14 | |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 15 | |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 16 | class NeutronAutoscalingTest(scenario_base.ScenarioTestsBase): |
Tetiana Lashchova | d2f4a5a | 2015-02-06 13:55:34 +0200 | [diff] [blame] | 17 | """ |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 18 | The class is responsible for testing of neutron resources autoscaling. |
| 19 | """ |
| 20 | |
| 21 | def setUp(self): |
| 22 | super(NeutronAutoscalingTest, self).setUp() |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 23 | if not self.conf.fixed_subnet_name: |
| 24 | raise self.skipException("No sub-network configured to test") |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 25 | self.template_name = 'test_neutron_autoscaling.yaml' |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 26 | |
| 27 | def test_neutron_autoscaling(self): |
| 28 | """ |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 29 | Check autoscaling of load balancer members in Heat. |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 30 | |
| 31 | The alternative scenario is the following: |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 32 | 1. Launch a stack with a load balancer. |
| 33 | 2. Check that the load balancer created |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 34 | one load balancer member for stack. |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 35 | 3. Update stack definition: increase desired capacity of stack. |
| 36 | 4. Check that number of members in load balancer was increased. |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 37 | """ |
| 38 | |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 39 | parameters = { |
| 40 | "image_id": self.conf.minimal_image_ref, |
| 41 | "capacity": "1", |
Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 42 | "instance_type": self.conf.minimal_instance_type, |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 43 | "fixed_subnet_name": self.conf.fixed_subnet_name, |
| 44 | } |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 45 | |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 46 | # Launch stack |
| 47 | stack_id = self.launch_stack( |
| 48 | template_name=self.template_name, |
| 49 | parameters=parameters |
| 50 | ) |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 51 | |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 52 | # Check number of members |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 53 | members = self.network_client.list_members() |
| 54 | self.assertEqual(1, len(members["members"])) |
| 55 | |
| 56 | # Increase desired capacity and update the stack |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 57 | 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_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 66 | |
Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 67 | # Check number of members |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 68 | upd_members = self.network_client.list_members() |
Tetiana Lashchova | d2f4a5a | 2015-02-06 13:55:34 +0200 | [diff] [blame] | 69 | self.assertEqual(2, len(upd_members["members"])) |