Skip to content

Commit f2ffe1d

Browse files
authored
Merge branch 'master' into issue/3139
2 parents 3f92109 + 36619a5 commit f2ffe1d

File tree

187 files changed

+15673
-7523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+15673
-7523
lines changed

.flake8

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/actions/run-tests/action.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: 'Run redis-py tests'
2+
description: 'Runs redis-py tests against different Redis versions and configurations'
3+
inputs:
4+
python-version:
5+
description: 'Python version to use for running tests'
6+
default: '3.12'
7+
parser-backend:
8+
description: 'Parser backend to use: plain or hiredis'
9+
required: true
10+
redis-version:
11+
description: 'Redis version to test against'
12+
required: true
13+
hiredis-version:
14+
description: 'hiredis version to test against'
15+
required: false
16+
default: '>3.0.0'
17+
hiredis-branch:
18+
description: 'hiredis branch to test against'
19+
required: false
20+
default: 'master'
21+
event-loop:
22+
description: 'Event loop to use'
23+
required: false
24+
default: 'asyncio'
25+
runs:
26+
using: "composite"
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ inputs.python-version }}
33+
cache: 'pip'
34+
35+
- uses: actions/checkout@v4
36+
if: ${{ inputs.parser-backend == 'hiredis' && inputs.hiredis-version == 'unstable' }}
37+
with:
38+
repository: redis/hiredis-py
39+
submodules: true
40+
path: hiredis-py
41+
ref: ${{ inputs.hiredis-branch }}
42+
43+
- name: Setup Test environment
44+
env:
45+
REDIS_VERSION: ${{ inputs.redis-version }}
46+
CLIENT_LIBS_TEST_IMAGE_TAG: ${{ inputs.redis-version }}
47+
run: |
48+
set -e
49+
50+
echo "::group::Installing dependencies"
51+
pip install -r dev_requirements.txt
52+
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
53+
pip install -e .[jwt] # install the working copy
54+
if [ "${{inputs.parser-backend}}" == "hiredis" ]; then
55+
if [[ "${{inputs.hiredis-version}}" == "unstable" ]]; then
56+
echo "Installing unstable version of hiredis from local directory"
57+
pip install -e ./hiredis-py
58+
else
59+
pip install "hiredis${{inputs.hiredis-version}}"
60+
fi
61+
echo "PARSER_BACKEND=$(echo "${{inputs.parser-backend}}_${{inputs.hiredis-version}}" | sed 's/[^a-zA-Z0-9]/_/g')" >> $GITHUB_ENV
62+
else
63+
echo "PARSER_BACKEND=${{inputs.parser-backend}}" >> $GITHUB_ENV
64+
fi
65+
echo "::endgroup::"
66+
67+
echo "::group::Starting Redis servers"
68+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
69+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
70+
71+
if (( redis_major_version < 8 )); then
72+
echo "Using redis-stack for module tests"
73+
74+
# Mapping of redis version to stack version
75+
declare -A redis_stack_version_mapping=(
76+
["7.4.2"]="rs-7.4.0-v2"
77+
["7.2.7"]="rs-7.2.0-v14"
78+
["6.2.17"]="rs-6.2.6-v18"
79+
)
80+
81+
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
82+
export CLIENT_LIBS_TEST_STACK_IMAGE_TAG=${redis_stack_version_mapping[$REDIS_VERSION]}
83+
echo "REDIS_MOD_URL=redis://127.0.0.1:6479/0" >> $GITHUB_ENV
84+
else
85+
echo "Version not found in the mapping."
86+
exit 1
87+
fi
88+
89+
if (( redis_major_version < 7 )); then
90+
export REDIS_STACK_EXTRA_ARGS="--tls-auth-clients optional --save ''"
91+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
92+
fi
93+
94+
invoke devenv --endpoints=all-stack
95+
else
96+
echo "Using redis CE for module tests"
97+
echo "REDIS_MOD_URL=redis://127.0.0.1:6379" >> $GITHUB_ENV
98+
invoke devenv --endpoints all
99+
fi
100+
101+
sleep 10 # time to settle
102+
echo "::endgroup::"
103+
shell: bash
104+
105+
- name: Run tests
106+
run: |
107+
set -e
108+
109+
run_tests() {
110+
local protocol=$1
111+
local eventloop=""
112+
113+
if [ "${{inputs.event-loop}}" == "uvloop" ]; then
114+
eventloop="--uvloop"
115+
fi
116+
117+
echo "::group::RESP${protocol} standalone tests"
118+
echo "REDIS_MOD_URL=${REDIS_MOD_URL}"
119+
120+
if (( $REDIS_MAJOR_VERSION < 7 )) && [ "$protocol" == "3" ]; then
121+
echo "Skipping module tests: Modules doesn't support RESP3 for Redis versions < 7"
122+
invoke standalone-tests --redis-mod-url=${REDIS_MOD_URL} $eventloop --protocol="${protocol}" --extra-markers="not redismod and not cp_integration"
123+
else
124+
invoke standalone-tests --redis-mod-url=${REDIS_MOD_URL} $eventloop --protocol="${protocol}"
125+
fi
126+
127+
echo "::endgroup::"
128+
129+
echo "::group::RESP${protocol} cluster tests"
130+
invoke cluster-tests $eventloop --protocol=${protocol}
131+
echo "::endgroup::"
132+
}
133+
134+
run_tests 2 "${{inputs.event-loop}}"
135+
run_tests 3 "${{inputs.event-loop}}"
136+
shell: bash
137+
138+
- name: Debug
139+
if: failure()
140+
run: |
141+
sudo apt-get install -y redis-tools
142+
echo "Docker Containers:"
143+
docker ps
144+
redis-cli -p 16379 CLUSTER NODES
145+
shell: bash
146+
147+
- name: Upload test results and profiling data
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: pytest-results-redis_${{inputs.redis-version}}-python_${{inputs.python-version}}-parser_${{env.PARSER_BACKEND}}-el_${{inputs.event-loop}}
151+
path: |
152+
*-results.xml
153+
prof/**
154+
profile_output*
155+
if-no-files-found: error
156+
retention-days: 10
157+
158+
- name: Upload codecov coverage
159+
uses: codecov/codecov-action@v4
160+
with:
161+
fail_ci_if_error: false

.github/wordlist.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
APM
22
ARGV
33
BFCommands
4+
CacheImpl
5+
CAS
46
CFCommands
57
CMSCommands
68
ClusterNode
@@ -11,7 +13,6 @@ ConnectionPool
1113
CoreCommands
1214
EVAL
1315
EVALSHA
14-
GraphCommands
1516
Grokzen's
1617
INCR
1718
IOError
@@ -38,7 +39,6 @@ RedisCluster
3839
RedisClusterCommands
3940
RedisClusterException
4041
RedisClusters
41-
RedisGraph
4242
RedisInstrumentor
4343
RedisJSON
4444
RedisTimeSeries

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
sudo apt-get install -yqq pandoc make
3737
- name: run code linters
3838
run: |
39-
pip install -r requirements.txt -r dev_requirements.txt -r docs/requirements.txt
39+
pip install -r dev_requirements.txt -r docs/requirements.txt
4040
invoke build-docs
4141
4242
- name: upload docs
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Hiredis-py integration tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
redis-py-branch:
7+
description: 'redis-py branch to run tests on'
8+
required: true
9+
default: 'master'
10+
hiredis-branch:
11+
description: 'hiredis-py branch to run tests on'
12+
required: true
13+
default: 'master'
14+
15+
concurrency:
16+
group: ${{ github.event.pull_request.number || github.ref }}-hiredis-integration
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read # to fetch code (actions/checkout)
21+
22+
env:
23+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
24+
# this speeds up coverage with Python 3.12: https://github.com/nedbat/coveragepy/issues/1665
25+
COVERAGE_CORE: sysmon
26+
CURRENT_CLIENT_LIBS_TEST_STACK_IMAGE_TAG: 'rs-7.4.0-v2'
27+
CURRENT_REDIS_VERSION: '7.4.2'
28+
29+
jobs:
30+
redis_version:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
CURRENT: ${{ env.CURRENT_REDIS_VERSION }}
34+
steps:
35+
- name: Compute outputs
36+
run: |
37+
echo "CURRENT=${{ env.CURRENT_REDIS_VERSION }}" >> $GITHUB_OUTPUT
38+
39+
hiredis-tests:
40+
runs-on: ubuntu-latest
41+
needs: [redis_version]
42+
timeout-minutes: 60
43+
strategy:
44+
max-parallel: 15
45+
fail-fast: false
46+
matrix:
47+
redis-version: [ '${{ needs.redis_version.outputs.CURRENT }}' ]
48+
python-version: [ '3.8', '3.13']
49+
parser-backend: [ 'hiredis' ]
50+
hiredis-version: [ 'unstable' ]
51+
event-loop: [ 'asyncio' ]
52+
env:
53+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
54+
name: Redis ${{ matrix.redis-version }}; Python ${{ matrix.python-version }}; RESP Parser:${{matrix.parser-backend}} (${{ matrix.hiredis-version }}); EL:${{matrix.event-loop}}
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
ref: ${{ inputs.redis-py-branch }}
59+
- name: Run tests
60+
uses: ./.github/actions/run-tests
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
parser-backend: ${{ matrix.parser-backend }}
64+
redis-version: ${{ matrix.redis-version }}
65+
hiredis-version: ${{ matrix.hiredis-version }}
66+
hiredis-branch: ${{ inputs.hiredis-branch }}

.github/workflows/install_and_test.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ python -m venv ${DESTENV}
2121
source ${DESTENV}/bin/activate
2222
pip install --upgrade --quiet pip
2323
pip install --quiet -r dev_requirements.txt
24-
invoke devenv
24+
pip uninstall -y redis # uninstall Redis package installed via redis-entraid
25+
invoke devenv --endpoints=all-stack
2526
invoke package
2627

2728
# find packages
@@ -42,4 +43,6 @@ pip install ${PKG}
4243
pytest -m 'not onlycluster'
4344
# RedisCluster tests
4445
CLUSTER_URL="redis://localhost:16379/0"
45-
pytest -m 'not onlynoncluster and not redismod and not ssl' --redis-url=${CLUSTER_URL}
46+
CLUSTER_SSL_URL="rediss://localhost:27379/0"
47+
pytest -m 'not onlynoncluster and not redismod and not ssl' \
48+
--redis-url="${CLUSTER_URL}" --redis-ssl-url="${CLUSTER_SSL_URL}"

0 commit comments

Comments
 (0)