Merge "Remove Ceilometer API"
diff --git a/ceilometer/tests/tempest/api/__init__.py b/ceilometer/tests/tempest/api/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/ceilometer/tests/tempest/api/__init__.py
+++ /dev/null
diff --git a/ceilometer/tests/tempest/api/base.py b/ceilometer/tests/tempest/api/base.py
deleted file mode 100644
index ac65c3c..0000000
--- a/ceilometer/tests/tempest/api/base.py
+++ /dev/null
@@ -1,145 +0,0 @@
-#    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 time
-
-from oslo_utils import timeutils
-from tempest.common import compute
-from tempest import config
-from tempest.lib.common.utils import data_utils
-from tempest.lib import exceptions as lib_exc
-import tempest.test
-
-from ceilometer.tests.tempest.service import client
-
-
-CONF = config.CONF
-
-
-class ClientManager(client.Manager):
-
-    load_clients = [
-        'servers_client',
-        'compute_networks_client',
-        'compute_floating_ips_client',
-        'flavors_client',
-        'image_client_v2',
-        'telemetry_client',
-    ]
-
-
-class BaseTelemetryTest(tempest.test.BaseTestCase):
-
-    """Base test case class for all Telemetry API tests."""
-
-    credentials = ['primary']
-    client_manager = ClientManager
-
-    @classmethod
-    def skip_checks(cls):
-        super(BaseTelemetryTest, cls).skip_checks()
-        if (not CONF.service_available.ceilometer or
-                not CONF.telemetry.deprecated_api_enabled):
-            raise cls.skipException("Ceilometer API support is required")
-
-    @classmethod
-    def setup_credentials(cls):
-        cls.set_network_resources()
-        super(BaseTelemetryTest, cls).setup_credentials()
-
-    @classmethod
-    def setup_clients(cls):
-        super(BaseTelemetryTest, cls).setup_clients()
-        cls.telemetry_client = cls.os_primary.telemetry_client
-        cls.servers_client = cls.os_primary.servers_client
-        cls.flavors_client = cls.os_primary.flavors_client
-        cls.image_client_v2 = cls.os_primary.image_client_v2
-
-    @classmethod
-    def resource_setup(cls):
-        super(BaseTelemetryTest, cls).resource_setup()
-        cls.nova_notifications = ['memory', 'vcpus', 'disk.root.size',
-                                  'disk.ephemeral.size']
-
-        cls.glance_v2_notifications = ['image.download', 'image.serve']
-
-        cls.server_ids = []
-        cls.image_ids = []
-
-    @classmethod
-    def create_server(cls):
-        tenant_network = cls.get_tenant_network()
-        body, server = compute.create_test_server(
-            cls.os_primary,
-            tenant_network=tenant_network,
-            name=data_utils.rand_name('ceilometer-instance'),
-            wait_until='ACTIVE')
-        cls.server_ids.append(body['id'])
-        return body
-
-    @classmethod
-    def create_image(cls, client, **kwargs):
-        body = client.create_image(name=data_utils.rand_name('image'),
-                                   container_format='bare',
-                                   disk_format='raw',
-                                   **kwargs)
-        # TODO(jswarren) Move ['image'] up to initial body value assignment
-        # once both v1 and v2 glance clients include the full response
-        # object.
-        if 'image' in body:
-            body = body['image']
-        cls.image_ids.append(body['id'])
-        return body
-
-    @staticmethod
-    def cleanup_resources(method, list_of_ids):
-        for resource_id in list_of_ids:
-            try:
-                method(resource_id)
-            except lib_exc.NotFound:
-                pass
-
-    @classmethod
-    def resource_cleanup(cls):
-        cls.cleanup_resources(cls.servers_client.delete_server, cls.server_ids)
-        cls.cleanup_resources(cls.image_client_v2.delete_image, cls.image_ids)
-        super(BaseTelemetryTest, cls).resource_cleanup()
-
-    def await_samples(self, metric, query):
-        """This method is to wait for sample to add it to database.
-
-        There are long time delays when using Postgresql (or Mysql)
-        database as ceilometer backend
-        """
-        timeout = CONF.compute.build_timeout
-        start = timeutils.utcnow()
-        while timeutils.delta_seconds(start, timeutils.utcnow()) < timeout:
-            body = self.telemetry_client.list_samples(metric, query)
-            if body:
-                return body
-            time.sleep(CONF.compute.build_interval)
-
-        raise lib_exc.TimeoutException(
-            'Sample for metric:%s with query:%s has not been added to the '
-            'database within %d seconds' % (metric, query,
-                                            CONF.compute.build_timeout))
-
-
-class BaseTelemetryAdminTest(BaseTelemetryTest):
-    """Base test case class for admin Telemetry API tests."""
-
-    credentials = ['primary', 'admin']
-
-    @classmethod
-    def setup_clients(cls):
-        super(BaseTelemetryAdminTest, cls).setup_clients()
-        cls.telemetry_admin_client = cls.os_admin.telemetry_client
diff --git a/ceilometer/tests/tempest/api/test_telemetry_notification_api.py b/ceilometer/tests/tempest/api/test_telemetry_notification_api.py
deleted file mode 100644
index ec754c8..0000000
--- a/ceilometer/tests/tempest/api/test_telemetry_notification_api.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#    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.
-
-# Change-Id: I14e16a1a7d9813b324ee40545c07f0e88fb637b7
-
-import six
-import testtools
-
-from ceilometer.tests.tempest.api import base
-from tempest.common import utils
-from tempest import config
-from tempest.lib.common.utils import data_utils
-from tempest.lib import decorators
-
-
-CONF = config.CONF
-
-
-class TelemetryNotificationAPITest(base.BaseTelemetryTest):
-    @classmethod
-    def skip_checks(cls):
-        super(TelemetryNotificationAPITest, cls).skip_checks()
-
-        if ("gnocchi" in CONF.service_available and
-                CONF.service_available.gnocchi):
-            skip_msg = ("%s skipped as gnocchi is enabled" %
-                        cls.__name__)
-            raise cls.skipException(skip_msg)
-
-    @decorators.idempotent_id('d7f8c1c8-d470-4731-8604-315d3956caae')
-    @utils.services('compute')
-    def test_check_nova_notification(self):
-
-        body = self.create_server()
-
-        query = ('resource', 'eq', body['id'])
-
-        for metric in self.nova_notifications:
-            self.await_samples(metric, query)
-
-    @decorators.idempotent_id('c240457d-d943-439b-8aea-85e26d64fe8f')
-    @utils.services("image")
-    @testtools.skipIf(not CONF.image_feature_enabled.api_v2,
-                      "Glance api v2 is disabled")
-    def test_check_glance_v2_notifications(self):
-        body = self.create_image(self.image_client_v2, visibility='private')
-
-        file_content = data_utils.random_bytes()
-        image_file = six.BytesIO(file_content)
-        self.image_client_v2.store_image_file(body['id'], image_file)
-        self.image_client_v2.show_image_file(body['id'])
-
-        query = 'resource', 'eq', body['id']
-
-        for metric in self.glance_v2_notifications:
-            self.await_samples(metric, query)
-
-
-class TelemetryNotificationAdminAPITest(base.BaseTelemetryAdminTest):
-    @classmethod
-    def skip_checks(cls):
-        super(TelemetryNotificationAdminAPITest, cls).skip_checks()
-
-        if ("gnocchi" in CONF.service_available and
-                CONF.service_available.gnocchi):
-            skip_msg = ("%s skipped as gnocchi is enabled" %
-                        cls.__name__)
-            raise cls.skipException(skip_msg)
-
-    @decorators.idempotent_id('29604198-8b45-4fc0-8af8-1cae4f94ebea')
-    @utils.services('compute')
-    def test_check_nova_notification_event_and_meter(self):
-
-        body = self.create_server()
-
-        query = ('resource', 'eq', body['id'])
-        for metric in self.nova_notifications:
-            self.await_samples(metric, query)
diff --git a/ceilometer/tests/tempest/config.py b/ceilometer/tests/tempest/config.py
index 0df195b..d39874c 100644
--- a/ceilometer/tests/tempest/config.py
+++ b/ceilometer/tests/tempest/config.py
@@ -25,20 +25,6 @@
                                title='Telemetry Service Options')
 
 TelemetryGroup = [
-    cfg.StrOpt('catalog_type',
-               default='metering',
-               help="Catalog type of the Telemetry service."),
-    cfg.StrOpt('endpoint_type',
-               default='publicURL',
-               choices=['public', 'admin', 'internal',
-                        'publicURL', 'adminURL', 'internalURL'],
-               help="The endpoint type to use for the telemetry service."),
-    cfg.BoolOpt('event_enabled',
-                default=True,
-                help="Runs Ceilometer event-related tests"),
-    cfg.BoolOpt('deprecated_api_enabled',
-                default=True,
-                help="Runs Ceilometer deprecated API tests"),
     cfg.IntOpt('notification_wait',
                default=120,
                help="The seconds to wait for notifications which "
diff --git a/ceilometer/tests/tempest/scenario/test_object_storage_telemetry_middleware.py b/ceilometer/tests/tempest/scenario/test_object_storage_telemetry_middleware.py
deleted file mode 100644
index e02e454..0000000
--- a/ceilometer/tests/tempest/scenario/test_object_storage_telemetry_middleware.py
+++ /dev/null
@@ -1,146 +0,0 @@
-# Copyright 2014 Red Hat
-#
-# 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.
-
-from oslo_log import log as logging
-from tempest.common import utils
-from tempest import config
-from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
-from tempest.lib import decorators
-from tempest import test
-
-from ceilometer.tests.tempest.service import client
-
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class ClientManager(client.Manager):
-
-    load_clients = [
-        'telemetry_client',
-        'container_client',
-        'object_client',
-    ]
-
-
-class TestObjectStorageTelemetry(test.BaseTestCase):
-    """Test that swift uses the ceilometer middleware.
-
-     * create container.
-     * upload a file to the created container.
-     * retrieve the file from the created container.
-     * wait for notifications from ceilometer.
-    """
-
-    credentials = ['primary']
-    client_manager = ClientManager
-
-    @classmethod
-    def skip_checks(cls):
-        super(TestObjectStorageTelemetry, cls).skip_checks()
-        if ("gnocchi" in CONF.service_available and
-                CONF.service_available.gnocchi):
-            skip_msg = ("%s skipped as gnocchi is enabled" %
-                        cls.__name__)
-            raise cls.skipException(skip_msg)
-        if not CONF.service_available.swift:
-            skip_msg = ("%s skipped as swift is not available" %
-                        cls.__name__)
-            raise cls.skipException(skip_msg)
-        if not CONF.service_available.ceilometer:
-            skip_msg = ("%s skipped as ceilometer is not available" %
-                        cls.__name__)
-            raise cls.skipException(skip_msg)
-
-    @classmethod
-    def setup_credentials(cls):
-        cls.set_network_resources()
-        super(TestObjectStorageTelemetry, cls).setup_credentials()
-
-    @classmethod
-    def setup_clients(cls):
-        super(TestObjectStorageTelemetry, cls).setup_clients()
-        cls.telemetry_client = cls.os_primary.telemetry_client
-        cls.container_client = cls.os_primary.container_client
-        cls.object_client = cls.os_primary.object_client
-
-    def _confirm_notifications(self, container_name, obj_name):
-        # NOTE: Loop seeking for appropriate notifications about the containers
-        # and objects sent to swift.
-
-        def _check_samples():
-            # NOTE: Return True only if we have notifications about some
-            # containers and some objects and the notifications are about
-            # the expected containers and objects.
-            # Otherwise returning False will case _check_samples to be
-            # called again.
-            results = self.telemetry_client.list_samples(
-                'storage.objects.incoming.bytes')
-            LOG.debug('got samples %s', results)
-
-            # Extract container info from samples.
-            containers, objects = [], []
-            for sample in results:
-                meta = sample['resource_metadata']
-                if meta.get('container') and meta['container'] != 'None':
-                    containers.append(meta['container'])
-                elif (meta.get('target.metadata:container') and
-                      meta['target.metadata:container'] != 'None'):
-                    containers.append(meta['target.metadata:container'])
-
-                if meta.get('object') and meta['object'] != 'None':
-                    objects.append(meta['object'])
-                elif (meta.get('target.metadata:object') and
-                      meta['target.metadata:object'] != 'None'):
-                    objects.append(meta['target.metadata:object'])
-
-            return (container_name in containers and obj_name in objects)
-
-        self.assertTrue(
-            test_utils.call_until_true(_check_samples,
-                                       CONF.telemetry.notification_wait,
-                                       CONF.telemetry.notification_sleep),
-            'Correct notifications were not received after '
-            '%s seconds.' % CONF.telemetry.notification_wait)
-
-    def create_container(self):
-        name = data_utils.rand_name('swift-scenario-container')
-        self.container_client.create_container(name)
-        # look for the container to assure it is created
-        self.container_client.list_container_objects(name)
-        LOG.debug('Container %s created' % (name))
-        self.addCleanup(self.container_client.delete_container,
-                        name)
-        return name
-
-    def upload_object_to_container(self, container_name):
-        obj_name = data_utils.rand_name('swift-scenario-object')
-        obj_data = data_utils.arbitrary_string()
-        self.object_client.create_object(container_name, obj_name, obj_data)
-        self.addCleanup(self.object_client.delete_object,
-                        container_name,
-                        obj_name)
-        return obj_name
-
-    @decorators.idempotent_id('6d6b88e5-3e38-41bc-b34a-79f713a6cb85')
-    @utils.services('object_storage')
-    def test_swift_middleware_notifies(self):
-        container_name = self.create_container()
-        obj_name = self.upload_object_to_container(container_name)
-        self._confirm_notifications(container_name, obj_name)
diff --git a/ceilometer/tests/tempest/service/__init__.py b/ceilometer/tests/tempest/service/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/ceilometer/tests/tempest/service/__init__.py
+++ /dev/null
diff --git a/ceilometer/tests/tempest/service/client.py b/ceilometer/tests/tempest/service/client.py
deleted file mode 100644
index 59c585e..0000000
--- a/ceilometer/tests/tempest/service/client.py
+++ /dev/null
@@ -1,110 +0,0 @@
-# Copyright 2014 OpenStack Foundation
-# 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.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-
-from tempest import clients
-from tempest import config
-from tempest.lib.common import rest_client
-
-
-CONF = config.CONF
-
-
-class TelemetryClient(rest_client.RestClient):
-
-    version = '2'
-    uri_prefix = "v2"
-
-    def deserialize(self, body):
-        return json.loads(body.replace("\n", ""))
-
-    def serialize(self, body):
-        return json.dumps(body)
-
-    def create_sample(self, meter_name, sample_list):
-        uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
-        body = self.serialize(sample_list)
-        resp, body = self.post(uri, body)
-        self.expected_success(200, resp.status)
-        body = self.deserialize(body)
-        return rest_client.ResponseBody(resp, body)
-
-    def _helper_list(self, uri, query=None, period=None):
-        uri_dict = {}
-        if query:
-            uri_dict = {'q.field': query[0],
-                        'q.op': query[1],
-                        'q.value': query[2]}
-        if period:
-            uri_dict['period'] = period
-        if uri_dict:
-            uri += "?%s" % urllib.urlencode(uri_dict)
-        resp, body = self.get(uri)
-        self.expected_success(200, resp.status)
-        body = self.deserialize(body)
-        return rest_client.ResponseBodyList(resp, body)
-
-    def list_resources(self, query=None):
-        uri = '%s/resources' % self.uri_prefix
-        return self._helper_list(uri, query)
-
-    def list_meters(self, query=None):
-        uri = '%s/meters' % self.uri_prefix
-        return self._helper_list(uri, query)
-
-    def list_statistics(self, meter, period=None, query=None):
-        uri = "%s/meters/%s/statistics" % (self.uri_prefix, meter)
-        return self._helper_list(uri, query, period)
-
-    def list_samples(self, meter_id, query=None):
-        uri = '%s/meters/%s' % (self.uri_prefix, meter_id)
-        return self._helper_list(uri, query)
-
-    def show_resource(self, resource_id):
-        uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
-        resp, body = self.get(uri)
-        self.expected_success(200, resp.status)
-        body = self.deserialize(body)
-        return rest_client.ResponseBody(resp, body)
-
-
-class Manager(clients.Manager):
-
-    default_params = config.service_client_config()
-
-    telemetry_params = {
-        'service': CONF.telemetry.catalog_type,
-        'region': CONF.identity.region,
-        'endpoint_type': CONF.telemetry.endpoint_type,
-    }
-    telemetry_params.update(default_params)
-
-    def __init__(self, credentials):
-        # TODO(andreaf) Overriding Manager is a workaround. The "proper" way
-        # would it to expose the ceilometer service client via the plugin
-        # interface, use tempest.lib.clients and tempest master.
-        # Then ceilometer service client would be loaded and configured
-        # automatically into ServiceClients.
-        # In any case we're about to declare clients.Manager a stable
-        # interface for plugins and we won't change it, so this code won't
-        # break.
-        super(Manager, self).__init__(credentials=credentials)
-        self.set_telemetry_client()
-
-    def set_telemetry_client(self):
-        self.telemetry_client = TelemetryClient(self.auth_provider,
-                                                **self.telemetry_params)