aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-10-08 14:50:28 +0200
committerJon Marius Venstad <venstad@gmail.com>2019-10-08 14:50:28 +0200
commitbdbc7feedfb1ee4767a37e5166a884b71221ba45 (patch)
tree857aa730f482a420977426851af61ea662d781ee /hosted-api
parent1be5a1edc8d308a6be8c4b43a72ce395fec04359 (diff)
Indicate whether test runtime is CI or not, in TestConfig
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java19
-rw-r--r--hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java3
-rw-r--r--hosted-api/src/test/resources/test-config.json1
3 files changed, 17 insertions, 6 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
index c1104c649f2..768b7d9a50c 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java
@@ -28,16 +28,18 @@ public class TestConfig {
private final ApplicationId application;
private final ZoneId zone;
private final SystemName system;
+ private final boolean isCI;
private final Map<ZoneId, Map<String, URI>> deployments;
private final Map<ZoneId, List<String>> contentClusters;
- public TestConfig(ApplicationId application, ZoneId zone, SystemName system, Map<ZoneId, Map<String, URI>> deployments,
- Map<ZoneId, List<String>> contentClusters) {
+ public TestConfig(ApplicationId application, ZoneId zone, SystemName system, boolean isCI,
+ Map<ZoneId, Map<String, URI>> deployments, Map<ZoneId, List<String>> contentClusters) {
if ( ! deployments.containsKey(zone))
throw new IllegalArgumentException("Config must contain a deployment for its zone, but only does for " + deployments.keySet());
this.application = requireNonNull(application);
this.zone = requireNonNull(zone);
this.system = requireNonNull(system);
+ this.isCI = isCI;
this.deployments = deployments.entrySet().stream()
.collect(Collectors.toUnmodifiableMap(entry -> entry.getKey(),
entry -> Map.copyOf(entry.getValue())));
@@ -60,6 +62,7 @@ public class TestConfig {
ApplicationId application = ApplicationId.fromSerializedForm(config.field("application").asString());
ZoneId zone = ZoneId.from(config.field("zone").asString());
SystemName system = SystemName.from(config.field("system").asString());
+ boolean isCI = config.field("isCI").asBool();
Map<ZoneId, Map<String, URI>> deployments = new HashMap<>();
config.field("zoneEndpoints").traverse((ObjectTraverser) (zoneId, clustersObject) -> {
deployments.put(ZoneId.from(zoneId), toClusterMap(clustersObject));
@@ -70,7 +73,7 @@ public class TestConfig {
clustersArray.traverse((ArrayTraverser) (__, cluster) -> clusters.add(cluster.asString()));
contentClusters.put(ZoneId.from(zoneId), clusters);
}));
- return new TestConfig(application, zone, system, deployments, contentClusters);
+ return new TestConfig(application, zone, system, isCI, deployments, contentClusters);
}
static Map<String, URI> toClusterMap(Inspector clustersObject) {
@@ -87,6 +90,7 @@ public class TestConfig {
return new TestConfig(ApplicationId.defaultId(),
ZoneId.defaultId(),
SystemName.defaultSystem(),
+ false,
Map.of(ZoneId.defaultId(), endpoints),
Map.of());
}
@@ -97,13 +101,16 @@ public class TestConfig {
/** Returns the zone of the deployment to test. */
public ZoneId zone() { return zone; }
+ /** Returns the Vespa cloud system this is run against. */
+ public SystemName system() { return system; }
+
+ /** Returns whether this is a CI job (or a local developer environment). */
+ public boolean isCI() { return isCI; }
+
/** Returns an immutable view of deployments, per zone, of the application to test. */
public Map<ZoneId, Map<String, URI>> deployments() { return deployments; }
/** Returns an immutable view of content clusters, per zone, of the application to test. */
public Map<ZoneId, List<String>> contentClusters() { return contentClusters; }
- /** Returns the hosted Vespa system this is run against. */
- public SystemName system() { return system; }
-
}
diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java
index 5ed008cc2ec..9ac02cd9130 100644
--- a/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java
+++ b/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java
@@ -13,6 +13,8 @@ import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* @author jonmv
@@ -28,6 +30,7 @@ public class TestConfigTest {
config.zone());
assertEquals(SystemName.PublicCd,
config.system());
+ assertTrue(config.isCI());
assertEquals(Map.of(ZoneId.from("dev", "aws-us-east-1c"),
Map.of("default", URI.create("https://dev.endpoint:443/")),
ZoneId.from("prod", "aws-us-east-1a"),
diff --git a/hosted-api/src/test/resources/test-config.json b/hosted-api/src/test/resources/test-config.json
index bd337e1c28a..07454efdb66 100644
--- a/hosted-api/src/test/resources/test-config.json
+++ b/hosted-api/src/test/resources/test-config.json
@@ -2,6 +2,7 @@
"application": "t:a:i",
"zone": "dev.aws-us-east-1c",
"system": "publiccd",
+ "isCI": true,
"zoneEndpoints": {
"dev.aws-us-east-1c": {
"default": "https://dev.endpoint:443/"