Skip to content

Commit 821450e

Browse files
authored
Merge branch 'master' into docs-tweak
2 parents 316bd91 + 72cdaf6 commit 821450e

File tree

123 files changed

+9047
-2857
lines changed

Some content is hidden

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

123 files changed

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

.github/wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
APM
22
ARGV
33
BFCommands
4+
CacheImpl
45
CFCommands
56
CMSCommands
67
ClusterNode

.github/workflows/install_and_test.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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+
invoke devenv --endpoints=all-stack
2525
invoke package
2626

2727
# find packages
@@ -39,7 +39,9 @@ cd ${TESTDIR}
3939
# install, run tests
4040
pip install ${PKG}
4141
# Redis tests
42-
pytest -m 'not onlycluster'
42+
pytest -m 'not onlycluster and not graph'
4343
# RedisCluster tests
4444
CLUSTER_URL="redis://localhost:16379/0"
45-
pytest -m 'not onlynoncluster and not redismod and not ssl' --redis-url=${CLUSTER_URL}
45+
CLUSTER_SSL_URL="rediss://localhost:27379/0"
46+
pytest -m 'not onlynoncluster and not redismod and not ssl and not graph' \
47+
--redis-url="${CLUSTER_URL}" --redis-ssl-url="${CLUSTER_SSL_URL}"

0 commit comments

Comments
 (0)