summaryrefslogtreecommitdiff
path: root/trove/tests/scenario/runners/instance_delete_runners.py
blob: f5d1bb3e5711cf551b8224841d9ece11e6ca9091 (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
# Copyright 2015 Tesora Inc.
# 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.

import proboscis

from trove.tests.scenario.runners.test_runners import TestRunner


class InstanceDeleteRunner(TestRunner):

    def __init__(self):
        super(InstanceDeleteRunner, self).__init__()

    def run_instance_delete(self, expected_http_code=202):
        if self.has_do_not_delete_instance:
            self.report.log("TESTS_DO_NOT_DELETE_INSTANCE=True was "
                            "specified, skipping delete...")
            raise proboscis.SkipTest("TESTS_DO_NOT_DELETE_INSTANCE "
                                     "was specified.")

        self.assert_instance_delete(self.instance_info.id, expected_http_code)

    def assert_instance_delete(self, instance_id, expected_http_code):
        self.report.log("Testing delete on instance: %s" % instance_id)

        self.auth_client.instances.delete(instance_id)
        self.assert_client_code(expected_http_code, client=self.auth_client)

    def run_instance_delete_wait(self, expected_states=['SHUTDOWN']):
        if self.has_do_not_delete_instance:
            self.report.log("TESTS_DO_NOT_DELETE_INSTANCE=True was "
                            "specified, skipping delete wait...")
            raise proboscis.SkipTest("TESTS_DO_NOT_DELETE_INSTANCE "
                                     "was specified.")
        self.assert_all_gone(self.instance_info.id, expected_states[-1])
        self.assert_server_group_gone(self.instance_info.srv_grp_id)