From bba5cc1a11f591b5f51479508d62a802411d3571 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 3 Feb 2024 23:06:18 +0900 Subject: [PATCH] Add functional test with redis backend Change-Id: I6318f6ad00d5b0ee3db1be5e8671a4c346b9daff --- .zuul.yaml | 28 ++++++++++++++++-- .../dogpile_cache_redis/test_cache_backend.py | 29 +++++++++++++++++++ .../test_cache_backend.py | 29 +++++++++++++++++++ tox.ini | 2 +- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 oslo_cache/tests/functional/dogpile_cache_redis/test_cache_backend.py create mode 100644 oslo_cache/tests/functional/dogpile_cache_redis_sentinel/test_cache_backend.py 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/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..ac0871d7 --- /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='dogpule.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/test_cache_backend.py b/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/test_cache_backend.py new file mode 100644 index 00000000..aa59d542 --- /dev/null +++ b/oslo_cache/tests/functional/dogpile_cache_redis_sentinel/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 TestRedisSentinelCacheBackend(test_base.BaseTestCaseCacheBackend): + def setUp(self): + self.config_fixture.config( + group='cache', + backend='dogpule.cache.redis_sentine;', + redis_sentinels=['127.0.0.1:6380'], + ) + + # 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/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 =