Skip to content

Commit

Permalink
Add redict to CI/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Apr 21, 2024
1 parent e52c396 commit ccc7d13
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 10 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
redis-version: ["6.2", "7.0", "7.2", "latest"]
test_params: ["-m '(not (keydb or dragonfly or valkey))'"]
test_params: ["-m '(not (keydb or dragonfly or valkey or redict))'"]
orjson: ["False"]
uvloop: ["True", "False"]
runtime_type_checks: ["True"]
Expand All @@ -72,24 +72,24 @@ jobs:
include:
- python-version: "3.11"
redis-version: next
test_params: "-m '(not (keydb or dragonfly or valkey))'"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
runtime_type_checks: "True"
label: ""
- python-version: "3.11"
redis-version: latest
test_params: "-m '(not (keydb or dragonfly or valkey))'"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
extensions: "False"
runtime_type_checks: "True"
label: ""
- python-version: "3.11"
redis-version: latest
test_params: "-m '(not (keydb or dragonfly or valkey))'"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
runtime_type_checks: "True"
orjson: "True"
label: ""
- python-version: "3.11"
redis-version: 7.0
test_params: "-m '(not (keydb or dragonfly or valkey))'"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
runtime_type_checks: "False"
label: ""
- python-version: "3.11"
Expand All @@ -105,16 +105,20 @@ jobs:
redis-version: 7.0
test_params: "-m valkey"
label: "Valkey"
- python-version: "3.11"
redis-version: 7.0
test_params: "-m redict"
label: "Redict"
- python-version: "pypy-3.8"
redis-version: 7.0
test_params: "-m '(not (keydb or dragonfly or valkey))' tests/commands tests/test_tracking_cache.py"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))' tests/commands tests/test_tracking_cache.py"
runtime_type_checks: "False"
extensions: "False"
uvloop: "False"
label: ""
- python-version: "pypy-3.9"
redis-version: 7.0
test_params: "-m '(not (keydb or dragonfly or valkey))' tests/commands tests/test_tracking_cache.py"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))' tests/commands tests/test_tracking_cache.py"
runtime_type_checks: "False"
extensions: "False"
uvloop: "False"
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12"]
redis-version: ["6.2", "7.0", "7.2", "latest"]
test_params: ["-m '(not (keydb or dragonfly or valkey))'"]
test_params: ["-m '(not (keydb or dragonfly or valkey or redict))'"]
uvloop: ["True", "False"]
orjson: ["False"]
runtime_type_checks: ["True"]
Expand All @@ -66,7 +66,7 @@ jobs:
include:
- python-version: "3.11"
redis-version: "latest"
test_params: "-m '(not (keydb or dragonfly or valkey))'"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
runtime_type_checks: "True"
extensions: "False"
- python-version: "3.11"
Expand All @@ -81,9 +81,13 @@ jobs:
redis-version: "7.0"
test_params: "-m valkey"
label: "Valkey"
- python-version: "3.11"
redis-version: "7.0"
test_params: "-m redict"
label: "Redict"
- python-version: "pypy-3.9"
redis-version: "7.0"
test_params: "-m '(not (keydb or dragonfly or valkey))' tests/commands tests/test_tracking_cache.py"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))' tests/commands tests/test_tracking_cache.py"
runtime_type_checks: "False"
extensions: "False"
uvloop: "False"
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,7 @@ services:
image: "valkey/valkey:${VALKEY_VERSION:-unstable}"
ports:
- '12379:6379'
redict:
image: "registry.redict.io/redict:${REDICT_VERSION:-latest}"
ports:
- '13379:6379'
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ markers =
sentinel
stack
valkey
redict
ssl
uds
nocluster
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async def teardown(client):
"redis_cluster_raw",
"keydb",
"valkey",
"redict",
)
@pytest.mark.min_server_version("6.0.0")
class TestACL:
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"redis_cluster_raw",
"keydb",
"valkey",
"redict",
)
class TestBitmap:
async def test_bitcount(self, client, _s):
Expand Down
6 changes: 6 additions & 0 deletions tests/commands/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"redis_cluster_cached",
"keydb",
"valkey",
"redict",
)
class TestGeneric:
async def test_sort_basic(self, client, _s):
Expand Down Expand Up @@ -188,6 +189,7 @@ async def test_delete_with_multiple_keys(self, client, _s):

@pytest.mark.xfail
@pytest.mark.novalkey
@pytest.mark.noredict
async def test_dump_and_restore_with_ttl(self, client, _s):
await client.set("a", "foo")
dumped = await client.dump("a")
Expand Down Expand Up @@ -219,6 +221,7 @@ async def test_dump_and_restore_with_freq(self, client, _s):
assert freq + 1 == freq_now

@pytest.mark.novalkey
@pytest.mark.noredict
async def test_dump_and_restore_with_idle_time(self, client, _s):
await client.set("a", "foo")
idle = await client.object_idletime("a")
Expand All @@ -240,6 +243,7 @@ async def test_dump_and_restore_and_replace(self, client, _s):

@pytest.mark.nocluster
@pytest.mark.novalkey
@pytest.mark.noredict
async def test_migrate_single_key_with_auth(self, client, redis_auth, _s):
auth_connection = await redis_auth.connection_pool.get_connection()
await client.set("a", "1")
Expand Down Expand Up @@ -317,6 +321,7 @@ async def test_migrate_single_key_with_auth(self, client, redis_auth, _s):

@pytest.mark.nocluster
@pytest.mark.novalkey
@pytest.mark.noredict
async def test_migrate_multiple_keys_with_auth(self, client, redis_auth, _s):
auth_connection = await redis_auth.connection_pool.get_connection()
await client.set("a", "1")
Expand Down Expand Up @@ -375,6 +380,7 @@ async def test_object_encoding_listpack(self, client, _s):
assert await client.object_encoding("b") == _s("listpack")

@pytest.mark.novalkey
@pytest.mark.noredict
async def test_object_freq(self, client, _s):
await client.set("a", "foo")
with pytest.raises(ResponseError):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"redis_cluster_raw",
"keydb",
"valkey",
"redict",
)
class TestGeo:
async def test_geoadd(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"keydb",
"dragonfly",
"valkey",
"redict",
)
class TestHash:
async def test_hget_and_hset(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_hyperloglog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"redis_cluster_raw",
"keydb",
"valkey",
"redict",
)
class TestHyperLogLog:
async def test_pfadd(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"keydb",
"dragonfly",
"valkey",
"redict",
)
class TestList:
async def test_blpop(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"keydb",
"dragonfly",
"valkey",
"redict",
)
class TestSet:
async def test_sadd(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_sorted_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"keydb",
"dragonfly",
"valkey",
"redict",
)
class TestSortedSet:
async def test_zadd(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def get_stream_message(client, stream, message_id):
"redis_cluster_raw",
"keydb",
"valkey",
"redict",
)
class TestStreams:
async def test_xadd_with_wrong_id(self, client, _s):
Expand Down
1 change: 1 addition & 0 deletions tests/commands/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"keydb_resp2",
"dragonfly",
"valkey",
"redict",
)
class TestString:
async def test_append(self, client, _s):
Expand Down
35 changes: 35 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ async def get_version(client):

if "dragonfly_version" in client_info:
SERVER_TYPES[str(client)] = "dragonfly"
if "redict_version" in client_info:
SERVER_TYPES[str(client)] = "redict"
if "valkey" == client_info.get("server_name"):
SERVER_TYPES[str(client)] = "valkey"

Expand Down Expand Up @@ -210,6 +212,9 @@ async def check_test_constraints(request, client, protocol=3):
if marker.name == "novalkey" and SERVER_TYPES.get(str(client)) == "valkey":
return pytest.skip("Skipped for Valkey")

if marker.name == "noredict" and SERVER_TYPES.get(str(client)) == "redict":
return pytest.skip("Skipped for redict")

if marker.name == "nopypy" and PY_IMPLEMENTATION == "PyPy":
return pytest.skip("Skipped for PyPy")

Expand Down Expand Up @@ -485,6 +490,13 @@ def valkey_server(docker_services):
yield ["localhost", 12379]


@pytest.fixture(scope="session")
def redict_server(docker_services):
docker_services.start("redict")
docker_services.wait_for_service("redict", 6379, ping_socket)
yield ["localhost", 13379]


@pytest.fixture(scope="session")
def keydb_cluster_server(docker_services):
docker_services.start("keydb-cluster-init")
Expand Down Expand Up @@ -1234,6 +1246,23 @@ async def valkey(valkey_server, request):
client.connection_pool.disconnect()


@pytest.fixture
async def redict(redict_server, request):
client = coredis.Redis(
"localhost",
13379,
decode_responses=True,
**get_client_test_args(request),
)
await client.flushall()
await check_test_constraints(request, client)
await set_default_test_config(client, variant="redict")

yield client

client.connection_pool.disconnect()


@pytest.fixture(scope="session")
def docker_services_project_name():
return "coredis"
Expand Down Expand Up @@ -1363,5 +1392,11 @@ def pytest_collection_modifyitems(items):
item.add_marker(getattr(pytest.mark, "valkey"))
tokens = client_name.replace("valkey_", "").split("_")

for token in tokens:
item.add_marker(getattr(pytest.mark, token))
elif client_name.startswith("redict"):
item.add_marker(getattr(pytest.mark, "redict"))
tokens = client_name.replace("redict_", "").split("_")

for token in tokens:
item.add_marker(getattr(pytest.mark, token))

0 comments on commit ccc7d13

Please sign in to comment.