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