Adds basic Marconi test

This patch adds the config options needed to add Queuing tests.
This patch also has a basic test to verify that everything works
as expected.

Change-Id: I0769affe66a1e94bff366305e230c1b388e68278
Implements: blueprint add-basic-marconi-tests
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index b0c7826..872cac0 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -712,6 +712,16 @@
 #max_template_size=524288
 
 
+[queuing]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Queuing service. (string value)
+#catalog_type=queuing
+
+
 [scenario]
 
 #
@@ -791,6 +801,10 @@
 # value)
 #trove=false
 
+# Whether or not Marconi is expected to be available (boolean
+# value)
+#marconi=false
+
 
 [stress]
 
diff --git a/tempest/api/queuing/__init__.py b/tempest/api/queuing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/api/queuing/__init__.py
diff --git a/tempest/api/queuing/base.py b/tempest/api/queuing/base.py
new file mode 100644
index 0000000..5656850
--- /dev/null
+++ b/tempest/api/queuing/base.py
@@ -0,0 +1,49 @@
+# 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.openstack.common import log as logging
+from tempest import test
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+class BaseQueuingTest(test.BaseTestCase):
+
+    """
+    Base class for the Queuing tests that use the Tempest Marconi REST client
+
+    It is assumed that the following option is defined in the
+    [service_available] section of etc/tempest.conf
+
+        queuing as True
+    """
+
+    @classmethod
+    def setUpClass(cls):
+        super(BaseQueuingTest, cls).setUpClass()
+        if not CONF.service_available.marconi:
+            raise cls.skipException("Marconi support is required")
+        os = cls.get_client_manager()
+        cls.queuing_cfg = CONF.queuing
+        cls.client = os.queuing_client
+
+    @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
diff --git a/tempest/api/queuing/test_queues.py b/tempest/api/queuing/test_queues.py
new file mode 100644
index 0000000..6934b46
--- /dev/null
+++ b/tempest/api/queuing/test_queues.py
@@ -0,0 +1,37 @@
+# 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 logging
+
+from tempest.api.queuing import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
+
+
+class TestQueues(base.BaseQueuingTest):
+
+    @test.attr(type='smoke')
+    def test_create_queue(self):
+        # Create Queue
+        queue_name = data_utils.rand_name('test-')
+        resp, body = self.create_queue(queue_name)
+
+        self.addCleanup(self.client.delete_queue, queue_name)
+
+        self.assertEqual('201', resp['status'])
+        self.assertEqual('', body)
diff --git a/tempest/clients.py b/tempest/clients.py
index e16d0f4..4c4dcf4 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -152,6 +152,7 @@
     ObjectClientCustomizedHeader
 from tempest.services.orchestration.json.orchestration_client import \
     OrchestrationClient
+from tempest.services.queuing.json.queuing_client import QueuingClientJSON
 from tempest.services.telemetry.json.telemetry_client import \
     TelemetryClientJSON
 from tempest.services.telemetry.xml.telemetry_client import \
@@ -334,6 +335,7 @@
             self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
             self.database_flavors_client = DatabaseFlavorsClientJSON(
                 self.auth_provider)
+            self.queuing_client = QueuingClientJSON(self.auth_provider)
             if CONF.service_available.ceilometer:
                 self.telemetry_client = TelemetryClientJSON(
                     self.auth_provider)
diff --git a/tempest/config.py b/tempest/config.py
index 0c33233..f9417e5 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -381,6 +381,15 @@
                      'entry all which indicates every extension is enabled'),
 ]
 
+queuing_group = cfg.OptGroup(name='queuing',
+                             title='Queuing Service')
+
+QueuingGroup = [
+    cfg.StrOpt('catalog_type',
+               default='queuing',
+               help='Catalog type of the Queuing service.'),
+]
+
 volume_group = cfg.OptGroup(name='volume',
                             title='Block Storage Options')
 
@@ -753,6 +762,9 @@
     cfg.BoolOpt('trove',
                 default=False,
                 help="Whether or not Trove is expected to be available"),
+    cfg.BoolOpt('marconi',
+                default=False,
+                help="Whether or not Marconi is expected to be available"),
 ]
 
 debug_group = cfg.OptGroup(name="debug",
@@ -833,6 +845,7 @@
     register_opt_group(cfg.CONF, network_group, NetworkGroup)
     register_opt_group(cfg.CONF, network_feature_group,
                        NetworkFeaturesGroup)
+    register_opt_group(cfg.CONF, queuing_group, QueuingGroup)
     register_opt_group(cfg.CONF, volume_group, VolumeGroup)
     register_opt_group(cfg.CONF, volume_feature_group,
                        VolumeFeaturesGroup)
@@ -883,6 +896,7 @@
             'object-storage-feature-enabled']
         self.database = cfg.CONF.database
         self.orchestration = cfg.CONF.orchestration
+        self.queuing = cfg.CONF.queuing
         self.telemetry = cfg.CONF.telemetry
         self.dashboard = cfg.CONF.dashboard
         self.data_processing = cfg.CONF.data_processing
diff --git a/tempest/services/queuing/__init__.py b/tempest/services/queuing/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/queuing/__init__.py
diff --git a/tempest/services/queuing/json/__init__.py b/tempest/services/queuing/json/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/queuing/json/__init__.py
diff --git a/tempest/services/queuing/json/queuing_client.py b/tempest/services/queuing/json/queuing_client.py
new file mode 100644
index 0000000..4a0c495
--- /dev/null
+++ b/tempest/services/queuing/json/queuing_client.py
@@ -0,0 +1,58 @@
+# 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 json
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class QueuingClientJSON(rest_client.RestClient):
+
+    def __init__(self, auth_provider):
+        super(QueuingClientJSON, self).__init__(auth_provider)
+        self.service = CONF.queuing.catalog_type
+        self.version = '1'
+        self.uri_prefix = 'v{0}'.format(self.version)
+
+    def list_queues(self):
+        uri = '{0}/queues'.format(self.uri_prefix)
+        resp, body = self.get(uri)
+        body = json.loads(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)
+        return resp, body
+
+    def get_queue(self, queue_name):
+        uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+        resp, body = self.get(uri)
+        body = json.loads(body)
+        return resp, body
+
+    def head_queue(self, queue_name):
+        uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+        resp, body = self.head(uri)
+        body = json.loads(body)
+        return resp, body
+
+    def delete_queue(self, queue_name):
+        uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
+        resp = self.delete(uri)
+        return resp