Skip to content

Fix/testsuite cross suite result consistency - #25587

Merged
pmbrull merged 4 commits into
mainfrom
fix/testsuite-cross-suite-result-consistency
Feb 5, 2026
Merged

pmbrull merged 4 commits into
mainfrom
fix/testsuite-cross-suite-result-consistency

Conversation

@manerow

@manerow manerow commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/open-metadata/openmetadata-collate/issues/2769

When a test suite pipeline completes execution, other test suites that share overlapping test cases now have their result summaries and ordering kept consistent. Previously, if Test Suite A shared test cases with Test Suite B, completing A’s pipeline would leave B with stale result data and incorrect ordering in the test suite list.

What changed & why

  • ES index schema — Replaced the nested testCaseResultSummary with a scalar lastResultTimestamp in all locale index mappings (en, jp, ru, zh).
    Previously, Elasticsearch stored one nested document per test case solely to support sorting by latest result. Nested sorting (sortNestedPath + sortNestedMode=max) is significantly more expensive than scalar sorting and, more importantly, caused stale data when overlapping test cases were updated by another suite. Since ES only needed this value for ordering, the nested structure was replaced with a single scalar timestamp, improving performance and eliminating a major source of inconsistency.

  • On-demand computation — summary and testCaseResultSummary are no longer stored in ES and are instead computed from the database (the source of truth) when requested via listFromSearchWithOffset and batch field fetchers. Previously, these derived fields were written into ES at index time. Because test cases can belong to multiple suites, running one suite could invalidate another suite's cached summary in ES, leading to structurally inconsistent views. Computing these values on demand guarantees correctness, as the batch field fetchers efficiently compute summaries for all returned suites in a single query.

  • Cross-suite consistency — On pipeline completion, all related suites sharing test cases are discovered via a single findFromBatch call. Their latest timestamps are resolved with a single MAX() aggregate query, and ES documents are updated using a conditional Painless script (write only if newer) to avoid race conditions from concurrent pipeline runs.

  • Scalable batch queries — Introduced new ROW_NUMBER()-based queries (MySQL and PostgreSQL variants) that project only testCaseFQN, testCaseStatus, and timestamp directly from JSON fields. This replaces a previous O(N²) anti-join with full JSON deserialization query. A dedicated SuiteMaxTimestamp aggregate query now returns one row per suite with no JSON parsing.

  • Frontend — The test suite list now sorts by the scalar lastResultTimestamp, removing the need for sortNestedPath and sortNestedMode parameters.

Type of change:

  • Bug fix
  • Improvement

Checklist:

Note on migrations:
The Elasticsearch index mapping changes (replacing the nested testCaseResultSummary with the scalar lastResultTimestamp) take effect on reindex. No SQL migration is required — the database schema remains unchanged; only the ES projection was modified.

@manerow manerow self-assigned this Jan 28, 2026
@manerow
manerow requested review from a team as code owners January 28, 2026 11:12
@manerow manerow added safe to test Add this label to run secure Github workflows on PRs backend area:alerts-notifications Change events, event subscriptions, alerts, notification templates and channels, email. labels Jan 28, 2026
@manerow
manerow force-pushed the fix/testsuite-cross-suite-result-consistency branch from be61870 to da7d870 Compare January 28, 2026 11:15
@manerow
manerow changed the base branch from main to fix/testsuite-result-summary January 28, 2026 11:15
@github-actions

github-actions Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 65%
65.9% (55872/84786) 44.98% (28849/64143) 47.93% (8811/18384)

@gitar-bot

gitar-bot Bot commented Feb 3, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 2 resolved / 3 findings

Cannot perform detailed review - diff files are empty. Previous performance finding about sequential ES updates remains unresolved as PR description doesn't indicate bulk API adoption.

💡 Performance: Sequential ES updates for related suites could be slow

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java

The updateRelatedSuitesLastResultTimestamp method loops through each related suite and performs a sequential Elasticsearch update. If a test suite has many overlapping suites (e.g., 50+ related suites), this could cause latency in pipeline completion.

Consider using Elasticsearch bulk API for these updates to reduce network round trips:

List<Map<String, Object>> bulkUpdates = timestamps.stream()
    .map(entry -> Map.of(
        "id", entry.testSuiteId(),
        "doc", Map.of("lastResultTimestamp", entry.maxTimestamp()),
        "script", scriptContent
    ))
    .toList();
searchClient.bulkUpdate(indexName, bulkUpdates);

This is a minor optimization for edge cases with many overlapping suites.

✅ 2 resolved
✅ Edge Case: No lastResultTimestamp set when resultSummaries is empty

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/indexes/TestSuiteIndex.java
When resultSummaries is null or empty, lastResultTimestamp is not set in the Elasticsearch document. This could cause sorting inconsistencies where test suites without results would have a missing field rather than a consistent default value (like 0).

Consider adding an else clause to set a default value:

if (resultSummaries != null && !resultSummaries.isEmpty()) {
  long maxTimestamp =
      resultSummaries.stream().mapToLong(ResultSummary::getTimestamp).max().orElse(0L);
  doc.put("lastResultTimestamp", maxTimestamp);
} else {
  doc.put("lastResultTimestamp", 0L);
}

This ensures consistent sorting behavior for all test suites.

✅ Edge Case: Painless script may fail if lastResultTimestamp field doesn't exist

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java
The Painless script compares params.lastResultTimestamp > ctx._source.lastResultTimestamp, but if the target document doesn't have lastResultTimestamp (e.g., an older document not yet reindexed), this will throw a runtime exception in Elasticsearch.

Consider adding a null check in the Painless script:

"if (ctx._source.lastResultTimestamp == null || params.lastResultTimestamp > ctx._source.lastResultTimestamp) {"
    + " ctx._source.lastResultTimestamp = params.lastResultTimestamp; }"

The catch block already handles failures gracefully with a warning log, so this is a minor robustness improvement.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@pmbrull
pmbrull merged commit dae6d96 into main Feb 5, 2026
34 of 44 checks passed
@pmbrull
pmbrull deleted the fix/testsuite-cross-suite-result-consistency branch February 5, 2026 09:26
@manerow manerow added the To release Will cherry-pick this PR into the release branch label Feb 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Feb 5, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Feb 5, 2026

Copy link
Copy Markdown

manerow added a commit that referenced this pull request Feb 6, 2026
* refactor: replace testCaseResultSummary with lastResultTimestamp in ES index

* feat: add lean batch SQL queries for test suite result summaries

* fix: recompute related test suite results on pipeline completion

* test: update UI sort field and tests for lastResultTimestamp
manerow added a commit that referenced this pull request Feb 6, 2026
* refactor: replace testCaseResultSummary with lastResultTimestamp in ES index

* feat: add lean batch SQL queries for test suite result summaries

* fix: recompute related test suite results on pipeline completion

* test: update UI sort field and tests for lastResultTimestamp
mohityadav766 pushed a commit that referenced this pull request Feb 9, 2026
* refactor: replace testCaseResultSummary with lastResultTimestamp in ES index

* feat: add lean batch SQL queries for test suite result summaries

* fix: recompute related test suite results on pipeline completion

* test: update UI sort field and tests for lastResultTimestamp
mohityadav766 added a commit that referenced this pull request Feb 9, 2026
* use promote entity reindex in distributed

* Add Logs and finalize remaining entities

* fix nullpointer

* Fix Canonical Index Deletion

* Fix Test

* Optimize Reindexing

* Fix Default Recreate Handler

* Fix entity version history of dataProducts after removing inputPorts/ field (#25702)

* Fix: Use Downward API for pipelineRunId in standard K8s CronJobs (#25640)

When using the K8s pipeline client with useOMJobOperator=false, scheduled
pipelines (CronJobs) were failing because pipelineRunId was set to the
literal string "{{ omjob.uid }}" instead of a valid UUID.

This template syntax is designed for the OMJob operator to resolve at
runtime, but standard K8s CronJobs have no templating engine.

The fix uses the Kubernetes Downward API to inject the pod's own UID
(metadata.uid) as the pipelineRunId. Pod UIDs are valid UUIDv4 values
and unique per execution, making them suitable replacements.

Co-authored-by: Claude Opus 4.5 <[email protected]>

* Rename deny list recognizer (#25698)

* Rename deny list recognizer

* Update generated TypeScript types

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix/testsuite cross suite result consistency (#25587)

* refactor: replace testCaseResultSummary with lastResultTimestamp in ES index

* feat: add lean batch SQL queries for test suite result summaries

* fix: recompute related test suite results on pipeline completion

* test: update UI sort field and tests for lastResultTimestamp

* Revert MUITagSuggestion changes from PR #25588 (#25710)

* Initial plan

* Revert MUITagSuggestion changes from PR #25588

Co-authored-by: karanh37 <[email protected]>

* Revert test file changes from PR #25588

Co-authored-by: karanh37 <[email protected]>

* fix test

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: karanh37 <[email protected]>
Co-authored-by: karanh37 <[email protected]>

* Fix Elasticsearch/OpenSearch field explosion with custom properties (#25627)

* Flatten Custom Properties

* Fix UI Side

* Fix Reindex matching old index conflict with alias

* Hacky wacky

* Review comments

* Add tests for custom properties to check field don't exceed

* Change to nested

* Align tests

* Fix Column and DataModel and subassets customProperties

* Fix extension updates

* Fix Description Updates

* Temp fix from other PR

* Fix Test failures

* Fix Review comments

* Fix Tests for playwright

* Import export improvements (#25542)

* Batched Import

* Batched Import

* Batched Import

* Optimised Internal methods for adding relationships for import, fixed circular dependency, generated changeEvents (#25582)

* Fix tag clearing and circular dependency detection in batch CSV imports

  - **Tag clearing fix**: Add deleteTagsByTarget before applying new tags in batch imports to match single entity import behavior, ensuring empty CSV fields properly clear existing
   tags
  - **Circular dependency detection fix**: Pre-track entities in dryRunCreatedEntities before parent resolution to enable proper circular reference validation during CSV team
  imports
  - Resolves test failures in TeamResourceIT.test_importCsv_circularDependency_trueRun and tag-related import issues
  - Maintains batch import performance while restoring pre-batch-import validation contracts

* improve storeRelationshipsInternal internal methods - make them truly batched operations

* - Add storeEntities override to all repositories (57 repos)
-  Add batch lock check to HierarchicalLockManager
- Add batch cache write to EntityRepository
-  Fix createManyEntitiesForImport with batched operations
- Fix updateManyEntitiesForImport with batched operations
-  Add change event creation in flushPendingEntityOperations

---------

Co-authored-by: sonika-shah <[email protected]>

* have default implementation of storeEntities

* add batch relationship clearing while updating during import

* Fix column import failing for tables in same batch

 When importing CSV with batching, column rows failed to find their
  parent table because the table was queued but not yet persisted to DB.
  Added pendingEntityFQNs set to track entities in current batch. When
  processing columns, check if table is in this set - if so, add columns
  directly to the queued table object instead of creating a patch context.
  This ensures columns are persisted with the table in a single operation.

* fix UserResourceTest, TestCaseResourceIT

* Fix Circular Dependency Validation for GlossaryTerms

* Batch Insert ChangeEvents and Process Async

* fix: defer CSV result reporting until batch operations complete to ensure accuracy

* fix: ensure custom properties persist during batch CSV imports

* Fix rows processed count

* Fix: Moving of glossaryTerms to correctly detect update operation during import

* Increment version history

* fix TeamResourceTest

* Fix: Mutual Exclusivity Tag Validation during dry run, Deferring of failures

* Fix: Table Constraints Preservation on table import

* revert validateCsvString logic, needed for csv validation

* revert test changes

* Use dependency resolution to flush pending operations to find the parent

* fix search groping based on entityType in updateEntitiesBulk with tests

* Fetch original from db as cache takes some time to reload

* Test Cases

* Remove logs, fix TableResourceIT, Fix ChangeEvent Race Condition

---------

Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: sonika-shah <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Karan Hotchandani <[email protected]>
Co-authored-by: karanh37 <[email protected]>

* fix: databricks view definition (#25700)

* Column Edit - Address feedback (#25669)

* Address Test feedback for columns

* Add Translations

* Fix count issue

* nit

* nit

* fix pagination control

* fix e2e test

---------

Co-authored-by: anuj-kumary <[email protected]>

* chore(ui): fix pagination tests (#25715)

* update table selectors

* modify selector

* feat(ui): Learning Resources page improvements and form updates (#25681)

* feat(ui): Learning Resources page improvements and form updates

* Improved footer component

* fix color code combination

* fix view more issue in card view

* Addressed card related feedback

* fix test

* fix playwright test

* nit

* nit

---------

Co-authored-by: Cursor <[email protected]>

* fix pagination space between layout (#25728)

* Fix #25615 - Use system tables instead of API for lineage in UC (#25697)

* WIP - chore(ci): update playwright workflow to run ingestion with dataAsset… (#24753)

* chore(ci): update playwright workflow to run ingestion with dataAssetRules

* limit setup to required steps

* rearrnage spec files

* update condition

* update workflow

* update runners

* update console

* update config

* update arrangements

* fix typo

* rearrange specs

* remove unwanted import

* fix tests

* fix tests issues

* fix comment

* fix failing tests

* fix advance search

* fix test arrangements

* fix failing tests

* feat(ui): Remove resources count badge and add icon in left panel (#25735)

* Remove resources count badge and add icon in left panel

* nit

* Remove important from CSS

* Flaky(UI): Glossary import export  (#25693)

* fixed glossary import export flakyness

* removed timeout

* Flaky(UI) : Bulk import (#25653)

* fixed flaky bulk import

* fixed flaky bulk import

* formatted code

* removed unncessary loader await

* removed timeout

* Flaky(UI): Customize Detail Page spec (#25650)

* fixed customize detail page

* fixed button not clicking issue

* removed unncessary timeout

* added test id

* MINOR: use stats tables for MySQL and PSQL profiler (#25724)

* feat(system): use stats tables for mysl and psql profiler

* fix: skip tests if fail

* fix(trino): shadowing of http_scheme argument (#25726)

* fix(trino): shadowing of http_scheme argument

* fix: import chain

* fix: remove mock trino library

* [Search] Upgrade Clients (#25719)

* Upgrade Clients

* Update clients in docker files

* Fix Tests

* Fix integration test

* Fix Review Comments

* Fix More review comments :-
  1. ElasticSearchClient.java - Added keep-alive timeout configuration
  2. OpenSearchClient.java - Added keep-alive timeout configuration
  3. OpenMetadataOperations.java - Added logging for caught exception
  4. SigV4Hc5RequestSigningInterceptor.java - Now throws exception instead of silently returning

* Fix More review comments :-
  1. ElasticSearchClient.java - Added keep-alive timeout configuration
  2. OpenSearchClient.java - Added keep-alive timeout configuration
  3. OpenMetadataOperations.java - Added logging for caught exception
  4. SigV4Hc5RequestSigningInterceptor.java - Now throws exception instead of silently returning

Co-authored-by: mohityadav766 <[email protected]>

* upgrade to 9.3.0 vs 3.4.0 server since earlier had bug

* fix version in pom

* Fix Review Comments

* FIX IAM OpenSearch FIx

---------

Co-authored-by: Gitar <[email protected]>
Co-authored-by: mohityadav766 <[email protected]>

* Fix Failing Test (#25745)

* Optimize Reindexing

* Fix Issue in Partition Worker

* Fix Entity Stats writing too much to db

---------

Co-authored-by: sonika-shah <[email protected]>
Co-authored-by: IceS2 <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Eugenio <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Adrià Manero <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: karanh37 <[email protected]>
Co-authored-by: karanh37 <[email protected]>
Co-authored-by: Sriharsha Chintalapani <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Keshav Mohta <[email protected]>
Co-authored-by: anuj-kumary <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Mayur Singal <[email protected]>
Co-authored-by: Chirag Madlani <[email protected]>
Co-authored-by: Dhruv Parmar <[email protected]>
Co-authored-by: Teddy <[email protected]>
Co-authored-by: Gitar <[email protected]>
Co-authored-by: mohityadav766 <[email protected]>

This branch was previously deployed

1 inactive deployment
test — 808c86fc Deployed Feb 5, 2026 by manerow via playwright-ci-postgresql (3, 6) #33116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:alerts-notifications Change events, event subscriptions, alerts, notification templates and channels, email. backend safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants