diff --git a/.github/workflows/bashlib.sh b/.github/workflows/bashlib.sh index e34101ad7894a..3e407eb91d363 100644 --- a/.github/workflows/bashlib.sh +++ b/.github/workflows/bashlib.sh @@ -89,6 +89,8 @@ EOF setup-mysql() { say "::group::Initialize database" mysql -h 127.0.0.1 -P 13306 -u root --password=root <<-EOF + SET GLOBAL transaction_isolation='READ-COMMITTED'; + SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; DROP DATABASE IF EXISTS superset; CREATE DATABASE superset DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; DROP DATABASE IF EXISTS sqllab_test_db; diff --git a/.github/workflows/superset-python-integrationtest.yml b/.github/workflows/superset-python-integrationtest.yml index 2c1e721df479d..8005e055958b6 100644 --- a/.github/workflows/superset-python-integrationtest.yml +++ b/.github/workflows/superset-python-integrationtest.yml @@ -29,6 +29,11 @@ jobs: MYSQL_ROOT_PASSWORD: root ports: - 13306:3306 + options: >- + --health-cmd="mysqladmin ping --silent" + --health-interval=10s + --health-timeout=5s + --health-retries=5 redis: image: redis:7-alpine options: --entrypoint redis-server diff --git a/tests/integration_tests/charts/data/api_tests.py b/tests/integration_tests/charts/data/api_tests.py index 4eabd16eaa803..061cdece502f5 100644 --- a/tests/integration_tests/charts/data/api_tests.py +++ b/tests/integration_tests/charts/data/api_tests.py @@ -21,6 +21,7 @@ import copy from datetime import datetime from io import BytesIO +import time from typing import Any, Optional from unittest import mock from zipfile import ZipFile @@ -723,8 +724,12 @@ def test_chart_data_async(self): app._got_first_request = False async_query_manager_factory.init_app(app) self.login(ADMIN_USERNAME) + # Introducing time.sleep to make test less flaky with MySQL + time.sleep(1) rv = self.post_assert_metric(CHART_DATA_URI, self.query_context_payload, "data") + time.sleep(1) self.assertEqual(rv.status_code, 202) + time.sleep(1) data = json.loads(rv.data.decode("utf-8")) keys = list(data.keys()) self.assertCountEqual( diff --git a/tests/integration_tests/query_context_tests.py b/tests/integration_tests/query_context_tests.py index d36b6c85c14c2..6ad3c30cd01f5 100644 --- a/tests/integration_tests/query_context_tests.py +++ b/tests/integration_tests/query_context_tests.py @@ -151,8 +151,12 @@ def test_query_cache_key_changes_when_datasource_is_updated(self): description_original = datasource.description datasource.description = "temporary description" db.session.commit() + # wait a second since mysql records timestamps in second granularity + time.sleep(1) datasource.description = description_original db.session.commit() + # wait another second because why not + time.sleep(1) # create new QueryContext with unchanged attributes, extract new query_cache_key query_context = ChartDataQueryContextSchema().load(payload)