Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 3 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 18 | from tempest.openstack.common import log as logging |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 19 | from tempest.scenario import manager |
Matthew Treinish | 2153ec0 | 2013-09-09 20:57:30 +0000 | [diff] [blame] | 20 | from tempest.test import services |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 21 | |
| 22 | LOG = logging.getLogger(__name__) |
| 23 | |
| 24 | |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 25 | class TestServerAdvancedOps(manager.OfficialClientTest): |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 26 | |
| 27 | """ |
| 28 | This test case stresses some advanced server instance operations: |
| 29 | |
| 30 | * Resizing an instance |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 31 | * Sequence suspend resume |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 32 | """ |
| 33 | |
| 34 | @classmethod |
| 35 | def setUpClass(cls): |
| 36 | super(TestServerAdvancedOps, cls).setUpClass() |
| 37 | |
| 38 | if not cls.config.compute.resize_available: |
| 39 | msg = "Skipping test - resize not available on this host" |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 40 | raise cls.skipException(msg) |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 41 | |
| 42 | resize_flavor = cls.config.compute.flavor_ref_alt |
| 43 | |
| 44 | if resize_flavor == cls.config.compute.flavor_ref: |
| 45 | msg = "Skipping test - flavor_ref and flavor_ref_alt are identical" |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 46 | raise cls.skipException(msg) |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 47 | |
Matthew Treinish | 2153ec0 | 2013-09-09 20:57:30 +0000 | [diff] [blame] | 48 | @services('compute') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 49 | def test_resize_server_confirm(self): |
| 50 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 51 | instance = self.create_server() |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 52 | instance_id = instance.id |
| 53 | resize_flavor = self.config.compute.flavor_ref_alt |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 54 | LOG.debug("Resizing instance %s from flavor %s to flavor %s", |
| 55 | instance.id, instance.flavor, resize_flavor) |
| 56 | instance.resize(resize_flavor) |
Sean Dague | 35a7caf | 2013-05-10 10:38:22 -0400 | [diff] [blame] | 57 | self.status_timeout(self.compute_client.servers, instance_id, |
Maru Newby | dec13ec | 2012-08-30 11:19:17 -0700 | [diff] [blame] | 58 | 'VERIFY_RESIZE') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 59 | |
| 60 | LOG.debug("Confirming resize of instance %s", instance_id) |
| 61 | instance.confirm_resize() |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 62 | |
Sean Dague | 35a7caf | 2013-05-10 10:38:22 -0400 | [diff] [blame] | 63 | self.status_timeout( |
| 64 | self.compute_client.servers, instance_id, 'ACTIVE') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 65 | |
Matthew Treinish | 2153ec0 | 2013-09-09 20:57:30 +0000 | [diff] [blame] | 66 | @services('compute') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 67 | def test_server_sequence_suspend_resume(self): |
| 68 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 69 | instance = self.create_server() |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 70 | instance_id = instance.id |
| 71 | LOG.debug("Suspending instance %s. Current status: %s", |
| 72 | instance_id, instance.status) |
| 73 | instance.suspend() |
| 74 | self.status_timeout(self.compute_client.servers, instance_id, |
| 75 | 'SUSPENDED') |
| 76 | LOG.debug("Resuming instance %s. Current status: %s", |
| 77 | instance_id, instance.status) |
| 78 | instance.resume() |
| 79 | self.status_timeout(self.compute_client.servers, instance_id, |
| 80 | 'ACTIVE') |
| 81 | LOG.debug("Suspending instance %s. Current status: %s", |
| 82 | instance_id, instance.status) |
| 83 | instance.suspend() |
| 84 | self.status_timeout(self.compute_client.servers, instance_id, |
| 85 | 'SUSPENDED') |
| 86 | LOG.debug("Resuming instance %s. Current status: %s", |
| 87 | instance_id, instance.status) |
| 88 | instance.resume() |
| 89 | self.status_timeout(self.compute_client.servers, instance_id, |
| 90 | 'ACTIVE') |