Skip to content

Commit 65d717a

Browse files
authored
Merge pull request #124 from valkey-io/mkmkme/valkey-8-fixes
Fixes for valkey 8.0
2 parents 3f6a575 + 486a7b7 commit 65d717a

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ def master_host(request):
456456
return parts.hostname, (parts.port or 6379)
457457

458458

459+
@pytest.fixture()
460+
def valkey_version():
461+
return Version(VALKEY_INFO["version"])
462+
463+
459464
def wait_for_command(client, monitor, command, key=None):
460465
# issue a command with a key name that's local to this process.
461466
# if we find a command with our key before the command we're waiting

tests/test_asyncio/test_commands.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import pytest
1515
import pytest_asyncio
1616
import valkey
17+
from packaging.version import Version
1718
from tests.conftest import (
1819
assert_geo_is_close,
1920
assert_resp_response,
@@ -2378,13 +2379,18 @@ async def test_readwrite(self, r: valkey.Valkey):
23782379

23792380
@skip_if_server_version_lt("3.0.0")
23802381
@pytest.mark.onlynoncluster
2381-
async def test_readonly_invalid_cluster_state(self, r: valkey.Valkey):
2382-
with pytest.raises(exceptions.ValkeyError):
2383-
await r.readonly()
2382+
async def test_readonly(self, r: valkey.Valkey, valkey_version: Version):
2383+
# NOTE: Valkey 8.0.0 changes the behaviour of READONLY
2384+
# See https://github.com/valkey-io/valkey/pull/325
2385+
if valkey_version < Version("8.0.0"):
2386+
with pytest.raises(exceptions.ValkeyError):
2387+
await r.readonly()
2388+
else:
2389+
assert await r.readonly() is True
23842390

23852391
@skip_if_server_version_lt("3.0.0")
23862392
@pytest.mark.onlynoncluster
2387-
async def test_readonly(self, mock_cluster_resp_ok):
2393+
async def test_mock_readonly(self, mock_cluster_resp_ok):
23882394
assert await mock_cluster_resp_ok.readonly() is True
23892395

23902396
# GEO COMMANDS

tests/test_asyncio/test_hash.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import asyncio
22
from datetime import datetime, timedelta
33

4+
import pytest
45
from tests.conftest import skip_if_server_version_lt
56

7+
pytestmark = pytest.mark.skip
8+
69

710
@skip_if_server_version_lt("7.3.240")
811
async def test_hexpire_basic(r):

tests/test_commands.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import pytest
1313
import valkey
14+
from packaging.version import Version
1415
from valkey import exceptions
1516
from valkey._parsers.helpers import (
1617
_ValkeyCallbacks,
@@ -698,11 +699,15 @@ def test_client_kill_filter_by_user(self, r, request):
698699
@skip_if_server_version_lt("7.3.240")
699700
@pytest.mark.onlynoncluster
700701
def test_client_kill_filter_by_maxage(self, r, request):
701-
_get_client(valkey.Valkey, request, flushdb=False)
702+
client = _get_client(valkey.Valkey, request, flushdb=False)
703+
client_name = "test-kill-by-maxage"
704+
client.client_setname(client_name)
702705
time.sleep(4)
703-
assert len(r.client_list()) >= 2
706+
clients = r.client_list()
707+
assert client_name in [c["name"] for c in clients]
704708
r.client_kill_filter(maxage=2)
705-
assert len(r.client_list()) == 1
709+
clients = r.client_list()
710+
assert client_name not in [c["name"] for c in clients]
706711

707712
@pytest.mark.onlynoncluster
708713
@skip_if_server_version_lt("2.9.50")
@@ -3425,13 +3430,18 @@ def test_readwrite(self, r):
34253430

34263431
@pytest.mark.onlynoncluster
34273432
@skip_if_server_version_lt("3.0.0")
3428-
def test_readonly_invalid_cluster_state(self, r):
3429-
with pytest.raises(exceptions.ValkeyError):
3430-
r.readonly()
3433+
def test_readonly(self, r, valkey_version):
3434+
# NOTE: Valkey 8.0.0 changes the behaviour of READONLY
3435+
# See https://github.com/valkey-io/valkey/pull/325
3436+
if valkey_version < Version("8.0.0"):
3437+
with pytest.raises(exceptions.ValkeyError):
3438+
r.readonly()
3439+
else:
3440+
assert r.readonly() is True
34313441

34323442
@pytest.mark.onlynoncluster
34333443
@skip_if_server_version_lt("3.0.0")
3434-
def test_readonly(self, mock_cluster_resp_ok):
3444+
def test_readonly_mock(self, mock_cluster_resp_ok):
34353445
assert mock_cluster_resp_ok.readonly() is True
34363446

34373447
# GEO COMMANDS

tests/test_hash.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytest
55
from tests.conftest import skip_if_server_version_lt
66

7+
pytestmark = pytest.mark.skip
8+
79

810
@skip_if_server_version_lt("7.3.240")
911
def test_hexpire_basic(r):

0 commit comments

Comments
 (0)