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 | |
| 13 | from heat_integrationtests.common import test |
| 14 | |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 15 | |
| 16 | class NeutronAutoscalingTest(test.HeatIntegrationTest): |
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() |
| 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 Lashchova | d2f4a5a | 2015-02-06 13:55:34 +0200 | [diff] [blame] | 48 | "fixed_subnet_name": self.conf.fixed_subnet_name, |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 49 | }} |
| 50 | |
Sergey Kraynev | d6fa5c0 | 2015-02-13 03:03:55 -0500 | [diff] [blame] | 51 | template = self._load_template(__file__, |
| 52 | 'test_neutron_autoscaling.yaml', |
| 53 | 'templates') |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 54 | # Create stack |
Sergey Kraynev | d6fa5c0 | 2015-02-13 03:03:55 -0500 | [diff] [blame] | 55 | stack_id = self.stack_create(template=template, |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 56 | 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 Kraynev | d6fa5c0 | 2015-02-13 03:03:55 -0500 | [diff] [blame] | 64 | template=template, |
kairat_kushaev | 0ab3d7c | 2015-01-27 21:48:46 +0300 | [diff] [blame] | 65 | environment=env) |
| 66 | |
| 67 | upd_members = self.network_client.list_members() |
Tetiana Lashchova | d2f4a5a | 2015-02-06 13:55:34 +0200 | [diff] [blame] | 68 | self.assertEqual(2, len(upd_members["members"])) |