Skip to content

Add full-server integration test for PATCH table embedding + semantic search - #26356

Merged
pmbrull merged 5 commits into
mainfrom
task/add-patch-table-embedding-semantic-searc-c6475eda
Mar 10, 2026
Merged

pmbrull merged 5 commits into
mainfrom
task/add-patch-table-embedding-semantic-searc-c6475eda

Conversation

@pmbrull

@pmbrull pmbrull commented Mar 9, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds PatchTableEmbeddingIT — a full-server integration test that validates the end-to-end flow: create a table via the REST API, PATCH its description, let the server's VectorEmbeddingHandler automatically update the embedding in the search index, then execute a KNN semantic search and verify the patched table is found
  • Enables NaturalLanguageSearch with DJL embeddings in TestSuiteBootstrap when running with OpenSearch, so the VectorEmbeddingHandler lifecycle handler is active and indexes include the knn_vector embedding field
  • Calls initializeVectorSearchService() before createIndexes() so the embedding dimension is known at index creation time
  • Test gracefully skips (via Assumptions) when not running with OpenSearch or when the DJL model is unavailable

Test plan

  • CI integration tests pass with OpenSearch (-DsearchType=opensearch)
  • The test creates a table via API, PATCHes description, polls for fingerprint change, validates textToEmbed reflects the new description, and confirms KNN semantic search returns the patched table
  • Tests using Elasticsearch are unaffected (NaturalLanguageSearch config is only added for OpenSearch, and the new test skips on Elasticsearch)

…arch

Adds testPatchTableDescriptionUpdatesEmbeddingForSemanticSearch to
VectorEmbeddingIntegrationIT that validates the full flow: when a
table's description is updated via PATCH, the embedding is regenerated
(fingerprint and textToEmbed change) and a subsequent KNN semantic
search returns the patched table as the top result.

Also adds a reusable executeKnnSearch helper that builds a KNN query
via VectorSearchQueryBuilder and executes it directly against the test
OpenSearch index.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment on lines +337 to +340
try {
return new String(b.bodyAsBytes(), java.nio.charset.StandardCharsets.UTF_8);
} catch (Exception e) {
return "{}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Quality: Silent exception swallowing hides search failures

In executeKnnSearch, the lambda at lines 338-340 catches Exception and returns "{}". If the response body cannot be read (e.g., encoding issue, I/O error), the test will fail with a misleading assertion message ("Semantic search should return results") instead of surfacing the actual root cause. Since this is test code, it's better to let the exception propagate for clear diagnostics.

Suggested fix:

try {
  return new String(b.bodyAsBytes(), java.nio.charset.StandardCharsets.UTF_8);
} catch (Exception e) {
  throw new RuntimeException("Failed to read search response body", e);
}

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

… search

- Create PatchTableEmbeddingIT that validates the E2E flow: create a table
  via API, PATCH its description, poll for the embedding to update in the
  search index, then execute a KNN semantic search and verify the patched
  table is found.
- Enable NaturalLanguageSearch with DJL embeddings in TestSuiteBootstrap
  when running with OpenSearch, so the VectorEmbeddingHandler is active and
  indexes include the knn_vector embedding field.
- Call initializeVectorSearchService() before createIndexes() so the
  embedding dimension is known at index creation time.
- Test gracefully skips when not running with OpenSearch or when the DJL
  model is unavailable.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@pmbrull pmbrull changed the title Add PATCH table embedding semantic search integration test Add full-server integration test for PATCH table embedding + semantic search Mar 10, 2026
Instead of modifying the shared table search index with knn_vector
settings (which causes 503 "all shards failed" in CI), create a
temporary test-only knn_vector index, copy the embedding there,
and run the KNN search against it.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…red indexes

The NL search config in the Dropwizard app caused initializeVectorSearchService()
to run during app startup, which then made any SearchIndexingApplication reindex
add knn_vector to ALL shared indexes, causing 503 shard failures in CI.

Now: NL search is only enabled inside PatchTableEmbeddingIT itself, and cleaned
up after the test. This prevents knn_vector from leaking into shared indexes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
"opensearch".equalsIgnoreCase(System.getProperty("searchType", "elasticsearch")),
"Vector embedding tests require OpenSearch");

SearchRepository searchRepo = Entity.getSearchRepository();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Bug: Global config mutation not fully protected by try/finally

Lines 54–55 mutate the shared SearchRepository config (enabling NL search and re-initializing the vector service) before the try block starts at line 60. If initializeVectorSearchService() throws, or if the Assumptions.assumeTrue at line 57 aborts the test (via TestAbortedException), the finally block at line 63 is never reached and the global config remains permanently modified with NL search enabled for all subsequent tests in the suite.

Move the mutation inside the try block so the finally cleanup always runs.

Suggested fix:

SearchRepository searchRepo = Entity.getSearchRepository();
try {
  TestSuiteBootstrap.withNaturalLanguageSearch(searchRepo.getSearchConfiguration());
  searchRepo.initializeVectorSearchService();

  Assumptions.assumeTrue(
      searchRepo.isVectorEmbeddingEnabled(), "Vector embedding could not be initialized");

  runEmbeddingTest(ns);
} finally {
  searchRepo.getSearchConfiguration().setNaturalLanguageSearch(null);
}

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

…search

VectorEmbeddingIntegrationIT (parallel tests) registers a handler with the
lifecycle event dispatcher pointing at its own testcontainers OpenSearch.
When PatchTableEmbeddingIT runs later, the dispatcher keeps the old handler
(skipping the new one), so embedding updates fail silently against the
dead testcontainers client.

Fix: unregister the old handler before calling initializeVectorSearchService()
so the new handler with the correct OpenSearch client gets registered.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gitar-bot

gitar-bot Bot commented Mar 10, 2026 •

Copy link
Copy Markdown
🔍 CI failure analysis for 00fef9c: OpenSearch vector service encounters document-missing exceptions during entity embedding updates, causing failures in vector search operations; separately, 1 failed and 6 flaky Playwright E2E tests show UI/API timing issues likely related to test environment resource contention from the new embedding integration tests.

Overview

Analysis of 11 unique error templates across 18 CI logs reveals two distinct failure patterns: (1) backend vector embedding failures in OpenSearch during integration tests, and (2) frontend Playwright E2E test flakiness with UI timeouts and API response delays. The PR adds comprehensive integration tests for PATCH table embedding and semantic search functionality, which appears to introduce test environment stress affecting both backend operations and E2E test execution.

Failures

OpenSearch Vector Service Document Missing Exceptions (confidence: high)

  • Type: infrastructure, dependency
  • Affected jobs: integration-tests-postgres-opensearch (Run Integration Tests PostgreSQL + OpenSearch)
  • Related to PR: yes
  • Root cause: During entity embedding updates, OpenSearchVectorService attempts to perform partial updates on documents in openmetadata_glossary_search_index_rebuild_* indices. The service receives 404 "document_missing_exception" errors, indicating attempts to update entities that don't exist in the rebuild index. The issue occurs in VectorEmbeddingHandler.updateEmbedding() → OpenSearchVectorService.updateEntityEmbedding() → partialUpdateEntity(). This is likely caused by index synchronization lag or stale rebuild indices during the new embedding test execution.
  • Suggested fix: (1) Verify that vector search index rebuild completion waits properly before embedding operations begin. (2) Ensure VectorEmbeddingHandler is properly unregistered/re-registered between test runs (referenced in recent commit: "Unregister stale VectorEmbeddingHandler before reinitializing vector search"). (3) Add retry logic with exponential backoff for failed embedding updates. (4) Implement index state validation in TestSuiteBootstrap.java before starting embedding tests.

Playwright E2E Test Timeouts and UI Interaction Failures (confidence: medium)

  • Type: flaky_test, infrastructure

  • Affected jobs: Playwright E2E tests (6 flaky, 1 failed)

  • Related to PR: unclear

  • Root cause: Multiple E2E test failures show API response wait timeouts (60+ seconds) and UI elements not being in expected states:

    • Users.spec.ts:570 — Permission check timeout during setup fixture
    • Glossary.spec.ts:2342 — Glossary deletion returns 404; entity creation fails
    • ServiceListing.spec.ts:49 — Checkbox interaction fails due to element not visible
    • Tag.spec.ts:571 — Expected entity visibility state not reached
    • EntityVersionPages.spec.ts:152 — Page reload timeout (60s exceeded)
    • SearchIndexClass.ts:169 — Undefined fields array causes TypeError

    Pattern suggests: (1) API responses are delayed or not arriving, (2) UI state is not being updated after operations, (3) test infrastructure (app instance or search index) is under resource contention. The new embedding integration tests may be consuming database connections, CPU, or memory during the E2E test window.

  • Suggested fix: (1) Isolate E2E tests from integration tests — run in separate CI jobs or with resource limits. (2) Increase timeouts in flaky Playwright tests to 90-120s and add explicit retry logic. (3) Verify TestSuiteBootstrap changes don't impact app startup or initialization order. (4) Check if embedding tests are properly cleaning up resources in teardown. (5) Add health checks before E2E test execution. (6) Profile test environment CPU/memory during both backend and E2E test phases.

SearchIndex Response Data Missing Fields (confidence: medium)

  • Type: test
  • Affected jobs: Playwright E2E tests
  • Related to PR: unclear
  • Root cause: SearchIndexClass.ts:169 attempts to read this.entityResponseData.fields[0] but fields array is undefined. This occurs during entity version page tests for SearchIndex entities, suggesting API response is missing the expected fields array structure.
  • Suggested fix: (1) Add defensive null/undefined checks before array access. (2) Verify SearchIndex entity schema changes in the new PR don't affect response structure. (3) Add data validation in test fixtures to catch schema mismatches early.

Summary

  • PR-related failures: 1 high-confidence backend failure (OpenSearch document-missing) directly caused by new embedding test infrastructure. The vector embedding handler registration/cleanup appears to be creating stale index references. This affects the core functionality being tested (PATCH table embedding + semantic search).
  • Infrastructure/flaky failures: 6 flaky E2E tests + 1 failed test, primarily due to API timeouts and UI state synchronization. Likely caused by test environment resource contention from running intensive embedding integration tests concurrently with or immediately before E2E tests.
  • Recommended action: (1) Immediate: Fix OpenSearch index rebuild synchronization in TestSuiteBootstrap.java before embedding operations begin. Verify VectorEmbeddingHandler is properly cleaned up (ensure recent commit fix is complete). (2) Short-term: Isolate E2E tests from integration tests in CI pipeline or add test environment resource limits. (3) Short-term: Increase Playwright timeouts and add retry logic for failing tests. (4) Verification: Run integration tests alone, then E2E tests alone, to confirm they pass in isolation before running together.
Code Review ⚠️ Changes requested 1 resolved / 3 findings

Full-server integration test for PATCH table embedding and semantic search now recreates the Rest5Client only once instead of on every poll iteration. However, shared SearchRepository config is mutated before the try block begins, risking state corruption if initialization fails, and silent exception swallowing in executeKnnSearch hides search failures.

⚠️ Bug: Global config mutation not fully protected by try/finally

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PatchTableEmbeddingIT.java:53 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PatchTableEmbeddingIT.java:60 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java:585

Lines 54–55 mutate the shared SearchRepository config (enabling NL search and re-initializing the vector service) before the try block starts at line 60. If initializeVectorSearchService() throws, or if the Assumptions.assumeTrue at line 57 aborts the test (via TestAbortedException), the finally block at line 63 is never reached and the global config remains permanently modified with NL search enabled for all subsequent tests in the suite.

Move the mutation inside the try block so the finally cleanup always runs.

Suggested fix
SearchRepository searchRepo = Entity.getSearchRepository();
try {
  TestSuiteBootstrap.withNaturalLanguageSearch(searchRepo.getSearchConfiguration());
  searchRepo.initializeVectorSearchService();

  Assumptions.assumeTrue(
      searchRepo.isVectorEmbeddingEnabled(), "Vector embedding could not be initialized");

  runEmbeddingTest(ns);
} finally {
  searchRepo.getSearchConfiguration().setNaturalLanguageSearch(null);
}
💡 Quality: Silent exception swallowing hides search failures

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/VectorEmbeddingIntegrationIT.java:337-340

In executeKnnSearch, the lambda at lines 338-340 catches Exception and returns "{}". If the response body cannot be read (e.g., encoding issue, I/O error), the test will fail with a misleading assertion message ("Semantic search should return results") instead of surfacing the actual root cause. Since this is test code, it's better to let the exception propagate for clear diagnostics.

Suggested fix
try {
  return new String(b.bodyAsBytes(), java.nio.charset.StandardCharsets.UTF_8);
} catch (Exception e) {
  throw new RuntimeException("Failed to read search response body", e);
}
✅ 1 resolved
✅ Performance: New Rest5Client created on every Awaitility poll iteration

📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PatchTableEmbeddingIT.java:105
In getFieldFromIndex(), a new Rest5Client is created and closed via try-with-resources on every call. Since this method is invoked inside two Awaitility polling loops (lines 71-75 and 83-91, polling every 2s for up to 30s), this spins up and tears down an Apache HttpAsyncClient thread pool up to ~30 times per test run. Consider extracting the client creation outside the polling loop and reusing a single client instance.

🤖 Prompt for agents
Code Review: Full-server integration test for PATCH table embedding and semantic search now recreates the Rest5Client only once instead of on every poll iteration. However, shared SearchRepository config is mutated before the try block begins, risking state corruption if initialization fails, and silent exception swallowing in executeKnnSearch hides search failures.

1. 💡 Quality: Silent exception swallowing hides search failures
   Files: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/VectorEmbeddingIntegrationIT.java:337-340

   In `executeKnnSearch`, the lambda at lines 338-340 catches `Exception` and returns `"{}"`. If the response body cannot be read (e.g., encoding issue, I/O error), the test will fail with a misleading assertion message ("Semantic search should return results") instead of surfacing the actual root cause. Since this is test code, it's better to let the exception propagate for clear diagnostics.

   Suggested fix:
   try {
     return new String(b.bodyAsBytes(), java.nio.charset.StandardCharsets.UTF_8);
   } catch (Exception e) {
     throw new RuntimeException("Failed to read search response body", e);
   }

2. ⚠️ Bug: Global config mutation not fully protected by try/finally
   Files: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PatchTableEmbeddingIT.java:53, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/PatchTableEmbeddingIT.java:60, openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java:585

   Lines 54–55 mutate the shared `SearchRepository` config (enabling NL search and re-initializing the vector service) **before** the `try` block starts at line 60. If `initializeVectorSearchService()` throws, or if the `Assumptions.assumeTrue` at line 57 aborts the test (via `TestAbortedException`), the `finally` block at line 63 is never reached and the global config remains permanently modified with NL search enabled for all subsequent tests in the suite.
   
   Move the mutation inside the `try` block so the `finally` cleanup always runs.

   Suggested fix:
   SearchRepository searchRepo = Entity.getSearchRepository();
   try {
     TestSuiteBootstrap.withNaturalLanguageSearch(searchRepo.getSearchConfiguration());
     searchRepo.initializeVectorSearchService();
   
     Assumptions.assumeTrue(
         searchRepo.isVectorEmbeddingEnabled(), "Vector embedding could not be initialized");
   
     runEmbeddingTest(ns);
   } finally {
     searchRepo.getSearchConfiguration().setNaturalLanguageSearch(null);
   }

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

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 f26ba6e into main Mar 10, 2026
22 of 24 checks passed
@pmbrull
pmbrull deleted the task/add-patch-table-embedding-semantic-searc-c6475eda branch March 10, 2026 13:47

This branch was previously deployed

1 inactive deployment
test — 00fef9cc Deployed Mar 10, 2026 by pmbrull via playwright-ci-postgresql (3, 6) #36725
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.

2 participants