summaryrefslogtreecommitdiff
path: root/tempest/api/compute/admin/test_delete_server.py
blob: c625939f3471fae8ba1845732e7ef4cda82e18ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from tempest.api.compute import base
from tempest.common import waiters
from tempest.lib import decorators


class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
    """Test deletion of servers"""

    # NOTE: Server creations of each test class should be under 10
    # for preventing "Quota exceeded for instances".

    @classmethod
    def setup_clients(cls):
        super(DeleteServersAdminTestJSON, cls).setup_clients()
        cls.non_admin_client = cls.servers_client
        cls.admin_client = cls.os_admin.servers_client

    @decorators.idempotent_id('99774678-e072-49d1-9d2a-49a59bc56063')
    def test_delete_server_while_in_error_state(self):
        """Delete a server while it's VM state is error"""
        server = self.create_test_server(wait_until='ACTIVE')
        self.admin_client.reset_state(server['id'], state='error')
        # Verify server's state
        server = self.non_admin_client.show_server(server['id'])['server']
        self.assertEqual(server['status'], 'ERROR')
        self.non_admin_client.delete_server(server['id'])
        waiters.wait_for_server_termination(self.servers_client,
                                            server['id'],
                                            ignore_error=True)

    @decorators.idempotent_id('73177903-6737-4f27-a60c-379e8ae8cf48')
    def test_admin_delete_servers_of_others(self):
        """Administrator can delete servers of others"""
        server = self.create_test_server(wait_until='ACTIVE')
        self.admin_client.delete_server(server['id'])
        waiters.wait_for_server_termination(self.servers_client, server['id'])