Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker committed Oct 3, 2024
1 parent ac7c9ce commit f8c52d5
Show file tree
Hide file tree
Showing 35 changed files with 117 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,17 @@ public ExplainResponse explain(
}
}

private static void testLog(ObjectMapper mapper, SearchRequest searchRequest) {
private void testLog(ObjectMapper mapper, SearchRequest searchRequest) {
try {
log.warn("SearchRequest(custom): {}", mapper.writeValueAsString(customSearchConfiguration));
final String[] indices = searchRequest.indices();
log.warn(
String.format(
"SearchRequest: %s",
"SearchRequest(indices): %s",
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(indices)));
log.warn(
String.format(
"SearchRequest: %s",
"SearchRequest(query): %s",
mapper.writeValueAsString(mapper.readTree(searchRequest.source().toString()))));
} catch (JsonProcessingException e) {
log.warn("Error writing test log");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import static com.linkedin.metadata.search.utils.QueryUtils.*;
import static org.mockito.Mockito.*;
import static org.testng.AssertJUnit.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import com.datahub.util.RecordUtils;
import com.google.common.collect.ImmutableList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.metadata.extractor;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.Assert.assertEquals;

import com.datahub.test.TestEntityAspect;
import com.datahub.test.TestEntityAspectArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.graph.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.graph.search.SearchGraphServiceTestBase;
import com.linkedin.metadata.search.elasticsearch.ElasticSearchSuite;
import com.linkedin.metadata.search.elasticsearch.indexbuilder.ESIndexBuilder;
Expand All @@ -9,7 +11,6 @@
import org.opensearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({ElasticSearchSuite.class, SearchTestContainerConfiguration.class})
Expand Down Expand Up @@ -39,6 +40,6 @@ protected ESIndexBuilder getIndexBuilder() {

@Test
public void initTest() {
AssertJUnit.assertNotNull(_searchClient);
assertNotNull(_searchClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.graph.search.opensearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.graph.search.SearchGraphServiceTestBase;
import com.linkedin.metadata.search.elasticsearch.indexbuilder.ESIndexBuilder;
import com.linkedin.metadata.search.elasticsearch.update.ESBulkProcessor;
Expand All @@ -9,7 +11,6 @@
import org.opensearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({OpenSearchSuite.class, SearchTestContainerConfiguration.class})
Expand Down Expand Up @@ -39,6 +40,6 @@ protected ESIndexBuilder getIndexBuilder() {

@Test
public void initTest() {
AssertJUnit.assertNotNull(_searchClient);
assertNotNull(_searchClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.linkedin.metadata.search;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotSame;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotSame;

import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.linkedin.metadata.config.cache.SearchCacheConfiguration;
import com.linkedin.metadata.config.cache.SearchLineageCacheConfiguration;
import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.graph.EntityLineageResult;
import com.linkedin.metadata.graph.GraphService;
import com.linkedin.metadata.graph.LineageDirection;
Expand Down Expand Up @@ -103,9 +102,6 @@ public abstract class LineageServiceTestBase extends AbstractTestNGSpringContext
@Nonnull
protected abstract SearchConfiguration getSearchConfiguration();

@Nonnull
protected abstract CustomSearchConfiguration getCustomSearchConfiguration();

private SettingsBuilder settingsBuilder;
private ElasticSearchService elasticSearchService;
private GraphService graphService;
Expand Down Expand Up @@ -211,10 +207,7 @@ private ElasticSearchService buildEntitySearchService() {
QueryFilterRewriteChain.EMPTY);
ESBrowseDAO browseDAO =
new ESBrowseDAO(
searchClientSpy,
getSearchConfiguration(),
getCustomSearchConfiguration(),
QueryFilterRewriteChain.EMPTY);
searchClientSpy, getSearchConfiguration(), null, QueryFilterRewriteChain.EMPTY);
ESWriteDAO writeDAO = new ESWriteDAO(searchClientSpy, getBulkProcessor(), 1);
return new ElasticSearchService(indexBuilders, searchDAO, browseDAO, writeDAO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.linkedin.common.urn.Urn;
import com.linkedin.metadata.config.cache.EntityDocCountCacheConfiguration;
import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.models.registry.SnapshotEntityRegistry;
import com.linkedin.metadata.query.filter.Condition;
import com.linkedin.metadata.query.filter.ConjunctiveCriterion;
Expand Down Expand Up @@ -64,9 +63,6 @@ public abstract class SearchServiceTestBase extends AbstractTestNGSpringContextT
@Nonnull
protected abstract SearchConfiguration getSearchConfiguration();

@Nonnull
protected abstract CustomSearchConfiguration getCustomSearchConfiguration();

protected OperationContext operationContext;
private SettingsBuilder settingsBuilder;
private ElasticSearchService elasticSearchService;
Expand Down Expand Up @@ -136,10 +132,7 @@ private ElasticSearchService buildEntitySearchService() {
QueryFilterRewriteChain.EMPTY);
ESBrowseDAO browseDAO =
new ESBrowseDAO(
getSearchClient(),
getSearchConfiguration(),
getCustomSearchConfiguration(),
QueryFilterRewriteChain.EMPTY);
getSearchClient(), getSearchConfiguration(), null, QueryFilterRewriteChain.EMPTY);
ESWriteDAO writeDAO = new ESWriteDAO(getSearchClient(), getBulkProcessor(), 1);
return new ElasticSearchService(indexBuilders, searchDAO, browseDAO, writeDAO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.linkedin.metadata.browse.BrowseResult;
import com.linkedin.metadata.browse.BrowseResultV2;
import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.models.registry.SnapshotEntityRegistry;
import com.linkedin.metadata.search.elasticsearch.ElasticSearchService;
import com.linkedin.metadata.search.elasticsearch.indexbuilder.ESIndexBuilder;
Expand Down Expand Up @@ -53,9 +52,6 @@ public abstract class TestEntityTestBase extends AbstractTestNGSpringContextTest
@Nonnull
protected abstract SearchConfiguration getSearchConfiguration();

@Nonnull
protected abstract CustomSearchConfiguration getCustomSearchConfiguration();

private SettingsBuilder settingsBuilder;
private ElasticSearchService elasticSearchService;
private OperationContext opContext;
Expand Down Expand Up @@ -102,10 +98,7 @@ private ElasticSearchService buildService() {
QueryFilterRewriteChain.EMPTY);
ESBrowseDAO browseDAO =
new ESBrowseDAO(
getSearchClient(),
getSearchConfiguration(),
getCustomSearchConfiguration(),
QueryFilterRewriteChain.EMPTY);
getSearchClient(), getSearchConfiguration(), null, QueryFilterRewriteChain.EMPTY);
ESWriteDAO writeDAO = new ESWriteDAO(getSearchClient(), getBulkProcessor(), 1);
ElasticSearchService searchService =
new ElasticSearchService(indexBuilders, searchDAO, browseDAO, writeDAO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.search.SearchService;
import com.linkedin.metadata.search.fixtures.GoldenTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.search.indexbuilder.IndexBuilderTestBase;
import io.datahubproject.test.search.config.SearchTestContainerConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.search.LineageSearchService;
import com.linkedin.metadata.search.SearchService;
import com.linkedin.metadata.search.fixtures.LineageDataFixtureTestBase;
Expand All @@ -10,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Getter
Expand All @@ -35,6 +36,6 @@ public class LineageDataFixtureElasticSearchTest extends LineageDataFixtureTestB

@Test
public void initTest() {
AssertJUnit.assertNotNull(lineageService);
assertNotNull(lineageService);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.search.LineageServiceTestBase;
Expand All @@ -12,7 +14,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({
Expand Down Expand Up @@ -55,14 +56,8 @@ protected SearchConfiguration getSearchConfiguration() {
return _searchConfiguration;
}

@NotNull
@Override
protected CustomSearchConfiguration getCustomSearchConfiguration() {
return _customSearchConfiguration;
}

@Test
public void initTest() {
AssertJUnit.assertNotNull(_searchClient);
assertNotNull(_searchClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.Assert.assertNotNull;

import com.linkedin.entity.client.EntityClient;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.search.SearchService;
import com.linkedin.metadata.search.fixtures.SampleDataFixtureTestBase;
import io.datahubproject.metadata.context.OperationContext;
Expand Down Expand Up @@ -37,6 +38,11 @@ public class SampleDataFixtureElasticSearchTest extends SampleDataFixtureTestBas
@Qualifier("sampleDataOperationContext")
protected OperationContext operationContext;

@Getter
@Autowired
@Qualifier("fixtureCustomSearchConfig")
protected CustomSearchConfiguration customSearchConfiguration;

@Test
public void initTest() {
assertNotNull(searchClient);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.search.query.SearchDAOTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.search.SearchServiceTestBase;
Expand All @@ -12,7 +14,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({
Expand Down Expand Up @@ -55,14 +56,8 @@ protected SearchConfiguration getSearchConfiguration() {
return _searchConfiguration;
}

@NotNull
@Override
protected CustomSearchConfiguration getCustomSearchConfiguration() {
return _customSearchConfiguration;
}

@Test
public void initTest() {
AssertJUnit.assertNotNull(_searchClient);
assertNotNull(_searchClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.search.elasticsearch.indexbuilder.ESIndexBuilder;
import com.linkedin.metadata.search.elasticsearch.update.ESBulkProcessor;
import com.linkedin.metadata.systemmetadata.SystemMetadataServiceTestBase;
Expand All @@ -8,7 +10,6 @@
import org.opensearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({ElasticSearchSuite.class, SearchTestContainerConfiguration.class})
Expand Down Expand Up @@ -38,6 +39,6 @@ protected ESIndexBuilder getIndexBuilder() {

@Test
public void initTest() {
AssertJUnit.assertNotNull(_searchClient);
assertNotNull(_searchClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.linkedin.metadata.search.elasticsearch;

import static org.testng.Assert.assertNotNull;

import com.linkedin.metadata.config.search.SearchConfiguration;
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration;
import com.linkedin.metadata.search.TestEntityTestBase;
Expand All @@ -12,7 +14,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Import;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;

@Import({
Expand Down Expand Up @@ -55,14 +56,8 @@ protected SearchConfiguration getSearchConfiguration() {
return searchConfiguration;
}

@NotNull
@Override
protected CustomSearchConfiguration getCustomSearchConfiguration() {
return customSearchConfiguration;
}

@Test
public void initTest() {
AssertJUnit.assertNotNull(searchClient);
assertNotNull(searchClient);
}
}
Loading

0 comments on commit f8c52d5

Please sign in to comment.