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 | |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 28 | class TestServerAdvancedOps(manager.ScenarioTest): |
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 |
Andrea Frittoli | ac20b5e | 2014-09-15 13:31:14 +0100 | [diff] [blame] | 38 | def resource_setup(cls): |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 39 | if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref: |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 40 | msg = "Skipping test - flavor_ref and flavor_ref_alt are identical" |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 41 | raise cls.skipException(msg) |
Masayuki Igawa | 60ea6c5 | 2014-10-15 17:32:14 +0900 | [diff] [blame] | 42 | cls.set_network_resources() |
| 43 | super(TestServerAdvancedOps, cls).resource_setup() |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 44 | |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 45 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 46 | 'Resize is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 47 | @test.services('compute') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 48 | def test_resize_server_confirm(self): |
| 49 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 50 | instance = self.create_server() |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 51 | instance_id = instance['id'] |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 52 | resize_flavor = CONF.compute.flavor_ref_alt |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 53 | LOG.debug("Resizing instance %s from flavor %s to flavor %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 54 | instance['id'], instance['flavor']['id'], resize_flavor) |
| 55 | self.servers_client.resize(instance_id, resize_flavor) |
| 56 | self.servers_client.wait_for_server_status(instance_id, |
| 57 | 'VERIFY_RESIZE') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 58 | |
| 59 | LOG.debug("Confirming resize of instance %s", instance_id) |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 60 | self.servers_client.confirm_resize(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 61 | |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 62 | self.servers_client.wait_for_server_status(instance_id, |
| 63 | 'ACTIVE') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 64 | |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 65 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 66 | 'Suspend is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 67 | @test.services('compute') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 68 | def test_server_sequence_suspend_resume(self): |
| 69 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 70 | instance = self.create_server() |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 71 | instance_id = instance['id'] |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 72 | LOG.debug("Suspending instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 73 | instance_id, instance['status']) |
| 74 | self.servers_client.suspend_server(instance_id) |
| 75 | self.servers_client.wait_for_server_status(instance_id, |
| 76 | 'SUSPENDED') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 77 | fetched_instance = self.servers_client.get_server(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 78 | LOG.debug("Resuming instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 79 | instance_id, fetched_instance['status']) |
| 80 | self.servers_client.resume_server(instance_id) |
| 81 | self.servers_client.wait_for_server_status(instance_id, |
| 82 | 'ACTIVE') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 83 | fetched_instance = self.servers_client.get_server(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 84 | LOG.debug("Suspending instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 85 | instance_id, fetched_instance['status']) |
| 86 | self.servers_client.suspend_server(instance_id) |
| 87 | self.servers_client.wait_for_server_status(instance_id, |
| 88 | 'SUSPENDED') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 89 | fetched_instance = self.servers_client.get_server(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 90 | LOG.debug("Resuming instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 91 | instance_id, fetched_instance['status']) |
| 92 | self.servers_client.resume_server(instance_id) |
| 93 | self.servers_client.wait_for_server_status(instance_id, |
| 94 | 'ACTIVE') |