summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authortoby <smorgrav@yahoo-inc.com>2017-09-26 13:06:31 +0200
committertoby <smorgrav@yahoo-inc.com>2017-10-10 13:37:59 +0200
commitd440b79e005d7cf9ede08daac2e40ab22641bc53 (patch)
tree6e480266289975cb5c7b3546da4c6adadd3cda08 /controller-api
parentc91d75ffcd6fbc9bb55d28f8e6868d82c4080df7 (diff)
Add unit test
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java6
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java2
-rw-r--r--controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java29
3 files changed, 33 insertions, 4 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java
index 5acd51e0d2e..70fce483c38 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java
@@ -91,7 +91,7 @@ public interface Cost {
}
/**
- * @return zone->app for all known zones and applications
+ * @return Map from zone to app for all known zones and applications
*/
Map<Zone, List<ApplicationId>> getApplications();
@@ -101,7 +101,7 @@ public interface Cost {
*
* @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
* @param app ApplicationId e.g tenant:application:instance
- * @return Map between clusterid -> info
+ * @return Map between cluster id to cluster info
*/
Map<String, CostClusterInfo> getClusterInfo(Zone zone, ApplicationId app);
@@ -110,7 +110,7 @@ public interface Cost {
*
* @param zone The zone - the combination of a environment and region e.g 'test.us-east-1'
* @param app ApplicationId e.g tenant:application:instance
- * @return Map between clusterid -> resource utilization
+ * @return Map between cluster id to resource utilization
*/
Map<String, CostResources> getClusterUtilization(Zone zone, ApplicationId app);
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java
index 6d454d53268..be0aea6122d 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostCluster.java
@@ -17,7 +17,7 @@ public class CostCluster {
/**
* @param clusterInfo Value object with cluster info e.g. the TCO for the hardware used
* @param systemUtilization Utilization of system resources (as ratios)
- * @param targetUtilization Target utilization (ratios - usually < 1.0)
+ * @param targetUtilization Target utilization (ratios - usually less than 1.0)
*/
public CostCluster(CostClusterInfo clusterInfo,
CostResources systemUtilization,
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java
new file mode 100644
index 00000000000..a7ed2f90548
--- /dev/null
+++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostResourcesTest.java
@@ -0,0 +1,29 @@
+// Copyright 2017 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.cost;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author smorgrav
+ */
+public class CostResourcesTest {
+
+ private static double delta = Double.MIN_EXPONENT;
+
+ @Test
+ public void getMaxUtilization() throws Exception {
+ CostResources resources = new CostResources(0.3, 0.1, 0.4, 0.5);
+ Assert.assertEquals(0.5, resources.getMaxUtilization(), delta);
+
+ resources = new CostResources(0.3, 0.1, 0.4, 0.0);
+ Assert.assertEquals(0.4, resources.getMaxUtilization(), delta);
+
+ resources = new CostResources(0.4, 0.3, 0.3, 0.0);
+ Assert.assertEquals(0.4, resources.getMaxUtilization(), delta);
+
+ resources = new CostResources(0.1, 0.3, 0.3, 0.0);
+ Assert.assertEquals(0.3, resources.getMaxUtilization(), delta);
+ }
+} \ No newline at end of file