diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2022-04-22 14:47:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 14:47:30 +0200 |
commit | 2c501c1bf34579ea78c8c1230d711b5c51699173 (patch) | |
tree | 475f9b409b358cc325723b387eae380c0712ff1d | |
parent | a4a1648afb40218a61e792660882a79ad986c0a2 (diff) | |
parent | 67a57bd6ab92fc8328183bb820c22ed69b34414e (diff) |
Merge pull request #22221 from vespa-engine/jonmv/fix-job-type-order
Jonmv/fix job type order
3 files changed, 15 insertions, 14 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/zone/ZoneId.java b/config-provisioning/src/main/java/com/yahoo/config/provision/zone/ZoneId.java index 50556e3bad7..0424b1dae16 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/zone/ZoneId.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/zone/ZoneId.java @@ -14,7 +14,6 @@ import java.util.Objects; * @author jonmv */ public class ZoneId { - // TODO: Replace usages of environment + region with usages of this. private final Environment environment; private final RegionName region; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java index 2e8e086b0f3..9e14c4ae8dd 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java @@ -17,6 +17,8 @@ import static com.yahoo.config.provision.Environment.perf; import static com.yahoo.config.provision.Environment.prod; import static com.yahoo.config.provision.Environment.staging; import static com.yahoo.config.provision.Environment.test; +import static java.util.Comparator.naturalOrder; +import static java.util.stream.Collectors.toUnmodifiableList; /** * Specification for a deployment and/or test job to run: what zone, and whether it is a production test. @@ -135,7 +137,8 @@ public final class JobType implements Comparable<JobType> { return zones.zones().controllerUpgraded().zones().stream() .flatMap(zone -> zone.getEnvironment().isProduction() ? Stream.of(deploymentTo(zone.getId()), productionTestOf(zone.getId())) : Stream.of(deploymentTo(zone.getId()))) - .collect(Collectors.toUnmodifiableList()); + .sorted(naturalOrder()) + .collect(toUnmodifiableList()); } /** A serialized form of this: {@code <environment>.<region>[.test]}; the inverse of {@link #ofSerialized(String)} */ @@ -180,13 +183,12 @@ public final class JobType implements Comparable<JobType> { return zone.environment(); } - private static final Comparator<JobType> comparator = Comparator.comparing(JobType::environment) - .thenComparing(JobType::isDeployment) - .thenComparing(JobType::jobName); - @Override public int compareTo(JobType other) { - return comparator.compare(this, other); + int result; + if (0 != (result = environment().compareTo(other.environment()))) return -result; + if (0 != (result = zone.region().compareTo(other.zone.region()))) return result; + return Boolean.compare(isProductionTest, other.isProductionTest); } @Override diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json index 9c34f9410ee..13a6391d5da 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/deployment/responses/root.json @@ -353,21 +353,21 @@ "jobs": [ "system-test", "staging-test", - "production-aws-us-east-1a", - "test-aws-us-east-1a", "production-ap-northeast-1", "test-ap-northeast-1", "production-ap-northeast-2", "test-ap-northeast-2", "production-ap-southeast-1", "test-ap-southeast-1", + "production-aws-us-east-1a", + "test-aws-us-east-1a", + "production-eu-west-1", + "test-eu-west-1", + "production-us-central-1", + "test-us-central-1", "production-us-east-3", "test-us-east-3", "production-us-west-1", - "test-us-west-1", - "production-us-central-1", - "test-us-central-1", - "production-eu-west-1", - "test-eu-west-1" + "test-us-west-1" ] } |