diff --git a/.zuul.yaml b/.zuul.yaml index 36e01271..5a10f5e2 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,3 +1,12 @@ +## Functional Tests env vars +# +# PIFPAF_DAEMON: +# The binary to be installed by bindep filtered with +# [tests-functional-{PIFPAF_DAEMON}] and executed by pifpaf. +# +# OSLO_BACKEND: +# The functional test directory to pass to STESTR_TEST_PATH + - job: name: oslo.cache-functional parent: openstack-tox @@ -12,10 +21,22 @@ vars: tox_environment: PIFPAF_DAEMON: etcd - # The next env var correspond to the functional test - # directory to pass to STESTR_TEST_PATH OSLO_BACKEND: etcd3gw +- job: + name: oslo.cache-functional-memcached + parent: oslo.cache-functional + vars: + tox_environment: + PIFPAF_DAEMON: memcached + +- job: + name: oslo.cache-functional-dogpile.cache.bmemcached + parent: oslo.cache-functional-memcached + vars: + tox_environment: + OSLO_BACKEND: dogpile_cache_bmemcached + - project: templates: - check-requirements @@ -28,3 +49,4 @@ check: jobs: - oslo.cache-functional-etcd3gw + - oslo.cache-functional-dogpile.cache.bmemcached diff --git a/bindep.txt b/bindep.txt index d374994a..1e5a81e6 100644 --- a/bindep.txt +++ b/bindep.txt @@ -2,3 +2,4 @@ # More info at: https://docs.openstack.org/infra/bindep/readme.html etcd [tests-functional-etcd] +memcached [tests-functional-memcached] diff --git a/oslo_cache/tests/functional/dogpile_cache_bmemcached/__init__.py b/oslo_cache/tests/functional/dogpile_cache_bmemcached/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/oslo_cache/tests/functional/dogpile_cache_bmemcached/test_cache_backend.py b/oslo_cache/tests/functional/dogpile_cache_bmemcached/test_cache_backend.py new file mode 100644 index 00000000..aa0bb0c8 --- /dev/null +++ b/oslo_cache/tests/functional/dogpile_cache_bmemcached/test_cache_backend.py @@ -0,0 +1,29 @@ +# Copyright 2020 Red Hat, 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 oslo_cache.tests.functional import test_base + + +class TestDogpileCacheBMemcachedBackend(test_base.BaseTestCaseCacheBackend): + def setUp(self): + self.config_fixture.config( + group="cache", + backend="dogpile.cache.bmemcached", + memcache_servers="localhost:11212", + ) + + # NOTE(hberaud): super must be called after all to ensure that + # config fixture is properly initialized with value related to + # the current backend in use. + super().setUp() diff --git a/oslo_cache/tests/functional/etcd3gw/test_cache_backend.py b/oslo_cache/tests/functional/etcd3gw/test_cache_backend.py index 4a6fa7c4..83d0f837 100644 --- a/oslo_cache/tests/functional/etcd3gw/test_cache_backend.py +++ b/oslo_cache/tests/functional/etcd3gw/test_cache_backend.py @@ -12,22 +12,18 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import fixture as config_fixture - from oslo_cache.tests.functional import test_base class TestEtcdCacheBackend(test_base.BaseTestCaseCacheBackend): def setUp(self): - self.config_fixture = self.useFixture(config_fixture.Config()) self.config_fixture.config( group='cache', backend='oslo_cache.etcd3gw', - enabled=True, - proxies=['oslo_cache.testing.CacheIsolatingProxy'], backend_argument=['host:127.0.0.1', 'port:2379'] ) + # NOTE(hberaud): super must be called after all to ensure that # config fixture is properly initialized with value related to # the current backend in use. - super(TestEtcdCacheBackend, self).setUp() + super().setUp() diff --git a/oslo_cache/tests/functional/test_base.py b/oslo_cache/tests/functional/test_base.py index 17bf3c06..0a1ffc99 100644 --- a/oslo_cache/tests/functional/test_base.py +++ b/oslo_cache/tests/functional/test_base.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import fixture from oslo_utils import uuidutils from oslotest import base @@ -22,23 +23,31 @@ NO_VALUE = cache.NO_VALUE class BaseTestCaseCacheBackend(base.BaseTestCase): - def setUp(self): - super(BaseTestCaseCacheBackend, self).setUp() - if not hasattr(self, 'config_fixture'): - raise Exception("Functional tests base class can't be used " - "directly first you should define a test class " - "backend wrapper to init the related " - "config fixture") + super().setUp() + + self.conf = self.config_fixture.conf + self.region = cache.create_region() - cache.configure_cache_region(self.config_fixture.conf, self.region) self.region_kwargs = cache.create_region( function=cache.kwarg_function_key_generator ) - cache.configure_cache_region( - self.config_fixture.conf, - self.region_kwargs - ) + + cache.configure_cache_region(self.conf, self.region) + cache.configure_cache_region(self.conf, self.region_kwargs) + + @property + def config_fixture(self): + if not hasattr(self, "_config_fixture"): + self._config_fixture = self.useFixture(fixture.Config()) + + # default config for all tests + self._config_fixture.config( + group="cache", + enabled=True, + ) + + return self._config_fixture def test_backend_get_missing_data(self): random_key = uuidutils.generate_uuid(dashed=False)