mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-25 15:17:54 +00:00
Support Elasticsearch cluster alias for E2E tests (#17117)
* Fix backend tests and have index alias with clusterAlias appended * Fix backend tests and have index alias with clusterAlias appended * Fix failing tests * alias setup * fix suggestion not working due to alias * fix getIndexOrAliasName method for multiple indexes * update openmetadata.yaml * update childAliases with clusterAlias --------- Co-authored-by: Ashish Gupta <ashish@getcollate.io> Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
This commit is contained in:
parent
ab1e6b7acd
commit
8d5661a7bf
@ -278,7 +278,7 @@ elasticsearch:
|
|||||||
scheme: ${ELASTICSEARCH_SCHEME:-http}
|
scheme: ${ELASTICSEARCH_SCHEME:-http}
|
||||||
username: ${ELASTICSEARCH_USER:-""}
|
username: ${ELASTICSEARCH_USER:-""}
|
||||||
password: ${ELASTICSEARCH_PASSWORD:-""}
|
password: ${ELASTICSEARCH_PASSWORD:-""}
|
||||||
clusterAlias: ${ELASTICSEARCH_CLUSTER_ALIAS:-""}
|
clusterAlias: ${ELASTICSEARCH_CLUSTER_ALIAS:-"openmetadata"}
|
||||||
truststorePath: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
truststorePath: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
||||||
truststorePassword: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
truststorePassword: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
||||||
connectionTimeoutSecs: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
connectionTimeoutSecs: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
||||||
|
|||||||
@ -186,6 +186,7 @@ services:
|
|||||||
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
||||||
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
||||||
SEARCH_TYPE: ${SEARCH_TYPE:- "opensearch"}
|
SEARCH_TYPE: ${SEARCH_TYPE:- "opensearch"}
|
||||||
|
ELASTICSEARCH_CLUSTER_ALIAS: ${ELASTICSEARCH_CLUSTER_ALIAS:- "openmetadata"}
|
||||||
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
||||||
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
||||||
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
||||||
@ -400,6 +401,7 @@ services:
|
|||||||
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
||||||
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-"OpenMetadata_password123!!!"}
|
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-"OpenMetadata_password123!!!"}
|
||||||
SEARCH_TYPE: ${SEARCH_TYPE:- "opensearch"}
|
SEARCH_TYPE: ${SEARCH_TYPE:- "opensearch"}
|
||||||
|
ELASTICSEARCH_CLUSTER_ALIAS: ${ELASTICSEARCH_CLUSTER_ALIAS:- "openmetadata"}
|
||||||
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
||||||
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
||||||
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
||||||
|
|||||||
@ -185,6 +185,7 @@ services:
|
|||||||
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
||||||
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
||||||
SEARCH_TYPE: ${SEARCH_TYPE:- "elasticsearch"}
|
SEARCH_TYPE: ${SEARCH_TYPE:- "elasticsearch"}
|
||||||
|
ELASTICSEARCH_CLUSTER_ALIAS: ${ELASTICSEARCH_CLUSTER_ALIAS:- "openmetadata"}
|
||||||
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
||||||
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
||||||
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
||||||
@ -396,6 +397,7 @@ services:
|
|||||||
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
ELASTICSEARCH_USER: ${ELASTICSEARCH_USER:-""}
|
||||||
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD:-""}
|
||||||
SEARCH_TYPE: ${SEARCH_TYPE:- "elasticsearch"}
|
SEARCH_TYPE: ${SEARCH_TYPE:- "elasticsearch"}
|
||||||
|
ELASTICSEARCH_CLUSTER_ALIAS: ${ELASTICSEARCH_CLUSTER_ALIAS:- "openmetadata"}
|
||||||
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
ELASTICSEARCH_TRUST_STORE_PATH: ${ELASTICSEARCH_TRUST_STORE_PATH:-""}
|
||||||
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
ELASTICSEARCH_TRUST_STORE_PASSWORD: ${ELASTICSEARCH_TRUST_STORE_PASSWORD:-""}
|
||||||
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
ELASTICSEARCH_CONNECTION_TIMEOUT_SECS: ${ELASTICSEARCH_CONNECTION_TIMEOUT_SECS:-5}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ if [ $RESULT -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
until curl -s -f "http://localhost:9200/_cat/indices/team_search_index"; do
|
until curl -s -f "http://localhost:9200/_cat/indices/openmetadata_team_search_index"; do
|
||||||
echo 'Checking if Elastic Search instance is up...\n'
|
echo 'Checking if Elastic Search instance is up...\n'
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -44,6 +45,7 @@ import java.util.Set;
|
|||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -189,9 +191,12 @@ public class SearchRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexOrAliasName(String name) {
|
public String getIndexOrAliasName(String name) {
|
||||||
return clusterAlias != null && !clusterAlias.isEmpty()
|
if (clusterAlias == null || clusterAlias.isEmpty()) {
|
||||||
? clusterAlias + indexNameSeparator + name
|
return name;
|
||||||
: name;
|
}
|
||||||
|
return Arrays.stream(name.split(","))
|
||||||
|
.map(index -> clusterAlias + indexNameSeparator + index.trim())
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIndexNameWithoutAlias(String fullIndexName) {
|
public String getIndexNameWithoutAlias(String fullIndexName) {
|
||||||
|
|||||||
@ -286,6 +286,11 @@ public class ElasticSearchClient implements SearchClient {
|
|||||||
try {
|
try {
|
||||||
Set<String> aliases = new HashSet<>(indexMapping.getParentAliases(clusterAlias));
|
Set<String> aliases = new HashSet<>(indexMapping.getParentAliases(clusterAlias));
|
||||||
aliases.add(indexMapping.getAlias(clusterAlias));
|
aliases.add(indexMapping.getAlias(clusterAlias));
|
||||||
|
// Get the child aliases
|
||||||
|
List<String> childAliases = indexMapping.getChildAliases(clusterAlias);
|
||||||
|
|
||||||
|
// Add the child aliases to the set of aliases
|
||||||
|
aliases.addAll(childAliases);
|
||||||
IndicesAliasesRequest.AliasActions aliasAction =
|
IndicesAliasesRequest.AliasActions aliasAction =
|
||||||
IndicesAliasesRequest.AliasActions.add()
|
IndicesAliasesRequest.AliasActions.add()
|
||||||
.index(indexMapping.getIndexName(clusterAlias))
|
.index(indexMapping.getIndexName(clusterAlias))
|
||||||
@ -1690,7 +1695,8 @@ public class ElasticSearchClient implements SearchClient {
|
|||||||
Pair<String, String> fieldAndValue,
|
Pair<String, String> fieldAndValue,
|
||||||
Pair<String, Map<String, Object>> updates) {
|
Pair<String, Map<String, Object>> updates) {
|
||||||
if (isClientAvailable) {
|
if (isClientAvailable) {
|
||||||
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
|
UpdateByQueryRequest updateByQueryRequest =
|
||||||
|
new UpdateByQueryRequest(Entity.getSearchRepository().getIndexOrAliasName(indexName));
|
||||||
updateChildren(updateByQueryRequest, fieldAndValue, updates);
|
updateChildren(updateByQueryRequest, fieldAndValue, updates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1740,7 +1746,7 @@ public class ElasticSearchClient implements SearchClient {
|
|||||||
private void updateElasticSearchByQuery(UpdateByQueryRequest updateByQueryRequest) {
|
private void updateElasticSearchByQuery(UpdateByQueryRequest updateByQueryRequest) {
|
||||||
if (updateByQueryRequest != null && isClientAvailable) {
|
if (updateByQueryRequest != null && isClientAvailable) {
|
||||||
updateByQueryRequest.setRefresh(true);
|
updateByQueryRequest.setRefresh(true);
|
||||||
LOG.debug(SENDING_REQUEST_TO_ELASTIC_SEARCH, updateByQueryRequest);
|
LOG.info(SENDING_REQUEST_TO_ELASTIC_SEARCH, updateByQueryRequest);
|
||||||
client.updateByQuery(updateByQueryRequest, RequestOptions.DEFAULT);
|
client.updateByQuery(updateByQueryRequest, RequestOptions.DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -277,8 +277,13 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
@Override
|
@Override
|
||||||
public void createAliases(IndexMapping indexMapping) {
|
public void createAliases(IndexMapping indexMapping) {
|
||||||
try {
|
try {
|
||||||
List<String> aliases = indexMapping.getParentAliases(clusterAlias);
|
Set<String> aliases = new HashSet<>(indexMapping.getParentAliases(clusterAlias));
|
||||||
aliases.add(indexMapping.getAlias(clusterAlias));
|
aliases.add(indexMapping.getAlias(clusterAlias));
|
||||||
|
// Get the child aliases
|
||||||
|
List<String> childAliases = indexMapping.getChildAliases(clusterAlias);
|
||||||
|
|
||||||
|
// Add the child aliases to the set of aliases
|
||||||
|
aliases.addAll(childAliases);
|
||||||
IndicesAliasesRequest.AliasActions aliasAction =
|
IndicesAliasesRequest.AliasActions aliasAction =
|
||||||
IndicesAliasesRequest.AliasActions.add()
|
IndicesAliasesRequest.AliasActions.add()
|
||||||
.index(indexMapping.getIndexName(clusterAlias))
|
.index(indexMapping.getIndexName(clusterAlias))
|
||||||
@ -1673,7 +1678,8 @@ public class OpenSearchClient implements SearchClient {
|
|||||||
Pair<String, String> fieldAndValue,
|
Pair<String, String> fieldAndValue,
|
||||||
Pair<String, Map<String, Object>> updates) {
|
Pair<String, Map<String, Object>> updates) {
|
||||||
if (isClientAvailable) {
|
if (isClientAvailable) {
|
||||||
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
|
UpdateByQueryRequest updateByQueryRequest =
|
||||||
|
new UpdateByQueryRequest(Entity.getSearchRepository().getIndexOrAliasName(indexName));
|
||||||
updateChildren(updateByQueryRequest, fieldAndValue, updates);
|
updateChildren(updateByQueryRequest, fieldAndValue, updates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,7 @@ public abstract class OpenMetadataApplicationTest {
|
|||||||
public static final Integer ELASTIC_BATCH_SIZE = 10;
|
public static final Integer ELASTIC_BATCH_SIZE = 10;
|
||||||
public static final IndexMappingLanguage ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE =
|
public static final IndexMappingLanguage ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE =
|
||||||
IndexMappingLanguage.EN;
|
IndexMappingLanguage.EN;
|
||||||
|
public static final String ELASTIC_SEARCH_CLUSTER_ALIAS = "openmetadata";
|
||||||
public static final ElasticSearchConfiguration.SearchType ELASTIC_SEARCH_TYPE =
|
public static final ElasticSearchConfiguration.SearchType ELASTIC_SEARCH_TYPE =
|
||||||
ElasticSearchConfiguration.SearchType.ELASTICSEARCH;
|
ElasticSearchConfiguration.SearchType.ELASTICSEARCH;
|
||||||
public static DropwizardAppExtension<OpenMetadataApplicationConfig> APP;
|
public static DropwizardAppExtension<OpenMetadataApplicationConfig> APP;
|
||||||
@ -256,6 +257,7 @@ public abstract class OpenMetadataApplicationTest {
|
|||||||
.withKeepAliveTimeoutSecs(ELASTIC_KEEP_ALIVE_TIMEOUT)
|
.withKeepAliveTimeoutSecs(ELASTIC_KEEP_ALIVE_TIMEOUT)
|
||||||
.withBatchSize(ELASTIC_BATCH_SIZE)
|
.withBatchSize(ELASTIC_BATCH_SIZE)
|
||||||
.withSearchIndexMappingLanguage(ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE)
|
.withSearchIndexMappingLanguage(ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE)
|
||||||
|
.withClusterAlias(ELASTIC_SEARCH_CLUSTER_ALIAS)
|
||||||
.withSearchType(ELASTIC_SEARCH_TYPE);
|
.withSearchType(ELASTIC_SEARCH_TYPE);
|
||||||
SearchRepository searchRepository = new SearchRepository(esConfig);
|
SearchRepository searchRepository = new SearchRepository(esConfig);
|
||||||
LOG.info("creating indexes.");
|
LOG.info("creating indexes.");
|
||||||
@ -313,6 +315,8 @@ public abstract class OpenMetadataApplicationTest {
|
|||||||
ConfigOverride.config(
|
ConfigOverride.config(
|
||||||
"elasticsearch.searchIndexMappingLanguage",
|
"elasticsearch.searchIndexMappingLanguage",
|
||||||
ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE.value()));
|
ELASTIC_SEARCH_INDEX_MAPPING_LANGUAGE.value()));
|
||||||
|
configOverrides.add(
|
||||||
|
ConfigOverride.config("elasticsearch.clusterAlias", ELASTIC_SEARCH_CLUSTER_ALIAS));
|
||||||
configOverrides.add(
|
configOverrides.add(
|
||||||
ConfigOverride.config("elasticsearch.searchType", ELASTIC_SEARCH_TYPE.value()));
|
ConfigOverride.config("elasticsearch.searchType", ELASTIC_SEARCH_TYPE.value()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1079,7 +1079,12 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
RestClient searchClient = getSearchClient();
|
RestClient searchClient = getSearchClient();
|
||||||
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
||||||
Response response;
|
Response response;
|
||||||
Request request = new Request("GET", String.format("%s/_search", index.getIndexName(null)));
|
// Direct request to es needs to have es clusterAlias appended with indexName
|
||||||
|
Request request =
|
||||||
|
new Request(
|
||||||
|
"GET",
|
||||||
|
String.format(
|
||||||
|
"%s/_search", index.getIndexName(Entity.getSearchRepository().getClusterAlias())));
|
||||||
String query =
|
String query =
|
||||||
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
||||||
request.setJsonEntity(query);
|
request.setJsonEntity(query);
|
||||||
@ -1124,7 +1129,12 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
RestClient searchClient = getSearchClient();
|
RestClient searchClient = getSearchClient();
|
||||||
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
||||||
Response response;
|
Response response;
|
||||||
Request request = new Request("GET", String.format("%s/_search", index.getIndexName(null)));
|
// Direct request to es needs to have es clusterAlias appended with indexName
|
||||||
|
Request request =
|
||||||
|
new Request(
|
||||||
|
"GET",
|
||||||
|
String.format(
|
||||||
|
"%s/_search", index.getIndexName(Entity.getSearchRepository().getClusterAlias())));
|
||||||
String query =
|
String query =
|
||||||
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
||||||
request.setJsonEntity(query);
|
request.setJsonEntity(query);
|
||||||
@ -2190,9 +2200,8 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
EntityReference entityReference = getEntityReference(entity);
|
EntityReference entityReference = getEntityReference(entity);
|
||||||
IndexMapping indexMapping =
|
IndexMapping indexMapping =
|
||||||
Entity.getSearchRepository().getIndexMapping(entityReference.getType());
|
Entity.getSearchRepository().getIndexMapping(entityReference.getType());
|
||||||
SearchResponse response =
|
// search api method internally appends clusterAlias name
|
||||||
getResponseFormSearch(
|
SearchResponse response = getResponseFormSearch(indexMapping.getIndexName(null));
|
||||||
indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()));
|
|
||||||
List<String> entityIds = new ArrayList<>();
|
List<String> entityIds = new ArrayList<>();
|
||||||
SearchHit[] hits = response.getHits().getHits();
|
SearchHit[] hits = response.getHits().getHits();
|
||||||
for (SearchHit hit : hits) {
|
for (SearchHit hit : hits) {
|
||||||
@ -2212,9 +2221,8 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
EntityReference entityReference = getEntityReference(entity);
|
EntityReference entityReference = getEntityReference(entity);
|
||||||
IndexMapping indexMapping =
|
IndexMapping indexMapping =
|
||||||
Entity.getSearchRepository().getIndexMapping(entityReference.getType());
|
Entity.getSearchRepository().getIndexMapping(entityReference.getType());
|
||||||
SearchResponse response =
|
// search api method internally appends clusterAlias name
|
||||||
getResponseFormSearch(
|
SearchResponse response = getResponseFormSearch(indexMapping.getIndexName(null));
|
||||||
indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()));
|
|
||||||
List<String> entityIds = new ArrayList<>();
|
List<String> entityIds = new ArrayList<>();
|
||||||
SearchHit[] hits = response.getHits().getHits();
|
SearchHit[] hits = response.getHits().getHits();
|
||||||
for (SearchHit hit : hits) {
|
for (SearchHit hit : hits) {
|
||||||
@ -2229,9 +2237,8 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
TestUtils.delete(target, entityClass, ADMIN_AUTH_HEADERS);
|
TestUtils.delete(target, entityClass, ADMIN_AUTH_HEADERS);
|
||||||
// search again in search after deleting
|
// search again in search after deleting
|
||||||
|
|
||||||
response =
|
// search api method internally appends clusterAlias name
|
||||||
getResponseFormSearch(
|
response = getResponseFormSearch(indexMapping.getIndexName(null));
|
||||||
indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()));
|
|
||||||
hits = response.getHits().getHits();
|
hits = response.getHits().getHits();
|
||||||
for (SearchHit hit : hits) {
|
for (SearchHit hit : hits) {
|
||||||
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
|
Map<String, Object> sourceAsMap = hit.getSourceAsMap();
|
||||||
@ -2321,12 +2328,11 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
public static Map<String, Object> getEntityDocumentFromSearch(UUID entityId, String entityType)
|
public static Map<String, Object> getEntityDocumentFromSearch(UUID entityId, String entityType)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType);
|
IndexMapping indexMapping = Entity.getSearchRepository().getIndexMapping(entityType);
|
||||||
|
// SearchResource.java-searchEntityInEsIndexWithId method internally appends clusterAlias name
|
||||||
WebTarget target =
|
WebTarget target =
|
||||||
getResource(
|
getResource(
|
||||||
String.format(
|
String.format(
|
||||||
"search/get/%s/doc/%s",
|
"search/get/%s/doc/%s", indexMapping.getIndexName(null), entityId.toString()));
|
||||||
indexMapping.getIndexName(Entity.getSearchRepository().getClusterAlias()),
|
|
||||||
entityId.toString()));
|
|
||||||
String result = TestUtils.get(target, String.class, ADMIN_AUTH_HEADERS);
|
String result = TestUtils.get(target, String.class, ADMIN_AUTH_HEADERS);
|
||||||
GetResponse response = null;
|
GetResponse response = null;
|
||||||
try {
|
try {
|
||||||
@ -3357,7 +3363,12 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
RestClient searchClient = getSearchClient();
|
RestClient searchClient = getSearchClient();
|
||||||
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
IndexMapping index = Entity.getSearchRepository().getIndexMapping(entityType);
|
||||||
Request request = new Request("GET", String.format("%s/_search", index.getIndexName(null)));
|
// Direct request to es needs to have es clusterAlias appended with indexName
|
||||||
|
Request request =
|
||||||
|
new Request(
|
||||||
|
"GET",
|
||||||
|
String.format(
|
||||||
|
"%s/_search", index.getIndexName(Entity.getSearchRepository().getClusterAlias())));
|
||||||
String query =
|
String query =
|
||||||
String.format(
|
String.format(
|
||||||
"{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"_id\":\"%s\"}}]}}}", entity.getId());
|
"{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"_id\":\"%s\"}}]}}}", entity.getId());
|
||||||
|
|||||||
@ -25,17 +25,20 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.ws.rs.client.WebTarget;
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.client.HttpResponseException;
|
import org.apache.http.client.HttpResponseException;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.openmetadata.schema.analytics.EntityReportData;
|
import org.openmetadata.schema.analytics.EntityReportData;
|
||||||
import org.openmetadata.schema.analytics.ReportData;
|
import org.openmetadata.schema.analytics.ReportData;
|
||||||
import org.openmetadata.schema.analytics.WebAnalyticUserActivityReportData;
|
import org.openmetadata.schema.analytics.WebAnalyticUserActivityReportData;
|
||||||
import org.openmetadata.schema.type.MetadataOperation;
|
import org.openmetadata.schema.type.MetadataOperation;
|
||||||
|
import org.openmetadata.service.Entity;
|
||||||
import org.openmetadata.service.OpenMetadataApplicationTest;
|
import org.openmetadata.service.OpenMetadataApplicationTest;
|
||||||
import org.openmetadata.service.resources.analytics.ReportDataResource.ReportDataResultList;
|
import org.openmetadata.service.resources.analytics.ReportDataResource.ReportDataResultList;
|
||||||
import org.openmetadata.service.util.ResultList;
|
import org.openmetadata.service.util.ResultList;
|
||||||
import org.openmetadata.service.util.TestUtils;
|
import org.openmetadata.service.util.TestUtils;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
class ReportDataResourceTest extends OpenMetadataApplicationTest {
|
class ReportDataResourceTest extends OpenMetadataApplicationTest {
|
||||||
|
|
||||||
public static final String JSON_QUERY =
|
public static final String JSON_QUERY =
|
||||||
@ -228,7 +231,12 @@ class ReportDataResourceTest extends OpenMetadataApplicationTest {
|
|||||||
private JsonNode runSearchQuery(String query, String index) throws IOException {
|
private JsonNode runSearchQuery(String query, String index) throws IOException {
|
||||||
RestClient searchClient = getSearchClient();
|
RestClient searchClient = getSearchClient();
|
||||||
Response response;
|
Response response;
|
||||||
Request request = new Request("POST", String.format("/%s/_search", index));
|
Request request =
|
||||||
|
new Request(
|
||||||
|
"POST",
|
||||||
|
String.format(
|
||||||
|
"/%s/_search",
|
||||||
|
Entity.getSearchRepository().getIndexOrAliasName(String.valueOf(index))));
|
||||||
request.setJsonEntity(query);
|
request.setJsonEntity(query);
|
||||||
try {
|
try {
|
||||||
response = searchClient.performRequest(request);
|
response = searchClient.performRequest(request);
|
||||||
|
|||||||
@ -2410,7 +2410,12 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
RestClient searchClient = getSearchClient();
|
RestClient searchClient = getSearchClient();
|
||||||
IndexMapping index = Entity.getSearchRepository().getIndexMapping(TABLE);
|
IndexMapping index = Entity.getSearchRepository().getIndexMapping(TABLE);
|
||||||
Response response;
|
Response response;
|
||||||
Request request = new Request("GET", String.format("%s/_search", index.getIndexName(null)));
|
// Direct request to es needs to have es clusterAlias appended with indexName
|
||||||
|
Request request =
|
||||||
|
new Request(
|
||||||
|
"GET",
|
||||||
|
String.format(
|
||||||
|
"%s/_search", index.getIndexName(Entity.getSearchRepository().getClusterAlias())));
|
||||||
String query =
|
String query =
|
||||||
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
"{\"size\": 100,\"query\":{\"bool\":{\"must\":[{\"term\":{\"descriptionStatus\":\"INCOMPLETE\"}}]}}}";
|
||||||
request.setJsonEntity(query);
|
request.setJsonEntity(query);
|
||||||
|
|||||||
@ -261,7 +261,7 @@ export const filterOptionsByIndex = (
|
|||||||
maxItemsPerType = 5
|
maxItemsPerType = 5
|
||||||
) =>
|
) =>
|
||||||
options
|
options
|
||||||
.filter((option) => option._index === searchIndex)
|
.filter((option) => option._index.includes(searchIndex))
|
||||||
.map((option) => option._source)
|
.map((option) => option._source)
|
||||||
.slice(0, maxItemsPerType);
|
.slice(0, maxItemsPerType);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user