diff --git a/zaqar/tests/tempest_plugin/services/messaging/json/messaging_client.py b/zaqar/tests/tempest_plugin/services/messaging/json/messaging_client.py index f1ec759..9f3a44b 100644 --- a/zaqar/tests/tempest_plugin/services/messaging/json/messaging_client.py +++ b/zaqar/tests/tempest_plugin/services/messaging/json/messaging_client.py @@ -370,17 +370,20 @@ class V2MessagingClient(MessagingClient): return resp, body def show_queue_metadata(self, queue_name): - uri = '{0}/queues/{1}/metadata'.format(self.uri_prefix, queue_name) + uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) resp, body = self.get(uri, headers=self.headers) self.expected_success(200, resp.status) body = json.loads(body) return resp, body def set_queue_metadata(self, queue_name, rbody): - uri = '{0}/queues/{1}/metadata'.format(self.uri_prefix, queue_name) - resp, body = self.put(uri, body=json.dumps(rbody), - headers=self.headers) - self.expected_success(204, resp.status) + uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name) + headers = self.headers.copy() + headers['Content-Type'] =\ + 'application/openstack-messaging-v2.0-json-patch' + resp, body = self.patch(uri, body=json.dumps(rbody), + headers=headers) + self.expected_success(200, resp.status) return resp, body def post_messages(self, queue_name, rbody): @@ -439,8 +442,9 @@ class V2MessagingClient(MessagingClient): extra_headers=True, headers=self.headers) - body = json.loads(body) - self.validate_response(v2schema.claim_messages, resp, body) + if resp['status'] != '204': + body = json.loads(body) + self.validate_response(v2schema.claim_messages, resp, body) return resp, body def query_claim(self, claim_uri): diff --git a/zaqar/tests/tempest_plugin/tests/v1_1/test_queues.py b/zaqar/tests/tempest_plugin/tests/v1_1/test_queues.py index 4cbfb17..27f7152 100644 --- a/zaqar/tests/tempest_plugin/tests/v1_1/test_queues.py +++ b/zaqar/tests/tempest_plugin/tests/v1_1/test_queues.py @@ -17,7 +17,6 @@ from six import moves from tempest.lib.common.utils import data_utils from tempest.lib import decorators -from testtools import matchers from zaqar.tests.tempest_plugin.tests import base @@ -74,30 +73,6 @@ class TestManageQueue(base.BaseV11MessagingTest): for element in ('oldest', 'newest'): self.assertNotIn(element, msgs) - @decorators.skip_because(bug='1543900') - @decorators.idempotent_id('883a5fba-fb87-4663-b941-cf4a25e64607') - 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: diff --git a/zaqar/tests/tempest_plugin/tests/v2/test_queues.py b/zaqar/tests/tempest_plugin/tests/v2/test_queues.py index 492f441..71dca37 100644 --- a/zaqar/tests/tempest_plugin/tests/v2/test_queues.py +++ b/zaqar/tests/tempest_plugin/tests/v2/test_queues.py @@ -93,29 +93,31 @@ class TestManageQueue(base.BaseV2MessagingTest): for element in ('oldest', 'newest'): self.assertNotIn(element, msgs) - @decorators.skip_because(bug='1543900') @decorators.idempotent_id('dfb1e0b0-b481-4e2a-91ae-2c28b65e9c28') 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)) + QueueName = "QueueWithMeta" + self.client.create_queue(QueueName) + _, body = self.get_queue_metadata(QueueName) + self.assertThat(body, matchers.HasLength(2)) + self.assertEqual(262144, body['_max_messages_post_size']) + self.assertEqual(3600, body['_default_message_ttl']) # 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 + op1 = {"op": "add", + "path": "/metadata/_max_claim_count", "value": 2} + op2 = {"op": "add", + "path": "/metadata/_dead_letter_queue_messages_ttl", + "value": 7799} + metadata = [op1, op2] # Set Queue Metadata - self.set_queue_metadata(queue_name, req_body) - + self.set_queue_metadata(QueueName, metadata) # Get Queue Metadata - _, body = self.get_queue_metadata(queue_name) - self.assertThat(body, matchers.Equals(req_body)) + _, body = self.get_queue_metadata(QueueName) + self.assertThat(body, matchers.HasLength(4)) + self.assertEqual(262144, body['_max_messages_post_size']) + self.assertEqual(7799, body['_dead_letter_queue_messages_ttl']) + self.assertEqual(2, body['_max_claim_count']) + self.assertEqual(3600, body['_default_message_ttl']) + self.client.delete_queue(QueueName) @decorators.idempotent_id('2fb6e5a8-c18f-4407-9ee7-7a13c8e09f69') def test_purge_queue(self):