summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-11-05 13:40:08 +0100
committerJon Marius Venstad <venstad@gmail.com>2019-11-06 12:08:46 +0100
commite61643c5e0e2c42a362c88613e321cd96b1488a9 (patch)
tree1e6e7dc623e938e2941397d7ddd3d7e66eb1f553
parent2c8bb1153a6d9834c573e99a786637a5da52eee5 (diff)
Steps are either test or production
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java35
1 files changed, 18 insertions, 17 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
index 33db6b95db1..d4fb97a6d87 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentSteps.java
@@ -14,10 +14,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-import static java.util.Collections.singletonList;
import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.collectingAndThen;
@@ -40,7 +40,7 @@ public class DeploymentSteps {
public List<JobType> jobs() {
return spec.steps().stream()
.flatMap(step -> toJobs(step).stream())
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .collect(Collectors.toUnmodifiableList());
}
/** Returns job status sorted according to deployment spec */
@@ -48,7 +48,7 @@ public class DeploymentSteps {
List<JobType> sortedJobs = jobs();
return jobStatus.stream()
.sorted(comparingInt(job -> sortedJobs.indexOf(job.type())))
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .collect(Collectors.toUnmodifiableList());
}
/** Returns deployments sorted according to declared zones */
@@ -56,7 +56,7 @@ public class DeploymentSteps {
List<ZoneId> productionZones = spec.zones().stream()
.filter(z -> z.region().isPresent())
.map(z -> ZoneId.from(z.environment(), z.region().get()))
- .collect(Collectors.toList());
+ .collect(Collectors.toUnmodifiableList());
return deployments.stream()
.sorted(comparingInt(deployment -> productionZones.indexOf(deployment.zone())))
.collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
@@ -67,34 +67,35 @@ public class DeploymentSteps {
return step.zones().stream()
.map(this::toJob)
.flatMap(Optional::stream)
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .collect(Collectors.toUnmodifiableList());
}
- /** Returns test jobs in this */
+ /** Returns declared test jobs in this */
public List<JobType> testJobs() {
return toJobs(test());
}
- /** Returns production jobs in this */
+ /** Returns declared production jobs in this */
public List<JobType> productionJobs() {
return toJobs(production());
}
- /** Returns test steps in this */
+ /** Returns declared test steps in this */
public List<DeploymentSpec.Step> test() {
- if (spec.steps().isEmpty()) {
- return singletonList(new DeploymentSpec.DeclaredZone(Environment.test));
- }
return spec.steps().stream()
- .filter(step -> step.deploysTo(Environment.test) || step.deploysTo(Environment.staging))
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .filter(step -> isTest(step))
+ .collect(Collectors.toUnmodifiableList());
}
- /** Returns production steps in this */
+ /** Returns declared production steps in this */
public List<DeploymentSpec.Step> production() {
return spec.steps().stream()
- .filter(step -> step.deploysTo(Environment.prod) || step.zones().isEmpty())
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .filter(step -> ! isTest(step))
+ .collect(Collectors.toUnmodifiableList());
+ }
+
+ private boolean isTest(DeploymentSpec.Step step) {
+ return step.deploysTo(Environment.test) || step.deploysTo(Environment.staging);
}
/** Resolve job from deployment zone */
@@ -106,7 +107,7 @@ public class DeploymentSteps {
private List<JobType> toJobs(List<DeploymentSpec.Step> steps) {
return steps.stream()
.flatMap(step -> toJobs(step).stream())
- .collect(collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
+ .collect(Collectors.toUnmodifiableList());
}
}