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

perf(artifacts): use pageSize=1 when resolving prior artifacts #2955

Merged
merged 3 commits into from
Jun 4, 2019
Merged
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 @@ -252,8 +252,7 @@ public void resolveArtifacts(@Nonnull Map<String, Object> pipeline) {
return;
}

List<Artifact> priorArtifacts =
getArtifactsForPipelineId((String) pipeline.get("id"), new ExecutionCriteria());
List<Artifact> priorArtifacts = getPriorArtifacts(pipeline);
LinkedHashSet<Artifact> resolvedArtifacts =
resolveExpectedArtifacts(expectedArtifacts, receivedArtifacts, priorArtifacts, true);
LinkedHashSet<Artifact> allArtifacts = new LinkedHashSet<>(receivedArtifacts);
Expand All @@ -277,6 +276,16 @@ public void resolveArtifacts(@Nonnull Map<String, Object> pipeline) {
}
}

private List<Artifact> getPriorArtifacts(final Map<String, Object> pipeline) {
// set pageSize to a single record to avoid hydrating all of the stored Executions for
// the pipeline, since getArtifactsForPipelineId only uses the most recent Execution from the
// returned Observable<Execution>
ExecutionCriteria criteria = new ExecutionCriteria();
criteria.setPageSize(1);
criteria.setSortType(ExecutionRepository.ExecutionComparator.START_TIME_OR_ID);
return getArtifactsForPipelineId((String) pipeline.get("id"), criteria);
}

public Artifact resolveSingleArtifact(
ExpectedArtifact expectedArtifact,
List<Artifact> possibleMatches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,20 @@ import static com.netflix.spinnaker.orca.test.model.ExecutionBuilder.stage

class ArtifactResolverSpec extends Specification {
ObjectMapper objectMapper = new ObjectMapper()

def pipelineId = "abc"

def expectedExecutionCriteria = {
def criteria = new ExecutionRepository.ExecutionCriteria()
criteria.setPageSize(1)
return criteria
}()

def executionRepository = Stub(ExecutionRepository) {
retrievePipelinesForPipelineConfigId(*_) >> Observable.empty();
// only a call to retrievePipelinesForPipelineConfigId() with these argument values is expected
retrievePipelinesForPipelineConfigId(pipelineId, expectedExecutionCriteria) >> Observable.empty();
// any other interaction is unexpected
0 * _
}

def makeArtifactResolver() {
Expand Down