feat: add hook for dataset health check (#11970)

* feat: add hook for dataset health check

* add event log

* optimize datasource json data like certified data

* add unit test

* fix review comments

* extra code review comments
This commit is contained in:
Grace Guo
2020-12-15 18:12:06 -08:00
committed by GitHub
parent 76f9f185fb
commit 8da1900d8a
8 changed files with 86 additions and 3 deletions

View File

@@ -18,7 +18,7 @@
import json
from copy import deepcopy
from superset import db
from superset import app, db
from superset.connectors.sqla.models import SqlaTable
from superset.utils.core import get_example_database
@@ -190,6 +190,22 @@ class TestDatasource(SupersetTestCase):
},
)
def test_get_datasource_with_health_check(self):
def my_check(datasource):
return "Warning message!"
app.config["DATASET_HEALTH_CHECK"] = my_check
my_check.version = 0.1
self.login(username="admin")
tbl = self.get_table_by_name("birth_names")
url = f"/datasource/get/{tbl.type}/{tbl.id}/"
tbl.health_check(commit=True, force=True)
resp = self.get_json_resp(url)
self.assertEqual(resp["health_check_message"], "Warning message!")
del app.config["DATASET_HEALTH_CHECK"]
def test_get_datasource_failed(self):
self.login(username="admin")
url = f"/datasource/get/druid/500000/"