Skip to content

Commit

Permalink
Chnaged test infrastructure to run cluster and standalone tests separ…
Browse files Browse the repository at this point in the history
…ately
  • Loading branch information
vladvildanov committed Sep 4, 2024
1 parent 1cbb97e commit a744dac
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 32 deletions.
73 changes: 47 additions & 26 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ jobs:
pip install -r dev_requirements.txt
invoke linters
resp2-tests:
standalone:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
max-parallel: 15
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9']
test-type: ['standalone', 'cluster']
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9' ]
connection-type: ['hiredis', 'plain']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: RESP2 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
name: Standalone-${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
steps:
- uses: actions/checkout@v4

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

- name: Run tests
- name: Build infrastructure
run: |
pip install coverage
pip install -U setuptools wheel
pip install -r requirements.txt
pip install -r dev_requirements.txt
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
pip install hiredis
fi
mkdir coverage
invoke devenv
sleep 10 # time to settle
invoke ${{matrix.test-type}}-tests
- name: Run RESP2 tests
run: |
invoke standalone-tests
ls -1
- name: Run RESP3 tests
if: ${{matrix.python-version == '3.8' || matrix.python-version == '3.12'}}
run: |
invoke standalone-tests --uvloop --protocol=3
invoke standalone-tests --protocol=3
- name: Combine test coverage
run: coverage combine combined-coverage.xml coverage/

- 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}}
name: pytest-results-standalone-${{matrix.connection-type}}-${{matrix.python-version}}
path: |
${{matrix.test-type}}*-results.xml
combined-coverage.xml
prof/**
profile_output*
if-no-files-found: error
Expand All @@ -106,21 +119,18 @@ jobs:
with:
fail_ci_if_error: false

resp3-tests:
cluster:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
max-parallel: 15
fail-fast: false
matrix:
python-version: ['3.8', '3.12']
test-type: ['standalone', 'cluster']
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9' ]
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}}-${{matrix.event-loop}}
name: Cluster-${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
steps:
- uses: actions/checkout@v4

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

- name: Run tests
- name: Build infrastructure
run: |
pip install coverage
pip install -U setuptools wheel
pip install -r requirements.txt
pip install -r dev_requirements.txt
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
pip install hiredis
pip install hiredis
fi
invoke devenv
mkdir coverage
invoke devenv-cluster
sleep 10 # time to settle
if [ "${{matrix.event-loop}}" == "uvloop" ]; then
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
else
invoke ${{matrix.test-type}}-tests --protocol=3
fi
- name: Run RESP2 tests
run: |
invoke cluster-tests
ls -1
- name: Run RESP3 tests
if: ${{matrix.python-version == '3.8' || matrix.python-version == '3.12'}}
run: |
invoke cluster-tests --uvloop --protocol=3
invoke cluster-tests --protocol=3
- name: Combine test coverage
run: coverage combine combined-coverage.xml coverage/

- 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}}-${{matrix.event-loop}}-resp3
name: pytest-results-cluster-${{matrix.connection-type}}-${{matrix.python-version}}
path: |
${{matrix.test-type}}*-results.xml
combined-coverage.xml
prof/**
profile_output*
if-no-files-found: error
Expand Down
19 changes: 13 additions & 6 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@

@task
def devenv(c):
"""Brings up the test environment, by wrapping docker compose."""
"""Brings up the test environment for standalone redis, by wrapping docker compose."""
clean(c)
cmd = "docker compose --profile all up -d --build"
cmd = "docker compose --profile standalone --profile replica --profile sentinel up -d --build"
run(cmd)

@task
def devenv_cluster(c):
"""Brings up the test environment for OSS cluster redis, by wrapping docker compose."""
clean(c)
cmd = "docker compose --profile cluster up -d --build"
run(cmd)


Expand Down Expand Up @@ -55,11 +62,11 @@ def standalone_tests(c, uvloop=False, protocol=2, profile=False):
profile_arg = "--profile" if profile else ""
if uvloop:
run(
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=coverage/standalone-uvloop-results.xml"
)
else:
run(
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=standalone-results.xml"
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=coverage/standalone-results.xml"
)


Expand All @@ -70,11 +77,11 @@ def cluster_tests(c, uvloop=False, protocol=2, profile=False):
cluster_url = "redis://localhost:16379/0"
if uvloop:
run(
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"
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"
)
else:
run(
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"
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"
)


Expand Down

0 comments on commit a744dac

Please sign in to comment.