Skip to content

Commit 937a135

Browse files
committed
Use standard Redis docker image in CI
Adapt the tests to use the standard Redis docker image where possible, instead of using the Redis Stack image in all places. This way we can run the CI, at least in theory, against different versions of Redis and Redis Stack dockers.
1 parent b7a85eb commit 937a135

13 files changed

+151
-59
lines changed

docker-compose.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@ version: "3.8"
55
services:
66

77
redis:
8-
image: redis/redis-stack-server:edge
8+
image: redis:latest
99
container_name: redis-standalone
10+
command: redis-server --enable-debug-command yes
1011
ports:
1112
- 6379:6379
12-
environment:
13-
- "REDIS_ARGS=--enable-debug-command yes --enable-module-command yes"
1413
profiles:
1514
- standalone
1615
- sentinel
1716
- replica
1817
- all
1918

2019
replica:
21-
image: redis/redis-stack-server:edge
20+
image: redis:latest
2221
container_name: redis-replica
2322
depends_on:
2423
- redis
25-
environment:
26-
- "REDIS_ARGS=--replicaof redis 6379"
24+
command: redis-server --replicaof redis 6379
2725
ports:
2826
- 6380:6379
2927
profiles:
@@ -63,13 +61,11 @@ services:
6361
- "./dockers/stunnel/keys:/etc/stunnel/keys:ro"
6462

6563
sentinel:
66-
image: redis/redis-stack-server:edge
64+
image: redis:latest
6765
container_name: redis-sentinel
6866
depends_on:
6967
- redis
70-
environment:
71-
- "REDIS_ARGS=--port 26379"
72-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26379"
68+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26379"
7369
ports:
7470
- 26379:26379
7571
volumes:
@@ -79,13 +75,11 @@ services:
7975
- all
8076

8177
sentinel2:
82-
image: redis/redis-stack-server:edge
78+
image: redis:latest
8379
container_name: redis-sentinel2
8480
depends_on:
8581
- redis
86-
environment:
87-
- "REDIS_ARGS=--port 26380"
88-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26380"
82+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26380"
8983
ports:
9084
- 26380:26380
9185
volumes:
@@ -95,15 +89,26 @@ services:
9589
- all
9690

9791
sentinel3:
98-
image: redis/redis-stack-server:edge
92+
image: redis:latest
9993
container_name: redis-sentinel3
10094
depends_on:
10195
- redis
102-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26381"
96+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26381"
10397
ports:
10498
- 26381:26381
10599
volumes:
106100
- "./dockers/sentinel.conf:/redis.conf"
107101
profiles:
108102
- sentinel
109103
- all
104+
105+
redis-stack:
106+
image: redis/redis-stack-server:edge
107+
container_name: redis-stack
108+
ports:
109+
- 6479:6379
110+
environment:
111+
- "REDIS_ARGS=--enable-debug-command yes --enable-module-command yes"
112+
profiles:
113+
- standalone
114+
- all

tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
REDIS_INFO = {}
1919
default_redis_url = "redis://localhost:6379/0"
2020
default_protocol = "2"
21-
default_redismod_url = "redis://localhost:6379"
21+
default_redismod_url = "redis://localhost:6479"
2222

2323
# default ssl client ignores verification for the purpose of testing
2424
default_redis_ssl_url = "rediss://localhost:6666"
@@ -341,6 +341,12 @@ def r(request):
341341
yield client
342342

343343

344+
@pytest.fixture()
345+
def stack_r(request):
346+
with _get_client(redis.Redis, request, from_url=default_redismod_url) as client:
347+
yield client
348+
349+
344350
@pytest.fixture()
345351
def decoded_r(request):
346352
with _get_client(redis.Redis, request, decode_responses=True) as client:

tests/test_asyncio/test_bloom.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
from math import inf
22

33
import pytest
4+
import pytest_asyncio
45
import redis.asyncio as redis
56
from redis.exceptions import ModuleError, RedisError
67
from redis.utils import HIREDIS_AVAILABLE
78
from tests.conftest import (
89
assert_resp_response,
10+
default_redismod_url,
911
is_resp2_connection,
1012
skip_ifmodversion_lt,
1113
)
1214

1315

16+
@pytest_asyncio.fixture()
17+
async def decoded_r(create_redis):
18+
return await create_redis(decode_responses=True, url=default_redismod_url)
19+
20+
1421
def intlist(obj):
1522
return [int(v) for v in obj]
1623

tests/test_asyncio/test_graph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import pytest
2+
import pytest_asyncio
23
import redis.asyncio as redis
34
from redis.commands.graph import Edge, Node, Path
45
from redis.commands.graph.execution_plan import Operation
56
from redis.exceptions import ResponseError
6-
from tests.conftest import skip_if_redis_enterprise
7+
from tests.conftest import default_redismod_url, skip_if_redis_enterprise
8+
9+
10+
@pytest_asyncio.fixture()
11+
async def decoded_r(create_redis):
12+
return await create_redis(decode_responses=True, url=default_redismod_url)
713

814

915
async def test_bulk(decoded_r):

tests/test_asyncio/test_json.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import pytest
2+
import pytest_asyncio
23
import redis.asyncio as redis
34
from redis import exceptions
45
from redis.commands.json.path import Path
5-
from tests.conftest import assert_resp_response, skip_ifmodversion_lt
6+
from tests.conftest import (
7+
assert_resp_response,
8+
default_redismod_url,
9+
skip_ifmodversion_lt,
10+
)
11+
12+
13+
@pytest_asyncio.fixture()
14+
async def decoded_r(create_redis):
15+
return await create_redis(decode_responses=True, url=default_redismod_url)
616

717

818
async def test_json_setbinarykey(decoded_r: redis.Redis):

tests/test_asyncio/test_search.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from io import TextIOWrapper
66

77
import pytest
8+
import pytest_asyncio
89
import redis.asyncio as redis
910
import redis.commands.search
1011
import redis.commands.search.aggregation as aggregations
@@ -17,6 +18,7 @@
1718
from redis.commands.search.suggestion import Suggestion
1819
from tests.conftest import (
1920
assert_resp_response,
21+
default_redismod_url,
2022
is_resp2_connection,
2123
skip_if_redis_enterprise,
2224
skip_ifmodversion_lt,
@@ -31,6 +33,11 @@
3133
)
3234

3335

36+
@pytest_asyncio.fixture()
37+
async def decoded_r(create_redis):
38+
return await create_redis(decode_responses=True, url=default_redismod_url)
39+
40+
3441
async def waitForIndex(env, idx, timeout=None):
3542
delay = 0.1
3643
while True:

tests/test_asyncio/test_timeseries.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
from time import sleep
33

44
import pytest
5+
import pytest_asyncio
56
import redis.asyncio as redis
67
from tests.conftest import (
78
assert_resp_response,
9+
default_redismod_url,
810
is_resp2_connection,
911
skip_ifmodversion_lt,
1012
)
1113

1214

15+
@pytest_asyncio.fixture()
16+
async def decoded_r(create_redis):
17+
return await create_redis(decode_responses=True, url=default_redismod_url)
18+
19+
1320
async def test_create(decoded_r: redis.Redis):
1421
assert await decoded_r.ts().create(1)
1522
assert await decoded_r.ts().create(2, retention_msecs=5)
@@ -214,18 +221,20 @@ async def test_del_range(decoded_r: redis.Redis):
214221
)
215222

216223

217-
async def test_range(r: redis.Redis):
224+
async def test_range(decoded_r: redis.Redis):
218225
for i in range(100):
219-
await r.ts().add(1, i, i % 7)
220-
assert 100 == len(await r.ts().range(1, 0, 200))
226+
await decoded_r.ts().add(1, i, i % 7)
227+
assert 100 == len(await decoded_r.ts().range(1, 0, 200))
221228
for i in range(100):
222-
await r.ts().add(1, i + 200, i % 7)
223-
assert 200 == len(await r.ts().range(1, 0, 500))
229+
await decoded_r.ts().add(1, i + 200, i % 7)
230+
assert 200 == len(await decoded_r.ts().range(1, 0, 500))
224231
# last sample isn't returned
225232
assert 20 == len(
226-
await r.ts().range(1, 0, 500, aggregation_type="avg", bucket_size_msec=10)
233+
await decoded_r.ts().range(
234+
1, 0, 500, aggregation_type="avg", bucket_size_msec=10
235+
)
227236
)
228-
assert 10 == len(await r.ts().range(1, 0, 500, count=10))
237+
assert 10 == len(await decoded_r.ts().range(1, 0, 500, count=10))
229238

230239

231240
@skip_ifmodversion_lt("99.99.99", "timeseries")

tests/test_bloom.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@
55
from redis.exceptions import ModuleError, RedisError
66
from redis.utils import HIREDIS_AVAILABLE
77

8-
from .conftest import assert_resp_response, is_resp2_connection, skip_ifmodversion_lt
8+
from .conftest import (
9+
_get_client,
10+
assert_resp_response,
11+
default_redismod_url,
12+
is_resp2_connection,
13+
skip_ifmodversion_lt,
14+
)
15+
16+
17+
@pytest.fixture()
18+
def decoded_r(request):
19+
with _get_client(
20+
redis.Redis, request, decode_responses=True, from_url=default_redismod_url
21+
) as client:
22+
yield client
923

1024

1125
def intlist(obj):

tests/test_commands.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,44 +1818,44 @@ def try_delete_libs(self, r, *lib_names):
18181818

18191819
@pytest.mark.onlynoncluster
18201820
@skip_if_server_version_lt("7.1.140")
1821-
def test_tfunction_load_delete(self, r):
1822-
self.try_delete_libs(r, "lib1")
1821+
def test_tfunction_load_delete(self, stack_r):
1822+
self.try_delete_libs(stack_r, "lib1")
18231823
lib_code = self.generate_lib_code("lib1")
1824-
assert r.tfunction_load(lib_code)
1825-
assert r.tfunction_delete("lib1")
1824+
assert stack_r.tfunction_load(lib_code)
1825+
assert stack_r.tfunction_delete("lib1")
18261826

18271827
@pytest.mark.onlynoncluster
18281828
@skip_if_server_version_lt("7.1.140")
1829-
def test_tfunction_list(self, r):
1830-
self.try_delete_libs(r, "lib1", "lib2", "lib3")
1831-
assert r.tfunction_load(self.generate_lib_code("lib1"))
1832-
assert r.tfunction_load(self.generate_lib_code("lib2"))
1833-
assert r.tfunction_load(self.generate_lib_code("lib3"))
1829+
def test_tfunction_list(self, stack_r):
1830+
self.try_delete_libs(stack_r, "lib1", "lib2", "lib3")
1831+
assert stack_r.tfunction_load(self.generate_lib_code("lib1"))
1832+
assert stack_r.tfunction_load(self.generate_lib_code("lib2"))
1833+
assert stack_r.tfunction_load(self.generate_lib_code("lib3"))
18341834

18351835
# test error thrown when verbose > 4
18361836
with pytest.raises(redis.exceptions.DataError):
1837-
assert r.tfunction_list(verbose=8)
1837+
assert stack_r.tfunction_list(verbose=8)
18381838

1839-
functions = r.tfunction_list(verbose=1)
1839+
functions = stack_r.tfunction_list(verbose=1)
18401840
assert len(functions) == 3
18411841

18421842
expected_names = [b"lib1", b"lib2", b"lib3"]
18431843
actual_names = [functions[0][13], functions[1][13], functions[2][13]]
18441844

18451845
assert sorted(expected_names) == sorted(actual_names)
1846-
assert r.tfunction_delete("lib1")
1847-
assert r.tfunction_delete("lib2")
1848-
assert r.tfunction_delete("lib3")
1846+
assert stack_r.tfunction_delete("lib1")
1847+
assert stack_r.tfunction_delete("lib2")
1848+
assert stack_r.tfunction_delete("lib3")
18491849

18501850
@pytest.mark.onlynoncluster
18511851
@skip_if_server_version_lt("7.1.140")
1852-
def test_tfcall(self, r):
1853-
self.try_delete_libs(r, "lib1")
1854-
assert r.tfunction_load(self.generate_lib_code("lib1"))
1855-
assert r.tfcall("lib1", "foo") == b"bar"
1856-
assert r.tfcall_async("lib1", "foo") == b"bar"
1852+
def test_tfcall(self, stack_r):
1853+
self.try_delete_libs(stack_r, "lib1")
1854+
assert stack_r.tfunction_load(self.generate_lib_code("lib1"))
1855+
assert stack_r.tfcall("lib1", "foo") == b"bar"
1856+
assert stack_r.tfcall_async("lib1", "foo") == b"bar"
18571857

1858-
assert r.tfunction_delete("lib1")
1858+
assert stack_r.tfunction_delete("lib1")
18591859

18601860
def test_ttl(self, r):
18611861
r["a"] = "1"
@@ -5022,25 +5022,27 @@ def test_command_getkeysandflags(self, r: redis.Redis):
50225022
@pytest.mark.onlynoncluster
50235023
@skip_if_server_version_lt("4.0.0")
50245024
@skip_if_redis_enterprise()
5025-
def test_module(self, r):
5025+
def test_module(self, stack_r):
50265026
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
5027-
r.module_load("/some/fake/path")
5027+
stack_r.module_load("/some/fake/path")
50285028
assert "Error loading the extension." in str(excinfo.value)
50295029

50305030
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
5031-
r.module_load("/some/fake/path", "arg1", "arg2", "arg3", "arg4")
5031+
stack_r.module_load("/some/fake/path", "arg1", "arg2", "arg3", "arg4")
50325032
assert "Error loading the extension." in str(excinfo.value)
50335033

50345034
@pytest.mark.onlynoncluster
50355035
@skip_if_server_version_lt("7.0.0")
50365036
@skip_if_redis_enterprise()
5037-
def test_module_loadex(self, r: redis.Redis):
5037+
def test_module_loadex(self, stack_r: redis.Redis):
50385038
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
5039-
r.module_loadex("/some/fake/path")
5039+
stack_r.module_loadex("/some/fake/path")
50405040
assert "Error loading the extension." in str(excinfo.value)
50415041

50425042
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
5043-
r.module_loadex("/some/fake/path", ["name", "value"], ["arg1", "arg2"])
5043+
stack_r.module_loadex(
5044+
"/some/fake/path", ["name", "value"], ["arg1", "arg2"]
5045+
)
50445046
assert "Error loading the extension." in str(excinfo.value)
50455047

50465048
@skip_if_server_version_lt("2.6.0")

tests/test_graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
QueryResult,
2121
)
2222
from redis.exceptions import ResponseError
23-
from tests.conftest import _get_client, skip_if_redis_enterprise
23+
from tests.conftest import _get_client, default_redismod_url, skip_if_redis_enterprise
2424

2525

2626
@pytest.fixture
2727
def client(request):
28-
r = _get_client(Redis, request, decode_responses=True)
28+
r = _get_client(
29+
Redis, request, decode_responses=True, from_url=default_redismod_url
30+
)
2931
r.flushdb()
3032
return r
3133

0 commit comments

Comments
 (0)