blob: 58cac57f5c4390cc0af1ace3a8a6ba828063644d [file] [log] [blame]
Ken'ichi Ohmichi3cf16272017-04-25 11:49:18 -07001# Copyright 2012 OpenStack Foundation
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
16from tempest.api.compute import base
17from tempest.common import waiters
Ken'ichi Ohmichi3cf16272017-04-25 11:49:18 -070018from tempest.lib import decorators
19
Ken'ichi Ohmichi3cf16272017-04-25 11:49:18 -070020
21class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
22 # NOTE: Server creations of each test class should be under 10
23 # for preventing "Quota exceeded for instances".
24
25 @classmethod
26 def setup_clients(cls):
27 super(DeleteServersAdminTestJSON, cls).setup_clients()
28 cls.non_admin_client = cls.servers_client
jeremy.zhangd2c03942017-05-24 19:58:34 +080029 cls.admin_client = cls.os_admin.servers_client
Ken'ichi Ohmichi3cf16272017-04-25 11:49:18 -070030
31 @decorators.idempotent_id('99774678-e072-49d1-9d2a-49a59bc56063')
32 def test_delete_server_while_in_error_state(self):
33 # Delete a server while it's VM state is error
34 server = self.create_test_server(wait_until='ACTIVE')
35 self.admin_client.reset_state(server['id'], state='error')
36 # Verify server's state
37 server = self.non_admin_client.show_server(server['id'])['server']
38 self.assertEqual(server['status'], 'ERROR')
39 self.non_admin_client.delete_server(server['id'])
40 waiters.wait_for_server_termination(self.servers_client,
41 server['id'],
42 ignore_error=True)
43
44 @decorators.idempotent_id('73177903-6737-4f27-a60c-379e8ae8cf48')
45 def test_admin_delete_servers_of_others(self):
46 # Administrator can delete servers of others
47 server = self.create_test_server(wait_until='ACTIVE')
48 self.admin_client.delete_server(server['id'])
49 waiters.wait_for_server_termination(self.servers_client, server['id'])