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