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 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame^] | 16 | from oslo_log import log as logging |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 17 | import testtools |
| 18 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 19 | from tempest import config |
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 |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 38 | def skip_checks(cls): |
| 39 | super(TestServerAdvancedOps, cls).skip_checks() |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 40 | if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref: |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 41 | msg = "Skipping test - flavor_ref and flavor_ref_alt are identical" |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 42 | raise cls.skipException(msg) |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 43 | |
| 44 | @classmethod |
| 45 | def setup_credentials(cls): |
Masayuki Igawa | 60ea6c5 | 2014-10-15 17:32:14 +0900 | [diff] [blame] | 46 | cls.set_network_resources() |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 47 | super(TestServerAdvancedOps, cls).setup_credentials() |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 48 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 49 | @test.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 50 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 51 | 'Resize is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 52 | @test.services('compute') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 53 | def test_resize_server_confirm(self): |
| 54 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 55 | instance = self.create_server() |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 56 | instance_id = instance['id'] |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 57 | resize_flavor = CONF.compute.flavor_ref_alt |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 58 | LOG.debug("Resizing instance %s from flavor %s to flavor %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 59 | instance['id'], instance['flavor']['id'], resize_flavor) |
| 60 | self.servers_client.resize(instance_id, resize_flavor) |
| 61 | self.servers_client.wait_for_server_status(instance_id, |
| 62 | 'VERIFY_RESIZE') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 63 | |
| 64 | LOG.debug("Confirming resize of instance %s", instance_id) |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 65 | self.servers_client.confirm_resize(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 66 | |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 67 | self.servers_client.wait_for_server_status(instance_id, |
| 68 | 'ACTIVE') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 69 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 70 | @test.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 71 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 72 | 'Suspend is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 73 | @test.services('compute') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 74 | def test_server_sequence_suspend_resume(self): |
| 75 | # We create an instance for use in this test |
Giulio Fidente | 61cadca | 2013-09-24 18:33:37 +0200 | [diff] [blame] | 76 | instance = self.create_server() |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 77 | instance_id = instance['id'] |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 78 | LOG.debug("Suspending instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 79 | instance_id, instance['status']) |
| 80 | self.servers_client.suspend_server(instance_id) |
| 81 | self.servers_client.wait_for_server_status(instance_id, |
| 82 | 'SUSPENDED') |
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("Resuming 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.resume_server(instance_id) |
| 87 | self.servers_client.wait_for_server_status(instance_id, |
| 88 | 'ACTIVE') |
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("Suspending 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.suspend_server(instance_id) |
| 93 | self.servers_client.wait_for_server_status(instance_id, |
| 94 | 'SUSPENDED') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 95 | fetched_instance = self.servers_client.get_server(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 96 | LOG.debug("Resuming instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 97 | instance_id, fetched_instance['status']) |
| 98 | self.servers_client.resume_server(instance_id) |
| 99 | self.servers_client.wait_for_server_status(instance_id, |
| 100 | 'ACTIVE') |