diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py index 0f753a0e58..c6e000cdb2 100644 --- a/tempest/api/compute/servers/test_servers_negative.py +++ b/tempest/api/compute/servers/test_servers_negative.py @@ -359,6 +359,36 @@ class ServersNegativeTestJSON(base.BaseV2ComputeTest): self.client.get_console_output, nonexistent_server, 10) + @attr(type=['negative', 'gate']) + def test_force_delete_nonexistent_server_id(self): + non_existent_server_id = str(uuid.uuid4()) + + self.assertRaises(exceptions.NotFound, + self.client.force_delete_server, + non_existent_server_id) + + @attr(type=['negative', 'gate']) + def test_force_delete_server_invalid_state(self): + # we can only force-delete a server in 'soft-delete' state + self.assertRaises(exceptions.Conflict, + self.client.force_delete_server, + self.server_id) + + @attr(type=['negative', 'gate']) + def test_restore_nonexistent_server_id(self): + non_existent_server_id = str(uuid.uuid4()) + + self.assertRaises(exceptions.NotFound, + self.client.restore_soft_deleted_server, + non_existent_server_id) + + @attr(type=['negative', 'gate']) + def test_restore_server_invalid_state(self): + # we can only restore-delete a server in 'soft-delete' state + self.assertRaises(exceptions.Conflict, + self.client.restore_soft_deleted_server, + self.server_id) + class ServersNegativeTestXML(ServersNegativeTestJSON): _interface = 'xml' diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py index 07bb6ceab0..55a4a1b992 100644 --- a/tempest/services/compute/json/servers_client.py +++ b/tempest/services/compute/json/servers_client.py @@ -390,3 +390,11 @@ class ServersClientJSON(RestClient): (str(server_id), str(request_id))) body = json.loads(body) return resp, body['instanceAction'] + + def force_delete_server(self, server_id, **kwargs): + """Force delete a server.""" + return self.action(server_id, 'forceDelete', None, **kwargs) + + def restore_soft_deleted_server(self, server_id, **kwargs): + """Restore a soft-deleted server.""" + return self.action(server_id, 'restore', None, **kwargs) diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py index 43de4ef85f..e21bfc4222 100644 --- a/tempest/services/compute/xml/servers_client.py +++ b/tempest/services/compute/xml/servers_client.py @@ -600,3 +600,11 @@ class ServersClientXML(RestClientXML): (server_id, request_id), self.headers) body = xml_to_json(etree.fromstring(body)) return resp, body + + def force_delete_server(self, server_id, **kwargs): + """Force delete a server.""" + return self.action(server_id, 'forceDelete', None, **kwargs) + + def restore_soft_deleted_server(self, server_id, **kwargs): + """Restore a soft-deleted server.""" + return self.action(server_id, 'restore', None, **kwargs)