Skip to content

Changed test infrastructure to run separate cluster and standalone tests #3368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 40 additions & 27 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,35 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Run tests
- name: Build infrastructure
run: |
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: 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
coverage/*
prof/**
profile_output*
if-no-files-found: error
Expand All @@ -106,21 +115,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 +135,35 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Run tests
- name: Build infrastructure
run: |
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: 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
coverage/*
prof/**
profile_output*
if-no-files-found: error
Expand All @@ -164,7 +177,7 @@ jobs:
build-and-test-package:
name: Validate building and installing the package
runs-on: ubuntu-latest
needs: [resp2-tests, resp3-tests]
needs: [standalone, cluster]
strategy:
fail-fast: false
matrix:
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 --profile standalone 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
Loading