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

chore: Ensure local (tox) Python testing is somewhat akin to remote (GitHub actions) #27108

Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/superset-python-integrationtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Python integration tests (MySQL)
if: steps.check.outcome == 'failure'
run: |
./scripts/python_tests.sh
./scripts/python_tests.sh tests/integration_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
- name: Python integration tests (PostgreSQL)
if: steps.check.outcome == 'failure'
run: |
./scripts/python_tests.sh
./scripts/python_tests.sh tests/integration_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
- name: Python integration tests (SQLite)
if: steps.check.outcome == 'failure'
run: |
./scripts/python_tests.sh
./scripts/python_tests.sh tests/integration_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/superset-python-presto-hive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Python unit tests (PostgreSQL)
if: steps.check.outcome == 'failure'
run: |
./scripts/python_tests.sh -m 'chart_data_flow or sql_json_flow'
./scripts/python_tests.sh -m 'chart_data_flow or sql_json_flow' tests/integration_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
- name: Python unit tests (PostgreSQL)
if: steps.check.outcome == 'failure'
run: |
./scripts/python_tests.sh -m 'chart_data_flow or sql_json_flow'
./scripts/python_tests.sh -m 'chart_data_flow or sql_json_flow' tests/integration_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/superset-python-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
env:
SUPERSET_TESTENV: true
run: |
pytest --durations-min=0.5 --cov-report= --cov=superset ./tests/common ./tests/unit_tests --cache-clear
./scripts/python_tests.sh tests/unit_tests
- name: Upload code coverage
if: steps.check.outcome == 'failure'
run: |
Expand Down
13 changes: 8 additions & 5 deletions scripts/python_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ export LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6
export SUPERSET_CONFIG=${SUPERSET_CONFIG:-tests.integration_tests.superset_test_config}
export SUPERSET_TESTENV=true
echo "Superset config module: $SUPERSET_CONFIG"

superset db upgrade
superset init

echo "Running tests"

pytest --durations-min=2 --maxfail=1 --cov-report= --cov=superset ./tests/integration_tests "$@"
if [[ $@ =~ "integration_tests" ]]; then
superset db upgrade
superset init
superset load-test-users
pytest --durations-min=2 --maxfail=1 --cov-report= --cov=superset "$@"
else
pytest --durations-min=0.5 --cov-report= --cov=superset "$@"
Copy link
Member

Choose a reason for hiding this comment

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

Previously, unit tests also included ./tests/common for coverage reports.

pytest --durations-min=0.5 --cov-report= --cov=superset ./tests/common ./tests/unit_tests --cache-clear

Copy link
Member

Choose a reason for hiding this comment

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

There was also a --cache-clear which I don't know if it was relevant.

fi
4 changes: 0 additions & 4 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ def setup_sample_data() -> Any:
with app.app_context():
setup_presto_if_needed()

from superset.cli.test import load_test_users_run

load_test_users_run()

from superset.examples.css_templates import load_css_templates

load_css_templates()
Expand Down
7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
basepython = python3.9
ignore_basepython_conflict = true
commands =
superset db upgrade
superset init
# use -s to be able to use break pointers.
# no args or tests/* can be passed as an argument to run all tests
pytest -s {posargs}
{toxinidir}/scripts/python_tests.sh {posargs}
deps =
-rrequirements/testing.txt
setenv =
Expand All @@ -51,6 +47,7 @@ usedevelop = true
allowlist_externals =
npm
pkill
{toxinidir}/scripts/python_tests.sh

[testenv:cypress]
setenv =
Expand Down
Loading