fix(test): consolidate mae-consumer test entity registry (#8309)

This commit is contained in:
david-leifker 2023-06-27 02:58:34 -05:00 committed by GitHub
parent cbac747392
commit 3dba524b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 12 deletions

View File

@ -0,0 +1,18 @@
package com.linkedin.metadata.kafka.hook;
import com.linkedin.data.schema.annotation.PathSpecBasedSchemaAnnotationVisitor;
import com.linkedin.metadata.models.registry.ConfigEntityRegistry;
import com.linkedin.metadata.models.registry.EntityRegistry;
public class EntityRegistryTestUtil {
private EntityRegistryTestUtil() {
}
public static final EntityRegistry ENTITY_REGISTRY;
static {
EntityRegistryTestUtil.class.getClassLoader().setClassAssertionStatus(PathSpecBasedSchemaAnnotationVisitor.class.getName(), false);
ENTITY_REGISTRY = new ConfigEntityRegistry(
EntityRegistryTestUtil.class.getClassLoader().getResourceAsStream("test-entity-registry.yml"));
}
}

View File

@ -17,7 +17,6 @@ import com.linkedin.metadata.models.AspectSpec;
import com.linkedin.metadata.models.EntitySpec;
import com.linkedin.metadata.models.RelationshipFieldSpec;
import com.linkedin.metadata.models.extractor.FieldExtractor;
import com.linkedin.metadata.models.registry.ConfigEntityRegistry;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.utils.GenericRecordUtils;
import com.linkedin.mxe.MetadataChangeLog;
@ -31,6 +30,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static com.linkedin.metadata.graph.GraphIndexUtils.*;
import static com.linkedin.metadata.kafka.hook.EntityRegistryTestUtil.ENTITY_REGISTRY;
import static org.testng.Assert.*;
@ -57,8 +57,7 @@ public class GraphIndexUtilsTest {
_datasetUrn = UrnUtils.getUrn("urn:li:dataset:(urn:li:dataPlatform:bigquery,my-proj.jaffle_shop.customers,PROD)");
_upstreamDataset1 = UrnUtils.toDatasetUrn("snowflake", "test", "DEV");
_upstreamDataset2 = UrnUtils.toDatasetUrn("snowflake", "test2", "DEV");
_mockRegistry = new ConfigEntityRegistry(
UpdateIndicesHookTest.class.getClassLoader().getResourceAsStream("test-entity-registry.yml"));
_mockRegistry = ENTITY_REGISTRY;
}
@Test

View File

@ -29,7 +29,6 @@ import com.linkedin.metadata.graph.elastic.ElasticSearchGraphService;
import com.linkedin.metadata.key.ChartKey;
import com.linkedin.metadata.models.AspectSpec;
import com.linkedin.metadata.models.EntitySpec;
import com.linkedin.metadata.models.registry.ConfigEntityRegistry;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.query.filter.ConjunctiveCriterionArray;
import com.linkedin.metadata.query.filter.Filter;
@ -54,6 +53,7 @@ import java.util.ArrayList;
import java.util.Collections;
import static com.linkedin.metadata.Constants.*;
import static com.linkedin.metadata.kafka.hook.EntityRegistryTestUtil.ENTITY_REGISTRY;
import static com.linkedin.metadata.kafka.hook.MCLProcessingTestDataGenerator.*;
import static com.linkedin.metadata.search.utils.QueryUtils.newRelationshipFilter;
@ -88,8 +88,6 @@ public class UpdateIndicesHookTest {
@BeforeMethod
public void setupTest() {
_actorUrn = UrnUtils.getUrn(TEST_ACTOR_URN);
EntityRegistry registry = new ConfigEntityRegistry(
UpdateIndicesHookTest.class.getClassLoader().getResourceAsStream("test-entity-registry.yml"));
_mockGraphService = Mockito.mock(ElasticSearchGraphService.class);
_mockEntitySearchService = Mockito.mock(EntitySearchService.class);
_mockTimeseriesAspectService = Mockito.mock(TimeseriesAspectService.class);
@ -106,7 +104,7 @@ public class UpdateIndicesHookTest {
_mockEntitySearchService,
_mockTimeseriesAspectService,
_mockSystemMetadataService,
registry,
ENTITY_REGISTRY,
_searchDocumentTransformer
);
_updateIndicesHook = new UpdateIndicesHook(

View File

@ -6,8 +6,6 @@ import com.linkedin.events.metadata.ChangeType;
import com.linkedin.ingestion.DataHubIngestionSourceConfig;
import com.linkedin.ingestion.DataHubIngestionSourceInfo;
import com.linkedin.ingestion.DataHubIngestionSourceSchedule;
import com.linkedin.metadata.models.registry.ConfigEntityRegistry;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.utils.GenericRecordUtils;
import com.linkedin.mxe.MetadataChangeLog;
import org.mockito.Mockito;
@ -16,6 +14,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static com.linkedin.metadata.Constants.*;
import static com.linkedin.metadata.kafka.hook.EntityRegistryTestUtil.ENTITY_REGISTRY;
public class IngestionSchedulerHookTest {
@ -23,10 +22,8 @@ public class IngestionSchedulerHookTest {
@BeforeMethod
public void setupTest() {
EntityRegistry registry = new ConfigEntityRegistry(
IngestionSchedulerHookTest.class.getClassLoader().getResourceAsStream("test-entity-registry.yml"));
IngestionScheduler mockScheduler = Mockito.mock(IngestionScheduler.class);
_ingestionSchedulerHook = new IngestionSchedulerHook(registry, mockScheduler, true);
_ingestionSchedulerHook = new IngestionSchedulerHook(ENTITY_REGISTRY, mockScheduler, true);
}
@Test