mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore: stabilize MySQL tests by aligning isolation levels (#28028)
This commit is contained in:
committed by
GitHub
parent
c225e17a75
commit
de9daf7ad9
2
.github/workflows/bashlib.sh
vendored
2
.github/workflows/bashlib.sh
vendored
@@ -89,6 +89,8 @@ EOF
|
|||||||
setup-mysql() {
|
setup-mysql() {
|
||||||
say "::group::Initialize database"
|
say "::group::Initialize database"
|
||||||
mysql -h 127.0.0.1 -P 13306 -u root --password=root <<-EOF
|
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;
|
DROP DATABASE IF EXISTS superset;
|
||||||
CREATE DATABASE superset DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
|
CREATE DATABASE superset DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
|
||||||
DROP DATABASE IF EXISTS sqllab_test_db;
|
DROP DATABASE IF EXISTS sqllab_test_db;
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: root
|
MYSQL_ROOT_PASSWORD: root
|
||||||
ports:
|
ports:
|
||||||
- 13306:3306
|
- 13306:3306
|
||||||
|
options: >-
|
||||||
|
--health-cmd="mysqladmin ping --silent"
|
||||||
|
--health-interval=10s
|
||||||
|
--health-timeout=5s
|
||||||
|
--health-retries=5
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
options: --entrypoint redis-server
|
options: --entrypoint redis-server
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import unittest
|
|||||||
import copy
|
import copy
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
import time
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
@@ -723,8 +724,12 @@ class TestPostChartDataApi(BaseTestChartDataApi):
|
|||||||
app._got_first_request = False
|
app._got_first_request = False
|
||||||
async_query_manager_factory.init_app(app)
|
async_query_manager_factory.init_app(app)
|
||||||
self.login(ADMIN_USERNAME)
|
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")
|
rv = self.post_assert_metric(CHART_DATA_URI, self.query_context_payload, "data")
|
||||||
|
time.sleep(1)
|
||||||
self.assertEqual(rv.status_code, 202)
|
self.assertEqual(rv.status_code, 202)
|
||||||
|
time.sleep(1)
|
||||||
data = json.loads(rv.data.decode("utf-8"))
|
data = json.loads(rv.data.decode("utf-8"))
|
||||||
keys = list(data.keys())
|
keys = list(data.keys())
|
||||||
self.assertCountEqual(
|
self.assertCountEqual(
|
||||||
|
|||||||
@@ -151,8 +151,12 @@ class TestQueryContext(SupersetTestCase):
|
|||||||
description_original = datasource.description
|
description_original = datasource.description
|
||||||
datasource.description = "temporary description"
|
datasource.description = "temporary description"
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
# wait a second since mysql records timestamps in second granularity
|
||||||
|
time.sleep(1)
|
||||||
datasource.description = description_original
|
datasource.description = description_original
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
# wait another second because why not
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# create new QueryContext with unchanged attributes, extract new query_cache_key
|
# create new QueryContext with unchanged attributes, extract new query_cache_key
|
||||||
query_context = ChartDataQueryContextSchema().load(payload)
|
query_context = ChartDataQueryContextSchema().load(payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user