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