aboutsummaryrefslogtreecommitdiffstats
path: root/tenant-cd-api
diff options
context:
space:
mode:
authorMorten Tokle <mortent@verizonmedia.com>2020-06-10 14:56:07 +0200
committerMorten Tokle <mortent@verizonmedia.com>2020-06-15 12:34:46 +0200
commit71d24e5944fae958383cdb4fa63e37f4bbe1f2a0 (patch)
treee60feaf88d5d284fdfa9cc9d97b7f482479173a8 /tenant-cd-api
parenta19da10e4ab5997e3398754cdffc4e948f5ede60 (diff)
tenant-cd -> tenant-cd-api
Diffstat (limited to 'tenant-cd-api')
-rw-r--r--tenant-cd-api/OWNERS1
-rw-r--r--tenant-cd-api/README1
-rw-r--r--tenant-cd-api/pom.xml29
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Deployment.java14
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Endpoint.java37
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java27
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/ProductionTest.java25
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingSetup.java26
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingTest.java28
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/SystemTest.java28
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java19
11 files changed, 235 insertions, 0 deletions
diff --git a/tenant-cd-api/OWNERS b/tenant-cd-api/OWNERS
new file mode 100644
index 00000000000..d0a102ecbf4
--- /dev/null
+++ b/tenant-cd-api/OWNERS
@@ -0,0 +1 @@
+jonmv
diff --git a/tenant-cd-api/README b/tenant-cd-api/README
new file mode 100644
index 00000000000..a3803b81d53
--- /dev/null
+++ b/tenant-cd-api/README
@@ -0,0 +1 @@
+Library for integration tests of hosted Vespa applications
diff --git a/tenant-cd-api/pom.xml b/tenant-cd-api/pom.xml
new file mode 100644
index 00000000000..0c63a17dcc0
--- /dev/null
+++ b/tenant-cd-api/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>tenant-cd</artifactId>
+ <name>Hosted Vespa tenant CD</name>
+ <description>Test library for hosted Vespa applications.</description>
+ <url>https://github.com/vespa-engine</url>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>parent</artifactId>
+ <version>7-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Deployment.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Deployment.java
new file mode 100644
index 00000000000..7d7b2f74981
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Deployment.java
@@ -0,0 +1,14 @@
+// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+/**
+ * A deployment of a Vespa application, which contains endpoints for document retrieval.
+ *
+ * @author jonmv
+ */
+public interface Deployment {
+
+ /** Returns an Endpoint in the cluster with the given id. */
+ Endpoint endpoint(String id);
+
+}
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Endpoint.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Endpoint.java
new file mode 100644
index 00000000000..afc6aa1b519
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/Endpoint.java
@@ -0,0 +1,37 @@
+// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import java.net.URI;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * An endpoint in a Vespa application {@link Deployment}, which allows document retrieval.
+ *
+ * @author jonmv
+ */
+public interface Endpoint {
+
+ /** Returns the URI of the endpoint, with scheme, host and port. */
+ URI uri();
+
+ /** Sends the given request with required authentication. */
+ <T> HttpResponse<T> send(HttpRequest.Builder request, HttpResponse.BodyHandler<T> handler);
+
+ /** Sends the given request with required authentication. */
+ default HttpResponse<String> send(HttpRequest.Builder request) {
+ return send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
+ }
+
+ /** Creates a request against the endpoint, with the given path and properties. */
+ HttpRequest.Builder request(String path, Map<String, String> properties);
+
+ /** Creates a request against the endpoint, with the given path. */
+ default HttpRequest.Builder request(String path) {
+ return request(path, Collections.emptyMap());
+ }
+
+}
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java
new file mode 100644
index 00000000000..f9dc15df32e
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java
@@ -0,0 +1,27 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Tests which run against a fully operational Vespa deployment to verify its behaviour.
+ *
+ * Examples of integration test types are {@link SystemTest}, {@link StagingSetup}, {@link StagingTest}, and {@link ProductionTest}.
+ *
+ * @author jonmv
+ */
+@Target({TYPE, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+@Tag("integration")
+public @interface IntegrationTest { }
+
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/ProductionTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/ProductionTest.java
new file mode 100644
index 00000000000..b9054689b00
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/ProductionTest.java
@@ -0,0 +1,25 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import org.junit.jupiter.api.Tag;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Tests that verify the health of production deployments of Vespa applications.
+ *
+ * Test classes annotated with this annotation are run during declared production tests.
+ * See <a href="https://cloud.vespa.ai/automated-deployments.html">Vespa cloud documentation</a>.
+ *
+ * @author jonmv
+ */
+@Target({TYPE, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+@IntegrationTest
+@Tag("production")
+public @interface ProductionTest { }
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingSetup.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingSetup.java
new file mode 100644
index 00000000000..bef3eabcef6
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingSetup.java
@@ -0,0 +1,26 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import org.junit.jupiter.api.Tag;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Setup for tests that assert continuity of behaviour for Vespa application deployments, through upgrades.
+ *
+ * Test classes annotated with this annotation are run in the first phase of automated staging tests,
+ * to make the initial deployment similar to a production one.
+ * See <a href="https://cloud.vespa.ai/automated-deployments.html">Vespa cloud documentation</a>.
+ *
+ * @author jonmv
+ */
+@Target({TYPE, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+@IntegrationTest
+@Tag("staging-setup")
+public @interface StagingSetup { }
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingTest.java
new file mode 100644
index 00000000000..59360b2753c
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/StagingTest.java
@@ -0,0 +1,28 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Tests that assert continuity of behaviour for Vespa application deployments, through upgrades.
+ *
+ * Test classes annotated with this annotation are run in the second phase of automated staging tests,
+ * to verify the upgraded deployment.
+ * See <a href="https://cloud.vespa.ai/automated-deployments.html">Vespa cloud documentation</a>.
+ *
+ * @author jonmv
+ */
+@Target({TYPE, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+@IntegrationTest
+@Tag("staging")
+public @interface StagingTest {
+}
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/SystemTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/SystemTest.java
new file mode 100644
index 00000000000..f01f2ca6c90
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/SystemTest.java
@@ -0,0 +1,28 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Tests that compare the behaviour of a Vespa application deployment against a fixed specification.
+ *
+ * Test classes annotated with this annotation are run against a fresh deployment during automated system tests.
+ * See <a href="https://cloud.vespa.ai/automated-deployments.html">Vespa cloud documentation</a>.
+ *
+ * @author jonmv
+ */
+@Target({TYPE, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+@IntegrationTest
+@Tag("system")
+public @interface SystemTest { }
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
new file mode 100644
index 00000000000..feea05b7064
--- /dev/null
+++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java
@@ -0,0 +1,19 @@
+// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.cd;
+
+import java.util.ServiceLoader;
+
+/**
+ * The place to obtain environment-dependent configuration for test of a Vespa deployment.
+ *
+ * @author jvenstad
+ * @author mortent
+ */
+public interface TestRuntime {
+ static TestRuntime get() {
+ ServiceLoader<TestRuntime> serviceLoader = ServiceLoader.load(TestRuntime.class);
+ return serviceLoader.findFirst().orElseThrow(() -> new RuntimeException("No TestRuntime implementation found"));
+ }
+
+ Deployment deploymentToTest();
+}