diff options
author | toby <smorgrav@yahoo-inc.com> | 2017-10-13 13:58:21 +0200 |
---|---|---|
committer | toby <smorgrav@yahoo-inc.com> | 2017-10-13 13:58:21 +0200 |
commit | 75b888c31f0c751e3f6682bfd04efddeb7523913 (patch) | |
tree | 9c3bf4309e326db6eda33ce815722d0b4e51b6a9 /controller-server/src/test/java/com | |
parent | 82d187a6f7e3f6f6adbd4430951791c17af17558 (diff) |
Add deployment metric maintainer
Diffstat (limited to 'controller-server/src/test/java/com')
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
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 new file mode 100644 index 00000000000..cb503fc1fb7 --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentMetricsMaintainerTest.java @@ -0,0 +1,41 @@ +package com.yahoo.vespa.hosted.controller.maintenance; + +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.Environment; +import com.yahoo.vespa.hosted.controller.ControllerTester; +import com.yahoo.vespa.hosted.controller.application.Deployment; +import com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb; +import org.junit.Assert; +import org.junit.Test; + +import java.time.Duration; + +/** + * @author smorgrav + */ +public class DeploymentMetricsMaintainerTest { + + @Test + public void maintain() { + ControllerTester tester = new ControllerTester(); + ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id(); + + // Pre condition: no metric info on the deployment + Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get(); + Assert.assertEquals(0, deployment.metrics().documentCount(), Double.MIN_VALUE); + + DeploymentMetricsMaintainer maintainer = new DeploymentMetricsMaintainer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb())); + maintainer.maintain(); + + // Post condition: + deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get(); + Assert.assertEquals(1, deployment.metrics().queriesPerSecond(), Double.MIN_VALUE); + Assert.assertEquals(2, deployment.metrics().writesPerSecond(), Double.MIN_VALUE); + Assert.assertEquals(3, deployment.metrics().documentCount(), Double.MIN_VALUE); + Assert.assertEquals(4, deployment.metrics().queryLatencyMillis(), Double.MIN_VALUE); + Assert.assertEquals(5, deployment.metrics().writeLatencyMillis(), Double.MIN_VALUE); + } + +}
\ No newline at end of file |