[Do Not Merge] Testing with random cluster alias#27826
[Do Not Merge] Testing with random cluster alias#27826mohityadav766 wants to merge 13 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates OpenMetadata integration tests to support a per-test-session (optionally randomized) search cluster alias, so test code that talks directly to OpenSearch/Elasticsearch can derive the correct index names instead of assuming a fixed openmetadata_* prefix.
Changes:
- Resolve the search
clusterAliasinTestSuiteBootstrapfrom-DclusterAlias(or a randomized default) and pass it into the app’s search configuration. - Update ITs that directly reference index names to prefix with
TestSuiteBootstrap.getClusterAlias(). - Adjust inline documentation around index naming in a couple of tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestSuiteResourceIT.java | Build the test-suite index name using the resolved cluster alias. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java | Build the table index name using the resolved cluster alias; update method Javadoc. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java | Use the resolved cluster alias for the table index constant. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java | Introduce per-session cluster alias resolution (overrideable) and wire it into the search config + logging. |
| private static final String ELASTIC_SEARCH_CLUSTER_ALIAS = resolveClusterAlias(); | ||
|
|
| private static String resolveClusterAlias() { | ||
| String override = System.getProperty("clusterAlias"); | ||
| if (override != null && !override.isBlank()) { | ||
| return override.trim().toLowerCase(java.util.Locale.ROOT); | ||
| } | ||
| return "omtest_" + java.util.UUID.randomUUID().toString().replace("-", "").substring(0, 8); | ||
| } |
| * Get the full Elasticsearch index name with cluster alias prefix. The alias is randomized | ||
| * per JUnit session by {@link org.openmetadata.it.bootstrap.TestSuiteBootstrap}. |
| private static final int NUM_CUSTOM_PROPERTIES = 50; | ||
| // Index name with cluster alias prefix (from TestSuiteBootstrap.ELASTIC_SEARCH_CLUSTER_ALIAS) | ||
| private static final String TABLE_INDEX = "openmetadata_table_search_index"; | ||
| // Index name uses the cluster alias resolved by TestSuiteBootstrap (randomized per session). |
There was a problem hiding this comment.
Pull request overview
This PR updates the integration test infrastructure to avoid search-index cross-test pollution by introducing a per-JUnit-session randomized search clusterAlias (with an optional -DclusterAlias=... override), and adjusts tests that directly query OpenSearch/Elasticsearch to use the dynamic index prefix.
Changes:
- Randomize
ELASTIC_SEARCH_CLUSTER_ALIASper launcher session inTestSuiteBootstrap(overrideable via-DclusterAliaswith validation). - Update integration tests that query search indices directly to compute full index names using
TestSuiteBootstrap.getClusterAlias(). - Update a few tests to use the resolved alias constant instead of hardcoding
"openmetadata".
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java | Adds dynamic cluster alias resolution/validation and logs the chosen alias; passes alias into search configuration. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestSuiteResourceIT.java | Builds the test suite index name using the resolved cluster alias. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java | Builds the table index name using the resolved cluster alias and updates related documentation. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java | Uses the resolved cluster alias to build the mapping/index name used in low-level mapping assertions. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OrphanedIndexCleanerScopedCleanupIT.java | Replaces hardcoded cluster alias with the resolved session alias for scoped orphan-index tests. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IndexTemplateIT.java | Replaces hardcoded cluster alias with the resolved session alias for index-template assertions. |
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
There was a problem hiding this comment.
Pull request overview
This PR primarily improves integration-test isolation and stability by introducing a per-session randomized search clusterAlias (with an override for reproducibility) and by reducing test flakiness in a few timing-/async-sensitive tests. It also updates the tag index mapping to include classification.displayName.
Changes:
- Randomize the OpenSearch/Elasticsearch
clusterAliasper JUnit launcher session (overrideable via-DclusterAlias=...) and update ITs that depend on concrete index names. - Stabilize flaky ITs by adjusting cache-performance sampling logic and by refreshing entity state before patching in async-workflow scenarios.
- Increase
GlossaryOntologyExportITrequest timeout and extend tag index mappings withclassification.displayName.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java | Introduces randomized/overrideable cluster alias and logs it; used to prefix search indices in IT runs. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IndexTemplateIT.java | Uses dynamic cluster alias for template/index assertions. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OrphanedIndexCleanerScopedCleanupIT.java | Uses dynamic cluster alias to scope “our” indices vs “foreign” indices in assertions. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java | Uses dynamic cluster alias when directly querying table index mappings. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java | Uses dynamic cluster alias when referencing the table search index directly. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestSuiteResourceIT.java | Uses dynamic cluster alias when referencing the test suite search index directly. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/UserResourceIT.java | Reduces cache-performance test flakiness via warmup + median-of-samples approach. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java | Refreshes server-side entity state before patching to avoid async status-transition related failures. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryOntologyExportIT.java | Increases export timeout for slower RDF/XML serialization scenarios. |
| openmetadata-spec/src/main/resources/elasticsearch/en/tag_index_mapping.json | Adds classification.displayName field mapping for tag documents. |
| openmetadata-spec/src/main/resources/elasticsearch/jp/tag_index_mapping.json | Adds classification.displayName field mapping for tag documents. |
| openmetadata-spec/src/main/resources/elasticsearch/ru/tag_index_mapping.json | Adds classification.displayName field mapping for tag documents. |
| openmetadata-spec/src/main/resources/elasticsearch/zh/tag_index_mapping.json | Adds classification.displayName field mapping for tag documents. |
| "displayName": { | ||
| "type": "text", | ||
| "analyzer": "om_analyzer", | ||
| "fields": { | ||
| "keyword": { | ||
| "type": "keyword", | ||
| "normalizer": "lowercase_normalizer", | ||
| "ignore_above": 256 | ||
| } | ||
| } | ||
| }, |
| return org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias() | ||
| + "_table_search_index"; |
| return org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias() | ||
| + "_test_suite_search_index"; |
| // Index name uses the cluster alias resolved by TestSuiteBootstrap (randomized per session by | ||
| // default; pin with -DclusterAlias=... for reproducible debugging). | ||
| private static final String TABLE_INDEX = | ||
| org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias() + "_table_search_index"; |
There was a problem hiding this comment.
Pull request overview
This PR updates OpenMetadata integration tests and search index mappings to reduce test flakiness in parallel CI runs by (1) randomizing the search cluster alias per JUnit session and (2) making search lookups exact-match on UUIDs via id.keyword. It also aligns tag index mappings to include classification.displayName and hardens a few flaky tests.
Changes:
- Randomize the search cluster alias per JUnit session (overrideable via
-DclusterAlias) and update ITs that talk to physical index names to use the alias. - Standardize IT search lookups to use
id.keyword:<uuid>for exact-match behavior (avoids tokenized UUID matches). - Add
classification.displayNameto tag index mappings (multiple languages) and adjust a few flaky ITs (timing, patch-state refresh, longer ontology export timeout).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-spec/src/main/resources/elasticsearch/en/tag_index_mapping.json | Add classification.displayName mapping for tag documents (EN). |
| openmetadata-spec/src/main/resources/elasticsearch/jp/tag_index_mapping.json | Add classification.displayName mapping for tag documents (JP). |
| openmetadata-spec/src/main/resources/elasticsearch/ru/tag_index_mapping.json | Add classification.displayName mapping for tag documents (RU). |
| openmetadata-spec/src/main/resources/elasticsearch/zh/tag_index_mapping.json | Add classification.displayName mapping for tag documents (ZH). |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/bootstrap/TestSuiteBootstrap.java | Randomize per-session search cluster alias (+ override validation/logging). |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/BaseEntityIT.java | Use id.keyword for entity ID search helper. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java | Use id.keyword for UUID-based search lookups. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DomainResourceIT.java | Use id.keyword for exact domain ID search assertions. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryOntologyExportIT.java | Increase export HTTP timeout to reduce CI flakiness. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/GlossaryTermResourceIT.java | Refresh entity before patch operations to avoid async workflow status races; use id.keyword in search assertions. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/IndexTemplateIT.java | Use randomized cluster alias when asserting index template names/patterns. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/MultiDomainHasDomainIT.java | Use id.keyword for table ID search verification. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/OrphanedIndexCleanerScopedCleanupIT.java | Use per-session cluster alias for scoped orphan index tests. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/SearchIndexFieldLimitIT.java | Use per-session cluster alias when addressing the physical table index. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TableResourceIT.java | Use id.keyword in table search assertions; compute physical index name from cluster alias. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TagResourceIT.java | Use id.keyword for exact tag ID lookups in search index checks. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResourceIT.java | Use id.keyword for exact test case ID lookups in search index checks. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestSuiteResourceIT.java | Use per-session cluster alias for physical test-suite index refresh/search via low-level client. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/UserResourceIT.java | Make cache performance test less flaky by sampling and asserting median hit vs miss; add median() helper. |
| /** | ||
| * Pattern allowed for {@code -DclusterAlias} overrides — must be a valid OpenSearch / | ||
| * Elasticsearch index name prefix (lowercase alphanumeric, underscore, or hyphen; must start | ||
| * with a letter or digit; max 63 chars). | ||
| * | ||
| * <p>Declared <em>before</em> {@link #ELASTIC_SEARCH_CLUSTER_ALIAS} on purpose: static fields | ||
| * initialize in declaration order, and {@link #resolveClusterAlias()} reads this pattern. If | ||
| * this declaration moved below, override validation would NPE on the only path that uses it. | ||
| */ | ||
| private static final java.util.regex.Pattern CLUSTER_ALIAS_PATTERN = | ||
| java.util.regex.Pattern.compile("[a-z0-9][a-z0-9_\\-]{0,62}"); | ||
|
|
||
| /** | ||
| * Cluster alias used as the prefix for all search indices in this test session. | ||
| * | ||
| * <p>The OpenSearch / Elasticsearch testcontainer is shared across the entire JUnit launcher | ||
| * session (single static container, see {@link #SEARCH_CONTAINER}). When tests run in parallel | ||
| * (the {@code parallel-tests} profile sets {@code junit.jupiter.execution.parallel.enabled=true} | ||
| * and {@code reuseForks=true} keeps everything in one JVM), every test reads and writes against | ||
| * the same set of indices. {@link org.openmetadata.it.util.TestNamespace} only isolates entity | ||
| * FQNs in the database — it does not isolate documents in the search index. | ||
| * | ||
| * <p>To prevent cross-test pollution between concurrent CI runs that share the cluster, the alias | ||
| * is randomized per session by default so each session writes to its own {@code <alias>_*} | ||
| * indices. Set {@code -DclusterAlias=openmetadata} (or any fixed value matching {@link | ||
| * #CLUSTER_ALIAS_PATTERN}) to pin the alias for reproducible debugging. | ||
| */ | ||
| private static final String ELASTIC_SEARCH_CLUSTER_ALIAS = resolveClusterAlias(); | ||
|
|
||
| private static String resolveClusterAlias() { | ||
| String override = System.getProperty("clusterAlias"); | ||
| if (override == null || override.isBlank()) { | ||
| return "omtest_" + java.util.UUID.randomUUID().toString().replace("-", "").substring(0, 8); | ||
| } | ||
| String normalized = override.trim().toLowerCase(java.util.Locale.ROOT); | ||
| if (!CLUSTER_ALIAS_PATTERN.matcher(normalized).matches()) { | ||
| throw new IllegalArgumentException( | ||
| "Invalid -DclusterAlias='" | ||
| + override | ||
| + "'. Must match " | ||
| + CLUSTER_ALIAS_PATTERN.pattern() | ||
| + " (lowercase alphanumeric, underscore, or hyphen; must start with a letter or" | ||
| + " digit; max 63 chars) so it forms a valid OpenSearch/Elasticsearch index prefix."); | ||
| } | ||
| return normalized; | ||
| } | ||
|
|
||
| public static String getClusterAlias() { | ||
| return ELASTIC_SEARCH_CLUSTER_ALIAS; | ||
| } |
Code Review 👍 Approved with suggestions 1 resolved / 2 findingsFixes a static initialization order issue where CLUSTER_ALIAS_PATTERN was null. Addressed that, but note that the median cache-hit versus cache-miss assertion remains prone to flakiness at sub-millisecond scales. 💡 Edge Case: Median cache-hit <= cache-miss assertion can still flake📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/UserResourceIT.java:2214-2218 At sub-millisecond scale, Suggested fix✅ 1 resolved✅ Bug: Static init ordering: CLUSTER_ALIAS_PATTERN is null when used
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|



Describe your changes:
Fixes
I worked on ... because ...
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>Summary by Gitar
EntityNotFoundExceptionhandling inEntityRepository.setInheritedFieldsto allow graceful fallback when parent entities are hard-deleted.GlossaryTermRepositoryto use bulk entity resolution, preventing404errors for orphaned parent or glossary references.This will update automatically on new commits.