Skip to content

Commit 6df6566

Browse files
authored
Updating hybrid tests to be compatible with 8.4 and 8.6 changes. Adding 8.6 RC1 image to test matrix (#3922)
* Updating hybrid tests to be compatible with 8.4 and 8.6 changes. Adding 8.6 RC1 image to test matrix * Fix default command polocies test - json debug policies are updated from keyed to keyless * Fixind expected default policies map
1 parent c40ec52 commit 6df6566

6 files changed

Lines changed: 479 additions & 335 deletions

File tree

.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
max-parallel: 15
7777
fail-fast: false
7878
matrix:
79-
redis-version: ['${{ needs.redis_version.outputs.CURRENT }}', '8.2', '8.0.2' ,'7.4.4', '7.2.9']
79+
redis-version: ['8.6-rc1-21356658603-debian-amd64', '${{ needs.redis_version.outputs.CURRENT }}', '8.2', '8.0.2' ,'7.4.4', '7.2.9']
8080
python-version: ['3.10', '3.14']
8181
parser-backend: ['plain']
8282
event-loop: ['asyncio']

tests/helpers.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from time import sleep
33
from typing import Callable
44

5+
from redis._parsers.commands import RequestPolicy, ResponsePolicy
6+
57

68
def wait_for_condition(
79
predicate: Callable[[], bool],
@@ -45,3 +47,143 @@ def wait_for_condition(
4547
sleep(check_interval)
4648

4749
raise AssertionError(error_message)
50+
51+
52+
def get_expected_command_policies(changes_in_defaults={}):
53+
default_cmd_policies = {
54+
"core": {
55+
"keys": [
56+
"keys",
57+
RequestPolicy.ALL_SHARDS,
58+
ResponsePolicy.DEFAULT_KEYLESS,
59+
],
60+
"acl setuser": [
61+
"acl setuser",
62+
RequestPolicy.ALL_NODES,
63+
ResponsePolicy.ALL_SUCCEEDED,
64+
],
65+
"exists": ["exists", RequestPolicy.MULTI_SHARD, ResponsePolicy.AGG_SUM],
66+
"config resetstat": [
67+
"config resetstat",
68+
RequestPolicy.ALL_NODES,
69+
ResponsePolicy.ALL_SUCCEEDED,
70+
],
71+
"slowlog len": [
72+
"slowlog len",
73+
RequestPolicy.ALL_NODES,
74+
ResponsePolicy.AGG_SUM,
75+
],
76+
"scan": ["scan", RequestPolicy.SPECIAL, ResponsePolicy.SPECIAL],
77+
"latency history": [
78+
"latency history",
79+
RequestPolicy.ALL_NODES,
80+
ResponsePolicy.SPECIAL,
81+
],
82+
"memory doctor": [
83+
"memory doctor",
84+
RequestPolicy.ALL_SHARDS,
85+
ResponsePolicy.SPECIAL,
86+
],
87+
"randomkey": [
88+
"randomkey",
89+
RequestPolicy.ALL_SHARDS,
90+
ResponsePolicy.SPECIAL,
91+
],
92+
"mget": [
93+
"mget",
94+
RequestPolicy.MULTI_SHARD,
95+
ResponsePolicy.DEFAULT_KEYED,
96+
],
97+
"function restore": [
98+
"function restore",
99+
RequestPolicy.ALL_SHARDS,
100+
ResponsePolicy.ALL_SUCCEEDED,
101+
],
102+
},
103+
"json": {
104+
"debug": [
105+
"debug",
106+
RequestPolicy.DEFAULT_KEYED,
107+
ResponsePolicy.DEFAULT_KEYED,
108+
],
109+
"get": [
110+
"get",
111+
RequestPolicy.DEFAULT_KEYED,
112+
ResponsePolicy.DEFAULT_KEYED,
113+
],
114+
},
115+
"ft": {
116+
"search": [
117+
"search",
118+
RequestPolicy.DEFAULT_KEYLESS,
119+
ResponsePolicy.DEFAULT_KEYLESS,
120+
],
121+
"create": [
122+
"create",
123+
RequestPolicy.DEFAULT_KEYLESS,
124+
ResponsePolicy.DEFAULT_KEYLESS,
125+
],
126+
},
127+
"bf": {
128+
"add": [
129+
"add",
130+
RequestPolicy.DEFAULT_KEYED,
131+
ResponsePolicy.DEFAULT_KEYED,
132+
],
133+
"madd": [
134+
"madd",
135+
RequestPolicy.DEFAULT_KEYED,
136+
ResponsePolicy.DEFAULT_KEYED,
137+
],
138+
},
139+
"cf": {
140+
"add": [
141+
"add",
142+
RequestPolicy.DEFAULT_KEYED,
143+
ResponsePolicy.DEFAULT_KEYED,
144+
],
145+
"mexists": [
146+
"mexists",
147+
RequestPolicy.DEFAULT_KEYED,
148+
ResponsePolicy.DEFAULT_KEYED,
149+
],
150+
},
151+
"tdigest": {
152+
"add": [
153+
"add",
154+
RequestPolicy.DEFAULT_KEYED,
155+
ResponsePolicy.DEFAULT_KEYED,
156+
],
157+
"min": [
158+
"min",
159+
RequestPolicy.DEFAULT_KEYED,
160+
ResponsePolicy.DEFAULT_KEYED,
161+
],
162+
},
163+
"ts": {
164+
"create": [
165+
"create",
166+
RequestPolicy.DEFAULT_KEYED,
167+
ResponsePolicy.DEFAULT_KEYED,
168+
],
169+
"info": [
170+
"info",
171+
RequestPolicy.DEFAULT_KEYED,
172+
ResponsePolicy.DEFAULT_KEYED,
173+
],
174+
},
175+
"topk": {
176+
"list": [
177+
"list",
178+
RequestPolicy.DEFAULT_KEYED,
179+
ResponsePolicy.DEFAULT_KEYED,
180+
],
181+
"query": [
182+
"query",
183+
RequestPolicy.DEFAULT_KEYED,
184+
ResponsePolicy.DEFAULT_KEYED,
185+
],
186+
},
187+
}
188+
default_cmd_policies.update(changes_in_defaults)
189+
return default_cmd_policies

tests/test_asyncio/test_command_parser.py

Lines changed: 24 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -2,151 +2,47 @@
22

33
from redis._parsers import AsyncCommandsParser
44
from redis._parsers.commands import RequestPolicy, ResponsePolicy
5-
from tests.conftest import skip_if_server_version_lt
5+
from tests.conftest import skip_if_server_version_gte, skip_if_server_version_lt
6+
from tests.helpers import get_expected_command_policies
67

78

89
@pytest.mark.onlycluster
910
@skip_if_server_version_lt("8.0.0")
1011
class TestAsyncCommandParser:
1112
@pytest.mark.asyncio
13+
@skip_if_server_version_gte("8.5.240")
1214
async def test_get_command_policies(self, r):
1315
commands_parser = AsyncCommandsParser()
1416
await commands_parser.initialize(node=r.get_default_node())
15-
expected_command_policies = {
16-
"core": {
17-
"keys": [
18-
"keys",
19-
RequestPolicy.ALL_SHARDS,
20-
ResponsePolicy.DEFAULT_KEYLESS,
21-
],
22-
"acl setuser": [
23-
"acl setuser",
24-
RequestPolicy.ALL_NODES,
25-
ResponsePolicy.ALL_SUCCEEDED,
26-
],
27-
"exists": ["exists", RequestPolicy.MULTI_SHARD, ResponsePolicy.AGG_SUM],
28-
"config resetstat": [
29-
"config resetstat",
30-
RequestPolicy.ALL_NODES,
31-
ResponsePolicy.ALL_SUCCEEDED,
32-
],
33-
"slowlog len": [
34-
"slowlog len",
35-
RequestPolicy.ALL_NODES,
36-
ResponsePolicy.AGG_SUM,
37-
],
38-
"scan": ["scan", RequestPolicy.SPECIAL, ResponsePolicy.SPECIAL],
39-
"latency history": [
40-
"latency history",
41-
RequestPolicy.ALL_NODES,
42-
ResponsePolicy.SPECIAL,
43-
],
44-
"memory doctor": [
45-
"memory doctor",
46-
RequestPolicy.ALL_SHARDS,
47-
ResponsePolicy.SPECIAL,
48-
],
49-
"randomkey": [
50-
"randomkey",
51-
RequestPolicy.ALL_SHARDS,
52-
ResponsePolicy.SPECIAL,
53-
],
54-
"mget": [
55-
"mget",
56-
RequestPolicy.MULTI_SHARD,
57-
ResponsePolicy.DEFAULT_KEYED,
58-
],
59-
"function restore": [
60-
"function restore",
61-
RequestPolicy.ALL_SHARDS,
62-
ResponsePolicy.ALL_SUCCEEDED,
63-
],
64-
},
17+
expected_command_policies = get_expected_command_policies()
18+
19+
actual_policies = await commands_parser.get_command_policies()
20+
assert len(actual_policies) > 0
21+
22+
for module_name, commands in expected_command_policies.items():
23+
for command, command_policies in commands.items():
24+
assert command in actual_policies[module_name]
25+
assert command_policies == [
26+
command,
27+
actual_policies[module_name][command].request_policy,
28+
actual_policies[module_name][command].response_policy,
29+
]
30+
31+
@skip_if_server_version_lt("8.5.240")
32+
@pytest.mark.asyncio
33+
async def test_get_command_policies_json_debug_updated(self, r):
34+
commands_parser = AsyncCommandsParser()
35+
await commands_parser.initialize(node=r.get_default_node())
36+
changes_in_defaults = {
6537
"json": {
6638
"debug": [
6739
"debug",
68-
RequestPolicy.DEFAULT_KEYED,
69-
ResponsePolicy.DEFAULT_KEYED,
70-
],
71-
"get": [
72-
"get",
73-
RequestPolicy.DEFAULT_KEYED,
74-
ResponsePolicy.DEFAULT_KEYED,
75-
],
76-
},
77-
"ft": {
78-
"search": [
79-
"search",
8040
RequestPolicy.DEFAULT_KEYLESS,
8141
ResponsePolicy.DEFAULT_KEYLESS,
8242
],
83-
"create": [
84-
"create",
85-
RequestPolicy.DEFAULT_KEYLESS,
86-
ResponsePolicy.DEFAULT_KEYLESS,
87-
],
88-
},
89-
"bf": {
90-
"add": [
91-
"add",
92-
RequestPolicy.DEFAULT_KEYED,
93-
ResponsePolicy.DEFAULT_KEYED,
94-
],
95-
"madd": [
96-
"madd",
97-
RequestPolicy.DEFAULT_KEYED,
98-
ResponsePolicy.DEFAULT_KEYED,
99-
],
100-
},
101-
"cf": {
102-
"add": [
103-
"add",
104-
RequestPolicy.DEFAULT_KEYED,
105-
ResponsePolicy.DEFAULT_KEYED,
106-
],
107-
"mexists": [
108-
"mexists",
109-
RequestPolicy.DEFAULT_KEYED,
110-
ResponsePolicy.DEFAULT_KEYED,
111-
],
112-
},
113-
"tdigest": {
114-
"add": [
115-
"add",
116-
RequestPolicy.DEFAULT_KEYED,
117-
ResponsePolicy.DEFAULT_KEYED,
118-
],
119-
"min": [
120-
"min",
121-
RequestPolicy.DEFAULT_KEYED,
122-
ResponsePolicy.DEFAULT_KEYED,
123-
],
124-
},
125-
"ts": {
126-
"create": [
127-
"create",
128-
RequestPolicy.DEFAULT_KEYED,
129-
ResponsePolicy.DEFAULT_KEYED,
130-
],
131-
"info": [
132-
"info",
133-
RequestPolicy.DEFAULT_KEYED,
134-
ResponsePolicy.DEFAULT_KEYED,
135-
],
136-
},
137-
"topk": {
138-
"list": [
139-
"list",
140-
RequestPolicy.DEFAULT_KEYED,
141-
ResponsePolicy.DEFAULT_KEYED,
142-
],
143-
"query": [
144-
"query",
145-
RequestPolicy.DEFAULT_KEYED,
146-
ResponsePolicy.DEFAULT_KEYED,
147-
],
14843
},
14944
}
45+
expected_command_policies = get_expected_command_policies(changes_in_defaults)
15046

15147
actual_policies = await commands_parser.get_command_policies()
15248
assert len(actual_policies) > 0

0 commit comments

Comments
 (0)