summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2022-06-27 22:00:43 +0200
committerGitHub <noreply@github.com>2022-06-27 22:00:43 +0200
commit73c88cff03651415648b63f4458df20254a5629a (patch)
tree3c50df4717c4867061059a3f41b6a6e2e8f0fefd /controller-api
parent24c7eee36b9c251fc754e6ca51c921e97be44aeb (diff)
Revert "Jonmv/multiple test and staging zones"
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java54
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java2
2 files changed, 20 insertions, 36 deletions
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 3ecf350b0b5..77879699ab9 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
@@ -1,13 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.deployment;
-import com.yahoo.config.provision.Cloud;
-import com.yahoo.config.provision.CloudName;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.RegionName;
-import com.yahoo.config.provision.zone.ZoneApi;
import com.yahoo.config.provision.zone.ZoneId;
-import com.yahoo.config.provision.zone.ZoneList;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry;
import java.util.Comparator;
@@ -42,24 +38,18 @@ public final class JobType implements Comparable<JobType> {
}
/** A system test in a test zone, or throws if no test zones are present.. */
- public static JobType systemTest(ZoneRegistry zones, CloudName cloud) {
- return testIn(test, zones, cloud);
+ public static JobType systemTest(ZoneRegistry zones) {
+ return testIn(test, zones);
}
/** A staging test in a staging zone, or throws if no staging zones are present. */
- public static JobType stagingTest(ZoneRegistry zones, CloudName cloud){
- return testIn(staging, zones, cloud);
+ public static JobType stagingTest(ZoneRegistry zones){
+ return testIn(staging, zones);
}
- /** Returns a test job in the given environment, preferring the given cloud, is possible; using the system cloud otherwise. */
- private static JobType testIn(Environment environment, ZoneRegistry zones, CloudName cloud) {
- ZoneList candidates = zones.zones().controllerUpgraded().in(environment);
- if (cloud == null || candidates.in(cloud).zones().isEmpty())
- cloud = zones.systemZone().getCloudName();
-
- return candidates.in(cloud).zones().stream().map(zone -> deploymentTo(zone.getId()))
- .findFirst().orElseThrow(() -> new IllegalArgumentException("no zones in " + environment + " among " +
- zones.zones().controllerUpgraded().zones()));
+ private static JobType testIn(Environment environment, ZoneRegistry zones) {
+ return zones.zones().controllerUpgraded().in(environment).zones().stream().map(zone -> deploymentTo(zone.getId()))
+ .findFirst().orElseThrow(() -> new IllegalArgumentException("no zones in " + environment + " among " + zones.zones().controllerUpgraded().zones()));
}
/** A deployment to the given dev region. */
@@ -128,33 +118,27 @@ public final class JobType implements Comparable<JobType> {
throw new IllegalArgumentException("illegal serialized job type '" + raw + "'");
}
- /**
- * Creates a new job type from a job name, and a zone registry for looking up zones for the special system and staging test types.
- * Note: system and staging tests retrieved by job name always use the default cloud for the system!
- */
+ /** Creates a new job type from a job name, and a zone registry for looking up zones for the special system and staging test types. */
public static JobType fromJobName(String jobName, ZoneRegistry zones) {
- switch (jobName) {
- case "system-test": return systemTest(zones, null);
- case "staging-test": return stagingTest(zones, null);
- }
String[] parts = jobName.split("-", 2);
- if (parts.length == 2)
- switch (parts[0]) {
- case "production": return prod(parts[1]);
- case "test": return test(parts[1]);
- case "dev": return dev(parts[1]);
- case "perf": return perf(parts[1]);
- }
- throw new IllegalArgumentException("job names must be 'system-test', 'staging-test', or <test|environment>-<region>, but got: " + jobName);
+ if (parts.length != 2) throw new IllegalArgumentException("job names must be 'system-test', 'staging-test', or environment and region parts, separated by '-', but got: " + jobName);
+ switch (parts[0]) {
+ case "system": return systemTest(zones);
+ case "staging": return stagingTest(zones);
+ case "production": return prod(parts[1]);
+ case "test": return test(parts[1]);
+ case "dev": return dev(parts[1]);
+ case "perf": return perf(parts[1]);
+ default: throw new IllegalArgumentException("job names must begin with one of: system, staging, production, test, dev, perf; but got: " + jobName);
+ }
}
public static List<JobType> allIn(ZoneRegistry zones) {
return zones.zones().reachable().zones().stream()
.flatMap(zone -> zone.getEnvironment().isProduction() ? Stream.of(deploymentTo(zone.getId()), productionTestOf(zone.getId()))
: Stream.of(deploymentTo(zone.getId())))
- .distinct()
.sorted(naturalOrder())
- .toList();
+ .collect(toUnmodifiableList());
}
/** A serialized form of this: {@code &lt;environment&gt;.&lt;region&gt;[.test]}; the inverse of {@link #ofSerialized(String)} */
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java
index bbe0c2bd458..6ff52bd5f03 100644
--- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java
+++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobTypeTest.java
@@ -48,4 +48,4 @@ public class JobTypeTest {
assertTrue(JobType.test("snohetta").isProduction());
}
-} \ No newline at end of file
+}