diff --git a/zaqar_tempest_plugin/tests/base.py b/zaqar_tempest_plugin/tests/base.py index 044203c..c997bb7 100644 --- a/zaqar_tempest_plugin/tests/base.py +++ b/zaqar_tempest_plugin/tests/base.py @@ -146,31 +146,6 @@ class BaseMessagingTest(test.BaseTestCase): return rbody -class BaseV1MessagingTest(BaseMessagingTest): - """Base class for the Messaging (Zaqar) v1.0 tests.""" - @classmethod - def setup_clients(cls): - super(BaseV1MessagingTest, cls).setup_clients() - cls.client = messaging_client.V1MessagingClient( - cls.os_primary.auth_provider, - CONF.messaging.catalog_type, - CONF.identity.region, - build_interval=CONF.compute.build_interval, - build_timeout=CONF.compute.build_timeout) - - @classmethod - def check_queue_exists(cls, queue_name): - """Wrapper utility that checks the existence of a test queue.""" - resp, body = cls.client.show_queue(queue_name) - return resp, body - - @classmethod - def check_queue_exists_head(cls, queue_name): - """Wrapper utility checks the head of a queue via http HEAD.""" - resp, body = cls.client.head_queue(queue_name) - return resp, body - - class BaseV11MessagingTest(BaseMessagingTest): """Base class for the Messaging (Zaqar) v1.1 tests.""" @classmethod diff --git a/zaqar_tempest_plugin/tests/v1/__init__.py b/zaqar_tempest_plugin/tests/v1/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/zaqar_tempest_plugin/tests/v1/test_claims.py b/zaqar_tempest_plugin/tests/v1/test_claims.py deleted file mode 100644 index 9cdce2e..0000000 --- a/zaqar_tempest_plugin/tests/v1/test_claims.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (c) 2014 Rackspace, Inc. -# -# 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 urllib - -from tempest import config -from tempest.lib.common.utils import data_utils -from tempest.lib import decorators - -from zaqar_tempest_plugin.tests import base - - -CONF = config.CONF - - -class TestClaims(base.BaseV1MessagingTest): - - @classmethod - def resource_setup(cls): - super(TestClaims, cls).resource_setup() - cls.queue_name = data_utils.rand_name('Queues-Test') - # Create Queue - cls.create_queue(cls.queue_name) - - def _post_and_claim_messages(self, queue_name, repeat=1): - # Post Messages - message_body = self.generate_message_body(repeat=repeat) - self.client.post_messages(queue_name=self.queue_name, - rbody=message_body) - - # Post Claim - claim_ttl = data_utils.rand_int_id(start=60, - end=CONF.messaging.max_claim_ttl) - claim_grace = data_utils.\ - rand_int_id(start=60, end=CONF.messaging.max_claim_grace) - claim_body = {"ttl": claim_ttl, "grace": claim_grace} - resp, body = self.client.post_claims(queue_name=self.queue_name, - rbody=claim_body) - - return resp, body - - @decorators.idempotent_id('936cb1ca-b7af-44dd-a752-805e8c98156f') - def test_post_claim(self): - _, body = self._post_and_claim_messages(queue_name=self.queue_name) - claimed_message_uri = body[0]['href'] - - # Delete Claimed message - self.client.delete_messages(claimed_message_uri) - - @decorators.idempotent_id('84e491f4-68c6-451f-9846-b8f868eb27c5') - def test_query_claim(self): - # Post a Claim - resp, body = self._post_and_claim_messages(queue_name=self.queue_name) - - # Query Claim - claim_uri = resp['location'][resp['location'].find('/v1'):] - self.client.query_claim(claim_uri) - - # Delete Claimed message - claimed_message_uri = body[0]['href'] - self.delete_messages(claimed_message_uri) - - @decorators.idempotent_id('420ef0c5-9bd6-4b82-b06d-d9da330fefd3') - def test_update_claim(self): - # Post a Claim - resp, body = self._post_and_claim_messages(queue_name=self.queue_name) - - claim_uri = resp['location'][resp['location'].find('/v1'):] - claimed_message_uri = body[0]['href'] - - # Update Claim - claim_ttl = data_utils.rand_int_id(start=60, - end=CONF.messaging.max_claim_ttl) - update_rbody = {"ttl": claim_ttl} - - self.client.update_claim(claim_uri, rbody=update_rbody) - - # Verify claim ttl >= updated ttl value - _, body = self.client.query_claim(claim_uri) - updated_claim_ttl = body["ttl"] - self.assertGreaterEqual(claim_ttl, updated_claim_ttl) - - # Delete Claimed message - self.client.delete_messages(claimed_message_uri) - - @decorators.idempotent_id('fd4c7921-cb3f-4ed8-9ac8-e8f1e74c44aa') - def test_release_claim(self): - # Post a Claim - resp, body = self._post_and_claim_messages(queue_name=self.queue_name) - claim_uri = resp['location'][resp['location'].find('/v1'):] - - # Release Claim - self.client.delete_claim(claim_uri) - - # Delete Claimed message - # This will implicitly verify that the claim is deleted. - message_uri = urllib.parse.urlparse(claim_uri).path - self.client.delete_messages(message_uri) - - @classmethod - def resource_cleanup(cls): - cls.delete_queue(cls.queue_name) - super(TestClaims, cls).resource_cleanup() diff --git a/zaqar_tempest_plugin/tests/v1/test_messages.py b/zaqar_tempest_plugin/tests/v1/test_messages.py deleted file mode 100644 index 5da4d1a..0000000 --- a/zaqar_tempest_plugin/tests/v1/test_messages.py +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright (c) 2014 Rackspace, Inc. -# -# 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.common.utils import data_utils -from tempest.lib import decorators - -from zaqar_tempest_plugin.tests import base - -CONF = config.CONF - - -class TestMessages(base.BaseV1MessagingTest): - - @classmethod - def resource_setup(cls): - super(TestMessages, cls).resource_setup() - cls.queue_name = data_utils.rand_name('Queues-Test') - # Create Queue - cls.client.create_queue(cls.queue_name) - - def _post_messages(self, repeat=CONF.messaging.max_messages_per_page): - message_body = self.generate_message_body(repeat=repeat) - resp, body = self.post_messages(queue_name=self.queue_name, - rbody=message_body) - return resp, body - - @decorators.idempotent_id('93867172-a414-4eb3-a639-96e943c516b4') - def test_post_messages(self): - # Post Messages - resp, _ = self._post_messages() - - # Get on the posted messages - message_uri = resp['location'][resp['location'].find('/v1'):] - resp, _ = self.client.show_multiple_messages(message_uri) - # The test has an assertion here, because the response cannot be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('200', resp['status']) - - @decorators.idempotent_id('c967d59a-e919-41cb-994b-1c4300452c80') - def test_list_messages(self): - # Post Messages - self._post_messages() - - # List Messages - resp, _ = self.list_messages(queue_name=self.queue_name) - # The test has an assertion here, because the response cannot be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('200', resp['status']) - - @decorators.idempotent_id('2a68e3de-24df-47c3-9039-ec4156656bf8') - def test_get_message(self): - # Post Messages - _, body = self._post_messages() - message_uri = body['resources'][0] - - # Get posted message - resp, _ = self.client.show_single_message(message_uri) - # The test has an assertion here, because the response cannot be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('200', resp['status']) - - @decorators.idempotent_id('c4b0a30b-efda-4b87-a395-0c43140df74d') - def test_get_multiple_messages(self): - # Post Messages - resp, _ = self._post_messages() - message_uri = resp['location'][resp['location'].find('/v1'):] - - # Get posted messages - resp, _ = self.client.show_multiple_messages(message_uri) - # The test has an assertion here, because the response cannot be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('200', resp['status']) - - @decorators.idempotent_id('fc0fca47-dd8b-4ecc-8522-d9c191f9bc9f') - def test_delete_single_message(self): - # Post Messages - _, body = self._post_messages() - message_uri = body['resources'][0] - - # Delete posted message & verify the delete operration - self.client.delete_messages(message_uri) - - message_uri = message_uri.replace('/messages/', '/messages?ids=') - resp, _ = self.client.show_multiple_messages(message_uri) - # The test has an assertion here, because the response has to be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('204', resp['status']) - - @decorators.idempotent_id('00cca069-5c8f-4b42-bff1-c577da2a4546') - def test_delete_multiple_messages(self): - # Post Messages - resp, _ = self._post_messages() - message_uri = resp['location'][resp['location'].find('/v1'):] - - # Delete multiple messages - self.client.delete_messages(message_uri) - resp, _ = self.client.show_multiple_messages(message_uri) - # The test has an assertion here, because the response has to be 204 - # in this case (the client allows 200 or 204 for this API call). - self.assertEqual('204', resp['status']) - - @classmethod - def resource_cleanup(cls): - cls.delete_queue(cls.queue_name) - super(TestMessages, cls).resource_cleanup() diff --git a/zaqar_tempest_plugin/tests/v1/test_queues.py b/zaqar_tempest_plugin/tests/v1/test_queues.py deleted file mode 100644 index 1b470b9..0000000 --- a/zaqar_tempest_plugin/tests/v1/test_queues.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (c) 2014 Rackspace, Inc. -# -# 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.lib.common.utils import data_utils -from tempest.lib import decorators -from tempest.lib import exceptions as lib_exc -from testtools import matchers - -from zaqar_tempest_plugin.tests import base - - -class TestQueues(base.BaseV1MessagingTest): - - @decorators.idempotent_id('9f1c4c72-80c5-4dac-acf3-188cef42e36c') - def test_create_delete_queue(self): - # Create & Delete Queue - queue_name = data_utils.rand_name('test') - _, body = self.create_queue(queue_name) - - self.addCleanup(self.client.delete_queue, queue_name) - # NOTE(gmann): create_queue returns response status code as 201 - # so specifically checking the expected empty response body as - # this is not going to be checked in response_checker(). - self.assertEqual(b'', body) - - self.delete_queue(queue_name) - self.assertRaises(lib_exc.NotFound, - self.client.show_queue, - queue_name) - - -class TestManageQueue(base.BaseV1MessagingTest): - - @classmethod - def resource_setup(cls): - super(TestManageQueue, cls).resource_setup() - cls.queues = list() - for _ in range(5): - queue_name = data_utils.rand_name('Queues-Test') - cls.queues.append(queue_name) - # Create Queue - cls.client.create_queue(queue_name) - - @decorators.idempotent_id('ccd3d69e-f156-4c5f-8a12-b4f24bee44e1') - def test_check_queue_existence(self): - # Checking Queue Existence - for queue_name in self.queues: - self.check_queue_exists(queue_name) - - @decorators.idempotent_id('e27634d8-9c8f-47d8-a677-655c47658d3e') - def test_check_queue_head(self): - # Checking Queue Existence by calling HEAD - for queue_name in self.queues: - self.check_queue_exists_head(queue_name) - - @decorators.idempotent_id('0a0feeca-7768-4303-806d-82bbbb796ad3') - def test_list_queues(self): - # Listing queues - _, body = self.list_queues() - self.assertEqual(len(body['queues']), len(self.queues)) - for item in body['queues']: - self.assertIn(item['name'], self.queues) - - @decorators.idempotent_id('8fb66602-077d-49d6-ae1a-5f2091739178') - def test_get_queue_stats(self): - # Retrieve random queue - queue_name = self.queues[data_utils.rand_int_id(0, - len(self.queues) - 1)] - # Get Queue Stats for a newly created Queue - _, body = self.get_queue_stats(queue_name) - msgs = body['messages'] - for element in ('free', 'claimed', 'total'): - self.assertEqual(0, msgs[element]) - for element in ('oldest', 'newest'): - self.assertNotIn(element, msgs) - - @decorators.idempotent_id('0e2441e6-6593-4bdb-a3c0-20e66eeb3fff') - def test_set_and_get_queue_metadata(self): - # Retrieve random queue - queue_name = self.queues[data_utils.rand_int_id(0, - len(self.queues) - 1)] - # Check the Queue has no metadata - _, body = self.get_queue_metadata(queue_name) - self.assertThat(body, matchers.HasLength(0)) - # Create metadata - key3 = [0, 1, 2, 3, 4] - key2 = data_utils.rand_name('value') - req_body1 = dict() - req_body1[data_utils.rand_name('key3')] = key3 - req_body1[data_utils.rand_name('key2')] = key2 - req_body = dict() - req_body[data_utils.rand_name('key1')] = req_body1 - # Set Queue Metadata - self.set_queue_metadata(queue_name, req_body) - - # Get Queue Metadata - _, body = self.get_queue_metadata(queue_name) - self.assertThat(body, matchers.Equals(req_body)) - - @classmethod - def resource_cleanup(cls): - for queue_name in cls.queues: - cls.client.delete_queue(queue_name) - super(TestManageQueue, cls).resource_cleanup()