blob: 564961943012faa442fdde141b2fb0be740ec7bd [file] [log] [blame]
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -05001# Copyright (c) 2014 Rackspace, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from tempest import config
17from tempest.openstack.common import log as logging
18from tempest import test
19
20CONF = config.CONF
21
22LOG = logging.getLogger(__name__)
23
24
25class BaseQueuingTest(test.BaseTestCase):
26
27 """
28 Base class for the Queuing tests that use the Tempest Marconi REST client
29
30 It is assumed that the following option is defined in the
31 [service_available] section of etc/tempest.conf
32
33 queuing as True
34 """
35
36 @classmethod
37 def setUpClass(cls):
38 super(BaseQueuingTest, cls).setUpClass()
39 if not CONF.service_available.marconi:
40 raise cls.skipException("Marconi support is required")
41 os = cls.get_client_manager()
42 cls.queuing_cfg = CONF.queuing
43 cls.client = os.queuing_client
44
45 @classmethod
46 def create_queue(cls, queue_name):
47 """Wrapper utility that returns a test queue."""
48 resp, body = cls.client.create_queue(queue_name)
49 return resp, body
Jorge Chai4f5896e2014-02-17 14:34:54 -050050
51 @classmethod
52 def delete_queue(cls, queue_name):
Jorge Chai83ba4ee2014-04-15 18:58:08 +000053 """Wrapper utility that deletes a test queue."""
Jorge Chai4f5896e2014-02-17 14:34:54 -050054 resp, body = cls.client.delete_queue(queue_name)
55 return resp, body
Jorge Chai83ba4ee2014-04-15 18:58:08 +000056
57 @classmethod
58 def check_queue_exists(cls, queue_name):
59 """Wrapper utility that checks the existence of a test queue."""
60 resp, body = cls.client.get_queue(queue_name)
61 return resp, body
62
63 @classmethod
64 def check_queue_exists_head(cls, queue_name):
65 """Wrapper utility checks the head of a queue via http HEAD."""
66 resp, body = cls.client.head_queue(queue_name)
67 return resp, body
68
69 @classmethod
70 def list_queues(cls):
71 """Wrapper utility that lists queues."""
72 resp, body = cls.client.list_queues()
73 return resp, body
74
75 @classmethod
76 def get_queue_stats(cls, queue_name):
77 """Wrapper utility that returns the queue stats."""
78 resp, body = cls.client.get_queue_stats(queue_name)
79 return resp, body
80
81 @classmethod
82 def get_queue_metadata(cls, queue_name):
83 """Wrapper utility that gets a queue metadata."""
84 resp, body = cls.client.get_queue_metadata(queue_name)
85 return resp, body
86
87 @classmethod
88 def set_queue_metadata(cls, queue_name, rbody):
89 """Wrapper utility that sets the metadata of a queue."""
90 resp, body = cls.client.set_queue_metadata(queue_name, rbody)
91 return resp, body