Skip to content

Commit a744dac

Browse files
committed
Chnaged test infrastructure to run cluster and standalone tests separately
1 parent 1cbb97e commit a744dac

File tree

2 files changed

+60
-32
lines changed

2 files changed

+60
-32
lines changed

.github/workflows/integration.yaml

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ jobs:
5656
pip install -r dev_requirements.txt
5757
invoke linters
5858
59-
resp2-tests:
59+
standalone:
6060
runs-on: ubuntu-latest
6161
timeout-minutes: 60
6262
strategy:
6363
max-parallel: 15
6464
fail-fast: false
6565
matrix:
66-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9']
67-
test-type: ['standalone', 'cluster']
66+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9' ]
6867
connection-type: ['hiredis', 'plain']
6968
env:
7069
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
71-
name: RESP2 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
70+
name: Standalone-${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
7271
steps:
7372
- uses: actions/checkout@v4
7473

@@ -77,25 +76,39 @@ jobs:
7776
python-version: ${{ matrix.python-version }}
7877
cache: 'pip'
7978

80-
- name: Run tests
79+
- name: Build infrastructure
8180
run: |
81+
pip install coverage
8282
pip install -U setuptools wheel
8383
pip install -r requirements.txt
8484
pip install -r dev_requirements.txt
8585
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
8686
pip install hiredis
8787
fi
88+
mkdir coverage
8889
invoke devenv
8990
sleep 10 # time to settle
90-
invoke ${{matrix.test-type}}-tests
91+
92+
- name: Run RESP2 tests
93+
run: |
94+
invoke standalone-tests
9195
ls -1
9296
97+
- name: Run RESP3 tests
98+
if: ${{matrix.python-version == '3.8' || matrix.python-version == '3.12'}}
99+
run: |
100+
invoke standalone-tests --uvloop --protocol=3
101+
invoke standalone-tests --protocol=3
102+
103+
- name: Combine test coverage
104+
run: coverage combine combined-coverage.xml coverage/
105+
93106
- name: Upload test results and profiling data
94107
uses: actions/upload-artifact@v4
95108
with:
96-
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}
109+
name: pytest-results-standalone-${{matrix.connection-type}}-${{matrix.python-version}}
97110
path: |
98-
${{matrix.test-type}}*-results.xml
111+
combined-coverage.xml
99112
prof/**
100113
profile_output*
101114
if-no-files-found: error
@@ -106,21 +119,18 @@ jobs:
106119
with:
107120
fail_ci_if_error: false
108121

109-
resp3-tests:
122+
cluster:
110123
runs-on: ubuntu-latest
124+
timeout-minutes: 60
111125
strategy:
126+
max-parallel: 15
112127
fail-fast: false
113128
matrix:
114-
python-version: ['3.8', '3.12']
115-
test-type: ['standalone', 'cluster']
129+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9' ]
116130
connection-type: ['hiredis', 'plain']
117-
event-loop: ['asyncio', 'uvloop']
118-
exclude:
119-
- test-type: 'cluster'
120-
connection-type: 'hiredis'
121131
env:
122132
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
123-
name: RESP3 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.event-loop}}
133+
name: Cluster-${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
124134
steps:
125135
- uses: actions/checkout@v4
126136

@@ -129,28 +139,39 @@ jobs:
129139
python-version: ${{ matrix.python-version }}
130140
cache: 'pip'
131141

132-
- name: Run tests
142+
- name: Build infrastructure
133143
run: |
144+
pip install coverage
134145
pip install -U setuptools wheel
135146
pip install -r requirements.txt
136147
pip install -r dev_requirements.txt
137148
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
138-
pip install hiredis
149+
pip install hiredis
139150
fi
140-
invoke devenv
151+
mkdir coverage
152+
invoke devenv-cluster
141153
sleep 10 # time to settle
142-
if [ "${{matrix.event-loop}}" == "uvloop" ]; then
143-
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
144-
else
145-
invoke ${{matrix.test-type}}-tests --protocol=3
146-
fi
154+
155+
- name: Run RESP2 tests
156+
run: |
157+
invoke cluster-tests
158+
ls -1
159+
160+
- name: Run RESP3 tests
161+
if: ${{matrix.python-version == '3.8' || matrix.python-version == '3.12'}}
162+
run: |
163+
invoke cluster-tests --uvloop --protocol=3
164+
invoke cluster-tests --protocol=3
165+
166+
- name: Combine test coverage
167+
run: coverage combine combined-coverage.xml coverage/
147168

148169
- name: Upload test results and profiling data
149170
uses: actions/upload-artifact@v4
150171
with:
151-
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-${{matrix.event-loop}}-resp3
172+
name: pytest-results-cluster-${{matrix.connection-type}}-${{matrix.python-version}}
152173
path: |
153-
${{matrix.test-type}}*-results.xml
174+
combined-coverage.xml
154175
prof/**
155176
profile_output*
156177
if-no-files-found: error

tasks.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
1111

1212
@task
1313
def devenv(c):
14-
"""Brings up the test environment, by wrapping docker compose."""
14+
"""Brings up the test environment for standalone redis, by wrapping docker compose."""
1515
clean(c)
16-
cmd = "docker compose --profile all up -d --build"
16+
cmd = "docker compose --profile standalone --profile replica --profile sentinel up -d --build"
17+
run(cmd)
18+
19+
@task
20+
def devenv_cluster(c):
21+
"""Brings up the test environment for OSS cluster redis, by wrapping docker compose."""
22+
clean(c)
23+
cmd = "docker compose --profile cluster up -d --build"
1724
run(cmd)
1825

1926

@@ -55,11 +62,11 @@ def standalone_tests(c, uvloop=False, protocol=2, profile=False):
5562
profile_arg = "--profile" if profile else ""
5663
if uvloop:
5764
run(
58-
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
65+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=coverage/standalone-uvloop-results.xml"
5966
)
6067
else:
6168
run(
62-
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=standalone-results.xml"
69+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=coverage/standalone-results.xml"
6370
)
6471

6572

@@ -70,11 +77,11 @@ def cluster_tests(c, uvloop=False, protocol=2, profile=False):
7077
cluster_url = "redis://localhost:16379/0"
7178
if uvloop:
7279
run(
73-
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop"
80+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=coverage/cluster-uvloop-results.xml --uvloop"
7481
)
7582
else:
7683
run(
77-
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-results.xml"
84+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=coverage/cluster-results.xml"
7885
)
7986

8087

0 commit comments

Comments
 (0)