Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint(test): fix unused imports #4

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ public RestoreIndicesResult restoreIndices(@Nonnull RestoreIndicesArgs args, @No
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public boolean setRetention(@Nullable String entityName, @Nullable String aspect
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
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;
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;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,38 +1153,41 @@ protected <T extends RecordTemplate> T simulatePullFromDB(T aspect, Class<T> cla

@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<>();

final UpstreamLineage upstreamLineage = AspectGenerationUtils.createUpstreamLineage();
String aspectName1 = AspectGenerationUtils.getAspectName(upstreamLineage);
pairToIngest.add(getAspectRecordPair(upstreamLineage, UpstreamLineage.class));

SystemMetadata metadata1 = AspectGenerationUtils.createSystemMetadata();

_entityService.ingestAspects(entityUrn, pairToIngest, TEST_AUDIT_STAMP, metadata1);

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 -> { });

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");
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));

SystemMetadata metadata1 = AspectGenerationUtils.createSystemMetadata();

_entityService.ingestAspects(entityUrn, pairToIngest, TEST_AUDIT_STAMP, metadata1);

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 -> {
});

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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;
Expand Down Expand Up @@ -179,7 +179,7 @@ private void handleUpdateChangeEvent(@Nonnull final MetadataChangeLog event) {

// 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);
Expand Down