Merge "Update tests to work with updated cluster delete"

This commit is contained in:
Zuul 2019-05-13 18:54:37 +00:00 committed by Gerrit Code Review
commit a082e32e9f
3 changed files with 66 additions and 63 deletions

View File

@ -43,5 +43,9 @@ ClusteringGroup = [
"Tempest selects tests based on the range between "
"microversion and max_microversion. If both values "
"are None, Tempest avoids tests which require a "
"microversion.")
"microversion."),
cfg.BoolOpt('delete_with_dependency',
default=False,
help="Enables tests that delete clusters with resources such "
"as policies or receivers attached to it.")
]

View File

@ -10,11 +10,15 @@
# 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):
@ -37,3 +41,60 @@ class TestClusterDelete(base.BaseSenlinAPITest):
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')

View File

@ -17,68 +17,6 @@ from senlin_tempest_plugin.common import utils
from senlin_tempest_plugin.tests.api import base
class TestClusterDeleteNegativePolicyConflict(base.BaseSenlinAPITest):
def setUp(self):
super(TestClusterDeleteNegativePolicyConflict, 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.addCleanup(utils.delete_a_cluster, self, self.cluster_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)
self.addCleanup(utils.cluster_detach_policy, self, self.cluster_id,
policy_id)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0de81427-2b2f-4821-9462-c893d35fb212')
def test_cluster_delete_policy_conflict(self):
# Verify conflict exception(409) is raised.
ex = self.assertRaises(exceptions.Conflict,
self.client.delete_obj,
'clusters', self.cluster_id)
message = ex.resp_body['error']['message']
self.assertEqual(
"The cluster '%s' cannot be deleted: there is still "
"policy(s) attached to it." % self.cluster_id,
str(message))
class TestClusterDeleteNegativeReceiverConflict(base.BaseSenlinAPITest):
def setUp(self):
super(TestClusterDeleteNegativeReceiverConflict, 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.addCleanup(utils.delete_a_cluster, self, self.cluster_id)
self.receiver_id = utils.create_a_receiver(
self, self.cluster_id, 'CLUSTER_SCALE_OUT', 'webhook',
'fake', params={'count': '1'})
self.addCleanup(utils.delete_a_receiver, self, self.receiver_id)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0de81427-2b2f-4821-9462-c893d35fb212')
def test_cluster_delete_receiver_conflict(self):
# Verify conflict exception(409) is raised.
ex = self.assertRaises(exceptions.Conflict,
self.client.delete_obj,
'clusters', self.cluster_id)
message = ex.resp_body['error']['message']
self.assertEqual(
"The cluster '%s' cannot be deleted: there is still "
"receiver(s) associated with it." % self.cluster_id,
str(message))
class TestClusterDeleteNegativeNotFound(base.BaseSenlinAPITest):
@decorators.attr(type=['negative'])