Skip to content

PYTHON-4558 Fix coverage and XML results for async tests #1738

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

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
28 changes: 12 additions & 16 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set -o xtrace

AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
TEST_SUITES="test/ test/asynchronous/"
TEST_ARGS="${*:1}"

export PIP_QUIET=1 # Quiet by default
Expand Down Expand Up @@ -95,7 +96,7 @@ if [ -n "$TEST_LOADBALANCER" ]; then
export LOAD_BALANCER=1
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI:-mongodb://127.0.0.1:8000/?loadBalanced=true}"
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI:-mongodb://127.0.0.1:8001/?loadBalanced=true}"
export TEST_ARGS="test/test_load_balancer.py"
export TEST_SUITES="test/test_load_balancer.py"
fi

if [ "$SSL" != "nossl" ]; then
Expand Down Expand Up @@ -171,9 +172,7 @@ if [ -n "$TEST_ENCRYPTION" ]; then
export PATH=$CRYPT_SHARED_DIR:$PATH
fi
# Only run the encryption tests.
if [ -z "$TEST_ARGS" ]; then
TEST_ARGS="test/test_encryption.py"
fi
TEST_SUITES="test/test_encryption.py"
fi

if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
Expand All @@ -187,9 +186,7 @@ if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
exit 1
fi

if [ -z "$TEST_ARGS" ]; then
TEST_ARGS="test/test_on_demand_csfle.py"
fi
TEST_SUITES="test/test_on_demand_csfle.py"
fi

if [ -n "$TEST_INDEX_MANAGEMENT" ]; then
Expand All @@ -198,36 +195,36 @@ if [ -n "$TEST_INDEX_MANAGEMENT" ]; then
set +x
export DB_PASSWORD="${DRIVERS_ATLAS_LAMBDA_PASSWORD}"
set -x
TEST_ARGS="test/test_index_management.py"
TEST_SUITES="test/test_index_management.py"
fi

if [ -n "$TEST_DATA_LAKE" ] && [ -z "$TEST_ARGS" ]; then
TEST_ARGS="test/test_data_lake.py"
TEST_SUITES="test/test_data_lake.py"
fi

if [ -n "$TEST_ATLAS" ]; then
TEST_ARGS="test/atlas/test_connection.py"
TEST_SUITES="test/atlas/test_connection.py"
fi

if [ -n "$TEST_OCSP" ]; then
python -m pip install ".[ocsp]"
TEST_ARGS="test/ocsp/test_ocsp.py"
TEST_SUITES="test/ocsp/test_ocsp.py"
fi

if [ -n "$TEST_AUTH_AWS" ]; then
python -m pip install ".[aws]"
TEST_ARGS="test/auth_aws/test_auth_aws.py"
TEST_SUITES="test/auth_aws/test_auth_aws.py"
fi

if [ -n "$TEST_AUTH_OIDC" ]; then
python -m pip install ".[aws]"
TEST_ARGS="test/auth_oidc/test_auth_oidc.py $TEST_ARGS"
TEST_SUITES="test/auth_oidc/test_auth_oidc.py $TEST_ARGS"
fi

if [ -n "$PERF_TEST" ]; then
python -m pip install simplejson
start_time=$(date +%s)
TEST_ARGS="test/performance/perf_test.py"
TEST_SUITES="test/performance/perf_test.py"
fi

echo "Running $AUTH tests over $SSL with python $(which python)"
Expand Down Expand Up @@ -257,8 +254,7 @@ PIP_QUIET=0 python -m pip list
if [ -z "$GREEN_FRAMEWORK" ]; then
# Use --capture=tee-sys so pytest prints test output inline:
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 $TEST_ARGS
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 test/asynchronous/ $TEST_ARGS
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 $TEST_SUITES $TEST_ARGS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is a clean solution. Do we still need $TEST_ARGS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_ARGS is still used to add --cov.

else
python green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
fi
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,11 @@ jobs:
python-version: '3.8'
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
- name: Run Test
- name: Run connect test from sdist
shell: bash
run: |
cd sdist/test
ls
which python
pip install -e ".[test]"
pytest -v
pytest -v test/asynchronous/
PYMONGO_MUST_CONNECT=1 pytest -v test/test_client_context.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this test been just running the wrong suite this whole time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but it just seems unnessecary to run the whole suite from the sdist, we already run the whole suite elsewhere on the same commit.

Loading