-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Simplify Python test process #10038
Simplify Python test process #10038
Conversation
fb14488
to
ac0b3d2
Compare
Run Python PreCommit |
Run Python2_PVR_Flink PreCommit |
6f5558b
to
2bc357c
Compare
2128a40
to
491a190
Compare
17ec0b1
to
a9d4a72
Compare
sdks/python/scripts/run_pytest.sh
Outdated
@@ -28,10 +28,10 @@ envname=${1?First argument required: suite base name} | |||
posargs=$2 | |||
|
|||
# Run with pytest-xdist and without. | |||
python setup.py pytest --addopts="-o junit_suite_name=${envname} \ | |||
pytest --addopts="-o junit_suite_name=${envname} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to remove the --addopts
flag and leave the value part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I was wrangling with that the other day. It would simplify things if we could just get rid of run_pytest.sh. Do we still need to run the tests with and without xdist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are a few tests that are still incompatible with xdist, such as those using save_main_session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the goal is to run both tests regardless of whether there is a failure (i.e. avoid early abort) then you can set the tox setting ignore_errors=true
: https://tox.readthedocs.io/en/latest/config.html#conf-ignore_errors
If false, a non-zero exit code from one command will abort execution of commands for that environment. If true, a non-zero exit code from one command will be ignored and further commands will be executed. The overall status will be “commands failed”, i.e. tox will exit non-zero in case any command failed.
I was trying to get run_pytest.sh to work with tox -e py37-pytest -- path/to/test
and I was struggling to get the arg passing correct, and ultimately I just moved it to tox.ini and it worked. With ignore_errors=true
in place I don't think the shell script will be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could try helping with arg passing.
If you specify a certain test to run, one of the pytest runs will certainly fail since it either has or doesn't have the no_xdist
marker. The script special-cases the 5 exit status from pytest to handle this scenario.
I'm probably missing something, because the way you set things up tox -e py37-pytest -- path/to/test
should have failed (either the -m not no_xdist
or the -m no_xdist
command should have failed).
In any case, I'm strongly in favor of simplifying the build process by having as few shell scripts as possible.
There's also this plugin to suppress certain exit statuses:
https://github.com/yashtodi94/pytest-custom_exit_code
Run Python PreCommit |
I know it shouldn't be relevant, but I noticed the Java flakes and will file something about them. |
run java precommit |
Both already had Jiras, so Java precommit is g2g. |
sdks/python/setup.py
Outdated
setup_requires=['pytest_runner'], | ||
tests_require= [ | ||
REQUIRED_TEST_PACKAGES, | ||
INTERACTIVE_BEAM, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that removing INTERACTIVE_BEAM
would cause some tests that depend on these package to fail. I'm guessing there aren't any tests for this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests that require the interactive deps should add the 'interactive' extra. So far I haven't run into any failures related to this.
Thanks. Slowly chipping away at this. I'll bring this to the list when I have the remaining kinks worked out. |
sdks/python/tox.ini
Outdated
@@ -307,3 +331,10 @@ commands = | |||
coverage report --skip-covered | |||
# Generate report in xml format | |||
coverage xml | |||
|
|||
[testenv:py37-interactive] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this add any additional test coverage? I'd rather fold any 'interactive' tests into the py37 target if possible. Or at least not repeat all the py37 unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this addition is actually a rebase error on my part. These tests were not intentionally added by me. IIRC, they were added to tox on master then removed in a later commit, and I must've messed up on one of my rebases and left it in.
My last two jenkins jobs indicated it took 0s to run, but the logs show that it was aborted after 2 hours. Any idea what could be going on? |
@@ -226,12 +307,6 @@ def run(self): | |||
]), | |||
install_requires=REQUIRED_PACKAGES, | |||
python_requires=python_requires, | |||
test_suite='nose.collector', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's alternative collector it will use? Can we ensure the collection result unchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it will still use nose, just not via setup.py. We can compare nosetests.xml files to verify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, test_requires
and test_suite
are for the python setup.py test
and derivative workflows. That whole stack is now deprecated in favor of extras and pep517.
b1d0d2c
to
862d733
Compare
Run Python PreCommit |
862d733
to
5347a29
Compare
Run Python PreCommit |
1 similar comment
Run Python PreCommit |
5347a29
to
863d2af
Compare
- Use pyproject.toml and pep517 to install requirements for building beam - Use tox to build sdist of beam instead of gradle sdist - Don't call python setup.py nosetests because it rebuilds beam - Do not run tests on code in the source directory - Run lint jobs against the source
Tox knows how to do this too, and now that we're using pyproject.toml (pep517 & pep518) we can describe how to do this in a portable way.
WIP: trying to debug why these are failing
Also, fix a bug where cython coder tests were not actually being run fix fix Fixes
we have to set the pep517 isolated build directory as the site dir for the google .pth file to work and find the nested protobuf package
863d2af
to
ed06bf1
Compare
This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time. |
One thing to note here is that despite the progress made by peps 517 and 518 toward improving the python build toolchains, it's still not a turnkey solution. You can't just
pip build sdist
yet. I tried a dozen different things, but it looks like the best solution is this pep517 module. References:Another problem is that we're always building cython on linux, rather than doing it conditionally based on the test we're running. Need to figure out if we can control that with environment markers
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.See the Contributor Guide for more tips on how to make review process smoother.
Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.