ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -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 | |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 16 | import sys |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 17 | |
Masayuki Igawa | 90c914e | 2015-01-20 14:48:16 +0900 | [diff] [blame] | 18 | from tempest_lib import exceptions as lib_exc |
Eric Windisch | b553807 | 2014-03-09 23:47:35 -0400 | [diff] [blame] | 19 | import testtools |
| 20 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 21 | from tempest.api.compute import base |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 22 | from tempest import clients |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 23 | from tempest.common.utils import data_utils |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 24 | from tempest import config |
Daryl Walleck | ed8bef3 | 2011-12-05 23:02:08 -0600 | [diff] [blame] | 25 | from tempest import exceptions |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 26 | from tempest import test |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 27 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 28 | CONF = config.CONF |
| 29 | |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 30 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 31 | class ServersNegativeTestJSON(base.BaseV2ComputeTest): |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 32 | |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 33 | def setUp(self): |
| 34 | super(ServersNegativeTestJSON, self).setUp() |
| 35 | try: |
| 36 | self.client.wait_for_server_status(self.server_id, 'ACTIVE') |
| 37 | except Exception: |
Ken'ichi Ohmichi | 122cdf5 | 2013-12-11 21:32:25 +0900 | [diff] [blame] | 38 | self.__class__.server_id = self.rebuild_server(self.server_id) |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 39 | |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 40 | def tearDown(self): |
| 41 | self.server_check_teardown() |
| 42 | super(ServersNegativeTestJSON, self).tearDown() |
| 43 | |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 44 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 45 | def resource_setup(cls): |
| 46 | super(ServersNegativeTestJSON, cls).resource_setup() |
Daryl Walleck | c725196 | 2012-03-12 17:26:54 -0500 | [diff] [blame] | 47 | cls.client = cls.servers_client |
Andrea Frittoli | 8283b4e | 2014-07-17 13:28:58 +0100 | [diff] [blame] | 48 | cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds()) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 49 | cls.alt_client = cls.alt_os.servers_client |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 50 | server = cls.create_test_server(wait_until='ACTIVE') |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 51 | cls.server_id = server['id'] |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 52 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 53 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 54 | def test_server_name_blank(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 55 | # Create a server with name parameter empty |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 56 | |
| 57 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 58 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 59 | name='') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 60 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 61 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 62 | def test_personality_file_contents_not_encoded(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 63 | # Use an unencoded file when creating a server with personality |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 64 | |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 65 | file_contents = 'This is a test file.' |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 66 | person = [{'path': '/etc/testfile.txt', |
| 67 | 'contents': file_contents}] |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 68 | |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 69 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 70 | self.create_test_server, |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 71 | personality=person) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 72 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 73 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 74 | def test_create_with_invalid_image(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 75 | # Create a server with an unknown image |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 76 | |
| 77 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 78 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 79 | image_id=-1) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 80 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 81 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 82 | def test_create_with_invalid_flavor(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 83 | # Create a server with an unknown flavor |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 84 | |
| 85 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 86 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 87 | flavor=-1,) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 88 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 89 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 90 | def test_invalid_access_ip_v4_address(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 91 | # An access IPv4 address must match a valid address pattern |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 92 | |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 93 | IPv4 = '1.1.1.1.1.1' |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 94 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 95 | self.create_test_server, accessIPv4=IPv4) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 96 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 97 | @test.attr(type=['negative', 'gate']) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 98 | def test_invalid_ip_v6_address(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 99 | # An access IPv6 address must match a valid address pattern |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 100 | |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 101 | IPv6 = 'notvalid' |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 102 | |
| 103 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 104 | self.create_test_server, accessIPv6=IPv6) |
ravikumar-venkatesan | 36892e1 | 2012-05-11 18:01:41 +0000 | [diff] [blame] | 105 | |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 106 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 107 | 'Resize not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 108 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | f49bf18 | 2013-10-21 10:19:43 +0530 | [diff] [blame] | 109 | def test_resize_nonexistent_server(self): |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 110 | # Resize a non-existent server |
| 111 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 112 | self.assertRaises(lib_exc.NotFound, |
Hoisaleshwara Madan V S | f49bf18 | 2013-10-21 10:19:43 +0530 | [diff] [blame] | 113 | self.client.resize, |
| 114 | nonexistent_server, self.flavor_ref) |
| 115 | |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 116 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 117 | 'Resize not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 118 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 119 | def test_resize_server_with_non_existent_flavor(self): |
| 120 | # Resize a server with non-existent flavor |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 121 | nonexistent_flavor = data_utils.rand_uuid() |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 122 | self.assertRaises(exceptions.BadRequest, self.client.resize, |
| 123 | self.server_id, flavor_ref=nonexistent_flavor) |
| 124 | |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 125 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 126 | 'Resize not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 127 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 128 | def test_resize_server_with_null_flavor(self): |
| 129 | # Resize a server with null flavor |
| 130 | self.assertRaises(exceptions.BadRequest, self.client.resize, |
| 131 | self.server_id, flavor_ref="") |
| 132 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 133 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 134 | def test_reboot_non_existent_server(self): |
| 135 | # Reboot a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 136 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 137 | self.assertRaises(lib_exc.NotFound, self.client.reboot, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 138 | nonexistent_server, 'SOFT') |
| 139 | |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 140 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 141 | 'Pause is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 142 | @test.attr(type=['negative', 'gate']) |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 143 | def test_pause_paused_server(self): |
| 144 | # Pause a paused server. |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 145 | self.client.pause_server(self.server_id) |
| 146 | self.client.wait_for_server_status(self.server_id, 'PAUSED') |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 147 | self.assertRaises(lib_exc.Conflict, |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 148 | self.client.pause_server, |
| 149 | self.server_id) |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 150 | self.client.unpause_server(self.server_id) |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 151 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 152 | @test.attr(type=['negative', 'gate']) |
Attila Fazekas | 6fab1a1 | 2013-10-17 17:38:54 +0200 | [diff] [blame] | 153 | def test_rebuild_reboot_deleted_server(self): |
| 154 | # Rebuild and Reboot a deleted server |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 155 | server = self.create_test_server() |
Attila Fazekas | 6fab1a1 | 2013-10-17 17:38:54 +0200 | [diff] [blame] | 156 | self.client.delete_server(server['id']) |
| 157 | self.client.wait_for_server_termination(server['id']) |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 158 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 159 | self.assertRaises(lib_exc.NotFound, |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 160 | self.client.rebuild, |
Attila Fazekas | 6fab1a1 | 2013-10-17 17:38:54 +0200 | [diff] [blame] | 161 | server['id'], self.image_ref_alt) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 162 | self.assertRaises(lib_exc.NotFound, self.client.reboot, |
Attila Fazekas | 6fab1a1 | 2013-10-17 17:38:54 +0200 | [diff] [blame] | 163 | server['id'], 'SOFT') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 164 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 165 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 166 | def test_rebuild_non_existent_server(self): |
| 167 | # Rebuild a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 168 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 169 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 170 | self.client.rebuild, |
| 171 | nonexistent_server, |
ghanshyam | fe087de | 2014-12-16 09:23:58 +0900 | [diff] [blame] | 172 | self.image_ref_alt) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 173 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 174 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 175 | def test_create_numeric_server_name(self): |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 176 | server_name = 12345 |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 177 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 178 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 179 | name=server_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 180 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 181 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 182 | def test_create_server_name_length_exceeds_256(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 183 | # Create a server with name length exceeding 256 characters |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 184 | |
| 185 | server_name = 'a' * 256 |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 186 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 187 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 188 | name=server_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 189 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 190 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 191 | def test_create_with_invalid_network_uuid(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 192 | # Pass invalid network uuid while creating a server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 193 | |
Chris Yeoh | fc9e333 | 2013-01-21 09:28:13 +1030 | [diff] [blame] | 194 | networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}] |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 195 | |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 196 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 197 | self.create_test_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 198 | networks=networks) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 199 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 200 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 201 | def test_create_with_non_existent_keypair(self): |
Chang Bo Guo | f099f80 | 2013-09-13 19:01:46 -0700 | [diff] [blame] | 202 | # Pass a non-existent keypair while creating a server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 203 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 204 | key_name = data_utils.rand_name('key') |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 205 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 206 | self.create_test_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 207 | key_name=key_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 208 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 209 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 210 | def test_create_server_metadata_exceeds_length_limit(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 211 | # Pass really long metadata while creating a server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 212 | |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 213 | metadata = {'a': 'b' * 260} |
Masayuki Igawa | 90c914e | 2015-01-20 14:48:16 +0900 | [diff] [blame] | 214 | self.assertRaises((exceptions.BadRequest, lib_exc.OverLimit), |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 215 | self.create_test_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 216 | meta=metadata) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 217 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 218 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 219 | def test_update_name_of_non_existent_server(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 220 | # Update name of a non-existent server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 221 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 222 | server_name = data_utils.rand_name('server') |
| 223 | new_name = data_utils.rand_name('server') + '_updated' |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 224 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 225 | self.assertRaises(lib_exc.NotFound, self.client.update_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 226 | server_name, name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 227 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 228 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 229 | def test_update_server_set_empty_name(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 230 | # Update name of the server to an empty string |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 231 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 232 | server_name = data_utils.rand_name('server') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 233 | new_name = '' |
| 234 | |
| 235 | self.assertRaises(exceptions.BadRequest, self.client.update_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 236 | server_name, name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 237 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 238 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 239 | def test_update_server_of_another_tenant(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 240 | # Update name of a server that belongs to another tenant |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 241 | |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 242 | new_name = self.server_id + '_new' |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 243 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 244 | self.alt_client.update_server, self.server_id, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 245 | name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 246 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 247 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 248 | def test_update_server_name_length_exceeds_256(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 249 | # Update name of server exceed the name length limit |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 250 | |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 251 | new_name = 'a' * 256 |
| 252 | self.assertRaises(exceptions.BadRequest, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 253 | self.client.update_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 254 | self.server_id, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 255 | name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 256 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 257 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 258 | def test_delete_non_existent_server(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 259 | # Delete a non existent server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 260 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 261 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 262 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 263 | nonexistent_server) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 264 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 265 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 266 | def test_delete_a_server_of_another_tenant(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 267 | # Delete a server that belongs to another tenant |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 268 | self.assertRaises(lib_exc.NotFound, |
Matthew Treinish | 38c4dc4 | 2013-07-30 14:30:07 -0400 | [diff] [blame] | 269 | self.alt_client.delete_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 270 | self.server_id) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 271 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 272 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 273 | def test_delete_server_pass_negative_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 274 | # Pass an invalid string parameter to delete server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 275 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 276 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, -1) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 277 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 278 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 279 | def test_delete_server_pass_id_exceeding_length_limit(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 280 | # Pass a server ID that exceeds length limit to delete server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 281 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 282 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 283 | sys.maxint + 1) |
donald-ngo | 78bd7f5 | 2013-02-08 14:35:16 -0800 | [diff] [blame] | 284 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 285 | @test.attr(type=['negative', 'gate']) |
donald-ngo | 78bd7f5 | 2013-02-08 14:35:16 -0800 | [diff] [blame] | 286 | def test_create_with_nonexistent_security_group(self): |
| 287 | # Create a server with a nonexistent security group |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 288 | |
| 289 | security_groups = [{'name': 'does_not_exist'}] |
Jordan Pittier | ce89f63 | 2013-06-25 16:04:39 +0000 | [diff] [blame] | 290 | self.assertRaises(exceptions.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 291 | self.create_test_server, |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 292 | security_groups=security_groups) |
hi2suresh | 063acbc | 2013-02-20 09:32:03 +0000 | [diff] [blame] | 293 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 294 | @test.attr(type=['negative', 'gate']) |
hi2suresh | 063acbc | 2013-02-20 09:32:03 +0000 | [diff] [blame] | 295 | def test_get_non_existent_server(self): |
| 296 | # Get a non existent server details |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 297 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 298 | self.assertRaises(lib_exc.NotFound, self.client.get_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 299 | nonexistent_server) |
Sean Dague | e623f75 | 2013-02-27 14:52:15 -0500 | [diff] [blame] | 300 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 301 | @test.attr(type=['negative', 'gate']) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 302 | def test_stop_non_existent_server(self): |
| 303 | # Stop a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 304 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 305 | self.assertRaises(lib_exc.NotFound, self.servers_client.stop, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 306 | nonexistent_server) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 307 | |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 308 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 309 | 'Pause is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 310 | @test.attr(type=['negative', 'gate']) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 311 | def test_pause_non_existent_server(self): |
| 312 | # pause a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 313 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 314 | self.assertRaises(lib_exc.NotFound, self.client.pause_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 315 | nonexistent_server) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 316 | |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 317 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 318 | 'Pause is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 319 | @test.attr(type=['negative', 'gate']) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 320 | def test_unpause_non_existent_server(self): |
| 321 | # unpause a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 322 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 323 | self.assertRaises(lib_exc.NotFound, self.client.unpause_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 324 | nonexistent_server) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 325 | |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 326 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 327 | 'Pause is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 328 | @test.attr(type=['negative', 'gate']) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 329 | def test_unpause_server_invalid_state(self): |
| 330 | # unpause an active server. |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 331 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 332 | self.client.unpause_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 333 | self.server_id) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 334 | |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 335 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 336 | 'Suspend is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 337 | @test.attr(type=['negative', 'gate']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 338 | def test_suspend_non_existent_server(self): |
| 339 | # suspend a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 340 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 341 | self.assertRaises(lib_exc.NotFound, self.client.suspend_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 342 | nonexistent_server) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 343 | |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 344 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 345 | 'Suspend is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 346 | @test.attr(type=['negative', 'gate']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 347 | def test_suspend_server_invalid_state(self): |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 348 | # suspend a suspended server. |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame^] | 349 | self.client.suspend_server(self.server_id) |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 350 | self.client.wait_for_server_status(self.server_id, 'SUSPENDED') |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 351 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 352 | self.client.suspend_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 353 | self.server_id) |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 354 | self.client.resume_server(self.server_id) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 355 | |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 356 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 357 | 'Suspend is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 358 | @test.attr(type=['negative', 'gate']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 359 | def test_resume_non_existent_server(self): |
| 360 | # resume a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 361 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 362 | self.assertRaises(lib_exc.NotFound, self.client.resume_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 363 | nonexistent_server) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 364 | |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 365 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 366 | 'Suspend is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 367 | @test.attr(type=['negative', 'gate']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 368 | def test_resume_server_invalid_state(self): |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 369 | # resume an active server. |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 370 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 371 | self.client.resume_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 372 | self.server_id) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 373 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 374 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 375 | def test_get_console_output_of_non_existent_server(self): |
| 376 | # get the console output for a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 377 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 378 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 379 | self.client.get_console_output, |
| 380 | nonexistent_server, 10) |
| 381 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 382 | @test.attr(type=['negative', 'gate']) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 383 | def test_force_delete_nonexistent_server_id(self): |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 384 | # force-delete a non existent server |
| 385 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 386 | self.assertRaises(lib_exc.NotFound, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 387 | self.client.force_delete_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 388 | nonexistent_server) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 389 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 390 | @test.attr(type=['negative', 'gate']) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 391 | def test_restore_nonexistent_server_id(self): |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 392 | # restore-delete a non existent server |
| 393 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 394 | self.assertRaises(lib_exc.NotFound, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 395 | self.client.restore_soft_deleted_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 396 | nonexistent_server) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 397 | |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 398 | @test.attr(type=['negative', 'gate']) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 399 | def test_restore_server_invalid_state(self): |
| 400 | # we can only restore-delete a server in 'soft-delete' state |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 401 | self.assertRaises(lib_exc.Conflict, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 402 | self.client.restore_soft_deleted_server, |
| 403 | self.server_id) |
| 404 | |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 405 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 406 | 'Shelve is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 407 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 408 | def test_shelve_non_existent_server(self): |
| 409 | # shelve a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 410 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 411 | self.assertRaises(lib_exc.NotFound, self.client.shelve_server, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 412 | nonexistent_server) |
| 413 | |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 414 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 415 | 'Shelve is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 416 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 417 | def test_shelve_shelved_server(self): |
| 418 | # shelve a shelved server. |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame^] | 419 | self.client.shelve_server(self.server_id) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 420 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 421 | offload_time = CONF.compute.shelved_offload_time |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 422 | if offload_time >= 0: |
| 423 | self.client.wait_for_server_status(self.server_id, |
| 424 | 'SHELVED_OFFLOADED', |
| 425 | extra_timeout=offload_time) |
| 426 | else: |
| 427 | self.client.wait_for_server_status(self.server_id, |
| 428 | 'SHELVED') |
| 429 | |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 430 | server = self.client.get_server(self.server_id) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 431 | image_name = server['name'] + '-shelved' |
| 432 | params = {'name': image_name} |
David Kranz | a5299eb | 2015-01-15 17:24:05 -0500 | [diff] [blame] | 433 | images = self.images_client.list_images(params) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 434 | self.assertEqual(1, len(images)) |
| 435 | self.assertEqual(image_name, images[0]['name']) |
| 436 | |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 437 | self.assertRaises(lib_exc.Conflict, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 438 | self.client.shelve_server, |
| 439 | self.server_id) |
| 440 | |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 441 | self.client.unshelve_server(self.server_id) |
| 442 | |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 443 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 444 | 'Shelve is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 445 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 446 | def test_unshelve_non_existent_server(self): |
| 447 | # unshelve a non existent server |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 448 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 449 | self.assertRaises(lib_exc.NotFound, self.client.unshelve_server, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 450 | nonexistent_server) |
| 451 | |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 452 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 453 | 'Shelve is not available.') |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 454 | @test.attr(type=['negative', 'gate']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 455 | def test_unshelve_server_invalid_state(self): |
| 456 | # unshelve an active server. |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 457 | self.assertRaises(lib_exc.Conflict, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 458 | self.client.unshelve_server, |
| 459 | self.server_id) |