Skip to content

Commit 153c310

Browse files
committed
Use standard Redis docker image in CI (redis#3246)
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 against different versions of Redis and Redis Stack. Run the test cluster based on the default Redis docker image, i.e. without Stack support. This is needed in order to make the CI pass until Stack gets a new release. What is needed is to mark all Stack related tests accordingly, and then they don't get executed in the cluster tests (they are already filtered out in `invoke cluster-tests`). Take the opportunity to remove some empty tests and to fix the naming in two tests. --------- Co-authored-by: Gabriel Erzse <[email protected]>
1 parent 11f7615 commit 153c310

18 files changed

+344
-175
lines changed

docker-compose.yml

+23-16
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:7.2.0-v11
8+
image: ${REDIS_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:7.2.0-v11
20+
image: ${REDIS_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:
@@ -35,6 +33,8 @@ services:
3533
build:
3634
context: .
3735
dockerfile: dockers/Dockerfile.cluster
36+
args:
37+
REDIS_IMAGE: ${REDIS_IMAGE:-redis:latest}
3838
ports:
3939
- 16379:16379
4040
- 16380:16380
@@ -63,13 +63,11 @@ services:
6363
- "./dockers/stunnel/keys:/etc/stunnel/keys:ro"
6464

6565
sentinel:
66-
image: redis/redis-stack-server:7.2.0-v11
66+
image: ${REDIS_IMAGE:-redis:latest}
6767
container_name: redis-sentinel
6868
depends_on:
6969
- redis
70-
environment:
71-
- "REDIS_ARGS=--port 26379"
72-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26379"
70+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26379"
7371
ports:
7472
- 26379:26379
7573
volumes:
@@ -79,13 +77,11 @@ services:
7977
- all
8078

8179
sentinel2:
82-
image: redis/redis-stack-server:7.2.0-v11
80+
image: ${REDIS_IMAGE:-redis:latest}
8381
container_name: redis-sentinel2
8482
depends_on:
8583
- redis
86-
environment:
87-
- "REDIS_ARGS=--port 26380"
88-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26380"
84+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26380"
8985
ports:
9086
- 26380:26380
9187
volumes:
@@ -95,15 +91,26 @@ services:
9591
- all
9692

9793
sentinel3:
98-
image: redis/redis-stack-server:7.2.0-v11
94+
image: ${REDIS_IMAGE:-redis:latest}
9995
container_name: redis-sentinel3
10096
depends_on:
10197
- redis
102-
entrypoint: "/opt/redis-stack/bin/redis-sentinel /redis.conf --port 26381"
98+
entrypoint: "/usr/local/bin/redis-sentinel /redis.conf --port 26381"
10399
ports:
104100
- 26381:26381
105101
volumes:
106102
- "./dockers/sentinel.conf:/redis.conf"
107103
profiles:
108104
- sentinel
109105
- all
106+
107+
redis-stack:
108+
image: redis/redis-stack-server:edge
109+
container_name: redis-stack
110+
ports:
111+
- 6479:6379
112+
environment:
113+
- "REDIS_ARGS=--enable-debug-command yes --enable-module-command yes"
114+
profiles:
115+
- standalone
116+
- all

dockers/Dockerfile.cluster

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM redis/redis-stack-server:7.2.0-v11 as rss
1+
ARG REDIS_IMAGE=redis:latest
2+
FROM $REDIS_IMAGE
23

34
COPY dockers/create_cluster.sh /create_cluster.sh
4-
RUN ls -R /opt/redis-stack
55
RUN chmod a+x /create_cluster.sh
66

77
ENTRYPOINT [ "/create_cluster.sh"]

dockers/cluster.redis.conf

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
protected-mode no
22
enable-debug-command yes
3-
loadmodule /opt/redis-stack/lib/redisearch.so
4-
loadmodule /opt/redis-stack/lib/redistimeseries.so
5-
loadmodule /opt/redis-stack/lib/rejson.so
6-
loadmodule /opt/redis-stack/lib/redisbloom.so
7-
loadmodule /opt/redis-stack/lib/redisgears.so v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so

dockers/create_cluster.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dir /nodes/$PORT
3131
EOF
3232

3333
set -x
34-
/opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf
34+
/usr/local/bin/redis-server /nodes/$PORT/redis.conf
3535
sleep 1
3636
if [ $? -ne 0 ]; then
3737
echo "Redis failed to start, exiting."
@@ -40,8 +40,8 @@ EOF
4040
echo 127.0.0.1:$PORT >> /nodes/nodemap
4141
done
4242
if [ -z "${REDIS_PASSWORD}" ]; then
43-
echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
43+
echo yes | /usr/local/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
4444
else
45-
echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
45+
echo yes | /usr/local/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
4646
fi
4747
tail -f /redis.log

dockers/sentinel.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
sentinel monitor redis-py-test 127.0.0.1 6379 2
1+
sentinel resolve-hostnames yes
2+
sentinel monitor redis-py-test redis 6379 2
23
sentinel down-after-milliseconds redis-py-test 5000
34
sentinel failover-timeout redis-py-test 60000
45
sentinel parallel-syncs redis-py-test 1

tests/conftest.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
REDIS_INFO = {}
1818
default_redis_url = "redis://localhost:6379/0"
1919
default_protocol = "2"
20-
default_redismod_url = "redis://localhost:6379"
20+
default_redismod_url = "redis://localhost:6479"
2121

2222
# default ssl client ignores verification for the purpose of testing
2323
default_redis_ssl_url = "rediss://localhost:6666"
@@ -327,6 +327,21 @@ def r(request):
327327
yield client
328328

329329

330+
@pytest.fixture()
331+
def stack_url(request):
332+
stack_url = request.config.getoption("--redis-url", default=default_redismod_url)
333+
if stack_url == default_redis_url:
334+
return default_redismod_url
335+
else:
336+
return stack_url
337+
338+
339+
@pytest.fixture()
340+
def stack_r(request, stack_url):
341+
with _get_client(redis.Redis, request, from_url=stack_url) as client:
342+
yield client
343+
344+
330345
@pytest.fixture()
331346
def decoded_r(request):
332347
with _get_client(redis.Redis, request, decode_responses=True) as client:

tests/test_asyncio/test_bloom.py

+29-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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
@@ -11,10 +12,16 @@
1112
)
1213

1314

15+
@pytest_asyncio.fixture()
16+
async def decoded_r(create_redis, stack_url):
17+
return await create_redis(decode_responses=True, url=stack_url)
18+
19+
1420
def intlist(obj):
1521
return [int(v) for v in obj]
1622

1723

24+
@pytest.mark.redismod
1825
async def test_create(decoded_r: redis.Redis):
1926
"""Test CREATE/RESERVE calls"""
2027
assert await decoded_r.bf().create("bloom", 0.01, 1000)
@@ -30,10 +37,12 @@ async def test_create(decoded_r: redis.Redis):
3037

3138

3239
@pytest.mark.experimental
40+
@pytest.mark.redismod
3341
async def test_tdigest_create(decoded_r: redis.Redis):
3442
assert await decoded_r.tdigest().create("tDigest", 100)
3543

3644

45+
@pytest.mark.redismod
3746
async def test_bf_add(decoded_r: redis.Redis):
3847
assert await decoded_r.bf().create("bloom", 0.01, 1000)
3948
assert 1 == await decoded_r.bf().add("bloom", "foo")
@@ -46,6 +55,7 @@ async def test_bf_add(decoded_r: redis.Redis):
4655
assert [1, 0] == intlist(await decoded_r.bf().mexists("bloom", "foo", "noexist"))
4756

4857

58+
@pytest.mark.redismod
4959
async def test_bf_insert(decoded_r: redis.Redis):
5060
assert await decoded_r.bf().create("bloom", 0.01, 1000)
5161
assert [1] == intlist(await decoded_r.bf().insert("bloom", ["foo"]))
@@ -76,6 +86,7 @@ async def test_bf_insert(decoded_r: redis.Redis):
7686
)
7787

7888

89+
@pytest.mark.redismod
7990
async def test_bf_scandump_and_loadchunk(decoded_r: redis.Redis):
8091
# Store a filter
8192
await decoded_r.bf().create("myBloom", "0.0001", "1000")
@@ -127,6 +138,7 @@ async def do_verify():
127138
await decoded_r.bf().create("myBloom", "0.0001", "10000000")
128139

129140

141+
@pytest.mark.redismod
130142
async def test_bf_info(decoded_r: redis.Redis):
131143
expansion = 4
132144
# Store a filter
@@ -158,6 +170,7 @@ async def test_bf_info(decoded_r: redis.Redis):
158170
assert True
159171

160172

173+
@pytest.mark.redismod
161174
async def test_bf_card(decoded_r: redis.Redis):
162175
# return 0 if the key does not exist
163176
assert await decoded_r.bf().card("not_exist") == 0
@@ -172,6 +185,7 @@ async def test_bf_card(decoded_r: redis.Redis):
172185
await decoded_r.bf().card("setKey")
173186

174187

188+
@pytest.mark.redismod
175189
async def test_cf_add_and_insert(decoded_r: redis.Redis):
176190
assert await decoded_r.cf().create("cuckoo", 1000)
177191
assert await decoded_r.cf().add("cuckoo", "filter")
@@ -197,6 +211,7 @@ async def test_cf_add_and_insert(decoded_r: redis.Redis):
197211
)
198212

199213

214+
@pytest.mark.redismod
200215
async def test_cf_exists_and_del(decoded_r: redis.Redis):
201216
assert await decoded_r.cf().create("cuckoo", 1000)
202217
assert await decoded_r.cf().add("cuckoo", "filter")
@@ -208,6 +223,7 @@ async def test_cf_exists_and_del(decoded_r: redis.Redis):
208223
assert 0 == await decoded_r.cf().count("cuckoo", "filter")
209224

210225

226+
@pytest.mark.redismod
211227
async def test_cms(decoded_r: redis.Redis):
212228
assert await decoded_r.cms().initbydim("dim", 1000, 5)
213229
assert await decoded_r.cms().initbyprob("prob", 0.01, 0.01)
@@ -224,6 +240,7 @@ async def test_cms(decoded_r: redis.Redis):
224240

225241

226242
@pytest.mark.onlynoncluster
243+
@pytest.mark.redismod
227244
async def test_cms_merge(decoded_r: redis.Redis):
228245
assert await decoded_r.cms().initbydim("A", 1000, 5)
229246
assert await decoded_r.cms().initbydim("B", 1000, 5)
@@ -240,6 +257,7 @@ async def test_cms_merge(decoded_r: redis.Redis):
240257
assert [16, 15, 21] == await decoded_r.cms().query("C", "foo", "bar", "baz")
241258

242259

260+
@pytest.mark.redismod
243261
async def test_topk(decoded_r: redis.Redis):
244262
# test list with empty buckets
245263
assert await decoded_r.topk().reserve("topk", 3, 50, 4, 0.9)
@@ -320,6 +338,7 @@ async def test_topk(decoded_r: redis.Redis):
320338
assert 0.9 == round(float(info["decay"]), 1)
321339

322340

341+
@pytest.mark.redismod
323342
async def test_topk_incrby(decoded_r: redis.Redis):
324343
await decoded_r.flushdb()
325344
assert await decoded_r.topk().reserve("topk", 3, 10, 3, 1)
@@ -335,6 +354,7 @@ async def test_topk_incrby(decoded_r: redis.Redis):
335354

336355

337356
@pytest.mark.experimental
357+
@pytest.mark.redismod
338358
async def test_tdigest_reset(decoded_r: redis.Redis):
339359
assert await decoded_r.tdigest().create("tDigest", 10)
340360
# reset on empty histogram
@@ -351,6 +371,7 @@ async def test_tdigest_reset(decoded_r: redis.Redis):
351371

352372

353373
@pytest.mark.onlynoncluster
374+
@pytest.mark.redismod
354375
async def test_tdigest_merge(decoded_r: redis.Redis):
355376
assert await decoded_r.tdigest().create("to-tDigest", 10)
356377
assert await decoded_r.tdigest().create("from-tDigest", 10)
@@ -378,6 +399,7 @@ async def test_tdigest_merge(decoded_r: redis.Redis):
378399

379400

380401
@pytest.mark.experimental
402+
@pytest.mark.redismod
381403
async def test_tdigest_min_and_max(decoded_r: redis.Redis):
382404
assert await decoded_r.tdigest().create("tDigest", 100)
383405
# insert data-points into sketch
@@ -388,6 +410,7 @@ async def test_tdigest_min_and_max(decoded_r: redis.Redis):
388410

389411

390412
@pytest.mark.experimental
413+
@pytest.mark.redismod
391414
@skip_ifmodversion_lt("2.4.0", "bf")
392415
async def test_tdigest_quantile(decoded_r: redis.Redis):
393416
assert await decoded_r.tdigest().create("tDigest", 500)
@@ -416,6 +439,7 @@ async def test_tdigest_quantile(decoded_r: redis.Redis):
416439

417440

418441
@pytest.mark.experimental
442+
@pytest.mark.redismod
419443
async def test_tdigest_cdf(decoded_r: redis.Redis):
420444
assert await decoded_r.tdigest().create("tDigest", 100)
421445
# insert data-points into sketch
@@ -427,6 +451,7 @@ async def test_tdigest_cdf(decoded_r: redis.Redis):
427451

428452

429453
@pytest.mark.experimental
454+
@pytest.mark.redismod
430455
@skip_ifmodversion_lt("2.4.0", "bf")
431456
async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
432457
assert await decoded_r.tdigest().create("tDigest", 100)
@@ -437,6 +462,7 @@ async def test_tdigest_trimmed_mean(decoded_r: redis.Redis):
437462

438463

439464
@pytest.mark.experimental
465+
@pytest.mark.redismod
440466
async def test_tdigest_rank(decoded_r: redis.Redis):
441467
assert await decoded_r.tdigest().create("t-digest", 500)
442468
assert await decoded_r.tdigest().add("t-digest", list(range(0, 20)))
@@ -447,6 +473,7 @@ async def test_tdigest_rank(decoded_r: redis.Redis):
447473

448474

449475
@pytest.mark.experimental
476+
@pytest.mark.redismod
450477
async def test_tdigest_revrank(decoded_r: redis.Redis):
451478
assert await decoded_r.tdigest().create("t-digest", 500)
452479
assert await decoded_r.tdigest().add("t-digest", list(range(0, 20)))
@@ -456,6 +483,7 @@ async def test_tdigest_revrank(decoded_r: redis.Redis):
456483

457484

458485
@pytest.mark.experimental
486+
@pytest.mark.redismod
459487
async def test_tdigest_byrank(decoded_r: redis.Redis):
460488
assert await decoded_r.tdigest().create("t-digest", 500)
461489
assert await decoded_r.tdigest().add("t-digest", list(range(1, 11)))
@@ -467,6 +495,7 @@ async def test_tdigest_byrank(decoded_r: redis.Redis):
467495

468496

469497
@pytest.mark.experimental
498+
@pytest.mark.redismod
470499
async def test_tdigest_byrevrank(decoded_r: redis.Redis):
471500
assert await decoded_r.tdigest().create("t-digest", 500)
472501
assert await decoded_r.tdigest().add("t-digest", list(range(1, 11)))
@@ -475,19 +504,3 @@ async def test_tdigest_byrevrank(decoded_r: redis.Redis):
475504
assert (await decoded_r.tdigest().byrevrank("t-digest", 100))[0] == -inf
476505
with pytest.raises(redis.ResponseError):
477506
(await decoded_r.tdigest().byrevrank("t-digest", -1))[0]
478-
479-
480-
# # async def test_pipeline(decoded_r: redis.Redis):
481-
# pipeline = await decoded_r.bf().pipeline()
482-
# assert not await decoded_r.bf().execute_command("get pipeline")
483-
#
484-
# assert await decoded_r.bf().create("pipeline", 0.01, 1000)
485-
# for i in range(100):
486-
# pipeline.add("pipeline", i)
487-
# for i in range(100):
488-
# assert not (await decoded_r.bf().exists("pipeline", i))
489-
#
490-
# pipeline.execute()
491-
#
492-
# for i in range(100):
493-
# assert await decoded_r.bf().exists("pipeline", i)

0 commit comments

Comments
 (0)