mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-17 20:08:22 +00:00
lint(test): remove unused imports, other test fixes (#7659)
This commit is contained in:
parent
8963e53bbd
commit
1b15dd484f
@ -1084,7 +1084,7 @@ public class EntityService {
|
||||
logger.accept(String.format(
|
||||
"Reading rows %s through %s from the aspects table completed.", args.start, args.start + args.batchSize));
|
||||
|
||||
for (EbeanAspectV2 aspect : rows.getList()) {
|
||||
for (EbeanAspectV2 aspect : rows != null ? rows.getList() : List.<EbeanAspectV2>of()) {
|
||||
// 1. Extract an Entity type from the entity Urn
|
||||
result.timeGetRowMs = System.currentTimeMillis() - startTime;
|
||||
startTime = System.currentTimeMillis();
|
||||
|
@ -107,6 +107,7 @@ public abstract class RetentionService {
|
||||
GenericAspect retentionAspect = GenericRecordUtils.serializeAspect(retentionConfig);
|
||||
aspectProposal.setAspect(retentionAspect);
|
||||
aspectProposal.setAspectName(Constants.DATAHUB_RETENTION_ASPECT);
|
||||
aspectProposal.setChangeType(ChangeType.UPSERT);
|
||||
return getEntityService().ingestProposal(aspectProposal, auditStamp, false).isDidUpdate();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.linkedin.common.ChangeAuditStamps;
|
||||
import com.linkedin.common.urn.Urn;
|
||||
import com.linkedin.common.urn.UrnUtils;
|
||||
import com.linkedin.data.template.RecordTemplate;
|
||||
import com.linkedin.dataset.Upstream;
|
||||
import com.linkedin.dataset.UpstreamArray;
|
||||
import com.linkedin.dataset.UpstreamLineage;
|
||||
import com.linkedin.identity.CorpUserInfo;
|
||||
@ -14,7 +13,6 @@ import com.linkedin.metadata.key.CorpUserKey;
|
||||
import com.linkedin.metadata.utils.EntityKeyUtils;
|
||||
import com.linkedin.metadata.utils.PegasusUtils;
|
||||
import com.linkedin.mxe.SystemMetadata;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
|
@ -1153,38 +1153,41 @@ abstract public class EntityServiceTest<T_AD extends AspectDao, T_RS extends Ret
|
||||
|
||||
@Test
|
||||
public void testRestoreIndices() throws Exception {
|
||||
String urnStr = "urn:li:dataset:(urn:li:dataPlatform:looker,sample_dataset_unique,PROD)";
|
||||
Urn entityUrn = UrnUtils.getUrn(urnStr);
|
||||
List<Pair<String, RecordTemplate>> pairToIngest = new ArrayList<>();
|
||||
if (this instanceof EbeanEntityServiceTest) {
|
||||
String urnStr = "urn:li:dataset:(urn:li:dataPlatform:looker,sample_dataset_unique,PROD)";
|
||||
Urn entityUrn = UrnUtils.getUrn(urnStr);
|
||||
List<Pair<String, RecordTemplate>> pairToIngest = new ArrayList<>();
|
||||
|
||||
final UpstreamLineage upstreamLineage = AspectGenerationUtils.createUpstreamLineage();
|
||||
String aspectName1 = AspectGenerationUtils.getAspectName(upstreamLineage);
|
||||
pairToIngest.add(getAspectRecordPair(upstreamLineage, UpstreamLineage.class));
|
||||
final UpstreamLineage upstreamLineage = AspectGenerationUtils.createUpstreamLineage();
|
||||
String aspectName1 = AspectGenerationUtils.getAspectName(upstreamLineage);
|
||||
pairToIngest.add(getAspectRecordPair(upstreamLineage, UpstreamLineage.class));
|
||||
|
||||
SystemMetadata metadata1 = AspectGenerationUtils.createSystemMetadata();
|
||||
SystemMetadata metadata1 = AspectGenerationUtils.createSystemMetadata();
|
||||
|
||||
_entityService.ingestAspects(entityUrn, pairToIngest, TEST_AUDIT_STAMP, metadata1);
|
||||
_entityService.ingestAspects(entityUrn, pairToIngest, TEST_AUDIT_STAMP, metadata1);
|
||||
|
||||
clearInvocations(_mockProducer);
|
||||
clearInvocations(_mockProducer);
|
||||
|
||||
RestoreIndicesArgs args = new RestoreIndicesArgs();
|
||||
args.setAspectName(UPSTREAM_LINEAGE_ASPECT_NAME);
|
||||
args.setBatchSize(1);
|
||||
args.setStart(0);
|
||||
args.setBatchDelayMs(1L);
|
||||
args.setNumThreads(1);
|
||||
args.setUrn(urnStr);
|
||||
_entityService.restoreIndices(args, obj -> { });
|
||||
RestoreIndicesArgs args = new RestoreIndicesArgs();
|
||||
args.setAspectName(UPSTREAM_LINEAGE_ASPECT_NAME);
|
||||
args.setBatchSize(1);
|
||||
args.setStart(0);
|
||||
args.setBatchDelayMs(1L);
|
||||
args.setNumThreads(1);
|
||||
args.setUrn(urnStr);
|
||||
_entityService.restoreIndices(args, obj -> {
|
||||
});
|
||||
|
||||
ArgumentCaptor<MetadataChangeLog> mclCaptor = ArgumentCaptor.forClass(MetadataChangeLog.class);
|
||||
verify(_mockProducer, times(1)).produceMetadataChangeLog(
|
||||
Mockito.eq(entityUrn), Mockito.any(), mclCaptor.capture());
|
||||
MetadataChangeLog mcl = mclCaptor.getValue();
|
||||
assertEquals(mcl.getEntityType(), "dataset");
|
||||
assertNull(mcl.getPreviousAspectValue());
|
||||
assertNull(mcl.getPreviousSystemMetadata());
|
||||
assertEquals(mcl.getChangeType(), ChangeType.RESTATE);
|
||||
assertEquals(mcl.getSystemMetadata().getProperties().get(FORCE_INDEXING_KEY), "true");
|
||||
ArgumentCaptor<MetadataChangeLog> mclCaptor = ArgumentCaptor.forClass(MetadataChangeLog.class);
|
||||
verify(_mockProducer, times(1)).produceMetadataChangeLog(
|
||||
Mockito.eq(entityUrn), Mockito.any(), mclCaptor.capture());
|
||||
MetadataChangeLog mcl = mclCaptor.getValue();
|
||||
assertEquals(mcl.getEntityType(), "dataset");
|
||||
assertNull(mcl.getPreviousAspectValue());
|
||||
assertNull(mcl.getPreviousSystemMetadata());
|
||||
assertEquals(mcl.getChangeType(), ChangeType.RESTATE);
|
||||
assertEquals(mcl.getSystemMetadata().getProperties().get(FORCE_INDEXING_KEY), "true");
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -22,7 +22,7 @@ import com.linkedin.gms.factory.timeseries.TimeseriesAspectServiceFactory;
|
||||
import com.linkedin.metadata.Constants;
|
||||
import com.linkedin.metadata.graph.Edge;
|
||||
import com.linkedin.metadata.graph.GraphService;
|
||||
import com.linkedin.metadata.graph.elastic.ElasticSearchGraphService;
|
||||
import com.linkedin.metadata.graph.dgraph.DgraphGraphService;
|
||||
import com.linkedin.metadata.key.SchemaFieldKey;
|
||||
import com.linkedin.metadata.models.AspectSpec;
|
||||
import com.linkedin.metadata.models.EntitySpec;
|
||||
@ -179,7 +179,7 @@ public class UpdateIndicesHook implements MetadataChangeLogHook {
|
||||
|
||||
// Step 2. For all aspects, attempt to update Graph
|
||||
SystemMetadata systemMetadata = event.getSystemMetadata();
|
||||
if (_graphDiffMode && !(_graphService instanceof DGraphGraphService)
|
||||
if (_graphDiffMode && !(_graphService instanceof DgraphGraphService)
|
||||
&& (systemMetadata == null || systemMetadata.getProperties() == null
|
||||
|| !Boolean.parseBoolean(systemMetadata.getProperties().get(FORCE_INDEXING_KEY)))) {
|
||||
updateGraphServiceDiff(urn, aspectSpec, previousAspect, aspect, event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user