File: test_cluster_delete.py

package info (click to toggle)
senlin-tempest-plugin 1.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 888 kB
  • sloc: python: 7,478; sh: 34; makefile: 21
file content (100 lines) | stat: -rw-r--r-- 3,885 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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 import config
from tempest.lib import decorators
import testtools

from senlin_tempest_plugin.common import utils
from senlin_tempest_plugin.tests.api import base

CONF = config.CONF


class TestClusterDelete(base.BaseSenlinAPITest):

    def setUp(self):
        super(TestClusterDelete, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        # cluster will be deleted by test case
        self.cluster_id = utils.create_a_cluster(self, profile_id)

    @decorators.idempotent_id('33d7426e-0138-42c9-9ab4-ba796a7d1fdc')
    def test_cluster_delete_in_active_status(self):
        res = self.client.delete_obj('clusters', self.cluster_id)

        # Verify resp code, body and location in headers
        self.assertEqual(202, res['status'])
        self.assertIsNone(res['body'])
        self.assertIn('actions', res['location'])

        action_id = res['location'].split('/actions/')[1]
        self.client.wait_for_status('actions', action_id, 'SUCCEEDED')


class TestClusterDeleteWithPolicy(base.BaseSenlinAPITest):

    def setUp(self):
        super(TestClusterDeleteWithPolicy, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        self.cluster_id = utils.create_a_cluster(self, profile_id)

        policy_id = utils.create_a_policy(self)
        self.addCleanup(utils.delete_a_policy, self, policy_id)

        utils.cluster_attach_policy(self, self.cluster_id, policy_id)

    @decorators.idempotent_id('e563b05d-6b7f-4207-a7ac-e48e6607d4d8')
    @testtools.skipUnless(CONF.clustering.delete_with_dependency,
                          'Deleting clusters with dependancies not enabled')
    def test_cluster_delete_policy(self):
        res = self.client.delete_obj('clusters', self.cluster_id)

        # Verify resp code, body and location in headers
        self.assertEqual(202, res['status'])
        self.assertIsNone(res['body'])
        self.assertIn('actions', res['location'])

        action_id = res['location'].split('/actions/')[1]
        self.client.wait_for_status('actions', action_id, 'SUCCEEDED')


class TestClusterDeleteReceiver(base.BaseSenlinAPITest):

    def setUp(self):
        super(TestClusterDeleteReceiver, self).setUp()
        profile_id = utils.create_a_profile(self)
        self.addCleanup(utils.delete_a_profile, self, profile_id)

        self.cluster_id = utils.create_a_cluster(self, profile_id)

        self.receiver_id = utils.create_a_receiver(
            self, self.cluster_id, 'CLUSTER_SCALE_OUT', 'webhook',
            'fake', params={'count': '1'})

    @decorators.idempotent_id('bff84a28-1b81-42f2-ae88-42f50c9f0bb9')
    @testtools.skipUnless(CONF.clustering.delete_with_dependency,
                          'Deleting clusters with dependancies not enabled')
    def test_cluster_delete_receiver(self):
        res = self.client.delete_obj('clusters', self.cluster_id)

        # Verify resp code, body and location in headers
        self.assertEqual(202, res['status'])
        self.assertIsNone(res['body'])
        self.assertIn('actions', res['location'])

        action_id = res['location'].split('/actions/')[1]
        self.client.wait_for_status('actions', action_id, 'SUCCEEDED')