Skip to content

Commit

Permalink
FIXES open-metadata#14049 - Split test case resolution status from te…
Browse files Browse the repository at this point in the history
…st case result (open-metadata#14204)

* refactor: entityFQN as ListFilter condition

* feat: implement resolution entity timeseries

* fix: rename to testCaseResolutionStatus

* ref: extracted ES query builder into private method

* ref: extract OS query builder in its own method

* ref: remove ingestion logic for test case resolution

* fix: reorganize json schemas to fix circular import in Python

* ref: object names in typescript code

* feat: added indexing of test case resolution

* feat: added test case resolution sample data

* fix: test case resolution api logic

* fix: audit logger for entityTimeSeriesInterface

* fix: DDL generation

* style: python linting

* fix: skip UI test case resolution tests

* fix: remove extension field

* fix: renamed testCaseFailureStatus to testCaseResolutionStatus

* fix: remove reviewer

* fix: rename sequenceId to stateId

* fix: re adjust search weights

* fix: removed InReview status

* style: ran python linting
  • Loading branch information
TeddyCr authored and Shiyang Xiao committed Dec 12, 2023
1 parent 1c3b06f commit c1faabe
Show file tree
Hide file tree
Showing 42 changed files with 2,545 additions and 439 deletions.
17 changes: 17 additions & 0 deletions bootstrap/sql/migrations/native/1.3.0/mysql/schemaChanges.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
-- Data quality failure status extension time series
CREATE TABLE test_case_resolution_status_time_series (
id varchar(36) GENERATED ALWAYS AS (json_unquote(json_extract(json,'$.id'))) VIRTUAL NOT NULL,
stateId varchar(36) GENERATED ALWAYS AS (json_unquote(json_extract(json,'$.stateId'))) VIRTUAL NOT NULL,
assignee varchar(256) GENERATED ALWAYS AS (json_unquote(json_extract(json,'$.testCaseResolutionStatusDetails.assignee.name'))) VIRTUAL NULL,
timestamp bigint unsigned GENERATED ALWAYS AS (json_unquote(json_extract(json,'$.timestamp'))) VIRTUAL NOT NULL,
testCaseResolutionStatusType varchar(36) GENERATED ALWAYS AS (json_unquote(json_extract(json,'$.testCaseResolutionStatusType'))) VIRTUAL NOT NULL,
jsonSchema varchar(256) NOT NULL,
json json NOT NULL,
entityFQNHash varchar(768) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
CONSTRAINT test_case_resolution_status_unique_constraint UNIQUE (id,timestamp,entityFQNHash),
INDEX (id),
INDEX(testCaseResolutionStatusType),
INDEX(id, testCaseResolutionStatusType)

) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- DataInsightsApplication should not allow configuration
update apps_marketplace
set json = JSON_INSERT(
Expand Down
24 changes: 24 additions & 0 deletions bootstrap/sql/migrations/native/1.3.0/postgres/schemaChanges.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
-- Data quality failure status extension time series
CREATE TABLE test_case_resolution_status_time_series (
id varchar(36) GENERATED ALWAYS AS (json ->> 'id') STORED NOT NULL,
stateId varchar(36) GENERATED ALWAYS AS (json ->> 'stateId') STORED NOT NULL,
assignee varchar(256) GENERATED ALWAYS AS (
CASE
WHEN json->'testCaseResolutionStatusDetails' IS NOT NULL AND
json->'testCaseResolutionStatusDetails'->'assignee' IS NOT NULL AND
json->'testCaseResolutionStatusDetails'->'assignee'->>'name' IS NOT NULL
THEN json->'testCaseResolutionStatusDetails'->'assignee'->>'name'
ELSE NULL
END
) STORED NULL,
timestamp bigint GENERATED ALWAYS AS ((json ->> 'timestamp')::bigint) STORED NOT NULL,
testCaseResolutionStatusType varchar(36) GENERATED ALWAYS AS (json ->> 'testCaseResolutionStatusType') STORED NOT NULL,
jsonSchema varchar(256) NOT NULL,
json jsonb NOT NULL,
entityFQNHash varchar(768) COLLATE "C" DEFAULT NULL,
CONSTRAINT test_case_resolution_status_unique_constraint UNIQUE (id, timestamp, entityFQNHash)
);
create index test_case_resolution_status_time_series_id on test_case_resolution_status_time_series (id);
create index test_case_resolution_status_time_series_status_type on test_case_resolution_status_time_series (testCaseResolutionStatusType);
create index test_case_resolution_status_time_series_id_status_type on test_case_resolution_status_time_series (id, testCaseResolutionStatusType);

-- DataInsightsApplication should not allow configuration
UPDATE apps_marketplace
SET json = jsonb_set(
Expand Down
272 changes: 267 additions & 5 deletions ingestion/examples/sample_data/tests/testSuites.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,80 @@
"name": "columnCount",
"value": 10
}
]
],
"resolutions": {
"sequenceOne": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "aaron_johnson0"
}
],
"sequenceTwo": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "christopher_campbell7"
}
],
"sequenceThree": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity3",
"resolver": "aaron_johnson0"
}
],
"sequenceFour": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity5"
}
]
}
},
{
"name": "table_column_count_between",
Expand All @@ -32,7 +105,69 @@
"name": "maxColValue",
"value": 10
}
]
],
"resolutions": {
"sequenceOne": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "christine_day7"
}
],
"sequenceTwo": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "christopher_campbell7"
}
],
"sequenceThree": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "aaron_johnson0"
}
]
}
},
{
"name": "column_value_max_to_be_between",
Expand All @@ -48,7 +183,29 @@
"name": "maxValueForMaxInCol",
"value": 100
}
]
],
"resolutions": {
"sequenceOne": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "aaron_johnson0"
}
]
}
},
{
"name": "column_values_to_match_regex",
Expand All @@ -60,7 +217,35 @@
"name": "regex",
"value": "Doe.*"
}
]
],
"resolutions": {
"sequenceOne": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity5"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity5"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity5",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity5",
"resolver": "aaron_johnson0"
}
],
"sequenceFour": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity5"
}
]
}
},
{
"name": "column_values_to_be_between",
Expand All @@ -76,7 +261,84 @@
"name": "max",
"value": 96162
}
]
],
"resolutions": {
"sequenceOne": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "aaron_johnson0"
}
],
"sequenceTwo": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity1"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity1",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity1",
"resolver": "christopher_campbell7"
}
],
"sequenceThree": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity3"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "christopher_campbell7"
},
{
"testCaseResolutionStatusType": "Assigned",
"severity": "Severity3",
"assignee": "aaron_johnson0"
},
{
"testCaseResolutionStatusType": "Resolved",
"severity": "Severity3",
"resolver": "aaron_johnson0"
}
],
"sequenceFour": [
{
"testCaseResolutionStatusType": "New",
"severity": "Severity5"
},
{
"testCaseResolutionStatusType": "Ack",
"severity": "Severity5"
}
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
from typing import Callable, List, Optional, TypeVar, Union

from metadata.generated.schema.tests.basic import (
TestCaseFailureStatus,
TestCaseFailureStatusType,
TestCaseResult,
TestCaseStatus,
TestResultValue,
)
from metadata.generated.schema.tests.testCase import TestCase, TestCaseParameterValue
from metadata.generated.schema.type.basic import Timestamp
from metadata.profiler.processor.runner import QueryRunner

T = TypeVar("T", bound=Callable)
Expand Down Expand Up @@ -105,24 +102,12 @@ def get_test_case_result_object(
Returns:
TestCaseResult:
"""
if status == TestCaseStatus.Failed:
test_case_failure_status = TestCaseFailureStatus(
testCaseFailureStatusType=TestCaseFailureStatusType.New,
testCaseFailureReason=None,
testCaseFailureComment=None,
updatedAt=Timestamp(__root__=int(datetime.utcnow().timestamp() * 1000)),
updatedBy=None,
)
else:
test_case_failure_status = None

return TestCaseResult(
timestamp=execution_date, # type: ignore
testCaseStatus=status,
result=result,
testResultValue=test_result_value,
sampleData=None,
testCaseFailureStatus=test_case_failure_status,
)

def format_column_list(self, status: TestCaseStatus, cols: List):
Expand Down
Loading

0 comments on commit c1faabe

Please sign in to comment.