Refactored API V1 tests to use testscenarios

Related to blueprint db-tests-with-scenarios

Change-Id: Id44ac158b8ff39c3d414c511f1bb2b3c948db0d2
This commit is contained in:
Alexei Kornienko 2013-07-23 15:55:18 +03:00
parent 5bfbaba768
commit db423dde9c
14 changed files with 141 additions and 294 deletions

View File

@ -20,16 +20,25 @@
import datetime
import logging
import testscenarios
from ceilometer.openstack.common import timeutils
from ceilometer.storage import models
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__)
class TestComputeDurationByResource(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestComputeDurationByResource, self).setUp()

View File

@ -1,102 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2013 eNovance
#
# Author: Julien Danjou <julien@danjou.info>
#
# 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.
"""Test API against MongoDB.
"""
from . import compute_duration_by_resource as cdbr
from . import list_events
from . import list_meters
from . import list_projects
from . import list_resources
from . import list_sources
from . import list_users
from . import max_project_volume
from . import max_resource_volume
from . import sum_project_volume
from . import sum_resource_volume
class TestListEvents(list_events.TestListEvents):
database_connection = 'hbase://__test__'
class TestListEventsMetaQuery(list_events.TestListEventsMetaquery):
database_connection = 'hbase://__test__'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'hbase://__test__'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'hbase://__test__'
class TestListMetersMetaquery(list_meters.TestListMetersMetaquery):
database_connection = 'hbase://__test__'
class TestListEmptyUsers(list_users.TestListEmptyUsers):
database_connection = 'hbase://__test__'
class TestListUsers(list_users.TestListUsers):
database_connection = 'hbase://__test__'
class TestListEmptyProjects(list_projects.TestListEmptyProjects):
database_connection = 'hbase://__test__'
class TestListProjects(list_projects.TestListProjects):
database_connection = 'hbase://__test__'
class TestComputeDurationByResource(cdbr.TestComputeDurationByResource):
database_connection = 'hbase://__test__'
class TestListEmptyResources(list_resources.TestListEmptyResources):
database_connection = 'hbase://__test__'
class TestListResources(list_resources.TestListResources):
database_connection = 'hbase://__test__'
class TestListResourcesMetaquery(list_resources.TestListResourcesMetaquery):
database_connection = 'hbase://__test__'
class TestListSource(list_sources.TestListSource):
database_connection = 'hbase://__test__'
class TestMaxProjectVolume(max_project_volume.TestMaxProjectVolume):
database_connection = 'hbase://__test__'
class TestMaxResourceVolume(max_resource_volume.TestMaxResourceVolume):
database_connection = 'hbase://__test__'
class TestSumProjectVolume(sum_project_volume.TestSumProjectVolume):
database_connection = 'hbase://__test__'
class TestSumResourceVolume(sum_resource_volume.TestSumResourceVolume):
database_connection = 'hbase://__test__'

View File

@ -1,102 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2013 eNovance
#
# Author: Julien Danjou <julien@danjou.info>
#
# 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.
"""Test API against MongoDB.
"""
from . import compute_duration_by_resource as cdbr
from . import list_events
from . import list_meters
from . import list_projects
from . import list_resources
from . import list_sources
from . import list_users
from . import max_project_volume
from . import max_resource_volume
from . import sum_project_volume
from . import sum_resource_volume
class TestListEvents(list_events.TestListEvents):
database_connection = 'mongodb://__test__'
class TestListEventsMetaQuery(list_events.TestListEventsMetaquery):
database_connection = 'mongodb://__test__'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'mongodb://__test__'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'mongodb://__test__'
class TestListMetersMetaquery(list_meters.TestListMetersMetaquery):
database_connection = 'mongodb://__test__'
class TestListEmptyUsers(list_users.TestListEmptyUsers):
database_connection = 'mongodb://__test__'
class TestListUsers(list_users.TestListUsers):
database_connection = 'mongodb://__test__'
class TestListEmptyProjects(list_projects.TestListEmptyProjects):
database_connection = 'mongodb://__test__'
class TestListProjects(list_projects.TestListProjects):
database_connection = 'mongodb://__test__'
class TestComputeDurationByResource(cdbr.TestComputeDurationByResource):
database_connection = 'mongodb://__test__'
class TestListEmptyResources(list_resources.TestListEmptyResources):
database_connection = 'mongodb://__test__'
class TestListResources(list_resources.TestListResources):
database_connection = 'mongodb://__test__'
class TestListResourcesMetaquery(list_resources.TestListResourcesMetaquery):
database_connection = 'mongodb://__test__'
class TestListSource(list_sources.TestListSource):
database_connection = 'mongodb://__test__'
class TestMaxProjectVolume(max_project_volume.TestMaxProjectVolume):
database_connection = 'mongodb://__test__'
class TestMaxResourceVolume(max_resource_volume.TestMaxResourceVolume):
database_connection = 'mongodb://__test__'
class TestSumProjectVolume(sum_project_volume.TestSumProjectVolume):
database_connection = 'mongodb://__test__'
class TestSumResourceVolume(sum_resource_volume.TestSumResourceVolume):
database_connection = 'mongodb://__test__'

View File

@ -1,90 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2013 eNovance
#
# Author: Julien Danjou <julien@danjou.info>
#
# 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.
"""Test API against SQLAlchemy.
"""
import compute_duration_by_resource as cdbr
import list_events
import list_meters
import list_projects
import list_resources
import list_sources
import list_users
import max_project_volume
import max_resource_volume
import sum_project_volume
import sum_resource_volume
class TestListEvents(list_events.TestListEvents):
database_connection = 'sqlite://'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'sqlite://'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'sqlite://'
class TestListEmptyUsers(list_users.TestListEmptyUsers):
database_connection = 'sqlite://'
class TestListUsers(list_users.TestListUsers):
database_connection = 'sqlite://'
class TestListEmptyProjects(list_projects.TestListEmptyProjects):
database_connection = 'sqlite://'
class TestListProjects(list_projects.TestListProjects):
database_connection = 'sqlite://'
class TestComputeDurationByResource(cdbr.TestComputeDurationByResource):
database_connection = 'sqlite://'
class TestListEmptyResources(list_resources.TestListEmptyResources):
database_connection = 'sqlite://'
class TestListResources(list_resources.TestListResources):
database_connection = 'sqlite://'
class TestListSource(list_sources.TestListSource):
database_connection = 'sqlite://'
class TestMaxProjectVolume(max_project_volume.TestMaxProjectVolume):
database_connection = 'sqlite://'
class TestMaxResourceVolume(max_resource_volume.TestMaxResourceVolume):
database_connection = 'sqlite://'
class TestSumProjectVolume(sum_project_volume.TestSumProjectVolume):
database_connection = 'sqlite://'
class TestSumResourceVolume(sum_resource_volume.TestSumResourceVolume):
database_connection = 'sqlite://'

View File

@ -20,6 +20,7 @@
"""
import datetime
import testscenarios
from oslo.config import cfg
@ -28,9 +29,17 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestListEvents(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestListEvents, self).setUp()
for cnt in [
@ -176,6 +185,12 @@ class TestListEvents(tests_api.TestBase):
class TestListEventsMetaquery(TestListEvents):
scenarios = [
#('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_metaquery1(self):
q = '/sources/source1/meters/instance'
data = self.get('%s?metadata.tag=self.counter2' % q)

View File

@ -21,6 +21,7 @@
import datetime
import logging
import testscenarios
from oslo.config import cfg
@ -29,11 +30,19 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__)
class TestListEmptyMeters(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self):
data = self.get('/meters')
self.assertEquals({'meters': []}, data)
@ -41,6 +50,12 @@ class TestListEmptyMeters(tests_api.TestBase):
class TestListMeters(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestListMeters, self).setUp()
@ -210,6 +225,12 @@ class TestListMeters(tests_api.TestBase):
class TestListMetersMetaquery(TestListMeters):
scenarios = [
#('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_metaquery1(self):
data = self.get('/meters?metadata.tag=self.counter')
self.assertEquals(1, len(data['meters']))

View File

@ -21,6 +21,7 @@
import datetime
import logging
import testscenarios
from oslo.config import cfg
@ -29,11 +30,19 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__)
class TestListEmptyProjects(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self):
data = self.get('/projects')
self.assertEquals({'projects': []}, data)
@ -41,6 +50,12 @@ class TestListEmptyProjects(tests_api.TestBase):
class TestListProjects(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestListProjects, self).setUp()
counter1 = counter.Counter(

View File

@ -21,6 +21,7 @@
import datetime
import logging
import testscenarios
from oslo.config import cfg
@ -29,11 +30,19 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__)
class TestListEmptyResources(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self):
data = self.get('/resources')
self.assertEquals({'resources': []}, data)
@ -41,6 +50,12 @@ class TestListEmptyResources(tests_api.TestBase):
class TestListResourcesBase(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestListResourcesBase, self).setUp()
@ -262,6 +277,12 @@ class TestListResources(TestListResourcesBase):
class TestListResourcesMetaquery(TestListResourcesBase):
scenarios = [
#('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_metaquery1(self):
q = '/sources/test_list_resources/resources'
data = self.get('%s?metadata.display_name=test-server' % q)

View File

@ -17,12 +17,21 @@
# under the License.
"""Test listing users.
"""
import testscenarios
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestListSource(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_source(self):
ydata = self.get('/sources/test_source')
self.assert_("somekey" in ydata)

View File

@ -21,6 +21,7 @@
import datetime
import logging
import testscenarios
from oslo.config import cfg
@ -29,11 +30,19 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__)
class TestListEmptyUsers(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self):
data = self.get('/users')
self.assertEquals({'users': []}, data)
@ -41,6 +50,12 @@ class TestListEmptyUsers(tests_api.TestBase):
class TestListUsers(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestListUsers, self).setUp()

View File

@ -20,6 +20,7 @@
"""
import datetime
import testscenarios
from oslo.config import cfg
@ -28,9 +29,17 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestMaxProjectVolume(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestMaxProjectVolume, self).setUp()

View File

@ -19,6 +19,7 @@
"""
import datetime
import testscenarios
from oslo.config import cfg
@ -27,9 +28,17 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestMaxResourceVolume(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestMaxResourceVolume, self).setUp()

View File

@ -20,6 +20,7 @@
"""
import datetime
import testscenarios
from oslo.config import cfg
@ -28,9 +29,17 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestSumProjectVolume(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestSumProjectVolume, self).setUp()

View File

@ -20,6 +20,7 @@
"""
import datetime
import testscenarios
from oslo.config import cfg
@ -28,9 +29,17 @@ from ceilometer import counter
from ceilometer.tests import api as tests_api
load_tests = testscenarios.load_tests_apply_scenarios
class TestSumResourceVolume(tests_api.TestBase):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self):
super(TestSumResourceVolume, self).setUp()