From f6ed3c595f9445cf46bb7046a3ea688276560a8c Mon Sep 17 00:00:00 2001 From: Gabriel Erzse Date: Mon, 8 Jul 2024 17:07:27 +0300 Subject: [PATCH] Run uvloop tests in matrix --- .github/workflows/integration.yaml | 12 ++++++++---- redis/asyncio/cluster.py | 4 ++-- redis/cluster.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 25fdf12008..ba9e825014 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -112,12 +112,13 @@ jobs: python-version: ['3.8', '3.12'] test-type: ['standalone', 'cluster'] connection-type: ['hiredis', 'plain'] + event-loop: ['asyncio', 'uvloop'] exclude: - test-type: 'cluster' connection-type: 'hiredis' env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true - name: RESP3 [${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}] + name: RESP3 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.event-loop}} steps: - uses: actions/checkout@v4 @@ -136,13 +137,16 @@ jobs: fi invoke devenv sleep 10 # time to settle - invoke ${{matrix.test-type}}-tests --protocol=3 - invoke ${{matrix.test-type}}-tests --uvloop --protocol=3 + if [ "${{matrix.event-loop}}" == "uvloop" ]; then + invoke ${{matrix.test-type}}-tests --uvloop --protocol=3 + else + invoke ${{matrix.test-type}}-tests --protocol=3 + fi - name: Upload test results and profiling data uses: actions/upload-artifact@v4 with: - name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-resp3 + name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-${{matrix.event-loop}}-resp3 path: | ${{matrix.test-type}}*-results.xml prof/** diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index e04edccfdd..40b2948a7f 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -1328,7 +1328,7 @@ async def initialize(self) -> None: tmp_nodes_cache[target_node.name] = target_node nodes_for_slot.append(target_node) - replica_nodes = [slot[j] for j in range(3, len(slot))] + replica_nodes = slot[3:] for replica_node in replica_nodes: host = replica_node[0] port = replica_node[1] @@ -1339,9 +1339,9 @@ async def initialize(self) -> None: target_replica_node = ClusterNode( host, port, REPLICA, **self.connection_kwargs ) - nodes_for_slot.append(target_replica_node) # add this node to the nodes cache tmp_nodes_cache[target_replica_node.name] = target_replica_node + nodes_for_slot.append(target_replica_node) for i in range(int(slot[0]), int(slot[1]) + 1): if i not in tmp_slots: diff --git a/redis/cluster.py b/redis/cluster.py index 92f7c15eef..be7685e9a1 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -1594,7 +1594,7 @@ def initialize(self): ) nodes_for_slot.append(target_node) - replica_nodes = [slot[j] for j in range(3, len(slot))] + replica_nodes = slot[3:] for replica_node in replica_nodes: host = str_if_bytes(replica_node[0]) port = int(replica_node[1])