Refactored API V2 tests to use testscenarios

Related to blueprint db-tests-with-scenarios

Change-Id: Id11215edae79e5bd007fb28590f9c4cca25aacc9
This commit is contained in:
Alexei Kornienko 2013-07-23 15:16:59 +03:00
parent b9e9b623d7
commit a88b9581c5
11 changed files with 103 additions and 228 deletions

View File

@ -18,6 +18,8 @@
"""Test ACL.""" """Test ACL."""
import datetime import datetime
import testscenarios
from oslo.config import cfg from oslo.config import cfg
from ceilometer import counter from ceilometer import counter
@ -26,6 +28,8 @@ from ceilometer.publisher import rpc
from .base import FunctionalTest from .base import FunctionalTest
load_tests = testscenarios.load_tests_apply_scenarios
VALID_TOKEN = '4562138218392831' VALID_TOKEN = '4562138218392831'
VALID_TOKEN2 = '4562138218392832' VALID_TOKEN2 = '4562138218392832'
@ -71,6 +75,12 @@ class FakeMemcache(object):
class TestAPIACL(FunctionalTest): class TestAPIACL(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self): def setUp(self):
super(TestAPIACL, self).setUp() super(TestAPIACL, self).setUp()
self.environ = {'fake.cache': FakeMemcache()} self.environ = {'fake.cache': FakeMemcache()}

View File

@ -21,16 +21,25 @@
import logging import logging
import uuid import uuid
import testscenarios
from .base import FunctionalTest from .base import FunctionalTest
from ceilometer.storage.models import Alarm from ceilometer.storage.models import Alarm
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestListEmptyAlarms(FunctionalTest): class TestListEmptyAlarms(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
#('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self): def test_empty(self):
data = self.get_json('/alarms') data = self.get_json('/alarms')
self.assertEquals([], data) self.assertEquals([], data)
@ -38,6 +47,12 @@ class TestListEmptyAlarms(FunctionalTest):
class TestAlarms(FunctionalTest): class TestAlarms(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
#('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self): def setUp(self):
super(TestAlarms, self).setUp() super(TestAlarms, self).setUp()

View File

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

View File

@ -1,78 +0,0 @@
# -*- encoding: utf-8 -*-
#
# 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 testtools
from . import acl
from . import alarm
from . import compute_duration_by_resource
from . import list_events
from . import list_meters
from . import list_resources
from . import post_samples
from . import statistics
class TestAPIAcl(acl.TestAPIACL):
database_connection = 'hbase://__test__'
class TestListEvents(list_events.TestListEvents):
database_connection = 'hbase://__test__'
@testtools.skip('HBase alarms not implemented')
class TestListEmptyAlarms(alarm.TestListEmptyAlarms):
database_connection = 'hbase://__test__'
@testtools.skip('HBase alarms not implemented')
class TestAlarms(alarm.TestAlarms):
database_connection = 'hbase://__test__'
class TestComputeDurationByResource(
compute_duration_by_resource.TestComputeDurationByResource):
database_connection = 'hbase://__test__'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'hbase://__test__'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'hbase://__test__'
class TestListResources(list_resources.TestListResources):
database_connection = 'hbase://__test__'
class TestMaxProjectVolume(statistics.TestMaxProjectVolume):
database_connection = 'hbase://__test__'
class TestMaxResourceVolume(statistics.TestMaxResourceVolume):
database_connection = 'hbase://__test__'
class TestSumProjectVolume(statistics.TestSumProjectVolume):
database_connection = 'hbase://__test__'
class TestSumResourceVolume(statistics.TestSumProjectVolume):
database_connection = 'hbase://__test__'
class TestPostSamples(post_samples.TestPostSamples):
database_connection = 'hbase://__test__'

View File

@ -1,75 +0,0 @@
# -*- encoding: utf-8 -*-
#
# 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 . import acl
from . import alarm
from . import compute_duration_by_resource
from . import list_events
from . import list_meters
from . import list_resources
from . import post_samples
from . import statistics
class TestAPIAcl(acl.TestAPIACL):
database_connection = 'mongodb://__test__'
class TestListEvents(list_events.TestListEvents):
database_connection = 'mongodb://__test__'
class TestListEmptyAlarms(alarm.TestListEmptyAlarms):
database_connection = 'mongodb://__test__'
class TestAlarms(alarm.TestAlarms):
database_connection = 'mongodb://__test__'
class TestComputeDurationByResource(
compute_duration_by_resource.TestComputeDurationByResource):
database_connection = 'mongodb://__test__'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'mongodb://__test__'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'mongodb://__test__'
class TestListResources(list_resources.TestListResources):
database_connection = 'mongodb://__test__'
class TestMaxProjectVolume(statistics.TestMaxProjectVolume):
database_connection = 'mongodb://__test__'
class TestMaxResourceVolume(statistics.TestMaxResourceVolume):
database_connection = 'mongodb://__test__'
class TestSumProjectVolume(statistics.TestSumProjectVolume):
database_connection = 'mongodb://__test__'
class TestSumResourceVolume(statistics.TestSumProjectVolume):
database_connection = 'mongodb://__test__'
class TestPostSamples(post_samples.TestPostSamples):
database_connection = 'mongodb://__test__'

View File

@ -1,75 +0,0 @@
# -*- encoding: utf-8 -*-
#
# 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 . import acl
from . import alarm
from . import compute_duration_by_resource
from . import list_events
from . import list_meters
from . import list_resources
from . import post_samples
from . import statistics
class TestAPIAcl(acl.TestAPIACL):
database_connection = 'sqlite://'
class TestListEvents(list_events.TestListEvents):
database_connection = 'sqlite://'
class TestListEmptyAlarms(alarm.TestListEmptyAlarms):
database_connection = 'sqlite://'
class TestAlarms(alarm.TestAlarms):
database_connection = 'sqlite://'
class TestComputeDurationByResource(
compute_duration_by_resource.TestComputeDurationByResource):
database_connection = 'sqlite://'
class TestListEmptyMeters(list_meters.TestListEmptyMeters):
database_connection = 'sqlite://'
class TestListMeters(list_meters.TestListMeters):
database_connection = 'sqlite://'
class TestListResources(list_resources.TestListResources):
database_connection = 'sqlite://'
class TestMaxProjectVolume(statistics.TestMaxProjectVolume):
database_connection = 'sqlite://'
class TestMaxResourceVolume(statistics.TestMaxResourceVolume):
database_connection = 'sqlite://'
class TestSumProjectVolume(statistics.TestSumProjectVolume):
database_connection = 'sqlite:// '
class TestSumResourceVolume(statistics.TestSumProjectVolume):
database_connection = 'sqlite:// '
class TestPostSamples(post_samples.TestPostSamples):
database_connection = 'sqlite:// '

View File

@ -21,6 +21,7 @@
import datetime import datetime
import logging import logging
import webtest.app import webtest.app
import testscenarios
from oslo.config import cfg from oslo.config import cfg
@ -29,11 +30,19 @@ from ceilometer import counter
from .base import FunctionalTest from .base import FunctionalTest
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestListEvents(FunctionalTest): class TestListEvents(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self): def setUp(self):
super(TestListEvents, self).setUp() super(TestListEvents, self).setUp()
self.counter1 = counter.Counter( self.counter1 = counter.Counter(

View File

@ -20,6 +20,7 @@
import datetime import datetime
import logging import logging
import testscenarios
from oslo.config import cfg from oslo.config import cfg
@ -28,11 +29,19 @@ from ceilometer import counter
from .base import FunctionalTest from .base import FunctionalTest
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestListEmptyMeters(FunctionalTest): class TestListEmptyMeters(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def test_empty(self): def test_empty(self):
data = self.get_json('/meters') data = self.get_json('/meters')
self.assertEquals([], data) self.assertEquals([], data)
@ -40,6 +49,12 @@ class TestListEmptyMeters(FunctionalTest):
class TestListMeters(FunctionalTest): class TestListMeters(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def setUp(self): def setUp(self):
super(TestListMeters, self).setUp() super(TestListMeters, self).setUp()

View File

@ -20,6 +20,7 @@
import datetime import datetime
import logging import logging
import testscenarios
from oslo.config import cfg from oslo.config import cfg
@ -28,11 +29,19 @@ from ceilometer import counter
from .base import FunctionalTest from .base import FunctionalTest
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestListResources(FunctionalTest): class TestListResources(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
SOURCE_DATA = {'test_list_resources': {}} SOURCE_DATA = {'test_list_resources': {}}
def test_empty(self): def test_empty(self):

View File

@ -21,17 +21,26 @@
import copy import copy
import datetime import datetime
import logging import logging
import testscenarios
from ceilometer.openstack.common import rpc from ceilometer.openstack.common import rpc
from ceilometer.openstack.common import timeutils from ceilometer.openstack.common import timeutils
from .base import FunctionalTest from .base import FunctionalTest
load_tests = testscenarios.load_tests_apply_scenarios
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestPostSamples(FunctionalTest): class TestPostSamples(FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
def faux_cast(self, context, topic, msg): def faux_cast(self, context, topic, msg):
self.published.append((topic, msg)) self.published.append((topic, msg))

View File

@ -18,6 +18,7 @@
"""Test events statistics retrieval.""" """Test events statistics retrieval."""
import datetime import datetime
import testscenarios
from oslo.config import cfg from oslo.config import cfg
@ -25,9 +26,17 @@ from . import base
from ceilometer import counter from ceilometer import counter
from ceilometer.publisher import rpc from ceilometer.publisher import rpc
load_tests = testscenarios.load_tests_apply_scenarios
class TestMaxProjectVolume(base.FunctionalTest): class TestMaxProjectVolume(base.FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
PATH = '/meters/volume.size/statistics' PATH = '/meters/volume.size/statistics'
def setUp(self): def setUp(self):
@ -128,6 +137,12 @@ class TestMaxProjectVolume(base.FunctionalTest):
class TestMaxResourceVolume(base.FunctionalTest): class TestMaxResourceVolume(base.FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
PATH = '/meters/volume.size/statistics' PATH = '/meters/volume.size/statistics'
def setUp(self): def setUp(self):
@ -244,6 +259,12 @@ class TestMaxResourceVolume(base.FunctionalTest):
class TestSumProjectVolume(base.FunctionalTest): class TestSumProjectVolume(base.FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
PATH = '/meters/volume.size/statistics' PATH = '/meters/volume.size/statistics'
def setUp(self): def setUp(self):
@ -346,6 +367,12 @@ class TestSumProjectVolume(base.FunctionalTest):
class TestSumResourceVolume(base.FunctionalTest): class TestSumResourceVolume(base.FunctionalTest):
scenarios = [
('sqlalchemy', dict(database_connection='sqlite://')),
('mongodb', dict(database_connection='mongodb://__test__')),
('hbase', dict(database_connection='hbase://__test__')),
]
PATH = '/meters/volume.size/statistics' PATH = '/meters/volume.size/statistics'
def setUp(self): def setUp(self):