Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,35 @@ public class TestSuiteBootstrap implements LauncherSessionListener {
private static final Integer ELASTIC_BATCH_SIZE = 10;
private static final IndexMappingLanguage ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE =
IndexMappingLanguage.EN;
private static final String ELASTIC_SEARCH_CLUSTER_ALIAS = "openmetadata";

/**
* 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 so each session writes to its own {@code <alias>_*} indices. Set
* {@code -DclusterAlias=openmetadata} (or any fixed value) to pin the alias for reproducible
* debugging.
*/
private static final String ELASTIC_SEARCH_CLUSTER_ALIAS = resolveClusterAlias();

Comment on lines +137 to +138
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);
}
Comment on lines +139 to +155

public static String getClusterAlias() {
return ELASTIC_SEARCH_CLUSTER_ALIAS;
}
Comment on lines +110 to +159

// Default images (can be overridden by system properties)
private static final String DEFAULT_POSTGRES_IMAGE = "postgres:15";
Expand Down Expand Up @@ -164,6 +192,7 @@ public void launcherSessionOpened(LauncherSession session) {
LOG.info("=== TestSuiteBootstrap: Starting test infrastructure ===");
LOG.info("Database type: {}", databaseType);
LOG.info("Search type: {}", searchType);
LOG.info("Search cluster alias: {}", ELASTIC_SEARCH_CLUSTER_ALIAS);
LOG.info("RDF enabled: {}", rdfEnabled);
Comment thread
mohityadav766 marked this conversation as resolved.
LOG.info("Cache provider: {}", cacheProvider);
boolean k8sEnabled = isK8sTestsRequested();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public class SearchIndexFieldLimitIT {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final String TABLE_TYPE_NAME = "table";
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).
private static final String TABLE_INDEX =
org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias() + "_table_search_index";

private static Type STRING_TYPE;
private static Type INTEGER_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4586,11 +4586,12 @@ protected Table getEntityIncludeDeleted(String id) {
// ===================================================================

/**
* Get the full Elasticsearch index name with cluster alias prefix.
* In test environment, cluster alias is "openmetadata" so table index is "openmetadata_table_search_index"
* 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 String getTableSearchIndexName() {
return "openmetadata_table_search_index";
return org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias()
+ "_table_search_index";
Comment on lines +4594 to +4595
Comment on lines +4594 to +4595
}

// ===================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ private void putPipelineStatus(
}

private String getTestSuiteSearchIndexName() {
return "openmetadata_test_suite_search_index";
return org.openmetadata.it.bootstrap.TestSuiteBootstrap.getClusterAlias()
+ "_test_suite_search_index";
Comment on lines +1142 to +1143
Comment on lines +1142 to +1143
}

private void refreshTestSuiteSearchIndex(Rest5Client searchClient) throws Exception {
Expand Down
Loading