Skip to content

Commit

Permalink
Switch test runner from nosetest to pytest (#6291)
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd authored Dec 19, 2024
2 parents b62e82e + c4dc652 commit 983f63f
Show file tree
Hide file tree
Showing 42 changed files with 573 additions and 627 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ jobs:
name: Download st2-packages repository
command: |
set -x
PIP_VERSION=$(grep ^PIP_VERSION Makefile)
git clone ${ST2_PACKAGES_REPO} ~/st2-packages
cd ~/st2-packages
git checkout ${CIRCLE_BRANCH} || true
sed -i -e "s/^PIP_VERSION .*$/${PIP_VERSION}/" packages/st2/debian/rules
- run:
name: Initialize packages Build Environment
command: |
Expand Down
43 changes: 16 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,34 +258,29 @@ jobs:
include:
- name: 'Unit Tests (chunk 1)'
task: 'ci-unit'
nosetests_node_total: 2
nosetests_node_index: 0
shard: {k: 0, n: 2}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Unit Tests (chunk 2)'
task: 'ci-unit'
nosetests_node_total: 2
nosetests_node_index: 1
shard: {k: 1, n: 2}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Unit Tests (chunk 1)'
task: 'ci-unit'
nosetests_node_total: 2
nosetests_node_index: 0
shard: {k: 0, n: 2}
python-version-short: '3.9'
python-version: '3.9.14'
- name: 'Unit Tests (chunk 2)'
task: 'ci-unit'
nosetests_node_total: 2
nosetests_node_index: 1
shard: {k: 1, n: 2}
python-version-short: '3.9'
python-version: '3.9.14'
# This job is slow so we only run in on a daily basis
# - name: 'Micro Benchmarks'
# task: 'micro-benchmarks'
# python-version: '3.6.13'
# nosetests_node_total: 1
# nosetests_node_ index: 0
# shard: {k: 0, n: 1}
services:
mongo:
image: mongo:7.0
Expand Down Expand Up @@ -317,8 +312,8 @@ jobs:
env:
TASK: '${{ matrix.task }}'
PYTHON_VERSION_SHORT: '${{ matrix.python-version-short }}'
NODE_TOTAL: '${{ matrix.nosetests_node_total }}'
NODE_INDEX: '${{ matrix.nosetests_node_index }}'
NODE_TOTAL: '${{ matrix.shard.n }}'
NODE_INDEX: '${{ matrix.shard.k }}'

# We need to explicitly specify terminal width otherwise some CLI tests fail on container
# environments where small terminal size is used.
Expand Down Expand Up @@ -417,38 +412,32 @@ jobs:
# up (aka stanley user being present, etc.)
- name: 'Pack Tests'
task: 'ci-packs-tests'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Integration Tests (chunk 1)'
task: 'ci-integration'
nosetests_node_total: 2
nosetests_node_index: 0
shard: {k: 0, n: 2}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Integration Tests (chunk 2)'
task: 'ci-integration'
nosetests_node_total: 2
nosetests_node_index: 1
shard: {k: 1, n: 2}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Pack Tests'
task: 'ci-packs-tests'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.9'
python-version: '3.9.14'
- name: 'Integration Tests (chunk 1)'
task: 'ci-integration'
nosetests_node_total: 2
nosetests_node_index: 0
shard: {k: 0, n: 2}
python-version-short: '3.9'
python-version: '3.9.14'
- name: 'Integration Tests (chunk 2)'
task: 'ci-integration'
nosetests_node_total: 2
nosetests_node_index: 1
shard: {k: 1, n: 2}
python-version-short: '3.9'
python-version: '3.9.14'
services:
Expand Down Expand Up @@ -504,8 +493,8 @@ jobs:
env:
TASK: '${{ matrix.task }}'
PYTHON_VERSION_SHORT: '${{ matrix.python-version-short }}'
NODE_TOTAL: '${{ matrix.nosetests_node_total }}'
NODE_INDEX: '${{ matrix.nosetests_node_index }}'
NODE_TOTAL: '${{ matrix.shard.n }}'
NODE_INDEX: '${{ matrix.shard.k }}'

# We need to explicitly specify terminal width otherwise some CLI tests fail on container
# environments where small terminal size is used.
Expand Down Expand Up @@ -591,7 +580,7 @@ jobs:
if: ${{ failure() && env.TASK == 'ci-integration' }}
uses: actions/upload-artifact@v4
with:
name: logs-py${{ matrix.python-version }}-nose-${{ matrix.nosetests_node_index }}
name: logs-py${{ matrix.python-version }}-pytest-${{ matrix.shard.k }}
path: logs.tar.gz
retention-days: 7

Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/microbenchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ jobs:
include:
- name: 'Microbenchmarks'
task: 'micro-benchmarks'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Microbenchmarks'
task: 'micro-benchmarks'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.9'
python-version: '3.9.14'
services:
Expand All @@ -64,8 +62,8 @@ jobs:
env:
TASK: '${{ matrix.task }}'

NODE_TOTAL: '${{ matrix.nosetests_node_total }}'
NODE_INDEX: '${{ matrix.nosetests_node_index }}'
NODE_TOTAL: '${{ matrix.shard.n }}'
NODE_INDEX: '${{ matrix.shard.k }}'

COLUMNS: '120'
ST2_CI: 'true'
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/orquesta-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ jobs:
include:
- name: 'Integration Tests (Orquesta)'
task: 'ci-orquesta'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.8'
python-version: '3.8.10'
- name: 'Integration Tests (Orquesta)'
task: 'ci-orquesta'
nosetests_node_total: 1
nosetests_node_index: 0
shard: {k: 0, n: 1}
python-version-short: '3.9'
python-version: '3.9.14'
services:
Expand Down Expand Up @@ -97,8 +95,8 @@ jobs:

env:
TASK: '${{ matrix.task }}'
NODE_TOTAL: '${{ matrix.nosetests_node_total }}'
NODE_INDEX: '${{ matrix.nosetests_node_index }}'
NODE_TOTAL: '${{ matrix.shard.n }}'
NODE_INDEX: '${{ matrix.shard.k }}'

# We need to explicitly specify terminal width otherwise some CLI tests fail on container
# environments where small terminal size is used.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Changed
* Relaxed `dnspython` pinning for compatibility with python 3.10 and greater. #6265
Contributed by @nzlosh

* Switched tests from `nosetest` to `pytest`. `st2-run-pack-tests` also uses pytest.
So, all pack tests must be runnable by `pytest`, which may require migration. #6291
Contributed by @nzlosh, @FileMagic, @guzzijones, and @cognifloyd.

Added
~~~~~
* Continue introducing `pants <https://www.pantsbuild.org/docs>`_ to improve DX (Developer Experience)
Expand Down
Loading

0 comments on commit 983f63f

Please sign in to comment.