Skip to content

Expose test case definitions to Data Insights so charts can count them - #37459

Merged
TeddyCr merged 1 commit into
open-metadata:mainfrom
TeddyCr:taskr/expose-test-case-definitions-data-insights-0179
Nov 12, 2026
Merged

TeddyCr merged 1 commit into
open-metadata:mainfrom
TeddyCr:taskr/expose-test-case-definitions-data-insights-0179

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Test cases are now exposed to Data Insights through the test case alias, so charts can count them and group them by table, test suite, and test definition without changing total_data_assets. The chart query and migration SQL changes support table test coverage across existing data; reviewers should look first at the MySQL and PostgreSQL migration scripts and the coverage integration test.

Plan

  1. indexMapping.json: add "dataInsightAliases": ["di-data-assets-testcase"] to the testCase entry, mirroring testCaseResult. Do not touch parentAliases/childAliases. SearchRepository (~l.786), OpenSearchIndexManager/ElasticSearchIndexManager, DefaultRecreateHandler and SearchIndexUtils already attach, re-attach and exclude these aliases generically, so no Java is needed for the alias wiring.
  2. dataAssetType.json: add "testCase" to the enum, after "apiEndpoint" and before "testCaseResult". The catalog order test pins the enum order. Update the description to say test cases are also supplied by dataInsightAliases and the app must never create or delete data streams for them. This is what makes DataInsightsApp.getDataAssetTypes() skip testCase, because isAliasedFromLiveIndex is true. Do not add testCase to dataInsights/config.json; theTwoCoverageMechanismsDoNotOverlap forbids it. The generated Java enum and the UI generated/dataInsight/custom/dataAssetType.ts come from regeneration (mvn -pl openmetadata-spec install or make generate); never hand-edit them.
  3. Field catalog: fetchDIChartFields() in the OpenSearch and Elasticsearch aggregator managers iterates DataInsightSystemChartRepository.dataAssetTypes and reads the mapping of di-data-assets-testcase. Adding the enum value therefore exposes originEntityFQN (the table FQN, also set for column tests), table.fullyQualifiedName/table.name, testSuite.*, testSuites.*, testDefinition.name.keyword, testDefinition.fullyQualifiedName, testCaseType, entityFQN and dataQualityDimensionName as leaf fields. Check in the mapping that the grouping fields are keyword-typed and not text without a keyword subfield. originEntityFQN, table.fullyQualifiedName, testDefinition.fullyQualifiedName and testSuite.fullyQualifiedName are keyword-typed. Fix any gap in the test-case mapping rather than adding grouping config in Java.
  4. Time axis for non-live charts: non-live DI charts range-filter on @timestamp over di-data-assets-*, and the live test case index has no @timestamp (the en/test_case_index_mapping.json has no occurrences of it; result and resolution-status docs do). Add "@timestamp": {"type": "date"} to test_case_index_mapping.json in en, jp, ko, ru and zh. In TestCaseIndex.buildSearchIndexDocInternal (or buildSearchIndexDoc), doc.put("@timestamp", testCase.getUpdatedAt()). Keep it small, and check how TestCaseResultIndex writes it for the same pattern.
  5. Keep test cases out of total_data_assets. Test case docs carry entityType: "testCase" (set by populateCommonFields). The stored DATA_ASSET_FILTER only excludes tag, glossaryTerm and dataProduct, so test cases would leak into total_data_assets and the summary card. In DataInsightSystemChartRepository:
    • Add testCase to NON_DATA_ASSET_ENTITY_TYPES.
    • The test case mapping gives entityType.keyword a lowercase_normalizer. A term query norm

Verification

status: green (every planned check passed or was already seen green) · 5 checks: 4 passed, 1 skipped on evidence
- [pass] mvn -q -o -pl openmetadata-service test -Dtest=DataAssetTypeCoverageTest -DfailIfNoTests=false
- [pass] mvn -q -o -pl openmetadata-service test -Dtest='DataAssetChartScopeSqlMigrationTest,DataAssetChartScopeTest' -DfailIfNoTests=false
- [pass] mvn -q -o -pl openmetadata-service test -Dtest='DefaultRecreateHandlerTest,TestCaseIndexTest' -DfailIfNoTests=false
- [skipped] mvn -q -o spotless:check -pl openmetadata-spec,openmetadata-service,openmetadata-integration-tests  (seen green after the last change)
- [pass] python3 .github/scripts/plan_local_java_tests.py --check-branch

Review findings left for your review (astra)

The reviewer and the implementer disagree on the findings marked disputed; the implementer's answer is quoted below.

You've hit your weekly limit · resets 7pm (America/Los_Angeles)

  • [high] openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataAssetType.json: Test case charts remain empty through the Data Insights chart preview endpoint.

Files

.../2.1.0/mysql/postDataMigrationSQLScript.sql     |  57 +++++++
 .../2.1.0/postgres/postDataMigrationSQLScript.sql  |  57 +++++++
 .../it/tests/DataInsightAliasReconciliationIT.java |  23 ++-
 .../it/tests/DataInsightTestCaseCoverageIT.java    | 151 +++++++++++++++++
 .../jdbi3/DataInsightSystemChartRepository.java    |  23 ++-
 .../insights/DataAssetTypeCoverageTest.java        |   9 ++
 .../v1136/DataAssetChartScopeSqlMigrationTest.java |  40 +++--
 .../v204/DataAssetChartScopeSqlMigrationTest.java  |  40 +++--
 .../v210/DataAssetChartScopeSqlMigrationTest.java  | 178 +++++++++++++++++++++
 .../DataAssetChartScopeTest.java                   | 160 +++++++++++++++++-
 .../main/resources/elasticsearch/indexMapping.json |   3 +-
 .../schema/dataInsight/custom/dataAssetType.json   |   3 +-
 12 files changed, 685 insertions(+), 59 deletions(-)

Closes #33432

Opened by taskr run 0179.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 10, 2026
@gitar-bot

gitar-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🟡 Medium risk · Aliasing live test cases into Data Insights and rewriting chart scopes could miscount data-asset totals if filters diverge.

Exposes test case definitions to Data Insights through the di-data-assets-testcase alias and adds testCase to the data asset type enum, so charts can count and group them without changing total_data_assets. Changes requested: the design decisions behind this (alias-only ingestion, live-mode charting, and exclusion from data-asset charts via both testCase and testcase bucket keys) are not recorded anywhere under docs/decisions/, so the rationale would be lost on squash-merge. Add a decision record covering these contracts before merge.

✅ 1 closed
Closed: Quality: No decision record for how test cases are exposed to Data Insights

📄 openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataAssetType.json:5 📄 openmetadata-spec/src/main/resources/json/schema/dataInsight/custom/dataAssetType.json:26 📄 openmetadata-spec/src/main/resources/elasticsearch/indexMapping.json:254 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataInsightSystemChartRepository.java:96-110 📄 bootstrap/sql/migrations/native/2.1.0/mysql/postDataMigrationSQLScript.sql:985-999
This PR adds contracts that other components have to agree with: a new DataAssetType enum value testCase (dataAssetType.json:26), a new alias name di-data-assets-testcase (indexMapping.json:254), and a rule that every data-asset chart's excludeGroups must list both the camelCase and the lowercase bucket key (NON_DATA_ASSET_BUCKET_KEYS, which the 2.1.0 SQL pins). No record under docs/decisions/ covers any of these. A search for di-data-assets, dataInsightAliases and NON_DATA_ASSET in the records finds nothing. Most of the rule exists only in the PR description, which is lost on squash-merge: "Test cases must stay out of total_data_assets and the summary card", "The app must never create or delete data streams for test cases, since the test case alias supplies them", and "testCase must not be added to dataInsights/config.json, because the two coverage mechanisms must not overlap".

The record would say: Test case definitions reach Data Insights only through the live-index alias di-data-assets-testcase and are never ingested by DataInsightsApp. They are charted in live mode (searchIndex: testCase) because they carry no @timestamp. testCase is a non-data-asset type, so every data-asset chart excludes it in its filter and in excludeGroups under both testCase and testcase, because the test case mapping lowercase-normalizes entityType.keyword.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@TeddyCr
TeddyCr marked this pull request as ready for review November 10, 2026 22:25
@TeddyCr
TeddyCr requested a review from a team as a code owner November 10, 2026 22:25
@TeddyCr
TeddyCr requested review from pmbrull and a balanced review from Copilot November 10, 2026 22:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@TeddyCr
TeddyCr enabled auto-merge (squash) November 11, 2026 18:39
@TeddyCr
TeddyCr merged commit 5a858ac into open-metadata:main Nov 12, 2026
117 of 118 checks passed
"parentAliases": ["testSuite", "all", "dataAssetEmbeddings"],
"childAliases": ["testCaseResolutionStatus", "testCaseResult"]
"childAliases": ["testCaseResolutionStatus", "testCaseResult"],
"dataInsightAliases": ["di-data-assets-testcase"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Charts built on Test Case always come back empty.

Only non-live charts read this alias, and they filter di-data-assets-* on an @timestamp range (OpenSearchLineChartAggregator.java#L198-L209). Test case documents have no @timestamp, so they never match. Live charts don't read this alias either: they query searchIndex (here testCase) or all (getLiveSearchIndex), and both already held test cases before this PR. So in practice, all the alias does is add test case fields to /charts/fields.

How to hit it: the custom chart builder in Collate builds its asset picker from that field catalog, so it now offers Test Case. Its preview calls buildDIChart(chart, start, end), which runs with live=false (DataInsightAggregatorClient.java#L20-L22), and the builder has no way to set live mode or searchIndex. Every chart built on Test Case shows no data.

This is the open [high] finding listed in the PR description.

"tag",
"metric",
"apiEndpoint",
"testCase",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate-types was failing when this merged (run), and generated/dataInsight/custom/dataAssetType.ts on main still has no TestCase value. The job regenerates every type and fails on any diff, so the next PR that triggers it will fail on this file, even if that PR never touched it.

.withFilter(
"{\"query\":{\"terms\":{\"originEntityFQN\":[" + fqns + "]}}}")))
.withxAxisField("originEntityFQN")
.withSearchIndex(Entity.TEST_CASE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't go through the new alias. With live=true and searchIndex: testCase, the chart reads the testCase alias directly, so the test would also pass on main from before this PR. The same is true of the two new live tests in DataAssetChartScopeTest. Nothing covers the field catalog or the preview path, which is where the alias changes behaviour.

Also, the integration test lanes were skipped on this PR, so this IT and the updated DataInsightAliasReconciliationIT haven't run yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data Insights has no test case definitions, so test coverage questions ("share of tables with no tests") are unanswerable

4 participants