From 756c77211f94261051a542657b16bcf391e5cf78 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 10:56:37 -0500 Subject: [PATCH 01/16] WIP: Support passing in special pytest args --- sdks/python/scripts/run_pytest.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 6c7d5c46e78e..1ae19b0bf29c 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -35,12 +35,27 @@ if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then exit 1 fi +pyargs="" +posargs_array=$(posargs) +echo "posargs:" +for i in $posargs_array +do + : + # do whatever on $i + echo "$i" + if [[ $i == "--skip"* ]]; then + pytest_args += " " + $i + else + pyargs += " " + $i + fi +done + # Run with pytest-xdist and without. pytest -o junit_suite_name=${envname} \ - --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${posargs} + --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${pyargs} status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${posargs} + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${pyargs} status2=$? # Exit with error if no tests were run in either suite (status code 5). From a9b23679c710ce3b30681e3ab8bdd130df3a9748 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 13:24:56 -0500 Subject: [PATCH 02/16] Shard precommit --- .test-infra/jenkins/README.md | 5 ++ .../jenkins/job_PreCommit_Python.groovy | 3 + .../jenkins/job_PreCommit_PythonIT.groovy | 37 ++++++++++ .../job_PreCommit_Python_Dataframes.groovy | 40 +++++++++++ .../job_PreCommit_Python_Examples.groovy | 40 +++++++++++ .../job_PreCommit_Python_Runners.groovy | 40 +++++++++++ .../job_PreCommit_Python_Transforms.groovy | 40 +++++++++++ build.gradle.kts | 4 ++ sdks/python/scripts/run_pytest.sh | 7 +- sdks/python/test-suites/tox/common.gradle | 12 ++-- sdks/python/test-suites/tox/py37/build.gradle | 6 +- sdks/python/test-suites/tox/py38/build.gradle | 71 ++++++++++--------- sdks/python/tox.ini | 8 ++- 13 files changed, 265 insertions(+), 48 deletions(-) create mode 100644 .test-infra/jenkins/job_PreCommit_PythonIT.groovy create mode 100644 .test-infra/jenkins/job_PreCommit_Python_Dataframes.groovy create mode 100644 .test-infra/jenkins/job_PreCommit_Python_Examples.groovy create mode 100644 .test-infra/jenkins/job_PreCommit_Python_Runners.groovy create mode 100644 .test-infra/jenkins/job_PreCommit_Python_Transforms.groovy diff --git a/.test-infra/jenkins/README.md b/.test-infra/jenkins/README.md index c596daf8ba48..932a7f89d646 100644 --- a/.test-infra/jenkins/README.md +++ b/.test-infra/jenkins/README.md @@ -45,6 +45,11 @@ Beam Jenkins overview page: [link](https://ci-beam.apache.org/) | beam_PreCommit_Portable_Python | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Phrase/) | `Run Portable_Python PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron) | | beam_PreCommit_PythonLint | [commit](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Phrase/) | `Run PythonLint PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron) | | beam_PreCommit_Python | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Phrase/) | `Run Python PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron) | +| beam_PreCommit_Python_Integration | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Integration_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Integration_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Integration_Phrase/) | `Run Python_Integration PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Integration_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Integration_Cron) | +| beam_PreCommit_Python_Dataframes | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Dataframes_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Dataframes_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Dataframes_Phrase/) | `Run Python_Dataframes PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Dataframes_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Dataframes_Cron) | +| beam_PreCommit_Python_Examples | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Examples_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Examples_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Examples_Phrase/) | `Run Python_Examples PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Examples_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Examples_Cron) | +| beam_PreCommit_Python_Runners | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Runners_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Runners_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Runners_Phrase/) | `Run Python_Runners PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Runners_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Runners_Cron) | +| beam_PreCommit_Python_Transforms | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_Transforms_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_Transforms_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_Transforms_Phrase/) | `Run Python_Transforms PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Transforms_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Transforms_Cron) | | beam_PreCommit_PythonDocker | [commit](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Phrase/) | `Run PythonDocker PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/) | | beam_PreCommit_PythonDocs| [commit](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Phrase/) | `Run PythonDocs PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/) | | beam_PreCommit_Python_PVR_Flink | [commit](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Commit/), [cron](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Cron/), [phrase](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Phrase/) | `Run Python_PVR_Flink PreCommit` | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_PVR_Flink_Cron) | diff --git a/.test-infra/jenkins/job_PreCommit_Python.groovy b/.test-infra/jenkins/job_PreCommit_Python.groovy index 0b5270f96eef..6c01750bf33d 100644 --- a/.test-infra/jenkins/job_PreCommit_Python.groovy +++ b/.test-infra/jenkins/job_PreCommit_Python.groovy @@ -27,6 +27,9 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder( '^model/.*$', '^sdks/python/.*$', '^release/.*$', + ], + gradleSwitches: [ + '-Pposargs=\"--skip=apache_beam/dataframe/ --skip=apache_beam/examples/ --skip=apache_beam/runners/ --skip=apache_beam/transforms/\"' // All other tests are covered by different jobs. ] ) builder.build { diff --git a/.test-infra/jenkins/job_PreCommit_PythonIT.groovy b/.test-infra/jenkins/job_PreCommit_PythonIT.groovy new file mode 100644 index 000000000000..21d249647e8b --- /dev/null +++ b/.test-infra/jenkins/job_PreCommit_PythonIT.groovy @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import PrecommitJobBuilder + +PrecommitJobBuilder builder = new PrecommitJobBuilder( + scope: this, + nameBase: 'Python_Integration', + gradleTask: ':pythonPreCommitIT', + timeoutMins: 180, + triggerPathPatterns: [ + '^model/.*$', + '^sdks/python/.*$', + '^release/.*$', + ] + ) +builder.build { + // Publish all test results to Jenkins. + publishers { + archiveJunit('**/pytest*.xml') + } +} \ No newline at end of file diff --git a/.test-infra/jenkins/job_PreCommit_Python_Dataframes.groovy b/.test-infra/jenkins/job_PreCommit_Python_Dataframes.groovy new file mode 100644 index 000000000000..e2914e9bdb8e --- /dev/null +++ b/.test-infra/jenkins/job_PreCommit_Python_Dataframes.groovy @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import PrecommitJobBuilder + +PrecommitJobBuilder builder = new PrecommitJobBuilder( + scope: this, + nameBase: 'Python_Dataframes', + gradleTask: ':pythonPreCommit', + gradleSwitches: [ + '-Pposargs=apache_beam/dataframe/' + ], + timeoutMins: 180, + triggerPathPatterns: [ + '^model/.*$', + '^sdks/python/.*$', + '^release/.*$', + ] + ) +builder.build { + // Publish all test results to Jenkins. + publishers { + archiveJunit('**/pytest*.xml') + } +} \ No newline at end of file diff --git a/.test-infra/jenkins/job_PreCommit_Python_Examples.groovy b/.test-infra/jenkins/job_PreCommit_Python_Examples.groovy new file mode 100644 index 000000000000..f4ef9f51d7fb --- /dev/null +++ b/.test-infra/jenkins/job_PreCommit_Python_Examples.groovy @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import PrecommitJobBuilder + +PrecommitJobBuilder builder = new PrecommitJobBuilder( + scope: this, + nameBase: 'Python_Examples', + gradleTask: ':pythonPreCommit', + gradleSwitches: [ + '-Pposargs=apache_beam/examples/' + ], + timeoutMins: 180, + triggerPathPatterns: [ + '^model/.*$', + '^sdks/python/.*$', + '^release/.*$', + ] + ) +builder.build { + // Publish all test results to Jenkins. + publishers { + archiveJunit('**/pytest*.xml') + } +} \ No newline at end of file diff --git a/.test-infra/jenkins/job_PreCommit_Python_Runners.groovy b/.test-infra/jenkins/job_PreCommit_Python_Runners.groovy new file mode 100644 index 000000000000..e80dba6cf5cd --- /dev/null +++ b/.test-infra/jenkins/job_PreCommit_Python_Runners.groovy @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import PrecommitJobBuilder + +PrecommitJobBuilder builder = new PrecommitJobBuilder( + scope: this, + nameBase: 'Python_Runners', + gradleTask: ':pythonPreCommit', + gradleSwitches: [ + '-Pposargs=apache_beam/runners/' + ], + timeoutMins: 180, + triggerPathPatterns: [ + '^model/.*$', + '^sdks/python/.*$', + '^release/.*$', + ] + ) +builder.build { + // Publish all test results to Jenkins. + publishers { + archiveJunit('**/pytest*.xml') + } +} \ No newline at end of file diff --git a/.test-infra/jenkins/job_PreCommit_Python_Transforms.groovy b/.test-infra/jenkins/job_PreCommit_Python_Transforms.groovy new file mode 100644 index 000000000000..dd16d48b1731 --- /dev/null +++ b/.test-infra/jenkins/job_PreCommit_Python_Transforms.groovy @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import PrecommitJobBuilder + +PrecommitJobBuilder builder = new PrecommitJobBuilder( + scope: this, + nameBase: 'Python_Transforms', + gradleTask: ':pythonPreCommit', + gradleSwitches: [ + '-Pposargs=apache_beam/transforms/' + ], + timeoutMins: 180, + triggerPathPatterns: [ + '^model/.*$', + '^sdks/python/.*$', + '^release/.*$', + ] + ) +builder.build { + // Publish all test results to Jenkins. + publishers { + archiveJunit('**/pytest*.xml') + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e146a4741481..01423965aa8d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -420,6 +420,10 @@ tasks.register("pythonPreCommit") { dependsOn(":sdks:python:test-suites:tox:py38:preCommitPy38") dependsOn(":sdks:python:test-suites:tox:py39:preCommitPy39") dependsOn(":sdks:python:test-suites:tox:py310:preCommitPy310") +} + +tasks.register("pythonPreCommitIT") { + dependsOn(":sdks:python:test-suites:tox:pycommon:preCommitPyCommon") dependsOn(":sdks:python:test-suites:dataflow:preCommitIT") dependsOn(":sdks:python:test-suites:dataflow:preCommitIT_V2") } diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 1ae19b0bf29c..a12977958dfb 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -58,12 +58,7 @@ pytest -o junit_suite_name=${envname}_no_xdist \ --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${pyargs} status2=$? -# Exit with error if no tests were run in either suite (status code 5). -if [[ $status1 == 5 && $status2 == 5 ]]; then - exit $status1 -fi - -# Exit with error if one of the statuses has an error that's not 5. +# Exit with error if one of the statuses has an error that's not 5 (no tests run). if [[ $status1 != 0 && $status1 != 5 ]]; then exit $status1 fi diff --git a/sdks/python/test-suites/tox/common.gradle b/sdks/python/test-suites/tox/common.gradle index 61802ac9c45e..5f5a1012f563 100644 --- a/sdks/python/test-suites/tox/common.gradle +++ b/sdks/python/test-suites/tox/common.gradle @@ -18,19 +18,21 @@ def pythonVersionSuffix = project.ext.pythonVersion.replace('.', '') -toxTask "testPython${pythonVersionSuffix}", "py${pythonVersionSuffix}" +def posargs = project.findProperty("posargs") ?: "" + +toxTask "testPython${pythonVersionSuffix}", "py${pythonVersionSuffix}", "${posargs}" test.dependsOn "testPython${pythonVersionSuffix}" -toxTask "testPy${pythonVersionSuffix}Cloud", "py${pythonVersionSuffix}-cloud" +toxTask "testPy${pythonVersionSuffix}Cloud", "py${pythonVersionSuffix}-cloud", "${posargs}" test.dependsOn "testPy${pythonVersionSuffix}Cloud" -toxTask "testPy${pythonVersionSuffix}Dask", "py${pythonVersionSuffix}-dask" +toxTask "testPy${pythonVersionSuffix}Dask", "py${pythonVersionSuffix}-dask", "${posargs}" test.dependsOn "testPy${pythonVersionSuffix}Dask" -toxTask "testPy${pythonVersionSuffix}Cython", "py${pythonVersionSuffix}-cython" +toxTask "testPy${pythonVersionSuffix}Cython", "py${pythonVersionSuffix}-cython", "${posargs}" test.dependsOn "testPy${pythonVersionSuffix}Cython" -toxTask "testPy38CloudCoverage", "py38-cloudcoverage" +toxTask "testPy38CloudCoverage", "py38-cloudcoverage", "${posargs}" test.dependsOn "testPy38CloudCoverage" project.tasks.register("preCommitPy${pythonVersionSuffix}") { diff --git a/sdks/python/test-suites/tox/py37/build.gradle b/sdks/python/test-suites/tox/py37/build.gradle index 2ea0e46ca5be..744ca6750629 100644 --- a/sdks/python/test-suites/tox/py37/build.gradle +++ b/sdks/python/test-suites/tox/py37/build.gradle @@ -26,13 +26,15 @@ applyPythonNature() // Required to setup a Python 3 virtualenv and task names. pythonVersion = '3.7' +def posargs = project.findProperty("posargs") ?: "" + task lint {} check.dependsOn lint -toxTask "lintPy37", "py37-lint" +toxTask "lintPy37", "py37-lint", "${posargs}" lint.dependsOn lintPy37 -toxTask "mypyPy37", "py37-mypy" +toxTask "mypyPy37", "py37-mypy", "${posargs}" lint.dependsOn mypyPy37 apply from: "../common.gradle" diff --git a/sdks/python/test-suites/tox/py38/build.gradle b/sdks/python/test-suites/tox/py38/build.gradle index f51eec00da0e..aa52e3736d48 100644 --- a/sdks/python/test-suites/tox/py38/build.gradle +++ b/sdks/python/test-suites/tox/py38/build.gradle @@ -34,79 +34,86 @@ apply from: "../common.gradle" // TODO(https://github.com/apache/beam/issues/20051): Remove this once tox uses isolated builds. testPy38Cython.mustRunAfter testPython38, testPy38CloudCoverage +// TODO(BEAM-12000): Move tasks that aren't specific to 3.8 to Py 3.9. +def posargs = project.findProperty("posargs") ?: "" +def runDataframesTests = (posargs == "" || posargs.contains("dataframes")) +logger.info('Running dataframes tests: ' + runDataframesTests) + // Create a test task for each major version of pyarrow -// TODO(BEAM-12000): Move these to Py 3.9. -toxTask "testPy38pyarrow-0", "py38-pyarrow-0" +toxTask "testPy38pyarrow-0", "py38-pyarrow-0", "${posargs}" test.dependsOn "testPy38pyarrow-0" preCommitPy38.dependsOn "testPy38pyarrow-0" -toxTask "testPy38pyarrow-1", "py38-pyarrow-1" +toxTask "testPy38pyarrow-1", "py38-pyarrow-1", "${posargs}" test.dependsOn "testPy38pyarrow-1" preCommitPy38.dependsOn "testPy38pyarrow-1" -toxTask "testPy38pyarrow-2", "py38-pyarrow-2" +toxTask "testPy38pyarrow-2", "py38-pyarrow-2", "${posargs}" test.dependsOn "testPy38pyarrow-2" preCommitPy38.dependsOn "testPy38pyarrow-2" -toxTask "testPy38pyarrow-3", "py38-pyarrow-3" +toxTask "testPy38pyarrow-3", "py38-pyarrow-3", "${posargs}" test.dependsOn "testPy38pyarrow-3" preCommitPy38.dependsOn "testPy38pyarrow-3" -toxTask "testPy38pyarrow-4", "py38-pyarrow-4" +toxTask "testPy38pyarrow-4", "py38-pyarrow-4", "${posargs}" test.dependsOn "testPy38pyarrow-4" preCommitPy38.dependsOn "testPy38pyarrow-4" -toxTask "testPy38pyarrow-5", "py38-pyarrow-5" +toxTask "testPy38pyarrow-5", "py38-pyarrow-5", "${posargs}" test.dependsOn "testPy38pyarrow-5" preCommitPy38.dependsOn "testPy38pyarrow-5" -toxTask "testPy38pyarrow-6", "py38-pyarrow-6" +toxTask "testPy38pyarrow-6", "py38-pyarrow-6", "${posargs}" test.dependsOn "testPy38pyarrow-6" preCommitPy38.dependsOn "testPy38pyarrow-6" -toxTask "testPy38pyarrow-7", "py38-pyarrow-7" +toxTask "testPy38pyarrow-7", "py38-pyarrow-7", "${posargs}" test.dependsOn "testPy38pyarrow-7" preCommitPy38.dependsOn "testPy38pyarrow-7" -toxTask "testPy38pyarrow-8", "py38-pyarrow-8" +toxTask "testPy38pyarrow-8", "py38-pyarrow-8", "${posargs}" test.dependsOn "testPy38pyarrow-8" preCommitPy38.dependsOn "testPy38pyarrow-8" -toxTask "testPy38pyarrow-9", "py38-pyarrow-9" +toxTask "testPy38pyarrow-9", "py38-pyarrow-9", "${posargs}" test.dependsOn "testPy38pyarrow-9" preCommitPy38.dependsOn "testPy38pyarrow-9" -// Create a test task for each minor version of pandas -toxTask "testPy38pandas-11", "py38-pandas-11" -test.dependsOn "testPy38pandas-11" -preCommitPy38.dependsOn "testPy38pandas-11" +// Dataframes tests won't get auto-filtered by path since they explicitly only run on the dataframes directory in tox.ini +if (runDataframesTests) { + // Create a test task for each minor version of pandas + toxTask "testPy38pandas-11", "py38-pandas-11", "${posargs}" + test.dependsOn "testPy38pandas-11" + preCommitPy38.dependsOn "testPy38pandas-11" -toxTask "testPy38pandas-12", "py38-pandas-12" -test.dependsOn "testPy38pandas-12" -preCommitPy38.dependsOn "testPy38pandas-12" + toxTask "testPy38pandas-12", "py38-pandas-12", "${posargs}" + test.dependsOn "testPy38pandas-12" + preCommitPy38.dependsOn "testPy38pandas-12" -toxTask "testPy38pandas-13", "py38-pandas-13" -test.dependsOn "testPy38pandas-13" -preCommitPy38.dependsOn "testPy38pandas-13" + toxTask "testPy38pandas-13", "py38-pandas-13", "${posargs}" + test.dependsOn "testPy38pandas-13" + preCommitPy38.dependsOn "testPy38pandas-13" -toxTask "testPy38pandas-14", "py38-pandas-14" -test.dependsOn "testPy38pandas-14" -preCommitPy38.dependsOn "testPy38pandas-14" + toxTask "testPy38pandas-14", "py38-pandas-14", "${posargs}" + test.dependsOn "testPy38pandas-14" + preCommitPy38.dependsOn "testPy38pandas-14" -toxTask "testPy38pandas-15", "py38-pandas-15" -test.dependsOn "testPy38pandas-15" -preCommitPy38.dependsOn "testPy38pandas-15" + toxTask "testPy38pandas-15", "py38-pandas-15", "${posargs}" + test.dependsOn "testPy38pandas-15" + preCommitPy38.dependsOn "testPy38pandas-15" +} // Create a test task for each minor version of pytorch -toxTask "testPy38pytorch-19", "py38-pytorch-19" +toxTask "testPy38pytorch-19", "py38-pytorch-19", "${posargs}" test.dependsOn "testPy38pytorch-19" preCommitPy38.dependsOn "testPy38pytorch-19" -toxTask "testPy38pytorch-110", "py38-pytorch-110" +toxTask "testPy38pytorch-110", "py38-pytorch-110", "${posargs}" test.dependsOn "testPy38pytorch-110" preCommitPy38.dependsOn "testPy38pytorch-110" -toxTask "whitespacelint", "whitespacelint" +toxTask "whitespacelint", "whitespacelint", "${posargs}" task archiveFilesToLint(type: Zip) { archiveFileName = "files-to-whitespacelint.zip" @@ -128,9 +135,9 @@ whitespacelint.dependsOn archiveFilesToLint, unpackFilesToLint unpackFilesToLint.dependsOn archiveFilesToLint archiveFilesToLint.dependsOn cleanPython -toxTask "jest", "jest" +toxTask "jest", "jest", "${posargs}" -toxTask "eslint", "eslint" +toxTask "eslint", "eslint", "${posargs}" task copyTsSource(type: Copy) { from ("$rootProject.projectDir") { diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index 2efa81ab2033..e5aecff48883 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -296,8 +296,9 @@ commands = # Log pyarrow and numpy version for debugging /bin/sh -c "pip freeze | grep -E '(pyarrow|numpy)'" # Run pytest directly rather using run_pytest.sh. It doesn't handle - # selecting tests with -m (BEAM-12985) - pytest -o junit_suite_name={envname} --junitxml=pytest_{envname}.xml -n 6 -m uses_pyarrow {posargs} + # selecting tests with -m (BEAM-12985). + # Allow exit code 5 (no tests run) so that we can run this command safely on arbitrary subdirectories. + /bin/sh -c 'pytest -o junit_suite_name={envname} --junitxml=pytest_{envname}.xml -n 6 -m uses_pyarrow {posargs}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret' [testenv:py{37,38,39,310}-pandas-{11,12,13,14,15}] deps = @@ -323,4 +324,5 @@ commands = # Log torch version for debugging /bin/sh -c "pip freeze | grep -E torch" # Run all PyTorch unit tests - pytest -o junit_suite_name={envname} --junitxml=pytest_{envname}.xml -n 6 -m uses_pytorch {posargs} + # Allow exit code 5 (no tests run) so that we can run this command safely on arbitrary subdirectories. + /bin/sh -c 'pytest -o junit_suite_name={envname} --junitxml=pytest_{envname}.xml -n 6 -m uses_pytorch {posargs}; ret=$?; [ $ret = 5 ] && exit 0 || exit $ret' From ca296ab71c4ec66ed3ec2c31891fa58ec9c48e1a Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 14:35:05 -0500 Subject: [PATCH 03/16] Syntax + easier testing --- sdks/python/scripts/run_pytest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index a12977958dfb..0cb2701bf2d5 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -27,7 +27,7 @@ # $3 - optional arguments to pytest envname=${1?First argument required: suite base name} -posargs=$2 +posargs="--skip=apache_beam/dataframes apache_beam" pytest_args=$3 if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then @@ -36,7 +36,7 @@ if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then fi pyargs="" -posargs_array=$(posargs) +posargs_array=($posargs) echo "posargs:" for i in $posargs_array do From 4205bfbdfa2f376f778cb9b41ee3b21568c5774c Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 14:55:35 -0500 Subject: [PATCH 04/16] Fix syntax --- sdks/python/scripts/run_pytest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 0cb2701bf2d5..70cb4afd6ed4 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -27,7 +27,7 @@ # $3 - optional arguments to pytest envname=${1?First argument required: suite base name} -posargs="--skip=apache_beam/dataframes apache_beam" +posargs="--skip=apache_beam/dataframes apache_beam" # TODO - change back to $2 pytest_args=$3 if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then @@ -44,9 +44,9 @@ do # do whatever on $i echo "$i" if [[ $i == "--skip"* ]]; then - pytest_args += " " + $i + pytest_args="$pytest_args $i" else - pyargs += " " + $i + pyargs="$pyargs $i" fi done From 73e27b34b859d600576460f17386f8b5b05086d6 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 15:02:26 -0500 Subject: [PATCH 05/16] Skip -> ignore --- .test-infra/jenkins/job_PreCommit_Python.groovy | 2 +- sdks/python/scripts/run_pytest.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.test-infra/jenkins/job_PreCommit_Python.groovy b/.test-infra/jenkins/job_PreCommit_Python.groovy index 6c01750bf33d..313a7716f607 100644 --- a/.test-infra/jenkins/job_PreCommit_Python.groovy +++ b/.test-infra/jenkins/job_PreCommit_Python.groovy @@ -29,7 +29,7 @@ PrecommitJobBuilder builder = new PrecommitJobBuilder( '^release/.*$', ], gradleSwitches: [ - '-Pposargs=\"--skip=apache_beam/dataframe/ --skip=apache_beam/examples/ --skip=apache_beam/runners/ --skip=apache_beam/transforms/\"' // All other tests are covered by different jobs. + '-Pposargs=\"--ignore=apache_beam/dataframe/ --ignore=apache_beam/examples/ --ignore=apache_beam/runners/ --ignore=apache_beam/transforms/\"' // All these tests are covered by different jobs. ] ) builder.build { diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 70cb4afd6ed4..8cf14808e00c 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -27,7 +27,7 @@ # $3 - optional arguments to pytest envname=${1?First argument required: suite base name} -posargs="--skip=apache_beam/dataframes apache_beam" # TODO - change back to $2 +posargs="--ignore=apache_beam/dataframes apache_beam" # TODO - change back to $2, and change everything to --ignore instead of --ignore pytest_args=$3 if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then @@ -43,7 +43,7 @@ do : # do whatever on $i echo "$i" - if [[ $i == "--skip"* ]]; then + if [[ $i == "--ignore"* ]]; then pytest_args="$pytest_args $i" else pyargs="$pyargs $i" From fd39e67df3dab5ec72f561290203cce2a8c39fd2 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 15:26:36 -0500 Subject: [PATCH 06/16] Fix loop --- sdks/python/scripts/run_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 8cf14808e00c..76bbf960d7cc 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -27,7 +27,7 @@ # $3 - optional arguments to pytest envname=${1?First argument required: suite base name} -posargs="--ignore=apache_beam/dataframes apache_beam" # TODO - change back to $2, and change everything to --ignore instead of --ignore +posargs="--ignore=apache_beam/dataframes apache_beam" # TODO - change back to $2 pytest_args=$3 if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then From 7a98c69b38f58c757bc57c80f96bb414afa32960 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 15:28:17 -0500 Subject: [PATCH 07/16] Fix loop --- sdks/python/scripts/run_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 76bbf960d7cc..b062e7f0279c 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -38,7 +38,7 @@ fi pyargs="" posargs_array=($posargs) echo "posargs:" -for i in $posargs_array +for i in "${posargs_array[@]}" do : # do whatever on $i From 9b034dfc54c7e9b66ec973bd661c0aa7860f0651 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 15:46:30 -0500 Subject: [PATCH 08/16] Remove local testing mechanism and setup to interact with Jenkins --- sdks/python/scripts/run_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index b062e7f0279c..fc5d8244f510 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -27,7 +27,7 @@ # $3 - optional arguments to pytest envname=${1?First argument required: suite base name} -posargs="--ignore=apache_beam/dataframes apache_beam" # TODO - change back to $2 +posargs=$2 pytest_args=$3 if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then From 467111dfd52942ac651bc9f504a5543ca123cee2 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 16:45:11 -0500 Subject: [PATCH 09/16] Strip off any quotes --- sdks/python/scripts/run_pytest.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index fc5d8244f510..ff6dd858d4b8 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -37,25 +37,27 @@ fi pyargs="" posargs_array=($posargs) -echo "posargs:" for i in "${posargs_array[@]}" do : - # do whatever on $i - echo "$i" - if [[ $i == "--ignore"* ]]; then - pytest_args="$pytest_args $i" + # strip leading/trailing quotes + stripped=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$i) + if [[ $stripped == "--ignore"* ]]; then + pytest_args="$pytest_args $stripped" else - pyargs="$pyargs $i" + pyargs="$pyargs $stripped" fi done +echo "pytest_args: $pytest_args" +echo "pyargs: $pyargs" + # Run with pytest-xdist and without. pytest -o junit_suite_name=${envname} \ - --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${pyargs} + --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 '${pytest_args}' --pyargs '${pyargs}' status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${pyargs} + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' '${pytest_args}' --pyargs '${pyargs}' status2=$? # Exit with error if one of the statuses has an error that's not 5 (no tests run). From 73afffa7d95f92702c8f2a7ff5ba7868e37cbc37 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 16:51:05 -0500 Subject: [PATCH 10/16] Strip off any quotes --- sdks/python/scripts/run_pytest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index ff6dd858d4b8..eb2e662db0ec 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -54,10 +54,10 @@ echo "pyargs: $pyargs" # Run with pytest-xdist and without. pytest -o junit_suite_name=${envname} \ - --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 '${pytest_args}' --pyargs '${pyargs}' + --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 "'${pytest_args}'" --pyargs "'${pyargs}'" status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' '${pytest_args}' --pyargs '${pyargs}' + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' "'${pytest_args}'" --pyargs "'${pyargs}'" status2=$? # Exit with error if one of the statuses has an error that's not 5 (no tests run). From 91a2b276a12e6fd70b3f0678ee641c5ce35b8ec2 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 16:56:18 -0500 Subject: [PATCH 11/16] Strip off any quotes --- sdks/python/scripts/run_pytest.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index eb2e662db0ec..abce707d2dc0 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -36,16 +36,16 @@ if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then fi pyargs="" -posargs_array=($posargs) +# strip leading/trailing quotes +stripped=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$posargs) +posargs_array=($stripped) for i in "${posargs_array[@]}" do : - # strip leading/trailing quotes - stripped=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$i) - if [[ $stripped == "--ignore"* ]]; then - pytest_args="$pytest_args $stripped" + if [[ $i == "--ignore"* ]]; then + pytest_args="$pytest_args $i" else - pyargs="$pyargs $stripped" + pyargs="$pyargs $i" fi done From 713b3bcc88959eaa1ee933a002dfcd95372bead5 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 16:59:55 -0500 Subject: [PATCH 12/16] Strip off any quotes --- sdks/python/scripts/run_pytest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index abce707d2dc0..dffe4cbb3eba 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -54,10 +54,10 @@ echo "pyargs: $pyargs" # Run with pytest-xdist and without. pytest -o junit_suite_name=${envname} \ - --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 "'${pytest_args}'" --pyargs "'${pyargs}'" + --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${pyargs} status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' "'${pytest_args}'" --pyargs "'${pyargs}'" + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' "'${pytest_args}'" --pyargs ${pyargs} status2=$? # Exit with error if one of the statuses has an error that's not 5 (no tests run). From 401b58f9981e94cf960b9df0be55fe47cb9dc75f Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Tue, 3 Jan 2023 17:00:56 -0500 Subject: [PATCH 13/16] Strip off any quotes --- sdks/python/scripts/run_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index dffe4cbb3eba..a8a1c731845f 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -57,7 +57,7 @@ pytest -o junit_suite_name=${envname} \ --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${pyargs} status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' "'${pytest_args}'" --pyargs ${pyargs} + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${pyargs} status2=$? # Exit with error if one of the statuses has an error that's not 5 (no tests run). From a62d422145957ff0e28baa5f1805bce1f3589d7d Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 4 Jan 2023 10:09:08 -0500 Subject: [PATCH 14/16] Simplify arg parsing --- sdks/python/scripts/run_pytest.sh | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index a8a1c731845f..a1072de4515b 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -35,29 +35,17 @@ if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then exit 1 fi -pyargs="" # strip leading/trailing quotes -stripped=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$posargs) -posargs_array=($stripped) -for i in "${posargs_array[@]}" -do - : - if [[ $i == "--ignore"* ]]; then - pytest_args="$pytest_args $i" - else - pyargs="$pyargs $i" - fi -done - +posargs=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$posargs) echo "pytest_args: $pytest_args" -echo "pyargs: $pyargs" +echo "posargs: $posargs" # Run with pytest-xdist and without. pytest -o junit_suite_name=${envname} \ - --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${pyargs} + --junitxml=pytest_${envname}.xml -m 'not no_xdist' -n 6 ${pytest_args} --pyargs ${posargs} status1=$? pytest -o junit_suite_name=${envname}_no_xdist \ - --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${pyargs} + --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${posargs} status2=$? # Exit with error if one of the statuses has an error that's not 5 (no tests run). From daeeb689e5e50464c74ed994c389288bc31667d6 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 4 Jan 2023 11:06:24 -0500 Subject: [PATCH 15/16] Improve comment --- sdks/python/scripts/run_pytest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index a1072de4515b..b8e200261aa3 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -35,7 +35,7 @@ if [[ $pytest_args =~ "-m" ]] || [[ $posargs =~ "-m" ]]; then exit 1 fi -# strip leading/trailing quotes +# strip leading/trailing quotes from posargs because it can get double quoted as its passed through. posargs=$(sed -e 's/^"//' -e 's/"$//' -e "s/'$//" -e "s/^'//" <<<$posargs) echo "pytest_args: $pytest_args" echo "posargs: $posargs" From 4f2385c36ca41c1b0bf571df625759635963e466 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Mon, 9 Jan 2023 15:19:21 -0500 Subject: [PATCH 16/16] Fail on no tests run --- sdks/python/scripts/run_pytest.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index b8e200261aa3..01f2318164c4 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -48,7 +48,12 @@ pytest -o junit_suite_name=${envname}_no_xdist \ --junitxml=pytest_${envname}_no_xdist.xml -m 'no_xdist' ${pytest_args} --pyargs ${posargs} status2=$? -# Exit with error if one of the statuses has an error that's not 5 (no tests run). +# Exit with error if no tests were run in either suite (status code 5). +if [[ $status1 == 5 && $status2 == 5 ]]; then + exit $status1 +fi + +# Exit with error if one of the statuses has an error that's not 5. if [[ $status1 != 0 && $status1 != 5 ]]; then exit $status1 fi