summaryrefslogtreecommitdiffstats
path: root/tenant-cd
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-08-21 14:00:33 +0200
committerJon Marius Venstad <venstad@gmail.com>2019-08-21 14:00:33 +0200
commit6a06c69162529273a386cd2a9c4cbac87eacce03 (patch)
tree6b87c46efbeeb61c011fae6a2bd99ad34d708ee7 /tenant-cd
parentb0c5517a54ce356abf0dd6cd5705846675ccf0db (diff)
Remove currently unused things from test library API
Diffstat (limited to 'tenant-cd')
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java6
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Digest.java28
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Document.java16
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/DocumentId.java71
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Endpoint.java18
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Feed.java25
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Query.java70
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Search.java32
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Selection.java58
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/TestDeployment.java18
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/TestEndpoint.java13
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/TestRuntime.java24
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/Visit.java17
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/VisitEndpoint.java10
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpDeployment.java29
-rw-r--r--tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpEndpoint.java61
16 files changed, 28 insertions, 468 deletions
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java
index e0abdde4687..0503e553e17 100644
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java
+++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java
@@ -7,13 +7,7 @@ package ai.vespa.hosted.cd;
*/
public interface Deployment {
- /** Returns an Endpoint in the cluster with the "default" id. */
- Endpoint endpoint();
-
/** Returns an Endpoint in the cluster with the given id. */
Endpoint endpoint(String id);
- /** Returns a {@link TestDeployment} view of this, or throws if this is a production deployment. */
- TestDeployment asTestDeployment();
-
}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Digest.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Digest.java
deleted file mode 100644
index dee13fdca13..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Digest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.util.Set;
-
-/**
- * An immutable report of the outcome of a {@link Feed} sent to a {@link TestEndpoint}.
- *
- * @author jonmv
- */
-public class Digest {
-
- public Set<DocumentId> created() {
- return null;
- }
-
- public Set<DocumentId> updated() {
- return null;
- }
-
- public Set<DocumentId> deleted() {
- return null;
- }
-
- public Set<DocumentId> failed() {
- return null;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Document.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Document.java
deleted file mode 100644
index 91adeded65c..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Document.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package ai.vespa.hosted.cd;
-
-/**
- * A schema-less representation of a generic Vespa document.
- *
- * @author jonmv
- */
-public class Document {
-
-
- /** Returns a copy of this document, updated with the data in the given document. */
- public Document updatedBy(Document update) {
- return null;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/DocumentId.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/DocumentId.java
deleted file mode 100644
index 9aa8e80c977..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/DocumentId.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Unique, immutable ID of a Vespa document, which contains information pertinent to its storage.
- *
- * @author jonmv
- */
-public class DocumentId {
-
- private final String namespace;
- private final String documentType;
- private final String group;
- private final Long number;
- private final String userDefined;
-
- private DocumentId(String namespace, String documentType, String group, Long number, String userDefined) {
- this.namespace = namespace;
- this.documentType = documentType;
- this.group = group;
- this.number = number;
- this.userDefined = userDefined;
- }
-
- public static DocumentId of(String namespace, String documentType, String id) {
- return new DocumentId(requireNonEmpty(namespace), requireNonEmpty(documentType), null, null, requireNonEmpty(id));
- }
-
- public static DocumentId of(String namespace, String documentType, String group, String id) {
- return new DocumentId(requireNonEmpty(namespace), requireNonEmpty(documentType), requireNonEmpty(group), null, requireNonEmpty(id));
- }
-
- public static DocumentId of(String namespace, String documentType, long number, String id) {
- return new DocumentId(requireNonEmpty(namespace), requireNonEmpty(documentType), null, number, requireNonEmpty(id));
- }
-
- public static DocumentId ofValue(String value) {
- List<String> parts = Arrays.asList(value.split(":"));
- String id = String.join(":", parts.subList(4, parts.size()));
- if ( parts.size() < 5
- || ! parts.get(0).equals("id")
- || id.isEmpty()
- || ! parts.get(3).matches("((n=\\d+)|(g=\\w+))?"))
- throw new IllegalArgumentException("Document id must be on the form" +
- " 'id:<namespace>:<document type>:n=<integer>|g=<name>|<empty>:<user defined id>'," +
- " but was '" + value + "'.");
-
- if (parts.get(3).matches("n=\\d+"))
- return of(parts.get(1), parts.get(2), Long.parseLong(parts.get(3).substring(2)), id);
- if (parts.get(3).matches("g=\\w+"))
- return of(parts.get(1), parts.get(2), parts.get(3).substring(2), id);
- return of(parts.get(1), parts.get(2), id);
- }
-
- public String asValue() {
- return "id:" + namespace + ":" + documentType + ":" + grouper() + ":" + userDefined;
- }
-
- private String grouper() {
- return group != null ? group : number != null ? number.toString() : "";
- }
-
- private static String requireNonEmpty(String string) {
- if (string.isEmpty())
- throw new IllegalArgumentException("The empty string is not allowed.");
- return string;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Endpoint.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Endpoint.java
index dbbb969efe2..fa6422d80e6 100644
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Endpoint.java
+++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Endpoint.java
@@ -1,29 +1,33 @@
package ai.vespa.hosted.cd;
+import ai.vespa.hosted.api.EndpointAuthenticator;
import ai.vespa.hosted.cd.metric.Metrics;
import java.net.URI;
+import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* An endpoint in a Vespa application {@link Deployment}, which allows document and metrics retrieval.
*
- * The endpoint translates {@link Query}s to {@link Search}s, and {@link Selection}s to {@link Visit}s.
- * It also supplies {@link Metrics}.
- *
* @author jonmv
*/
public interface Endpoint {
- URI uri();
+ /** Returns the URI of the endpoint, with scheme, host and port. */
+ URI hostUri();
+ /** Sends the given request with required authentication. See {@link EndpointAuthenticator#authenticated} and {@link HttpClient#send}. */
<T> HttpResponse<T> send(HttpRequest.Builder request, HttpResponse.BodyHandler<T> handler);
- Search search(Query query);
+ /** Sends the given request with required authentication. */
+ default HttpResponse<String> send(HttpRequest.Builder request) {
+ return send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
+ }
- Visit visit(Selection selection);
- Metrics metrics();
}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Feed.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Feed.java
deleted file mode 100644
index e9a0a0aeff0..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Feed.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An immutable set of document feed / update / delete operations, which can be sent to a Vespa {@link TestEndpoint}.
- *
- * @author jonmv
- */
-public class Feed {
-
- Map<DocumentId, Document> creations() {
- return null;
- }
-
- Map<DocumentId, Document> updates() {
- return null;
- }
-
- Set<DocumentId> deletions() {
- return null;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Query.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Query.java
deleted file mode 100644
index 9895f9df3a2..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Query.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.time.Duration;
-import java.time.temporal.ChronoUnit;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import static java.util.Map.copyOf;
-import static java.util.stream.Collectors.joining;
-import static java.util.stream.Collectors.toUnmodifiableMap;
-
-/**
- * An immutable query to send to a Vespa {@link Endpoint}, to receive a {@link Search}.
- *
- * @author jonmv
- */
-public class Query {
-
- private final String rawQuery;
- private final Map<String, String> parameters;
-
- private Query(String rawQuery, Map<String, String> parameters) {
- this.rawQuery = rawQuery;
- this.parameters = parameters;
- }
-
- /** Creates a query with the given raw query part, e.g. {@code Query.ofRaw("yql=select * ...")}. */
- public static Query ofRaw(String rawQuery) {
- if (rawQuery.isBlank())
- throw new IllegalArgumentException("Query can not be blank.");
-
- return new Query(rawQuery,
- Stream.of(rawQuery.split("&"))
- .map(pair -> pair.split("="))
- .collect(toUnmodifiableMap(pair -> pair[0], pair -> pair[1])));
- }
-
- /** Creates a query with the given name-value pairs, e.g. {@code Query.ofParameters(Map.of("yql", "select * ..."))}. */
- public static Query ofParameters(Map<String, String> parameters) {
- if (parameters.isEmpty())
- throw new IllegalArgumentException("Parameters can not be empty.");
-
- return new Query(parameters.entrySet().stream()
- .map(entry -> entry.getKey() + "=" + entry.getValue())
- .collect(joining("&")),
- copyOf(parameters));
- }
-
- /** Returns a copy of this with the given name-value pair added, potentially overriding any current value. */
- public Query withParameter(String name, String value) {
- return ofParameters(Stream.concat(parameters.entrySet().stream().filter(entry -> ! entry.getKey().equals(name)),
- Stream.of(Map.entry(name, value)))
- .collect(toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)));
- }
-
- /** Returns the raw string representation of this query. */
- public String rawQuery() { return rawQuery; }
-
- /** Returns the parameters of this query. */
- public Map<String, String> parameters() { return parameters; }
-
- /** Returns the timeout parameter of the request, if one is set. */
- public Optional<Duration> timeout() {
- return Optional.ofNullable(parameters.get("timeout"))
- .map(timeout -> Duration.of(Long.parseLong(timeout.replaceAll("\\s*m?s", "")),
- timeout.contains("ms") ? ChronoUnit.MILLIS : ChronoUnit.SECONDS));
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Search.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Search.java
deleted file mode 100644
index ace6262bb7c..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Search.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.util.Map;
-
-/**
- * The immutable result of sending a {@link Query} to a Vespa {@link Endpoint}.
- *
- * @author jonmv
- */
-public class Search {
-
- private final String raw;
-
- public Search(String raw) {
- this.raw = raw;
- }
-
- public String rawOutput() { return raw; }
-
- // hits
- // coverage
- // searched
- // full?
- // results?
- // resultsFull?
-
- /** Returns the documents that were returned as the result, with iteration order as returned. */
- Map<DocumentId, Document> documents() {
- return null;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Selection.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Selection.java
deleted file mode 100644
index 158ae279cb6..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Selection.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ai.vespa.hosted.cd;
-
-/**
- * A document selection expression, type and cluster, which can be used to visit an {@link Endpoint}.
- *
- * @author jonmv
- */
-public class Selection {
-
- private final String selection;
- private final String namespace;
- private final String type;
- private final String group;
- private final String cluster;
- private final int concurrency;
-
- private Selection(String selection, String namespace, String type, String group, String cluster, int concurrency) {
- this.selection = selection;
- this.namespace = namespace;
- this.type = type;
- this.group = group;
- this.cluster = cluster;
- this.concurrency = concurrency;
- }
-
- /** Returns a new selection which will visit documents in the given cluster. */
- public static Selection in(String cluster) {
- if (cluster.isBlank()) throw new IllegalArgumentException("Cluster name can not be blank.");
- return new Selection(null, null, null, cluster, null, 1);
- }
-
- /** Returns a new selection which will visit documents in the given namespace and of the given type. */
- public static Selection of(String namespace, String type) {
- if (namespace.isBlank()) throw new IllegalArgumentException("Namespace can not be blank.");
- if (type.isBlank()) throw new IllegalArgumentException("Document type can not be blank.");
- return new Selection(null, namespace, type, null, null, 1);
- }
-
- /** Returns a copy of this with the given selection criterion set. */
- public Selection matching(String selection) {
- if (selection.isBlank()) throw new IllegalArgumentException("Selection can not be blank.");
- return new Selection(selection, namespace, type, cluster, group, concurrency);
- }
-
- /** Returns a copy of this selection, with the group set to the specified value. Requires namespace and type to be set. */
- public Selection limitedTo(String group) {
- if (namespace == null || type == null) throw new IllegalArgumentException("Namespace and type must be specified to set group.");
- if (group.isBlank()) throw new IllegalArgumentException("Group name can not be blank.");
- return new Selection(selection, namespace, type, cluster, group, concurrency);
- }
-
- /** Returns a copy of this, with concurrency set to the given positive value. */
- public Selection concurrently(int concurrency) {
- if (concurrency < 1) throw new IllegalArgumentException("Concurrency must be a positive integer.");
- return new Selection(selection, namespace, type, cluster, group, concurrency);
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestDeployment.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestDeployment.java
deleted file mode 100644
index bc00b6e0dc6..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestDeployment.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package ai.vespa.hosted.cd;
-
-/**
- * A deployment of a Vespa application, which also contains endpoints for document manipulation.
- *
- * @author jonmv
- */
-public interface TestDeployment extends Deployment {
-
- /** Returns a {@link TestEndpoint} in the cluster with the "default" id. */
- @Override
- TestEndpoint endpoint();
-
- /** Returns a {@link TestEndpoint} in the cluster with the given id. */
- @Override
- TestEndpoint endpoint(String id);
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestEndpoint.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestEndpoint.java
deleted file mode 100644
index f6f8a722f19..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestEndpoint.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package ai.vespa.hosted.cd;
-
-/**
- * An endpoint in a Vespa application {@link TestDeployment}, which also translates {@link Feed}s to {@link Digest}s.
- *
- * @author jonmv
- */
-public interface TestEndpoint extends Endpoint {
-
- /** Sends the given Feed to this TestEndpoint, blocking until it is digested, and returns a feed report. */
- Digest digest(Feed feed);
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestRuntime.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
index e10d627808f..1136233113a 100644
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
+++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
@@ -1,10 +1,9 @@
package ai.vespa.hosted.cd;
-import ai.vespa.hosted.api.Authenticator;
import ai.vespa.hosted.api.ControllerHttpClient;
+import ai.vespa.hosted.api.EndpointAuthenticator;
import ai.vespa.hosted.api.Properties;
import ai.vespa.hosted.api.TestConfig;
-import ai.vespa.hosted.auth.CertificateAndKeyAuthenticator;
import ai.vespa.hosted.cd.http.HttpDeployment;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Environment;
@@ -12,9 +11,6 @@ import com.yahoo.config.provision.zone.ZoneId;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.Map;
-
-import static java.util.stream.Collectors.toUnmodifiableMap;
/**
* The place to obtain environment-dependent configuration for test of a Vespa deployment.
@@ -26,18 +22,11 @@ public class TestRuntime {
private static TestRuntime theRuntime;
private final TestConfig config;
- private final Map<String, Deployment> productionDeployments;
private final Deployment deploymentToTest;
- private TestRuntime(TestConfig config, Authenticator authenticator) {
+ private TestRuntime(TestConfig config, EndpointAuthenticator authenticator) {
this.config = config;
- this.productionDeployments = config.deployments().entrySet().stream()
- .filter(zoneDeployment -> zoneDeployment.getKey().environment() == Environment.prod)
- .collect(toUnmodifiableMap(zoneDeployment -> zoneDeployment.getKey().region().value(),
- zoneDeployment -> new HttpDeployment(zoneDeployment.getValue(),
- config.zone(),
- authenticator)));
- this.deploymentToTest = new HttpDeployment(config.deployments().get(config.zone()), config.zone(), authenticator);
+ this.deploymentToTest = new HttpDeployment(config.deployments().get(config.zone()), authenticator);
}
/**
@@ -55,13 +44,13 @@ public class TestRuntime {
String configPath = System.getProperty("vespa.test.config");
TestConfig config = configPath != null ? fromFile(configPath) : fromController();
theRuntime = new TestRuntime(config,
- new CertificateAndKeyAuthenticator(config.system()));
+ new ai.vespa.hosted.auth.EndpointAuthenticator(config.system()));
}
return theRuntime;
}
/** Returns a copy of this runtime, with the given endpoint authenticator. */
- public TestRuntime with(Authenticator authenticator) {
+ public TestRuntime with(EndpointAuthenticator authenticator) {
return new TestRuntime(config, authenticator);
}
@@ -71,9 +60,6 @@ public class TestRuntime {
/** Returns the zone of the deployment this is testing. */
public ZoneId zone() { return config.zone(); }
- /** Returns all production deployments of the application this is testing. */
- public Map<String, Deployment> productionDeployments() { return productionDeployments; }
-
/** Returns the deployment this is testing. */
public Deployment deploymentToTest() { return deploymentToTest; }
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Visit.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Visit.java
deleted file mode 100644
index 3bb2f59de97..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Visit.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package ai.vespa.hosted.cd;
-
-import java.util.Map;
-
-/**
- * A stateful visit operation against a {@link Endpoint}.
- *
- * @author jonmv
- */
-public class Visit {
-
- // Delegate to a blocking iterator, which can be used for iteration as visit is ongoing.
- public Map<DocumentId, Document> documents() {
- return null;
- }
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/VisitEndpoint.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/VisitEndpoint.java
deleted file mode 100644
index 618a004a571..00000000000
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/VisitEndpoint.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package ai.vespa.hosted.cd;
-
-/**
- * A remote endpoint in a Vespa application {@link Deployment}, which translates {@link Selection}s to {@link Visit}s.
- *
- * @author jonmv
- */
-public interface VisitEndpoint {
-
-}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpDeployment.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpDeployment.java
index 04cebcf50b2..f6ad4d0acf9 100644
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpDeployment.java
+++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpDeployment.java
@@ -1,10 +1,8 @@
package ai.vespa.hosted.cd.http;
-import ai.vespa.hosted.api.Authenticator;
-import ai.vespa.hosted.cd.TestDeployment;
-import ai.vespa.hosted.cd.TestEndpoint;
-import com.yahoo.config.provision.Environment;
-import com.yahoo.config.provision.zone.ZoneId;
+import ai.vespa.hosted.api.EndpointAuthenticator;
+import ai.vespa.hosted.cd.Deployment;
+import ai.vespa.hosted.cd.Endpoint;
import java.net.URI;
import java.util.Map;
@@ -16,38 +14,23 @@ import java.util.stream.Collectors;
*
* @author jonmv
*/
-public class HttpDeployment implements TestDeployment {
+public class HttpDeployment implements Deployment {
- private final ZoneId zone;
private final Map<String, HttpEndpoint> endpoints;
/** Creates a representation of the given deployment endpoints, using the authenticator for data plane access. */
- public HttpDeployment(Map<String, URI> endpoints, ZoneId zone, Authenticator authenticator) {
- this.zone = zone;
+ public HttpDeployment(Map<String, URI> endpoints, EndpointAuthenticator authenticator) {
this.endpoints = endpoints.entrySet().stream()
.collect(Collectors.toUnmodifiableMap(entry -> entry.getKey(),
entry -> new HttpEndpoint(entry.getValue(), authenticator)));
}
@Override
- public TestEndpoint endpoint() {
- return endpoint("default");
- }
-
- @Override
- public TestEndpoint endpoint(String id) {
+ public Endpoint endpoint(String id) {
if ( ! endpoints.containsKey(id))
throw new NoSuchElementException("No cluster with id '" + id + "'");
return endpoints.get(id);
}
- @Override
- public TestDeployment asTestDeployment() {
- if (zone.environment() == Environment.prod)
- throw new IllegalArgumentException("Won't return a mutable view of a production deployment");
-
- return this;
- }
-
}
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpEndpoint.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpEndpoint.java
index a9d8f2e7cc5..a3f1b90f5d4 100644
--- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpEndpoint.java
+++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/http/HttpEndpoint.java
@@ -1,14 +1,7 @@
package ai.vespa.hosted.cd.http;
-import ai.vespa.hosted.api.Authenticator;
-import ai.vespa.hosted.cd.Digest;
-import ai.vespa.hosted.cd.Feed;
-import ai.vespa.hosted.cd.Query;
-import ai.vespa.hosted.cd.Search;
-import ai.vespa.hosted.cd.Selection;
-import ai.vespa.hosted.cd.TestEndpoint;
-import ai.vespa.hosted.cd.Visit;
-import ai.vespa.hosted.cd.metric.Metrics;
+import ai.vespa.hosted.api.EndpointAuthenticator;
+import ai.vespa.hosted.cd.Endpoint;
import java.io.IOException;
import java.net.URI;
@@ -25,17 +18,13 @@ import static java.util.Objects.requireNonNull;
*
* @author jonmv
*/
-public class HttpEndpoint implements TestEndpoint {
-
- static final String metricsPath = "/state/v1/metrics"; // TODO metrics/v1/values?
- static final String documentApiPath = "/document/v1";
- static final String searchApiPath = "/search";
+public class HttpEndpoint implements Endpoint {
private final URI endpoint;
private final HttpClient client;
- private final Authenticator authenticator;
+ private final EndpointAuthenticator authenticator;
- public HttpEndpoint(URI endpoint, Authenticator authenticator) {
+ public HttpEndpoint(URI endpoint, EndpointAuthenticator authenticator) {
this.endpoint = requireNonNull(endpoint);
this.authenticator = requireNonNull(authenticator);
this.client = HttpClient.newBuilder()
@@ -46,12 +35,7 @@ public class HttpEndpoint implements TestEndpoint {
}
@Override
- public Digest digest(Feed feed) {
- return null;
- }
-
- @Override
- public URI uri() {
+ public URI hostUri() {
return endpoint;
}
@@ -66,38 +50,5 @@ public class HttpEndpoint implements TestEndpoint {
}
@Override
- public Search search(Query query) {
- try {
- URI target = endpoint.resolve(searchApiPath).resolve("?" + query.rawQuery());
- HttpResponse<byte[]> response = send(HttpRequest.newBuilder(target)
- .timeout(query.timeout().orElse(Duration.ofMillis(500))
- .plus(Duration.ofSeconds(1))),
- HttpResponse.BodyHandlers.ofByteArray());
- if (response.statusCode() / 100 != 2) // TODO consider allowing 504 if specified.
- throw new RuntimeException("Non-OK status code " + response.statusCode() + " at " + target +
- ", with response \n" + new String(response.body()));
-
- return toSearch(response.body());
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- static Search toSearch(byte[] body) {
- // TODO jvenstad
- // Inspector rootObject = new JsonDecoder().decode(new Slime(), body).get();
- return new Search(new String(body, UTF_8));
- }
-
- @Override
- public Visit visit(Selection selection) {
- return null;
- }
-
- @Override
- public Metrics metrics() {
- return null;
- }
}