diff --git a/.zuul.yaml b/.zuul.yaml index 90045537..49d7347f 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -35,14 +35,14 @@ parent: oslo.cache-functional-memcached vars: tox_environment: - OSLO_BACKEND: dogpile_cache_bmemcached + OSLO_BACKEND: dogpile_cache_bmemcached - job: name: oslo.cache-functional-dogpile.cache.pymemcache parent: oslo.cache-functional-memcached vars: tox_environment: - OSLO_BACKEND: dogpile_cache_pymemcache + OSLO_BACKEND: dogpile_cache_pymemcache - job: name: oslo.cache-functional-memcache_pool @@ -51,6 +51,28 @@ tox_environment: OSLO_BACKEND: memcache_pool +- job: + name: oslo.cache-functional-redis + parent: oslo.cache-functional + vars: + tox_environment: + PIFPAF_DAEMON: redis + +- job: + name: oslo.cache-functional-dogpile.cache.redis + parent: oslo.cache-functional-redis + vars: + tox_environment: + OSLO_BACKEND: dogpile_cache_redis + +- job: + name: oslo.cache-functional-dogpile.cache.redis_sentinel + parent: oslo.cache-functional-redis + vars: + tox_environment: + OSLO_BACKEND: dogpile_cache_redis_sentinel + PIFPAF_OPTS: --sentinel + - project: templates: - check-requirements @@ -65,3 +87,5 @@ - oslo.cache-functional-dogpile.cache.bmemcached - oslo.cache-functional-dogpile.cache.pymemcache - oslo.cache-functional-memcache_pool + - oslo.cache-functional-dogpile.cache.redis + - oslo.cache-functional-dogpile.cache.redis_sentinel diff --git a/bindep.txt b/bindep.txt index 1e5a81e6..1949ae48 100644 --- a/bindep.txt +++ b/bindep.txt @@ -3,3 +3,6 @@ etcd [tests-functional-etcd] memcached [tests-functional-memcached] +redis [platform:rpm tests-functional-redis] +redis-server [platform:dpkg tests-functional-redis] +redis-sentinel [platform:dpkg tests-functional-redis] diff --git a/oslo_cache/tests/functional/dogpile_cache_redis/__init__.py b/oslo_cache/tests/functional/dogpile_cache_redis/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/oslo_cache/tests/functional/dogpile_cache_redis/test_cache_backend.py b/oslo_cache/tests/functional/dogpile_cache_redis/test_cache_backend.py new file mode 100644 index 00000000..12ffa6eb --- /dev/null +++ b/oslo_cache/tests/functional/dogpile_cache_redis/test_cache_backend.py @@ -0,0 +1,29 @@ +# Copyright 2024 OpenStack Foundation +# +# 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 TestRedisCacheBackend(test_base.BaseTestCaseCacheBackend): + def setUp(self): + self.config_fixture.config( + group='cache', + backend='dogpile.cache.redis', + redis_server='127.0.0.1:6379', + ) + + # 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/dogpile_cache_redis_sentinel/__init__.py b/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/test_cache_backend.py b/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/test_cache_backend.py new file mode 100644 index 00000000..34546b4b --- /dev/null +++ b/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/test_cache_backend.py @@ -0,0 +1,30 @@ +# Copyright 2024 OpenStack Foundation +# +# 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 TestRedisSentinelCacheBackend(test_base.BaseTestCaseCacheBackend): + def setUp(self): + self.config_fixture.config( + group='cache', + backend='dogpile.cache.redis_sentinel', + redis_sentinels=['127.0.0.1:6380'], + redis_sentinel_service_name='pifpaf' + ) + + # 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/playbooks/tests/functional/Debian.yaml b/playbooks/tests/functional/Debian.yaml new file mode 100644 index 00000000..cd475fbc --- /dev/null +++ b/playbooks/tests/functional/Debian.yaml @@ -0,0 +1,9 @@ +--- +backend_services_map: + redis: + - redis-server + - redis-sentinel + memcached: + - memcached + etcd: + - etcd diff --git a/playbooks/tests/functional/RedHat.yaml b/playbooks/tests/functional/RedHat.yaml new file mode 100644 index 00000000..0b025751 --- /dev/null +++ b/playbooks/tests/functional/RedHat.yaml @@ -0,0 +1,9 @@ +--- +backend_services_map: + redis: + - redis + - redis-sentinel + memcached: + - memcached + etcd: + - etcd diff --git a/playbooks/tests/functional/pre.yml b/playbooks/tests/functional/pre.yml index e3c928f4..3abb4c4c 100644 --- a/playbooks/tests/functional/pre.yml +++ b/playbooks/tests/functional/pre.yml @@ -5,13 +5,16 @@ - role: bindep bindep_profile: "tests-functional-{{ oslo_cache_backend_daemon }}" tasks: + - name: Include OS-specific variables + include_vars: "{{ ansible_os_family }}.yaml" # NOTE(yoctozepto): Debian and Ubuntu have this nasty policy of starting # installed services for us. We don't rely on system-wide service and use # pifpaf. Unfortunately, default port may conflict with system-wide service. # So, for sanity and resource conservation, let's stop it before tests run. - - name: "Stop {{ oslo_cache_backend_daemon }}" + - name: "Stop backend services" service: - name: "{{ oslo_cache_backend_daemon }}" + name: "{{ item }}" state: stopped enabled: no become: yes + loop: "{{ backend_services_map[oslo_cache_backend_daemon] }}" diff --git a/setup.cfg b/setup.cfg index 3f6cc31c..b0329148 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,7 @@ dogpile = python-memcached>=1.56 # PSF pymemcache>=3.5.0 # Apache-2.0 python-binary-memcached>=0.29.0 # MIT + redis>=3.0.0 # MIT mongo = pymongo!=3.1,>=3.0.2 # Apache-2.0 etcd3gw = diff --git a/test-requirements.txt b/test-requirements.txt index f637ba37..e60f7078 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,3 +6,4 @@ python-binary-memcached>=0.29.0 # MIT python-memcached>=1.56 # PSF pymongo!=3.1,>=3.0.2 # Apache-2.0 etcd3gw>=0.2.0 # Apache-2.0 +redis>=3.0.0 # MIT diff --git a/tox.ini b/tox.ini index 9874b3fd..9cfda8b8 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ setenv = STESTR_TEST_PATH=./oslo_cache/tests/functional/{env:OSLO_BACKEND} commands = find . -type f -name "*.pyc" -delete - pifpaf -e OSLO_CACHE_TEST run {env:PIFPAF_DAEMON} -- stestr run --slowest + pifpaf -e OSLO_CACHE_TEST run {env:PIFPAF_DAEMON} {env:PIFPAF_OPTS} -- stestr run --slowest [testenv:pep8] deps =