Add reserved metadatas for dead letter queue

We support dead letter queue in Queens. There
are some new reserved metadatas which should be
returned.

Change-Id: Iba5add5b75fa67e025ec89a887db0d04fb61548a
This commit is contained in:
wanghao 2018-03-07 16:18:24 +08:00
parent e66ca5c7c9
commit 83300343d2
4 changed files with 31 additions and 3 deletions

View File

@ -2,5 +2,8 @@
"_max_messages_post_size": 262144,
"_default_message_ttl": 3600,
"_default_message_delay": 30,
"_dead_letter_queue": "dead_letter",
"_dead_letter_queue_messages_ttl": 3600,
"_max_claim_count": 10,
"description": "Queue for international traffic billing."
}

View File

@ -0,0 +1,6 @@
---
features:
- Add three new reserved metdata in response body of querying queue.
"_dead_letter_queue", "_dead_letter_queue_messages_ttl" and
"_max_claim_count". Those metadata will help user to know better about
dead letter queue.

View File

@ -110,6 +110,9 @@ class TestQueueLifecycleMongoDB(base.V2Base):
ref_doc['_default_message_ttl'] = 3600
ref_doc['_max_messages_post_size'] = 262144
ref_doc['_default_message_delay'] = 0
ref_doc['_dead_letter_queue'] = None
ref_doc['_dead_letter_queue_messages_ttl'] = None
ref_doc['_max_claim_count'] = None
self.assertEqual(ref_doc, result_doc)
# Stats empty queue
@ -247,6 +250,9 @@ class TestQueueLifecycleMongoDB(base.V2Base):
ref_doc['_default_message_ttl'] = 3600
ref_doc['_max_messages_post_size'] = 262144
ref_doc['_default_message_delay'] = 0
ref_doc['_dead_letter_queue'] = None
ref_doc['_dead_letter_queue_messages_ttl'] = None
ref_doc['_max_claim_count'] = None
self.assertEqual(ref_doc, result_doc)
self.assertEqual(falcon.HTTP_200, self.srmock.status)
@ -301,7 +307,10 @@ class TestQueueLifecycleMongoDB(base.V2Base):
self.assertEqual({'key1': 2, 'key2': 1,
'_default_message_ttl': 300,
'_max_messages_post_size': 262144,
'_default_message_delay': 0}, result_doc)
'_default_message_delay': 0,
'_dead_letter_queue': None,
'_dead_letter_queue_messages_ttl': None,
'_max_claim_count': None}, result_doc)
# remove metadata
doc3 = '[{"op":"remove", "path": "/metadata/key1"}]'
@ -323,7 +332,10 @@ class TestQueueLifecycleMongoDB(base.V2Base):
result_doc = jsonutils.loads(result[0])
self.assertEqual({'key2': 1, '_default_message_ttl': 3600,
'_max_messages_post_size': 262144,
'_default_message_delay': 0}, result_doc)
'_default_message_delay': 0,
'_dead_letter_queue': None,
'_dead_letter_queue_messages_ttl': None,
'_max_claim_count': None}, result_doc)
# replace non-existent metadata
doc4 = '[{"op":"replace", "path": "/metadata/key3", "value":2}]'
@ -438,7 +450,10 @@ class TestQueueLifecycleMongoDB(base.V2Base):
self.assertEqual(queue['metadata'], result_doc)
self.assertEqual({'node': 31, '_default_message_ttl': 3600,
'_max_messages_post_size': 262144,
'_default_message_delay': 0}, result_doc)
'_default_message_delay': 0,
'_dead_letter_queue': None,
'_dead_letter_queue_messages_ttl': None,
'_max_claim_count': None}, result_doc)
# List tail
self.simulate_get(target, headers=header, query_string=params)

View File

@ -37,6 +37,10 @@ def _get_reserved_metadata(validate):
validate.get_limit_conf_value(meta)
for meta in _reserved_metadata
}
for metadata in ['_dead_letter_queue', '_dead_letter_queue_messages_ttl',
'_max_claim_count']:
reserved_metadata.update({metadata: None})
return reserved_metadata