chore: stabilize MySQL tests by aligning isolation levels (#28028)
This commit is contained in:
parent
c225e17a75
commit
de9daf7ad9
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import unittest
|
|||
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 @@ class TestPostChartDataApi(BaseTestChartDataApi):
|
|||
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(
|
||||
|
|
|
|||
|
|
@ -151,8 +151,12 @@ class TestQueryContext(SupersetTestCase):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue