summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-03-05 11:00:52 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-03-05 11:10:11 +0100
commitad5f5c22b4e9a9612073eb863abf0e6441fab0ed (patch)
tree8cd9ccf6a9cf7efbcd613cd6f8d4016ddff4a874 /controller-api
parent21ffbf56b2d6ef21c55641d5fc41460f8a2e6d47 (diff)
Validate CNAMEs and IP lookup after deployment
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java14
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java20
2 files changed, 23 insertions, 11 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
index b76af2b2d51..f09340ce470 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java
@@ -1,11 +1,14 @@
// Copyright 2018 Yahoo Holdings. 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.HostName;
+import com.yahoo.config.provision.zone.RoutingMethod;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import java.net.URI;
import java.util.List;
+import java.util.Optional;
/**
* Allows running some predefined tests -- typically remotely.
@@ -29,14 +32,11 @@ public interface TesterCloud {
/** Returns whether the test container is ready to serve */
boolean testerReady(DeploymentId deploymentId);
- /** Returns whether the given URL is registered in DNS. */
- boolean exists(URI endpointUrl);
+ /** Returns the IP address of the given host name, if any. */
+ Optional<String> resolveHostName(HostName hostname);
- /**
- * Returns whether the given URL is registered in DNS. Always returns true,
- * as endpoints are not use in this case
- */
- default boolean exists(DeploymentId deploymentId) { return true; }
+ /** Returns the host name of the given CNAME, if any. */
+ Optional<HostName> resolveCName(HostName hostName);
enum Status {
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
index 5f315ec1456..f5594e60202 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
@@ -1,13 +1,19 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.stubs;
+import com.yahoo.config.provision.HostName;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud;
+import com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService;
+import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService;
+import com.yahoo.vespa.hosted.controller.api.integration.dns.Record;
+import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.stream.Collectors;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud.Status.NOT_STARTED;
@@ -15,10 +21,14 @@ import static com.yahoo.vespa.hosted.controller.api.integration.deployment.Teste
public class MockTesterCloud implements TesterCloud {
+ private final NameService cNames;
+
private List<LogEntry> log = new ArrayList<>();
private Status status = NOT_STARTED;
private byte[] config;
+ public MockTesterCloud(NameService cNames) {
+ this.cNames = cNames;
}
@Override
@@ -46,13 +56,15 @@ public class MockTesterCloud implements TesterCloud {
}
@Override
- public boolean exists(URI endpointUrl) {
- return true;
+ public Optional<String> resolveHostName(HostName hostname) {
+ return Optional.of("1.2.3.4");
}
@Override
- public boolean exists(DeploymentId deploymentId) {
- return true;
+ public Optional<HostName> resolveCName(HostName hostName) {
+ return cNames.findRecords(Record.Type.CNAME, RecordName.from(hostName.value())).stream()
+ .findFirst()
+ .map(record -> HostName.from(record.data().asString().substring(0, record.data().asString().length() - 1)));
}
public void add(LogEntry entry) {