Skip to content
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

Upgrade cgap-portal to pytest 7.2 (C4-183) #687

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
93fd6c6
WIP: This upgrades anew to pytest 4.5, which breaks testing.
netsettler Jan 28, 2021
578b9c9
Merge branch 'master' into kmp_C4-179_pycharm_support-checked_but_pyt…
netsettler Jan 28, 2021
bd479b8
WIP: Install the lock file from master. For debugging, it will be nec…
netsettler Jan 28, 2021
b2d45a0
Merge recent master.
netsettler Jan 20, 2023
493b1b1
Be resilient against lack of development.ini or test.ini
netsettler Jan 31, 2023
53a5728
Add makefile targets for test-full, test-unit-full and test-npm-full …
netsettler Jan 31, 2023
3e070f0
Update pyproject and poetry lock to accommodate pytest 7
netsettler Jan 31, 2023
8b1a008
Port delay_rerun back from Fourfront.
netsettler Jan 31, 2023
61267a1
Add make_testapp and friends, as well as context managers begin_neste…
netsettler Jan 31, 2023
6d23542
In conftest.py, replace yield_fixture with fixture, and add various n…
netsettler Jan 31, 2023
f9d08b9
Rearrange datafixtures to put fixtures common to cgap and fourfront a…
netsettler Jan 31, 2023
033b364
Make hidden_facet_test_data and bucket_range_data be module-scoped ra…
netsettler Jan 31, 2023
490b6ea
Rewrite some fixtures without yield_fixture in test_fixtures.py
netsettler Jan 31, 2023
77db6f2
Rewrite yield_fixture as fixture in test_generate_item_from_owl.py
netsettler Jan 31, 2023
3397313
Rewrite yield_fixture as fixture in test_ingestion_listener.py
netsettler Jan 31, 2023
1ef8706
Tentatively work past a potential indexing problem in test_create_map…
netsettler Jan 31, 2023
738549d
Account for what seems to be a timing error or need for forced indexi…
netsettler Jan 31, 2023
895cf22
Back-port from fourfront various fixes to src/encoded/tests/test_inde…
netsettler Jan 31, 2023
287154f
Merge branch 'master' into kmp_pytest_7.2
netsettler Jan 31, 2023
456f86b
Merge branch 'master' into kmp_pytest_7.2
netsettler Feb 13, 2023
add7b4e
Merge branch 'master' into kmp_pytest_7.2
netsettler Feb 16, 2023
2c700fb
Change some #'s to @#'s in Makefile to make PyCharm happy.
netsettler Feb 28, 2023
784e247
Make scripts/psql-start call prepare-local-dev if test.ini is missing.
netsettler Feb 28, 2023
b686854
PEP8 in src/encoded/server_defaults.py
netsettler Feb 28, 2023
bd37510
Add test-full, test-unit-full, and test-npm-full. Factor markers out …
netsettler Feb 28, 2023
626c9d0
Lock with poetry 1.1.15
netsettler Feb 28, 2023
c4ea17b
Support poetry 1.3.2
netsettler Feb 28, 2023
a466cb0
Don't load moto[server]==1.3.7 before poetry, just moto==4.0.3 in poe…
netsettler Feb 28, 2023
00f6d5c
Hopefully loadable lock.
netsettler Mar 13, 2023
dd5566f
Add path = "." to poetry.toml
netsettler Mar 13, 2023
d6de7fd
Better lock.
netsettler Mar 13, 2023
4b3686a
poetry 1.3.2, setuptools 67.6.0, wheel 0.38.4, pytest 7.2
netsettler Mar 13, 2023
d18ea7b
PEP8
netsettler Mar 13, 2023
e700146
Update docker for right version of poetry.
netsettler Mar 13, 2023
02ec0ae
Merge branch 'master' into kmp_pytest_7.2
netsettler Mar 23, 2023
010dc78
Merge branch 'master' into kmp_pytest_7.2
netsettler Mar 25, 2023
0ff7132
Some changes to prepare for an unrelated branch marge.
netsettler Mar 25, 2023
ca5c547
Merge branch 'kmp_misc_20230227_poetry-1-3-2' into kmp_pytest_7.2
netsettler Mar 25, 2023
78dae2a
Add a pytest marker.
netsettler Mar 25, 2023
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
60 changes: 30 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Build for cgap-portal
# Main python test suite for cgap-portal

name: CI

Expand All @@ -17,15 +17,15 @@ on:
jobs:
# This workflow contains a single job called "build"
build:
name: Test Suite for cgap-portal (Python 3.8, Node 16)
name: cgap-portal tests

# The type of runner that the job will run on
runs-on: ubuntu-20.04

# Build matrix
strategy:
matrix:
test_type: ['UNIT', 'NPM', 'Docker']
test_type: ['UNIT', 'INDEX', 'DOCKER']
# We are really not set up for these next two to be multiplicative, so be careful adding more.
python_version: ['3.8']
node_version: ['16']
Expand All @@ -45,7 +45,7 @@ jobs:
check-latest: false

- name: Install/Link Postgres
if: ${{ matrix.test_type == 'NPM' || matrix.test_type == 'UNIT' }}
if: ${{ matrix.test_type == 'UNIT' || matrix.test_type == 'INDEX' }}
run: |
sudo apt-get install curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Expand All @@ -55,7 +55,7 @@ jobs:
echo "/usr/lib/postgresql/14/bin" >> $GITHUB_PATH
sudo ln -s /usr/lib/postgresql/14/bin/initdb /usr/local/bin/initdb
- name: Install Deps
if: ${{ matrix.test_type == 'NPM' || matrix.test_type == 'UNIT' }}
if: ${{ matrix.test_type == 'INDEX' || matrix.test_type == 'UNIT' }}
run: |
node --version
make build
Expand All @@ -66,34 +66,28 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: QA (NPM)
if: ${{ matrix.test_type == 'NPM' }}
- name: QA (UNIT)
if: ${{ matrix.test_type == 'UNIT' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
# The need for this old environment variable name will go away soon.
# Once the new snovault is in, we should retain these for a little while to make sure the right
# variable is being used, and then this can go away. -kmp 9-Mar-2021
# I have named the ID slightly differently so we can see if the old names are in use.
TRAVIS_JOB_ID: cgap-npm-x-test-${{ github.run_number }}-
TRAVIS_JOB_ID: cgap-unit-x-test-${{ github.run_number }}-
# This will be the new environment variable name.
TEST_JOB_ID: cgap-npm-test-${{ github.run_number }}-
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
# npm test
make remote-test-unit
make remote-test-npm

- name: Cleanup (NPM)
if: ${{ always() && matrix.test_type == 'NPM' }}
- name: Cleanup (UNIT)
if: ${{ always() && matrix.test_type == 'UNIT' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
# The need for this old environment variable name will go away soon.
# Once the new snovault is in, we should retain these for a little while to make sure the right
# variable is being used, and then this can go away. -kmp 9-Mar-2021
# I have named the ID slightly differently so we can see if the old names are in use.
TRAVIS_JOB_ID: cgap-npm-x-test-${{ github.run_number }}-
TRAVIS_JOB_ID: cgap-unit-x-test-${{ github.run_number }}-
# This will be the new environment variable name.
TEST_JOB_ID: cgap-npm-test-${{ github.run_number }}-
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
Expand All @@ -102,27 +96,33 @@ jobs:
poetry run wipe-test-indices $TRAVIS_JOB_ID search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
poetry run wipe-test-indices cgap-test-$TRAVIS_JOB_ID search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443

- name: QA (UNIT)
if: ${{ matrix.test_type == 'UNIT' }}
- name: QA (INDEX)
if: ${{ matrix.test_type == 'INDEX' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
# The need for this old environment variable name will go away soon.
TRAVIS_JOB_ID: cgap-unit-x-test-${{ github.run_number }}-
# Once the new snovault is in, we should retain these for a little while to make sure the right
# variable is being used, and then this can go away. -kmp 9-Mar-2021
# I have named the ID slightly differently so we can see if the old names are in use.
TRAVIS_JOB_ID: cgap-idx-x-test-${{ github.run_number }}-
# This will be the new environment variable name.
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
TEST_JOB_ID: cgap-idx-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
make remote-test-unit
make remote-test-indexing

- name: Cleanup (UNIT)
if: ${{ always() && matrix.test_type == 'UNIT' }}
- name: Cleanup (INDEX)
if: ${{ always() && matrix.test_type == 'INDEX' }}
env:
S3_ENCRYPT_KEY: ${{ secrets.S3_ENCRYPT_KEY }}
# The need for this old environment variable name will go away soon.
TRAVIS_JOB_ID: cgap-unit-x-test-${{ github.run_number }}-
# Once the new snovault is in, we should retain these for a little while to make sure the right
# variable is being used, and then this can go away. -kmp 9-Mar-2021
# I have named the ID slightly differently so we can see if the old names are in use.
TRAVIS_JOB_ID: cgap-idx-x-test-${{ github.run_number }}-
# This will be the new environment variable name.
TEST_JOB_ID: cgap-unit-test-${{ github.run_number }}-
TEST_JOB_ID: cgap-idx-test-${{ github.run_number }}-
GLOBAL_ENV_BUCKET: ${{ secrets.GLOBAL_ENV_BUCKET }}
ACCOUNT_NUMBER: $ {{ secrets.ACCOUNT_NUMBER }}
run: |
Expand All @@ -132,7 +132,7 @@ jobs:
poetry run wipe-test-indices cgap-test-$TRAVIS_JOB_ID search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443

- name: Docker Build
if: ${{ matrix.test_type == 'Docker' && matrix.node_version == '16' && matrix.python_version == '3.8' }}
if: ${{ matrix.test_type == 'DOCKER' && matrix.node_version == '16' && matrix.python_version == '3.8' }}
run: |
touch deploy/docker/local/docker_development.ini # cheap substitute for prepare-docker to make ignored file
docker build .
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ cgap-portal
Change Log
----------


12.10.2
=======

* Backport pytest 7.2 support from Fourfront
* Move to poetry 1.3.2
* Remove dependence in a pinned version of setuptools


12.10.1
=======
`PR 702: VEP QC metrics fix <https://github.com/dbmi-bgm/cgap-portal/pull/702>`_
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends vim emacs net-tools ca-certificates build-essential \
gcc zlib1g-dev postgresql-client libpq-dev git make curl libmagic-dev && \
pip install --upgrade pip && \
pip install poetry==1.1.15 && \
pip install poetry==1.3.2 && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash && \
. "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} && \
nvm use v${NODE_VERSION} && \
Expand Down
117 changes: 94 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ npm-setup: # runs all front-end setup
make aws-ip-ranges

moto-setup: # optional moto setup that must be done separately
pip install "moto[server]==1.3.7"
@# This setup was needed here because there was no bracket syntax in pypoetry.com.
@# Now that we're using a higher version of moto, and not using the server parts, we don't need this here.
@# It's now all done in pyproject.toml, getting a higher version as well.
@# This comment and this make target can go away once that's proven effective. -kmp 23-Mar-2023
@# pip install "moto[server]==1.3.7"
@echo "'moto[server]' not being installed here. Regular 'moto' will be installed by pyproject.toml."

macpoetry-install: # Same as 'poetry install' except that on OSX Catalina, an environment variable wrapper is needed
bin/macpoetry-install
Expand All @@ -45,10 +50,11 @@ configure: # does any pre-requisite installs
@#pip install --upgrade pip==21.0.1
pip install --upgrade pip
@#pip install poetry==1.1.9 # this version is known to work. -kmp 11-Mar-2021
# Pin to version 1.1.15 for now to avoid this error:
# Because encoded depends on wheel (>=0.29.0) which doesn't match any versions, version solving failed.
pip install poetry==1.1.15
pip install setuptools==57.5.0 # this version allows 2to3, any later will break -wrr 20-Sept-2021
@# Pin to version 1.1.15 for now to avoid this error:
@# Because encoded depends on wheel (>=0.29.0) which doesn't match any versions, version solving failed.
pip install poetry==1.3.2
pip install setuptools # ==57.5.0 # this version allows 2to3, any later will break -wrr 20-Sept-2021
pip install wheel
poetry config virtualenvs.create false --local # do not create a virtualenv - the user should have already done this -wrr 20-Sept-2021

build-poetry:
Expand Down Expand Up @@ -150,46 +156,108 @@ clean-python:
pip uninstall encoded
pip uninstall -y -r <(pip freeze)

test:
test-full:
@git log -1 --decorate | head -1
@date
make test-unit || echo "unit tests failed"
make test-static-full || echo "static tests failed"
make test-unit-full || echo "unit tests failed"
make test-npm || echo "npm tests failed"
make test-static || echo "static tests failed"
make test-indexing-full || echo "indexing tests failed"
@git log -1 --decorate | head -1
@date

test:
@git log -1 --decorate | head -1
@date
make test-static && make test-unit && make test-npm && make test-indexing
@git log -1 --decorate | head -1
@date


BASE_MARKERS = not manual and not sloppy and not static and not broken
# Unit tests
NORM_MARKERS = not performance and not integratedx
# Performance tests
PERF_MARKERS = performance and not integratedx
# Integration tests
INTG_MARKERS = not performance and (integrated or integratedx)

retest:
poetry run python -m pytest -vv -r w --last-failed

test-any:
poetry run python -m pytest -xvv -r w --timeout=200

test-npm:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=600 -m "not manual and not integratedx and not performance and not broken and not sloppy and not indexing and not static"

test-unit:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=200 -m "not manual and not integratedx and not performance and not broken and not sloppy and indexing and not static"
poetry run python -m pytest -xvv -r w --durations=25 --timeout=600 -m "${BASE_MARKERS} and ${NORM_MARKERS} and not indexing"

test-unit-full:
poetry run python -m pytest -vv -r w --durations=25 --timeout=600 -m "${BASE_MARKERS} and ${NORM_MARKERS} and not indexing"

test-indexing-full:
make test-indexing-es-full
make test-indexing-not-es-full

test-indexing-es-full:
poetry run python -m pytest -vv -r w --durations=25 --timeout=300 -m "${BASE_MARKERS} and ${NORM_MARKERS} and indexing and es"

test-indexing-not-es-full:
poetry run python -m pytest -vv -r w --durations=25 --timeout=300 -m "${BASE_MARKERS} and ${NORM_MARKERS} and indexing and not es"

test-indexing:
make test-indexing-es && make test-indexing-not-es

test-indexing-es:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=200 -m "${BASE_MARKERS} and ${NORM_MARKERS} and indexing and es"

test-indexing-not-es:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=200 -m "${BASE_MARKERS} and ${NORM_MARKERS} and indexing and not es"

test-performance:
poetry run python -m pytest -xvv -r w --timeout=200 -m "not manual and not integratedx and performance and not broken and not sloppy and not static"
poetry run python -m pytest -xvv -r w --timeout=200 -m "${BASE_MARKERS} and ${PERF_MARKERS}"

test-integrated:
poetry run python -m pytest -xvv -r w --timeout=200 -m "not manual and (integrated or integratedx) and not performance and not broken and not sloppy and not static"
poetry run python -m pytest -xvv -r w --timeout=200 -m "${BASE_MARKERS} and ${INTG_MARKERS}"

test-static:
test-npm:
@#At one point we did 'npm test' here, but now we do separate cypress tests. -kmp 24-Mar-2023
@echo "npm tests would run here if they were enabled. Instead we have a separate Cypress test GA workflow."

test-static-full:
poetry run python -m pytest -vv -m static
make lint
make lint-full

test-static:
poetry run python -m pytest -vv -m static && make lint

TEST_NAME ?= missing_TEST_NAME_parameter

test-one:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=200 -m "${BASE_MARKERS} and ${NORM_MARKERS}" -k "${TEST_NAME}"

REMOTE_ES = search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
REMOTE_MARKERS = ${BASE_MARKERS} and ${NORM_MARKERS} and not broken_remotely

remote-test: # Actually, we don't normally use this. Instead the GA workflow sets up two parallel tests.
make remote-test-unit
make remote-test-npm
make remote-test-indexing && make remote-test-npm && make remote-test-unit

remote-test-npm:
make test-npm

remote-test-unit:
make remote-test-indexing-not-es

remote-test-not-indexing: # Note this only does the 'not indexing' tests
poetry run python -m pytest -xvv -r w --durations=25 --timeout=600 -m "${REMOTE_MARKERS} and not indexing" --aws-auth --es ${REMOTE_ES} --instafail --force-flaky --max-runs=2 --durations=20 --cov src/encoded

remote-test-npm: # Note this only does the 'not indexing' tests
poetry run python -m pytest -xvv -r w --instafail --force-flaky --max-runs=2 --timeout=600 -m "not manual and not integratedx and not performance and not broken and not broken_remotely and not sloppy and not indexing and not static" --aws-auth --durations=20 --cov src/encoded --es search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
remote-test-indexing:
make remote-test-indexing-es && make remote-test-not-indexing

remote-test-unit: # Note this does the 'indexing' tests
poetry run python -m pytest -xvv -r w --timeout=300 -m "not manual and not integratedx and not performance and not broken and not broken_remotely and not sloppy and indexing and not static" --aws-auth --es search-cgap-unit-testing-opensearch-tcs45cjpwgdzoi7pafr6oewq6u.us-east-1.es.amazonaws.com:443
remote-test-indexing-es:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=300 -m "${REMOTE_MARKERS} and indexing and es" --aws-auth --es ${REMOTE_ES} --cov-append

remote-test-indexing-not-es:
poetry run python -m pytest -xvv -r w --durations=25 --timeout=300 -m "${REMOTE_MARKERS} and indexing and not es" --aws-auth --es ${REMOTE_ES} --cov-append

update: # updates dependencies
poetry update
Expand Down Expand Up @@ -250,10 +318,13 @@ tag-and-push-docker-production:
docker push ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/${ENV_NAME}:latest
date

lint:
lint-full:
@flake8 deploy/ || echo "flake8 failed for deploy/"
@flake8 src/encoded/ || echo "flake8 failed for src/encoded"

lint:
@flake8 deploy/ && flake8 src/encoded/

help:
@make info

Expand Down
Loading