Skip to content

Commit 14f83c9

Browse files
Gabriel Erzseaiven-sal
authored andcommitted
Make sure the CI actually runs RESP3 tests (redis#3270)
The CI tests were not running with RESP3 protocol, it was just an illusion that they do. Fix this, and also preserve coverage and test artifacts from those runs too. Some issues have surfaced after the change. The most notable issue is a bug in hiredis-py, which prevents it from being used in cluster mode at least. Make sure cluster tests do not run with hiredis-py. Also make sure some specific unit tests do not run with hiredis-py. One other issue with hiredis-py is fixed in this commit. Use a sentinel object instance to signal lack of data in hiredis-py, instead of piggybacking of `False`, which can also be returned by parsing valid RESP payloads. Some of the unit tests, mostly for modules, were failing, they are now updated so that they pass. Remove async parser from test fixture params. Leave the decision for the async parser to be used in tests to be taken based on the availability of hiredis-py, and on the protocol that is set for the tests. Otherwise when hiredis-py is available we would also run the non-hiredis tests. Signed-off-by: Salvatore Mesoraca <[email protected]>
1 parent fcefb7a commit 14f83c9

File tree

9 files changed

+435
-169
lines changed

9 files changed

+435
-169
lines changed

.github/workflows/integration.yaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ jobs:
113113
python-version: ['3.8', '3.11']
114114
test-type: ['standalone', 'cluster']
115115
connection-type: ['hiredis', 'plain']
116-
protocol: ['3']
116+
exclude:
117+
- test-type: 'cluster'
118+
connection-type: 'hiredis'
117119
env:
118120
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
119121
name: RESP3 [${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}]
@@ -132,9 +134,33 @@ jobs:
132134
pip install hiredis
133135
fi
134136
invoke devenv
135-
sleep 5 # time to settle
136-
invoke ${{matrix.test-type}}-tests
137-
invoke ${{matrix.test-type}}-tests --uvloop
137+
sleep 10 # time to settle
138+
invoke ${{matrix.test-type}}-tests --protocol=3
139+
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
140+
141+
- uses: actions/upload-artifact@v4
142+
if: success() || failure()
143+
with:
144+
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-resp3
145+
path: '${{matrix.test-type}}*results.xml'
146+
147+
- name: Upload codecov coverage
148+
uses: codecov/codecov-action@v4
149+
with:
150+
fail_ci_if_error: false
151+
152+
- name: View Test Results
153+
uses: dorny/test-reporter@v1
154+
if: success() || failure()
155+
continue-on-error: true
156+
with:
157+
name: Test Results ${{matrix.python-version}} ${{matrix.test-type}}-${{matrix.connection-type}}-resp3
158+
path: '*.xml'
159+
reporter: java-junit
160+
list-suites: all
161+
list-tests: all
162+
max-annotations: 10
163+
fail-on-error: 'false'
138164

139165
build_and_test_package:
140166
name: Validate building and installing the package

tests/test_asyncio/conftest.py

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
import pytest_asyncio
66
import valkey.asyncio as valkey
77
from tests.conftest import VALKEY_INFO
8-
from valkey._parsers import _AsyncHiredisParser, _AsyncRESP2Parser
98
from valkey.asyncio import Sentinel
109
from valkey.asyncio.client import Monitor
1110
from valkey.asyncio.connection import Connection, parse_url
1211
from valkey.asyncio.retry import Retry
1312
from valkey.backoff import NoBackoff
14-
from valkey.utils import HIREDIS_AVAILABLE
1513

1614
from .compat import mock
1715

@@ -26,41 +24,21 @@ async def _get_info(valkey_url):
2624
@pytest_asyncio.fixture(
2725
params=[
2826
pytest.param(
29-
(True, _AsyncRESP2Parser),
27+
(True,),
3028
marks=pytest.mark.skipif(
3129
'config.VALKEY_INFO["cluster_enabled"]', reason="cluster mode enabled"
3230
),
3331
),
34-
(False, _AsyncRESP2Parser),
35-
pytest.param(
36-
(True, _AsyncHiredisParser),
37-
marks=[
38-
pytest.mark.skipif(
39-
'config.VALKEY_INFO["cluster_enabled"]',
40-
reason="cluster mode enabled",
41-
),
42-
pytest.mark.skipif(
43-
not HIREDIS_AVAILABLE, reason="hiredis is not installed"
44-
),
45-
],
46-
),
47-
pytest.param(
48-
(False, _AsyncHiredisParser),
49-
marks=pytest.mark.skipif(
50-
not HIREDIS_AVAILABLE, reason="hiredis is not installed"
51-
),
52-
),
32+
(False,),
5333
],
5434
ids=[
55-
"single-python-parser",
56-
"pool-python-parser",
57-
"single-hiredis",
58-
"pool-hiredis",
35+
"single",
36+
"pool",
5937
],
6038
)
6139
async def create_valkey(request):
6240
"""Wrapper around valkey.create_valkey."""
63-
single_connection, parser_cls = request.param
41+
(single_connection,) = request.param
6442

6543
teardown_clients = []
6644

@@ -76,10 +54,9 @@ async def client_factory(
7654
cluster_mode = VALKEY_INFO["cluster_enabled"]
7755
if not cluster_mode:
7856
single = kwargs.pop("single_connection_client", False) or single_connection
79-
parser_class = kwargs.pop("parser_class", None) or parser_cls
8057
url_options = parse_url(url)
8158
url_options.update(kwargs)
82-
pool = valkey.ConnectionPool(parser_class=parser_class, **url_options)
59+
pool = valkey.ConnectionPool(**url_options)
8360
client = cls(connection_pool=pool)
8461
else:
8562
client = valkey.ValkeyCluster.from_url(url, **kwargs)

0 commit comments

Comments
 (0)