Skip to content

Commit 1b13cf5

Browse files
authored
Another attempt to stabilize (and limit) integration tests (#39913)
There is no particular reason we should run the integration tests for both Postgres and mysql - and Postgres ones seem to be much more stable in general, so we only limit the tests to be run the tests for Postgres. Also - since the tests (especially mssql) seem to be flaky, we re-run them once if they fail
1 parent aba8def commit 1b13cf5

File tree

4 files changed

+64
-16
lines changed

4 files changed

+64
-16
lines changed

.github/workflows/integration-tests.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,18 @@ on: # yamllint disable-line rule:truthy
5959
jobs:
6060
tests-integration:
6161
timeout-minutes: 130
62-
name: Integration Tests ${{ matrix.backend }}-${{ matrix.integration }}
62+
name: "Integration Tests: ${{ matrix.integration }}"
6363
runs-on: ${{ fromJSON(inputs.runs-on-as-json-public) }}
6464
strategy:
6565
fail-fast: false
6666
matrix:
67-
backend: ["postgres", "mysql"]
6867
integration: ${{ fromJSON(inputs.testable-integrations) }}
6968
env:
7069
IMAGE_TAG: "${{ inputs.image-tag }}"
71-
BACKEND: "${{ matrix.backend }}"
72-
# yamllint disable-line rule:line-length
73-
BACKEND_VERSION: ${{ matrix.backend == 'postgres' && inputs.default-postgres-version || inputs.default-mysql-version }}"
70+
BACKEND: "postgres"
71+
BACKEND_VERSION: ${{ inputs.default-postgres-version }}"
7472
PYTHON_MAJOR_MINOR_VERSION: "${{ inputs.default-python-version }}"
75-
JOB_ID: "integration-${{ matrix.backend }}-${{ matrix.integration }}"
73+
JOB_ID: "integration-${{ matrix.integration }}"
7674
SKIP_PROVIDER_TESTS: "${{ inputs.skip-provider-tests }}"
7775
ENABLE_COVERAGE: "${{ inputs.run-coverage}}"
7876
DEBUG_RESOURCES: "${{ inputs.debug-resources }}"
@@ -92,13 +90,10 @@ jobs:
9290
run: ./scripts/ci/cleanup_docker.sh
9391
- name: "Prepare breeze & CI image: ${{ inputs.default-python-version }}:${{ inputs.image-tag }}"
9492
uses: ./.github/actions/prepare_breeze_and_image
95-
- name: "Integration Tests ${{ matrix.backend }}:${{ matrix.integration }}"
96-
run: |
97-
breeze down
98-
breeze testing integration-tests --integration ${{ matrix.integration }}
99-
breeze down
100-
- name: "Post Tests success: Integration Tests ${{ matrix.backend }}-${{ matrix.integration }}"
93+
- name: "Integration Tests: ${{ matrix.integration }}"
94+
run: ./scripts/ci/testing/run_integration_tests_with_retry.sh ${{ matrix.integration }}
95+
- name: "Post Tests success: Integration Tests ${{ matrix.integration }}"
10196
uses: ./.github/actions/post_tests_success
102-
- name: "Post Tests failure: Integration Tests ${{ matrix.backend }}-${{ matrix.integration }}"
97+
- name: "Post Tests failure: Integration Tests ${{ matrix.integration }}"
10398
uses: ./.github/actions/post_tests_failure
10499
if: failure()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
export COLOR_RED=$'\e[31m'
20+
export COLOR_YELLOW=$'\e[33m'
21+
export COLOR_RESET=$'\e[0m'
22+
23+
if [[ ! "$#" -eq 1 ]]; then
24+
echo "${COLOR_RED}You must provide exactly one argument!.${COLOR_RESET}"
25+
exit 1
26+
fi
27+
28+
INTEGRATION=${1}
29+
30+
breeze down
31+
set +e
32+
breeze testing integration-tests --integration "${INTEGRATION}"
33+
RESULT=$?
34+
set -e
35+
if [[ ${RESULT} != "0" ]]; then
36+
echo
37+
echo "${COLOR_YELLOW}Integration Tests failed. Retrying once${COLOR_RESET}"
38+
echo
39+
echo "This could be due to a flaky test, re-running once to re-check it After restarting docker."
40+
echo
41+
sudo service docker restart
42+
breeze down
43+
set +e
44+
breeze testing integration-tests --integration "${INTEGRATION}"
45+
RESULT=$?
46+
set -e
47+
if [[ ${RESULT} != "0" ]]; then
48+
echo
49+
echo "${COLOR_RED}The integration tests failed for the second time! Giving up${COLOR_RESET}"
50+
echo
51+
exit ${RESULT}
52+
fi
53+
fi

tests/integration/cli/commands/test_celery_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
@pytest.mark.integration("celery")
32-
@pytest.mark.backend("mysql", "postgres")
32+
@pytest.mark.backend("postgres")
3333
class TestWorkerServeLogs:
3434
@classmethod
3535
def setup_class(cls):

tests/integration/executors/test_celery_executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _prepare_app(broker_url=None, execute=None):
9797

9898

9999
@pytest.mark.integration("celery")
100-
@pytest.mark.backend("mysql", "postgres")
100+
@pytest.mark.backend("postgres")
101101
class TestCeleryExecutor:
102102
def setup_method(self) -> None:
103103
db.clear_db_runs()
@@ -276,7 +276,7 @@ def __ne__(self, other):
276276

277277

278278
@pytest.mark.integration("celery")
279-
@pytest.mark.backend("mysql", "postgres")
279+
@pytest.mark.backend("postgres")
280280
class TestBulkStateFetcher:
281281
bulk_state_fetcher_logger = "airflow.providers.celery.executors.celery_executor_utils.BulkStateFetcher"
282282

0 commit comments

Comments
 (0)