Add zaqar tempest plugin
This commit takes the zaqar tests which previously lived in tempest and creates an in-tree tempest plugin out of them. Change-Id: I06053d2d0d761c6398708280f3ef38274dec390c
This commit is contained in:
parent
b24be72fde
commit
dce51da5b0
@ -2,7 +2,6 @@
|
|||||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||||
${PYTHON:-python} $JIT_FLAG -m subunit.run discover -t . $LISTOPT $IDOPTION
|
${PYTHON:-python} $JIT_FLAG -m subunit.run discover -t ${OS_TOP_LEVEL:-./} ${OS_TEST_PATH:-./zaqar/tests/unit} $LISTOPT $IDOPTION
|
||||||
|
|
||||||
test_id_option=--load-list $IDFILE
|
test_id_option=--load-list $IDFILE
|
||||||
test_list_option=--list
|
test_list_option=--list
|
||||||
|
@ -73,6 +73,9 @@ zaqar.notification.tasks =
|
|||||||
https = zaqar.notification.task.webhook:WebhookTask
|
https = zaqar.notification.task.webhook:WebhookTask
|
||||||
mailto = zaqar.notification.task.mailto:MailtoTask
|
mailto = zaqar.notification.task.mailto:MailtoTask
|
||||||
|
|
||||||
|
tempest.test_plugins =
|
||||||
|
zaqar_tests = zaqar.tests.tempest_plugin.plugin:ZaqarTempestPlugin
|
||||||
|
|
||||||
[nosetests]
|
[nosetests]
|
||||||
where=zaqar/tests
|
where=zaqar/tests
|
||||||
verbosity=2
|
verbosity=2
|
||||||
|
@ -26,3 +26,6 @@ oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
|
|||||||
openstack-doc-tools>=0.23 # Apache-2.0
|
openstack-doc-tools>=0.23 # Apache-2.0
|
||||||
oslotest>=1.10.0 # Apache-2.0
|
oslotest>=1.10.0 # Apache-2.0
|
||||||
reno>=0.1.1 # Apache2
|
reno>=0.1.1 # Apache2
|
||||||
|
|
||||||
|
# Tempest Plugin
|
||||||
|
tempest-lib>=0.14.0 # Apache-2.0
|
||||||
|
3
tox.ini
3
tox.ini
@ -25,7 +25,8 @@ setenv = {[testenv]setenv}
|
|||||||
[testenv:integration]
|
[testenv:integration]
|
||||||
setenv = {[testenv]setenv}
|
setenv = {[testenv]setenv}
|
||||||
ZAQAR_TEST_INTEGRATION=1
|
ZAQAR_TEST_INTEGRATION=1
|
||||||
commands = python setup.py testr --slowest --testr-args='--concurrency 1 zaqar.tests.functional'
|
OS_TEST_PATH=./zaqar/tests/functional
|
||||||
|
commands = python setup.py testr --slowest --testr-args='--concurrency 1'
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands = flake8
|
commands = flake8
|
||||||
|
0
zaqar/tests/tempest_plugin/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/api_schema/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/api_schema/__init__.py
Normal file
238
zaqar/tests/tempest_plugin/api_schema/response/v1/queues.py
Normal file
238
zaqar/tests/tempest_plugin/api_schema/response/v1/queues.py
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
list_link = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'rel': {'type': 'string'},
|
||||||
|
'href': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'uri'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['href', 'rel']
|
||||||
|
}
|
||||||
|
|
||||||
|
list_queue = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'name': {'type': 'string'},
|
||||||
|
'href': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'uri'
|
||||||
|
},
|
||||||
|
'metadata': {'type': 'object'}
|
||||||
|
},
|
||||||
|
'required': ['name', 'href']
|
||||||
|
}
|
||||||
|
|
||||||
|
list_queues = {
|
||||||
|
'status_code': [200, 204],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'links': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': list_link,
|
||||||
|
'maxItems': 1
|
||||||
|
},
|
||||||
|
'queues': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': list_queue
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['links', 'queues']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
age = {
|
||||||
|
'type': 'number',
|
||||||
|
'minimum': 0
|
||||||
|
}
|
||||||
|
|
||||||
|
message_link = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'href': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'uri'
|
||||||
|
},
|
||||||
|
'age': age,
|
||||||
|
'created': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'date-time'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['href', 'age', 'created']
|
||||||
|
}
|
||||||
|
|
||||||
|
messages = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'free': {'type': 'number'},
|
||||||
|
'claimed': {'type': 'number'},
|
||||||
|
'total': {'type': 'number'},
|
||||||
|
'oldest': message_link,
|
||||||
|
'newest': message_link
|
||||||
|
},
|
||||||
|
'required': ['free', 'claimed', 'total']
|
||||||
|
}
|
||||||
|
|
||||||
|
queue_stats = {
|
||||||
|
'status_code': [200],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'messages': messages
|
||||||
|
},
|
||||||
|
'required': ['messages']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource_schema = {
|
||||||
|
'type': 'array',
|
||||||
|
'items': {
|
||||||
|
'type': 'string'
|
||||||
|
},
|
||||||
|
'minItems': 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post_messages = {
|
||||||
|
'status_code': [201],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'resources': resource_schema,
|
||||||
|
'partial': {'type': 'boolean'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['resources', 'partial']
|
||||||
|
}
|
||||||
|
|
||||||
|
message_ttl = {
|
||||||
|
'type': 'number',
|
||||||
|
'minimum': 1
|
||||||
|
}
|
||||||
|
|
||||||
|
list_messages_links = {
|
||||||
|
'type': 'array',
|
||||||
|
'maxItems': 1,
|
||||||
|
'minItems': 1,
|
||||||
|
'items': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'rel': {'type': 'string'},
|
||||||
|
'href': {'type': 'string'}
|
||||||
|
},
|
||||||
|
'required': ['rel', 'href']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list_messages_response = {
|
||||||
|
'type': 'array',
|
||||||
|
'minItems': 1,
|
||||||
|
'items': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'href': {'type': 'string'},
|
||||||
|
'ttl': message_ttl,
|
||||||
|
'age': age,
|
||||||
|
'body': {'type': 'object'}
|
||||||
|
},
|
||||||
|
'required': ['href', 'ttl', 'age', 'body']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list_messages = {
|
||||||
|
'status_code': [200, 204],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'links': list_messages_links,
|
||||||
|
'messages': list_messages_response
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['links', 'messages']
|
||||||
|
}
|
||||||
|
|
||||||
|
single_message = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'href': {'type': 'string'},
|
||||||
|
'ttl': message_ttl,
|
||||||
|
'age': age,
|
||||||
|
'body': {'type': 'object'}
|
||||||
|
},
|
||||||
|
'required': ['href', 'ttl', 'age', 'body']
|
||||||
|
}
|
||||||
|
|
||||||
|
get_single_message = {
|
||||||
|
'status_code': [200],
|
||||||
|
'response_body': single_message
|
||||||
|
}
|
||||||
|
|
||||||
|
get_multiple_messages = {
|
||||||
|
'status_code': [200],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': single_message,
|
||||||
|
'minItems': 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
messages_claimed = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'href': {
|
||||||
|
'type': 'string',
|
||||||
|
'format': 'uri'
|
||||||
|
},
|
||||||
|
'ttl': message_ttl,
|
||||||
|
'age': {'type': 'number'},
|
||||||
|
'body': {'type': 'object'}
|
||||||
|
},
|
||||||
|
'required': ['href', 'ttl', 'age', 'body']
|
||||||
|
}
|
||||||
|
|
||||||
|
claim_messages = {
|
||||||
|
'status_code': [201, 204],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': messages_claimed,
|
||||||
|
'minItems': 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
claim_ttl = {
|
||||||
|
'type': 'number',
|
||||||
|
'minimum': 1
|
||||||
|
}
|
||||||
|
|
||||||
|
query_claim = {
|
||||||
|
'status_code': [200],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'age': {'type': 'number'},
|
||||||
|
'ttl': claim_ttl,
|
||||||
|
'messages': {
|
||||||
|
'type': 'array',
|
||||||
|
'minItems': 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['ttl', 'age', 'messages']
|
||||||
|
}
|
||||||
|
}
|
56
zaqar/tests/tempest_plugin/config.py
Normal file
56
zaqar/tests/tempest_plugin/config.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# Copyright (c) 2016 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# 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 oslo_config import cfg
|
||||||
|
|
||||||
|
service_option = cfg.BoolOpt('zaqar',
|
||||||
|
default=False,
|
||||||
|
help="Whether or not Zaqar is expected to be "
|
||||||
|
"available"),
|
||||||
|
|
||||||
|
messaging_group = cfg.OptGroup(name='messaging',
|
||||||
|
title='Messaging Service')
|
||||||
|
|
||||||
|
MessagingGroup = [
|
||||||
|
cfg.StrOpt('catalog_type',
|
||||||
|
default='messaging',
|
||||||
|
help='Catalog type of the Messaging service.'),
|
||||||
|
cfg.IntOpt('max_queues_per_page',
|
||||||
|
default=20,
|
||||||
|
help='The maximum number of queue records per page when '
|
||||||
|
'listing queues'),
|
||||||
|
cfg.IntOpt('max_queue_metadata',
|
||||||
|
default=65536,
|
||||||
|
help='The maximum metadata size for a queue'),
|
||||||
|
cfg.IntOpt('max_messages_per_page',
|
||||||
|
default=20,
|
||||||
|
help='The maximum number of queue message per page when '
|
||||||
|
'listing (or) posting messages'),
|
||||||
|
cfg.IntOpt('max_message_size',
|
||||||
|
default=262144,
|
||||||
|
help='The maximum size of a message body'),
|
||||||
|
cfg.IntOpt('max_messages_per_claim',
|
||||||
|
default=20,
|
||||||
|
help='The maximum number of messages per claim'),
|
||||||
|
cfg.IntOpt('max_message_ttl',
|
||||||
|
default=1209600,
|
||||||
|
help='The maximum ttl for a message'),
|
||||||
|
cfg.IntOpt('max_claim_ttl',
|
||||||
|
default=43200,
|
||||||
|
help='The maximum ttl for a claim'),
|
||||||
|
cfg.IntOpt('max_claim_grace',
|
||||||
|
default=43200,
|
||||||
|
help='The maximum grace period for a claim'),
|
||||||
|
]
|
40
zaqar/tests/tempest_plugin/plugin.py
Normal file
40
zaqar/tests/tempest_plugin/plugin.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright (c) 2016 Hewlett-Packard Development Company, L.P.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 os
|
||||||
|
|
||||||
|
from tempest.test_discover import plugins
|
||||||
|
|
||||||
|
from zaqar.tests.tempest_plugin import config as zaqar_config
|
||||||
|
|
||||||
|
|
||||||
|
class ZaqarTempestPlugin(plugins.TempestPlugin):
|
||||||
|
def load_tests(self):
|
||||||
|
base_path = os.path.split(os.path.dirname(
|
||||||
|
os.path.abspath(__file__)))[0]
|
||||||
|
test_dir = "zaqar/tests/tempest_plugin/tests"
|
||||||
|
full_test_dir = os.path.join(base_path, test_dir)
|
||||||
|
return full_test_dir, base_path
|
||||||
|
|
||||||
|
def register_opts(self, conf):
|
||||||
|
conf.register_group(zaqar_config.messaging_group)
|
||||||
|
conf.register_opts(zaqar_config.MessagingGroup, group='messaging')
|
||||||
|
conf.register_opts(zaqar_config.service_option,
|
||||||
|
group='service_available')
|
||||||
|
|
||||||
|
def get_opt_lists(self):
|
||||||
|
return [('messaging', zaqar_config.MessagingGroup),
|
||||||
|
('service_available', [zaqar_config.service_option])]
|
0
zaqar/tests/tempest_plugin/services/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/services/__init__.py
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
# 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 uuid
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils as json
|
||||||
|
from six.moves.urllib import parse as urllib
|
||||||
|
from tempest_lib.common import rest_client
|
||||||
|
|
||||||
|
from zaqar.tests.tempest_plugin.api_schema.response.v1 import queues as schema
|
||||||
|
|
||||||
|
|
||||||
|
class MessagingClient(rest_client.RestClient):
|
||||||
|
|
||||||
|
def __init__(self, auth_provider, service, region,
|
||||||
|
endpoint_type=None, build_interval=None, build_timeout=None,
|
||||||
|
disable_ssl_certificate_validation=None, ca_certs=None,
|
||||||
|
trace_requests=None):
|
||||||
|
dscv = disable_ssl_certificate_validation
|
||||||
|
super(MessagingClient, self).__init__(
|
||||||
|
auth_provider, service, region,
|
||||||
|
endpoint_type=endpoint_type,
|
||||||
|
build_interval=build_interval,
|
||||||
|
build_timeout=build_timeout,
|
||||||
|
disable_ssl_certificate_validation=dscv,
|
||||||
|
ca_certs=ca_certs,
|
||||||
|
trace_requests=trace_requests)
|
||||||
|
|
||||||
|
self.version = '1'
|
||||||
|
self.uri_prefix = 'v{0}'.format(self.version)
|
||||||
|
|
||||||
|
client_id = uuid.uuid4().hex
|
||||||
|
self.headers = {'Client-ID': client_id}
|
||||||
|
|
||||||
|
def list_queues(self):
|
||||||
|
uri = '{0}/queues'.format(self.uri_prefix)
|
||||||
|
resp, body = self.get(uri)
|
||||||
|
|
||||||
|
if resp['status'] != '204':
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.list_queues, resp, body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def create_queue(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.put(uri, body=None)
|
||||||
|
self.expected_success(201, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def show_queue(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.get(uri)
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def head_queue(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.head(uri)
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def delete_queue(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.delete(uri)
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def show_queue_stats(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}/stats'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.get(uri)
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.queue_stats, resp, body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def show_queue_metadata(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}/metadata'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.get(uri)
|
||||||
|
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))
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def post_messages(self, queue_name, rbody):
|
||||||
|
uri = '{0}/queues/{1}/messages'.format(self.uri_prefix, queue_name)
|
||||||
|
resp, body = self.post(uri, body=json.dumps(rbody),
|
||||||
|
extra_headers=True,
|
||||||
|
headers=self.headers)
|
||||||
|
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.post_messages, resp, body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def list_messages(self, queue_name):
|
||||||
|
uri = '{0}/queues/{1}/messages?echo=True'.format(self.uri_prefix,
|
||||||
|
queue_name)
|
||||||
|
resp, body = self.get(uri, extra_headers=True, headers=self.headers)
|
||||||
|
|
||||||
|
if resp['status'] != '204':
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.list_messages, resp, body)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def show_single_message(self, message_uri):
|
||||||
|
resp, body = self.get(message_uri, extra_headers=True,
|
||||||
|
headers=self.headers)
|
||||||
|
if resp['status'] != '204':
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.get_single_message, resp,
|
||||||
|
body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def show_multiple_messages(self, message_uri):
|
||||||
|
resp, body = self.get(message_uri, extra_headers=True,
|
||||||
|
headers=self.headers)
|
||||||
|
|
||||||
|
if resp['status'] != '204':
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.get_multiple_messages,
|
||||||
|
resp,
|
||||||
|
body)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def delete_messages(self, message_uri):
|
||||||
|
resp, body = self.delete(message_uri)
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def post_claims(self, queue_name, rbody, url_params=False):
|
||||||
|
uri = '{0}/queues/{1}/claims'.format(self.uri_prefix, queue_name)
|
||||||
|
if url_params:
|
||||||
|
uri += '?%s' % urllib.urlencode(url_params)
|
||||||
|
|
||||||
|
resp, body = self.post(uri, body=json.dumps(rbody),
|
||||||
|
extra_headers=True,
|
||||||
|
headers=self.headers)
|
||||||
|
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.claim_messages, resp, body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def query_claim(self, claim_uri):
|
||||||
|
resp, body = self.get(claim_uri)
|
||||||
|
|
||||||
|
if resp['status'] != '204':
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.query_claim, resp, body)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def update_claim(self, claim_uri, rbody):
|
||||||
|
resp, body = self.patch(claim_uri, body=json.dumps(rbody))
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
def delete_claim(self, claim_uri):
|
||||||
|
resp, body = self.delete(claim_uri)
|
||||||
|
self.expected_success(204, resp.status)
|
||||||
|
return resp, body
|
0
zaqar/tests/tempest_plugin/tests/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/tests/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/tests/api/__init__.py
Normal file
0
zaqar/tests/tempest_plugin/tests/api/__init__.py
Normal file
167
zaqar/tests/tempest_plugin/tests/api/base.py
Normal file
167
zaqar/tests/tempest_plugin/tests/api/base.py
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
# 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 import test
|
||||||
|
from tempest_lib.common.utils import data_utils
|
||||||
|
|
||||||
|
from zaqar.tests.tempest_plugin.services.messaging.json import messaging_client
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class BaseMessagingTest(test.BaseTestCase):
|
||||||
|
|
||||||
|
"""Base class for the Messaging (Zaqar) tests
|
||||||
|
|
||||||
|
It is assumed that the following option is defined in the
|
||||||
|
[service_available] section of etc/tempest.conf
|
||||||
|
|
||||||
|
messaging as True
|
||||||
|
"""
|
||||||
|
|
||||||
|
credentials = ['primary']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def skip_checks(cls):
|
||||||
|
super(BaseMessagingTest, cls).skip_checks()
|
||||||
|
if not CONF.service_available.zaqar:
|
||||||
|
raise cls.skipException("Zaqar support is required")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setup_clients(cls):
|
||||||
|
super(BaseMessagingTest, cls).setup_clients()
|
||||||
|
cls.client = messaging_client.MessagingClient(
|
||||||
|
cls.os.auth_provider,
|
||||||
|
CONF.messaging.catalog_type,
|
||||||
|
CONF.identity.region,
|
||||||
|
**cls.os.default_params_with_timeout_values)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def resource_setup(cls):
|
||||||
|
super(BaseMessagingTest, cls).resource_setup()
|
||||||
|
cls.messaging_cfg = CONF.messaging
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create_queue(cls, queue_name):
|
||||||
|
"""Wrapper utility that returns a test queue."""
|
||||||
|
resp, body = cls.client.create_queue(queue_name)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def delete_queue(cls, queue_name):
|
||||||
|
"""Wrapper utility that deletes a test queue."""
|
||||||
|
resp, body = cls.client.delete_queue(queue_name)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def list_queues(cls):
|
||||||
|
"""Wrapper utility that lists queues."""
|
||||||
|
resp, body = cls.client.list_queues()
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_queue_stats(cls, queue_name):
|
||||||
|
"""Wrapper utility that returns the queue stats."""
|
||||||
|
resp, body = cls.client.show_queue_stats(queue_name)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_queue_metadata(cls, queue_name):
|
||||||
|
"""Wrapper utility that gets a queue metadata."""
|
||||||
|
resp, body = cls.client.show_queue_metadata(queue_name)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_queue_metadata(cls, queue_name, rbody):
|
||||||
|
"""Wrapper utility that sets the metadata of a queue."""
|
||||||
|
resp, body = cls.client.set_queue_metadata(queue_name, rbody)
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def post_messages(cls, queue_name, rbody):
|
||||||
|
"""Wrapper utility that posts messages to a queue."""
|
||||||
|
resp, body = cls.client.post_messages(queue_name, rbody)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def list_messages(cls, queue_name):
|
||||||
|
"""Wrapper utility that lists the messages in a queue."""
|
||||||
|
resp, body = cls.client.list_messages(queue_name)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def delete_messages(cls, message_uri):
|
||||||
|
"""Wrapper utility that deletes messages."""
|
||||||
|
resp, body = cls.client.delete_messages(message_uri)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def post_claims(cls, queue_name, rbody, url_params=False):
|
||||||
|
"""Wrapper utility that claims messages."""
|
||||||
|
resp, body = cls.client.post_claims(
|
||||||
|
queue_name, rbody, url_params=False)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def query_claim(cls, claim_uri):
|
||||||
|
"""Wrapper utility that gets a claim."""
|
||||||
|
resp, body = cls.client.query_claim(claim_uri)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_claim(cls, claim_uri, rbody):
|
||||||
|
"""Wrapper utility that updates a claim."""
|
||||||
|
resp, body = cls.client.update_claim(claim_uri, rbody)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def release_claim(cls, claim_uri):
|
||||||
|
"""Wrapper utility that deletes a claim."""
|
||||||
|
resp, body = cls.client.delete_claim(claim_uri)
|
||||||
|
|
||||||
|
return resp, body
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def generate_message_body(cls, repeat=1):
|
||||||
|
"""Wrapper utility that sets the metadata of a queue."""
|
||||||
|
message_ttl = data_utils.\
|
||||||
|
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
|
||||||
|
|
||||||
|
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
|
||||||
|
value = data_utils.arbitrary_string(size=20,
|
||||||
|
base_text='MessagingValue')
|
||||||
|
message_body = {key: value}
|
||||||
|
|
||||||
|
rbody = ([{'body': message_body, 'ttl': message_ttl}] * repeat)
|
||||||
|
return rbody
|
120
zaqar/tests/tempest_plugin/tests/api/test_claims.py
Normal file
120
zaqar/tests/tempest_plugin/tests/api/test_claims.py
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
# 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 six.moves.urllib import parse as urlparse
|
||||||
|
from tempest import config
|
||||||
|
from tempest_lib.common.utils import data_utils
|
||||||
|
from tempest_lib import decorators
|
||||||
|
|
||||||
|
from zaqar.tests.tempest_plugin.tests.api import base
|
||||||
|
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class TestClaims(base.BaseMessagingTest):
|
||||||
|
|
||||||
|
@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']
|
||||||
|
|
||||||
|
# Skipping this step till bug-1331517 is fixed
|
||||||
|
# Get posted claim
|
||||||
|
# self.client.query_claim(claimed_message_uri)
|
||||||
|
|
||||||
|
# Delete Claimed message
|
||||||
|
self.client.delete_messages(claimed_message_uri)
|
||||||
|
|
||||||
|
@decorators.skip_because(bug="1331517")
|
||||||
|
@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']
|
||||||
|
self.client.query_claim(claim_uri)
|
||||||
|
|
||||||
|
# Delete Claimed message
|
||||||
|
claimed_message_uri = body[0]['href']
|
||||||
|
self.delete_messages(claimed_message_uri)
|
||||||
|
|
||||||
|
@decorators.skip_because(bug="1328111")
|
||||||
|
@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']
|
||||||
|
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.assertTrue(updated_claim_ttl >= 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']
|
||||||
|
|
||||||
|
# Release Claim
|
||||||
|
self.client.delete_claim(claim_uri)
|
||||||
|
|
||||||
|
# Delete Claimed message
|
||||||
|
# This will implicitly verify that the claim is deleted.
|
||||||
|
message_uri = urlparse.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()
|
118
zaqar/tests/tempest_plugin/tests/api/test_messages.py
Normal file
118
zaqar/tests/tempest_plugin/tests/api/test_messages.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# 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.tests.tempest_plugin.tests.api import base
|
||||||
|
|
||||||
|
CONF = config.CONF
|
||||||
|
|
||||||
|
|
||||||
|
class TestMessages(base.BaseMessagingTest):
|
||||||
|
|
||||||
|
@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, _ = 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']
|
||||||
|
|
||||||
|
# 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']
|
||||||
|
|
||||||
|
# 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()
|
118
zaqar/tests/tempest_plugin/tests/api/test_queues.py
Normal file
118
zaqar/tests/tempest_plugin/tests/api/test_queues.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# 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 six import moves
|
||||||
|
from tempest.common.utils import data_utils
|
||||||
|
from tempest_lib import decorators
|
||||||
|
from tempest_lib import exceptions as lib_exc
|
||||||
|
from testtools import matchers
|
||||||
|
|
||||||
|
from zaqar.tests.tempest_plugin.tests.api import base
|
||||||
|
|
||||||
|
|
||||||
|
class TestQueues(base.BaseMessagingTest):
|
||||||
|
|
||||||
|
@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('', body)
|
||||||
|
|
||||||
|
self.delete_queue(queue_name)
|
||||||
|
self.assertRaises(lib_exc.NotFound,
|
||||||
|
self.client.show_queue,
|
||||||
|
queue_name)
|
||||||
|
|
||||||
|
|
||||||
|
class TestManageQueue(base.BaseMessagingTest):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def resource_setup(cls):
|
||||||
|
super(TestManageQueue, cls).resource_setup()
|
||||||
|
cls.queues = list()
|
||||||
|
for _ in moves.xrange(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()
|
Loading…
Reference in New Issue
Block a user