From a88b9581c58fbb0cd3a8db3c0602c48613d789b5 Mon Sep 17 00:00:00 2001 From: Alexei Kornienko Date: Tue, 23 Jul 2013 15:16:59 +0300 Subject: [PATCH] Refactored API V2 tests to use testscenarios Related to blueprint db-tests-with-scenarios Change-Id: Id11215edae79e5bd007fb28590f9c4cca25aacc9 --- .../api/v2/{acl.py => test_acl_scenarios.py} | 10 +++ .../v2/{alarm.py => test_alarm_scenarios.py} | 15 ++++ ...compute_duration_by_resource_scenarios.py} | 9 +++ tests/api/v2/test_impl_hbase.py | 78 ------------------- tests/api/v2/test_impl_mongodb.py | 75 ------------------ tests/api/v2/test_impl_sqlalchemy.py | 75 ------------------ ...vents.py => test_list_events_scenarios.py} | 9 +++ ...eters.py => test_list_meters_scenarios.py} | 15 ++++ ...es.py => test_list_resources_scenarios.py} | 9 +++ ...ples.py => test_post_samples_scenarios.py} | 9 +++ ...istics.py => test_statistics_scenarios.py} | 27 +++++++ 11 files changed, 103 insertions(+), 228 deletions(-) rename tests/api/v2/{acl.py => test_acl_scenarios.py} (96%) rename tests/api/v2/{alarm.py => test_alarm_scenarios.py} (92%) rename tests/api/v2/{compute_duration_by_resource.py => test_compute_duration_by_resource_scenarios.py} (96%) delete mode 100644 tests/api/v2/test_impl_hbase.py delete mode 100644 tests/api/v2/test_impl_mongodb.py delete mode 100644 tests/api/v2/test_impl_sqlalchemy.py rename tests/api/v2/{list_events.py => test_list_events_scenarios.py} (95%) rename tests/api/v2/{list_meters.py => test_list_meters_scenarios.py} (92%) rename tests/api/v2/{list_resources.py => test_list_resources_scenarios.py} (98%) rename tests/api/v2/{post_samples.py => test_post_samples_scenarios.py} (97%) rename tests/api/v2/{statistics.py => test_statistics_scenarios.py} (95%) diff --git a/tests/api/v2/acl.py b/tests/api/v2/test_acl_scenarios.py similarity index 96% rename from tests/api/v2/acl.py rename to tests/api/v2/test_acl_scenarios.py index 4d4fe373b..8c7a8140b 100644 --- a/tests/api/v2/acl.py +++ b/tests/api/v2/test_acl_scenarios.py @@ -18,6 +18,8 @@ """Test ACL.""" import datetime +import testscenarios + from oslo.config import cfg from ceilometer import counter @@ -26,6 +28,8 @@ from ceilometer.publisher import rpc from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + VALID_TOKEN = '4562138218392831' VALID_TOKEN2 = '4562138218392832' @@ -71,6 +75,12 @@ class FakeMemcache(object): class TestAPIACL(FunctionalTest): + scenarios = [ + ('sqlalchemy', dict(database_connection='sqlite://')), + ('mongodb', dict(database_connection='mongodb://__test__')), + ('hbase', dict(database_connection='hbase://__test__')), + ] + def setUp(self): super(TestAPIACL, self).setUp() self.environ = {'fake.cache': FakeMemcache()} diff --git a/tests/api/v2/alarm.py b/tests/api/v2/test_alarm_scenarios.py similarity index 92% rename from tests/api/v2/alarm.py rename to tests/api/v2/test_alarm_scenarios.py index 251022d96..2aced87be 100644 --- a/tests/api/v2/alarm.py +++ b/tests/api/v2/test_alarm_scenarios.py @@ -21,16 +21,25 @@ import logging import uuid +import testscenarios from .base import FunctionalTest from ceilometer.storage.models import Alarm +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) 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): data = self.get_json('/alarms') self.assertEquals([], data) @@ -38,6 +47,12 @@ class TestListEmptyAlarms(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): super(TestAlarms, self).setUp() diff --git a/tests/api/v2/compute_duration_by_resource.py b/tests/api/v2/test_compute_duration_by_resource_scenarios.py similarity index 96% rename from tests/api/v2/compute_duration_by_resource.py rename to tests/api/v2/test_compute_duration_by_resource_scenarios.py index a1428e3fe..2b416dc31 100644 --- a/tests/api/v2/compute_duration_by_resource.py +++ b/tests/api/v2/test_compute_duration_by_resource_scenarios.py @@ -20,16 +20,25 @@ import datetime import logging +import testscenarios from ceilometer.openstack.common import timeutils from ceilometer.storage import models from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) class TestComputeDurationByResource(FunctionalTest): + 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() diff --git a/tests/api/v2/test_impl_hbase.py b/tests/api/v2/test_impl_hbase.py deleted file mode 100644 index 5a857b6d2..000000000 --- a/tests/api/v2/test_impl_hbase.py +++ /dev/null @@ -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__' diff --git a/tests/api/v2/test_impl_mongodb.py b/tests/api/v2/test_impl_mongodb.py deleted file mode 100644 index 105c76046..000000000 --- a/tests/api/v2/test_impl_mongodb.py +++ /dev/null @@ -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__' diff --git a/tests/api/v2/test_impl_sqlalchemy.py b/tests/api/v2/test_impl_sqlalchemy.py deleted file mode 100644 index 18f0a480f..000000000 --- a/tests/api/v2/test_impl_sqlalchemy.py +++ /dev/null @@ -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:// ' diff --git a/tests/api/v2/list_events.py b/tests/api/v2/test_list_events_scenarios.py similarity index 95% rename from tests/api/v2/list_events.py rename to tests/api/v2/test_list_events_scenarios.py index 6b51309e7..c1a76181f 100644 --- a/tests/api/v2/list_events.py +++ b/tests/api/v2/test_list_events_scenarios.py @@ -21,6 +21,7 @@ import datetime import logging import webtest.app +import testscenarios from oslo.config import cfg @@ -29,11 +30,19 @@ from ceilometer import counter from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) class TestListEvents(FunctionalTest): + 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() self.counter1 = counter.Counter( diff --git a/tests/api/v2/list_meters.py b/tests/api/v2/test_list_meters_scenarios.py similarity index 92% rename from tests/api/v2/list_meters.py rename to tests/api/v2/test_list_meters_scenarios.py index f6b10c05e..caf004b0a 100644 --- a/tests/api/v2/list_meters.py +++ b/tests/api/v2/test_list_meters_scenarios.py @@ -20,6 +20,7 @@ import datetime import logging +import testscenarios from oslo.config import cfg @@ -28,11 +29,19 @@ from ceilometer import counter from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) 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): data = self.get_json('/meters') self.assertEquals([], data) @@ -40,6 +49,12 @@ class TestListEmptyMeters(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): super(TestListMeters, self).setUp() diff --git a/tests/api/v2/list_resources.py b/tests/api/v2/test_list_resources_scenarios.py similarity index 98% rename from tests/api/v2/list_resources.py rename to tests/api/v2/test_list_resources_scenarios.py index 626a33862..fb7f2a5bf 100644 --- a/tests/api/v2/list_resources.py +++ b/tests/api/v2/test_list_resources_scenarios.py @@ -20,6 +20,7 @@ import datetime import logging +import testscenarios from oslo.config import cfg @@ -28,11 +29,19 @@ from ceilometer import counter from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) 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': {}} def test_empty(self): diff --git a/tests/api/v2/post_samples.py b/tests/api/v2/test_post_samples_scenarios.py similarity index 97% rename from tests/api/v2/post_samples.py rename to tests/api/v2/test_post_samples_scenarios.py index 6a50409d8..c2c5eaaae 100644 --- a/tests/api/v2/post_samples.py +++ b/tests/api/v2/test_post_samples_scenarios.py @@ -21,17 +21,26 @@ import copy import datetime import logging +import testscenarios from ceilometer.openstack.common import rpc from ceilometer.openstack.common import timeutils from .base import FunctionalTest +load_tests = testscenarios.load_tests_apply_scenarios + LOG = logging.getLogger(__name__) 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): self.published.append((topic, msg)) diff --git a/tests/api/v2/statistics.py b/tests/api/v2/test_statistics_scenarios.py similarity index 95% rename from tests/api/v2/statistics.py rename to tests/api/v2/test_statistics_scenarios.py index 6d5f4dc45..607240c82 100644 --- a/tests/api/v2/statistics.py +++ b/tests/api/v2/test_statistics_scenarios.py @@ -18,6 +18,7 @@ """Test events statistics retrieval.""" import datetime +import testscenarios from oslo.config import cfg @@ -25,9 +26,17 @@ from . import base from ceilometer import counter from ceilometer.publisher import rpc +load_tests = testscenarios.load_tests_apply_scenarios + 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' def setUp(self): @@ -128,6 +137,12 @@ class TestMaxProjectVolume(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' def setUp(self): @@ -244,6 +259,12 @@ class TestMaxResourceVolume(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' def setUp(self): @@ -346,6 +367,12 @@ class TestSumProjectVolume(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' def setUp(self):