Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RE tests to CI #3119

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
75 changes: 75 additions & 0 deletions .github/workflows/test-redis-enterprise.yml
@@ -0,0 +1,75 @@
name: RE Tests

on:
push:
paths-ignore:
- 'docs/**'
- '**/*.rst'
- '**/*.md'
branches:
- master
- '[0-9].[0-9]'
pull_request:
branches:
- master
- '[0-9].[0-9]'
schedule:
- cron: '0 1 * * *' # nightly build

concurrency:
group: ${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
enterprise_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
test-type: ['standalone']
connection-type: ['hiredis', 'plain']
re-build: ["latest"]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: RE [${{ matrix.re-build }} ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Clone Redis EE docker repository
uses: actions/checkout@v4
with:
repository: RedisLabs/redis-ee-docker
path: redis-ee

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Build cluster
working-directory: redis-ee
env:
IMAGE: "redislabs/redis:${{ matrix.re-build }}"
RE_USERNAME: test@test.com
RE_PASS: 12345
RE_CLUSTER_NAME: test
RE_USE_OSS_CLUSTER: false
RE_DB_PORT: 6379
run: ./build.sh

- name: Run tests
run: |
pip install -U setuptools wheel
pip install -r requirements.txt
pip install -r dev_requirements.txt
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
pip install hiredis
fi
sleep 10 # time to settle
invoke ${{matrix.test-type}}-tests
22 changes: 17 additions & 5 deletions redis/_parsers/helpers.py
Expand Up @@ -379,13 +379,21 @@ def parse_item(item):
# an O(N) complexity) instead of the command.
if isinstance(item[3], list):
result["command"] = space.join(item[3])
result["client_address"] = item[4]
result["client_name"] = item[5]
try:
result["client_address"] = item[4]
result["client_name"] = item[5]
except IndexError:
# The client address and name are not always present (in enterprise)
pass
else:
result["complexity"] = item[3]
result["command"] = space.join(item[4])
result["client_address"] = item[5]
result["client_name"] = item[6]
try:
result["client_address"] = item[5]
result["client_name"] = item[6]
except IndexError:
# The client address and name are not always present (in enterprise)
pass
return result

return [parse_item(item) for item in response]
Expand Down Expand Up @@ -650,7 +658,11 @@ def parse_client_info(value):
"omem",
"tot-mem",
}:
client_info[int_key] = int(client_info[int_key])
try:
client_info[int_key] = int(client_info[int_key])
except KeyError:
# not all fields exist in enterprise
pass
return client_info


Expand Down
2 changes: 1 addition & 1 deletion redis/asyncio/connection.py
Expand Up @@ -696,7 +696,7 @@ def _cache_invalidation_process(
and the second string is the list of keys to invalidate.
(if the list of keys is None, then all keys are invalidated)
"""
if data[1] is not None:
if data[1] is None:
self.client_cache.flush()
else:
for key in data[1]:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_asyncio/test_bloom.py
Expand Up @@ -7,6 +7,7 @@
from tests.conftest import (
assert_resp_response,
is_resp2_connection,
skip_if_redis_enterprise,
skip_ifmodversion_lt,
)

Expand Down Expand Up @@ -224,6 +225,7 @@ async def test_cms(decoded_r: redis.Redis):


@pytest.mark.onlynoncluster
@skip_if_redis_enterprise()
async def test_cms_merge(decoded_r: redis.Redis):
assert await decoded_r.cms().initbydim("A", 1000, 5)
assert await decoded_r.cms().initbydim("B", 1000, 5)
Expand Down Expand Up @@ -351,6 +353,7 @@ async def test_tdigest_reset(decoded_r: redis.Redis):


@pytest.mark.onlynoncluster
@skip_if_redis_enterprise()
async def test_tdigest_merge(decoded_r: redis.Redis):
assert await decoded_r.tdigest().create("to-tDigest", 10)
assert await decoded_r.tdigest().create("from-tDigest", 10)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_asyncio/test_cache.py
Expand Up @@ -4,6 +4,7 @@
import pytest_asyncio
from redis._cache import _LocalCache
from redis.utils import HIREDIS_AVAILABLE
from tests.conftest import skip_if_server_version_lt


@pytest_asyncio.fixture
Expand All @@ -15,6 +16,7 @@ async def r(request, create_redis):


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@skip_if_server_version_lt("7.4.0")
class TestLocalCache:
@pytest.mark.onlynoncluster
@pytest.mark.parametrize("r", [{"cache": _LocalCache()}], indirect=True)
Expand Down Expand Up @@ -187,6 +189,7 @@ async def test_csc_not_cause_disconnects(self, r):

@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@pytest.mark.onlycluster
@skip_if_server_version_lt("7.4.0")
class TestClusterLocalCache:
@pytest.mark.parametrize("r", [{"cache": _LocalCache()}], indirect=True)
async def test_get_from_cache(self, r, r2):
Expand Down