[BEAM-10527] Migrate Flink and Spark tests to pytest.#12385
[BEAM-10527] Migrate Flink and Spark tests to pytest.#12385mxm merged 2 commits intoapache:masterfrom
Conversation
8ae28f6 to
a51fed8
Compare
|
Run Portable_Python PreCommit |
sdks/python/apache_beam/runners/portability/flink_runner_test.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/runners/portability/flink_runner_test.py
Outdated
Show resolved
Hide resolved
sdks/python/apache_beam/runners/portability/spark_runner_test.py
Outdated
Show resolved
Hide resolved
|
Run Java PreCommit |
mxm
left a comment
There was a problem hiding this comment.
I couldn't find the published test results in Jenkins. Do we have to add this separately? https://ci-beam.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Commit/6126/
This is because publishing the test results relies on a change to the Jenkins job config, and I didn't want to |
|
I got I have already spent a long time trying to fix quotes, so I can't help but wondering: why do we need |
Another solution I had in mind was reworking the |
udim
left a comment
There was a problem hiding this comment.
The approach to using pytest looks good. One comment.
|
Thanks for fixing the quoting issue!
I think that feature only works in newer versions of
|
@mxm what do you think about https://issues.apache.org/jira/browse/BEAM-10671? |
I think it makes sense. Especially for error reporting by having dedicated argument parsers for all environments parameters. |
The default pytest timeout is 600s. Once all portable runner tests are migrated to pytest, we can use the pytest timeout instead of portable_runner_test's bespoke implementation. See apache#12385.
6c233c2 to
2a0ad5d
Compare
Codecov Report
@@ Coverage Diff @@
## master #12385 +/- ##
==========================================
+ Coverage 82.39% 82.50% +0.11%
==========================================
Files 453 453
Lines 54623 54612 -11
==========================================
+ Hits 45005 45059 +54
+ Misses 9618 9553 -65
Continue to review full report at Codecov.
|
|
Run Python Spark ValidatesRunner |
|
This looks good to me after rebasing. Thanks for porting this to pytest! |
| # Run as | ||
| # | ||
| # pytest flink_runner_test.py \ | ||
| # [--test_pipeline_options "--flink_job_server_jar=/path/to/job_server.jar \ |
There was a problem hiding this comment.
Oh yeah, --test_pipeline_options is now required (even though it should be possible to leave it empty). Boyuan, would you mind filing a PR to fix this?
| # pytest flink_runner_test.py \ | ||
| # [--test_pipeline_options "--flink_job_server_jar=/path/to/job_server.jar \ | ||
| # --environment_type=DOCKER"] \ | ||
| # [FlinkRunnerTest.test_method, ...] |
There was a problem hiding this comment.
And the test filter here doesn't work for me properly. The working version for me is
pytest flink_runner_test.py::TestClass:test_case --test-pipeline-options "--flink_job_server_jar=XXX --environment_type=XXX "
Motivation
The main goals of migrating to pytest are:
This also implicitly raises the timeout for all these tests from 60s to 600s, which should reduce the likelihood of timeout flakes (BEAM-8912).Implementation
I originally wanted to do this in incremental changes, but I gradually realized a complete overhaul of these tests' configuration was needed. The main challenge was that
flink_runner_test.pyexpected to be run as__main__, which is impossible with pytest. I basically reworked everything except the tests themselves; the tests themselves are unchanged.Test parametrization
flink_runner_test.pybecause it removes the need to set up separate tox tasks, separate test result files, etc.flink_job_server_driver,environment_type, andenvironment_configare all pipeline options, I decided to pass them toflink_runner_test.pyby introducing a global pytest option,--test-pipeline-options.noseuses--test-pipeline-optionsfor integration tests, so I figured this would be generally useful beyond just these tests in the future.Bonus trivia
Prior to this change, we were running the exact same streaming test suite four times per Jenkins run.
Every
flinkCompatibilityMatrixtask ran the entirety offlink_runner_test.pywhich contained two classes:FlinkRunnerTestandFlinkRunnerTestOptimized.FlinkRunnerTestOptimizedwas basically the same thing asFlinkRunnerTest, but it added thepre_optimize=allexperiment and skipped external transform tests, since the Python optimizer breaks external transforms (BEAM-7252). But we were also addingpre_optimize=allin Gradle, redundantly.The old configuration looks like this:
Notice that pre-optimized batch is missing. This is because
flinkCompatibilityMatrixBatchPreOptimize*would runFlinkRunnerTestwithpre_optimize=allbut without skipping the external transform tests, causing failure.What about streaming, then? Well, the optimizer doesn't affect streaming pipelines at all:
beam/sdks/python/apache_beam/runners/portability/portable_runner.py
Line 319 in 489cf2c
So in one invocation of
flinkValidatesRunner,flinkCompatibilityMatrixStreamingLoopbackwould runFlinkRunnerTest(withoutpre_optimize=all) andFlinkRunnerTestOptimized, thenflinkCompatibilityMatrixStreamingPreOptimizeLoopbackwould runFlinkRunnerTest(withpre_optimize=all) andFlinkRunnerTestOptimized(withpre_optimize=alltwice). Besides the skips inFlinkRunnerTestOptimized, all four tests would be doing the exact same thing.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-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.mdwith noteworthy changes.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.