diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-31 14:27:13 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-31 14:27:13 +0100 |
commit | 9f3db74fb5199cefaf94961b70374e6c2d3243f7 (patch) | |
tree | e8943a3bb20a1aa9f74d183be63134e0918510e1 | |
parent | 2fe6aa0c3c53bc7a8c8b6a0feed85f53248de1de (diff) |
Update DeploymentMetricsMaintainerTest
4 files changed, 20 insertions, 28 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index 95934b528e0..b0adebfbb19 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -275,10 +275,15 @@ public class DeploymentContext { return this; } + /** Runs a deployment of the given package to the given dev/perf job, on the given version. */ + public DeploymentContext runJob(JobType type, ApplicationPackage applicationPackage, Version vespaVersion) { + jobs.deploy(instanceId, type, Optional.ofNullable(vespaVersion), applicationPackage); + return runJob(type); + } + /** Runs a deployment of the given package to the given dev/perf job. */ public DeploymentContext runJob(JobType type, ApplicationPackage applicationPackage) { - jobs.deploy(instanceId, type, Optional.empty(), applicationPackage); - return runJob(type); + return runJob(type, applicationPackage, null); } /** Pulls the ready job trigger, and then runs the whole of the given job, successfully. */ diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java index 73ddeeaa0c6..e88452bd54e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java @@ -11,9 +11,11 @@ import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.application.v4.model.ClusterMetrics; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; +import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import org.junit.Test; import java.time.Duration; @@ -33,17 +35,17 @@ import static org.junit.Assert.assertFalse; */ public class DeploymentMetricsMaintainerTest { - private final DeploymentTester tester = new DeploymentTester(); + private final InternalDeploymentTester tester = new InternalDeploymentTester(); @Test public void updates_metrics() { - var application = tester.createApplication("app1", "tenant1", 123L, 1L); - deploy(application.id().defaultInstance(), Version.fromString("7.1")); + var application = tester.deploymentContext(); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("7.1")); DeploymentMetricsMaintainer maintainer = maintainer(tester.controller()); - Supplier<Application> app = () -> tester.application(application.id()); - Supplier<Instance> instance = () -> tester.defaultInstance(application.id()); - Supplier<Deployment> deployment = () -> instance.get().deployments().values().stream().findFirst().get(); + Supplier<Application> app = application::application; + Supplier<Instance> instance = application::instance; + Supplier<Deployment> deployment = () -> application.deployment(ZoneId.from("dev", "us-east-1")); // No metrics gathered yet assertEquals(0, app.get().metrics().queryServiceQuality(), 0); @@ -53,7 +55,7 @@ public class DeploymentMetricsMaintainerTest { assertFalse("Never received any writes", deployment.get().activity().lastWritten().isPresent()); // Only get application metrics for old version - deploy(application.id().defaultInstance(), Version.fromString("6.3.3")); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("6.3.3")); maintainer.maintain(); assertEquals(0, app.get().metrics().queryServiceQuality(), 0); assertEquals(0, deployment.get().metrics().documentCount(), 0); @@ -62,13 +64,13 @@ public class DeploymentMetricsMaintainerTest { assertFalse("Never received any writes", deployment.get().activity().lastWritten().isPresent()); // Metrics are gathered and saved to application - deploy(application.id().defaultInstance(), Version.fromString("7.5.5")); + application.runJob(JobType.devUsEast1, new ApplicationPackage(new byte[0]), Version.fromString("7.5.5")); var metrics0 = Map.of(ClusterMetrics.QUERIES_PER_SECOND, 1D, ClusterMetrics.FEED_PER_SECOND, 2D, ClusterMetrics.DOCUMENT_COUNT, 3D, ClusterMetrics.QUERY_LATENCY, 4D, ClusterMetrics.FEED_LATENCY, 5D); - setMetrics(application.id().defaultInstance(), metrics0); + setMetrics(application.application().id().defaultInstance(), metrics0); maintainer.maintain(); Instant t1 = tester.clock().instant().truncatedTo(MILLIS); assertEquals(0.0, app.get().metrics().queryServiceQuality(), Double.MIN_VALUE); @@ -98,7 +100,7 @@ public class DeploymentMetricsMaintainerTest { var metrics1 = new HashMap<>(metrics0); metrics1.put(ClusterMetrics.QUERIES_PER_SECOND, 0D); metrics1.put(ClusterMetrics.FEED_PER_SECOND, 5D); - setMetrics(application.id().defaultInstance(), metrics1); + setMetrics(application.application().id().defaultInstance(), metrics1); maintainer.maintain(); assertEquals(t2, deployment.get().activity().lastQueried().get()); assertEquals(t3, deployment.get().activity().lastWritten().get()); @@ -109,7 +111,7 @@ public class DeploymentMetricsMaintainerTest { tester.clock().advance(Duration.ofHours(1)); var metrics2 = new HashMap<>(metrics1); metrics2.put(ClusterMetrics.FEED_PER_SECOND, 0D); - setMetrics(application.id().defaultInstance(), metrics2); + setMetrics(application.application().id().defaultInstance(), metrics2); maintainer.maintain(); assertEquals(t2, deployment.get().activity().lastQueried().get()); assertEquals(t3, deployment.get().activity().lastWritten().get()); @@ -129,12 +131,4 @@ public class DeploymentMetricsMaintainerTest { return new DeploymentMetricsMaintainer(controller, Duration.ofDays(1), new JobControl(controller.curator())); } - private void deploy(ApplicationId id, Version version) { - tester.controllerTester().deploy(id, - ZoneId.from(Environment.dev, RegionName.from("us-east-1")), - Optional.of(new ApplicationPackage(new byte[0])), - false, - Optional.of(version)); - } - } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java index 127104724a5..fde6db37d62 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java @@ -4,19 +4,13 @@ package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.ControllerTester; -import com.yahoo.vespa.hosted.controller.Instance; import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus; -import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; -import com.yahoo.vespa.hosted.controller.deployment.BuildJob; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import com.yahoo.vespa.hosted.controller.rotation.RotationState; import org.junit.Test; import java.time.Duration; -import java.util.function.Supplier; import static org.junit.Assert.assertEquals; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java index 1aa88dde258..b7671cf47c2 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java @@ -18,7 +18,6 @@ import com.yahoo.vespa.hosted.controller.application.RoutingPolicy; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; -import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; import com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester; import org.junit.Test; |