diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-02-15 13:52:23 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-02-15 13:52:23 +0100 |
commit | 4c9206d8119d1131e248419c7e1ba669c396b89b (patch) | |
tree | 414dfdc40c088e06c108e28a7f050bf375ce9d3b /node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi | |
parent | b9b7e3cf8529e6f7e9904c1013174e37c0460696 (diff) |
Exchange BCP info WIP
Diffstat (limited to 'node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi')
3 files changed, 85 insertions, 9 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcherTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcherTest.java index 79722a747e2..200187ea5d6 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcherTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationPatcherTest.java @@ -2,14 +2,20 @@ package com.yahoo.vespa.hosted.provision.restapi; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.hosted.provision.NodeRepository; +import com.yahoo.config.provision.Capacity; +import com.yahoo.config.provision.ClusterResources; +import com.yahoo.config.provision.ClusterSpec; +import com.yahoo.config.provision.NodeResources; import com.yahoo.vespa.hosted.provision.NodeRepositoryTester; import com.yahoo.vespa.hosted.provision.applications.Application; +import com.yahoo.vespa.hosted.provision.applications.BcpGroupInfo; +import com.yahoo.vespa.hosted.provision.applications.Cluster; import org.junit.Test; import java.io.ByteArrayInputStream; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author bratseth @@ -26,8 +32,63 @@ public class ApplicationPatcherTest { application.id(), tester.nodeRepository()); Application patched = patcher.apply(); - assertEquals(0.4, patcher.application().status().currentReadShare(), 0.0000001); - assertEquals(1.0, patcher.application().status().maxReadShare(), 0.0000001); + assertEquals(0.4, patched.status().currentReadShare(), 0.0000001); + assertEquals(1.0, patched.status().maxReadShare(), 0.0000001); + patcher.close(); + } + + @Test + public void testPatchingWithBcpGroupInfo() { + var c1 = ClusterSpec.Id.from("c1"); + var c2 = ClusterSpec.Id.from("c2"); + var capacity = Capacity.from(new ClusterResources(10, 1, new NodeResources(1.0, 10.0, 100.0, 3.0))); + NodeRepositoryTester tester = new NodeRepositoryTester(); + Application application = Application.empty(ApplicationId.from("t1", "a1", "i1")); + application = application.with(Cluster.create(c1, false, capacity)); + application = application.with(Cluster.create(c2, false, capacity)); + tester.nodeRepository().applications().put(application, tester.nodeRepository().applications().lock(application.id())); + + String patch = """ + { + "currentReadShare": 0.4, + "maxReadShare": 1.0, + "clusters": { + "c1": { + "bcpGroupInfo": { + "queryRate": 0.1, + "growthRateHeadroom": 0.2, + "cpuCostPerQuery": 0.3 + } + }, + "c2": { + "bcpGroupInfo": { + "queryRate": 1, + "growthRateHeadroom": 2, + "cpuCostPerQuery": 3 + } + }, + "ignored": { + "bcpGroupInfo": { + "queryRate": 1, + "growthRateHeadroom": 2, + "cpuCostPerQuery": 3 + } + } + } + } + """; + + ApplicationPatcher patcher = new ApplicationPatcher(new ByteArrayInputStream(patch.getBytes()), + application.id(), + tester.nodeRepository()); + Application patched = patcher.apply(); + assertEquals(0.4, patched.status().currentReadShare(), 0.0000001); + assertEquals(1.0, patched.status().maxReadShare(), 0.0000001); + assertEquals(new BcpGroupInfo(0.1, 0.2, 0.3), + patched.cluster(c1).get().bcpGroupInfo()); + assertEquals(new BcpGroupInfo(1.0, 2.0, 3.0), + patched.cluster(c2).get().bcpGroupInfo()); + assertTrue(patched.cluster(ClusterSpec.Id.from("ignored")).isEmpty()); patcher.close(); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json index c9046998e91..4c18b614075 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json @@ -69,6 +69,11 @@ "cpu" : 0.0, "memory" : 0.0, "disk" : 0.0 + }, + "metrics" : { + "queryRate" : 0.0, + "growthRateHeadroom" : 0.0, + "cpuCostPerQuery" : 0.0 } }, "target" : { @@ -89,14 +94,19 @@ }, "at" : 123, "peak" : { - "cpu" : 0.0, - "memory" : 0.0, - "disk" : 0.0 + "cpu" : 0.1, + "memory" : 0.2, + "disk" : 0.3 }, "ideal" : { - "cpu" : 0.0, - "memory" : 0.0, - "disk" : 0.0 + "cpu" : 0.4, + "memory" : 0.5, + "disk" : 0.6 + }, + "metrics" : { + "queryRate" : 0.7, + "growthRateHeadroom" : 0.8, + "cpuCostPerQuery" : 0.9 } }, "scalingEvents" : [ diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json index 4166d20ad8d..ea4d5e01ebc 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json @@ -56,6 +56,11 @@ "cpu" : 0.0, "memory" : 0.0, "disk" : 0.0 + }, + "metrics" : { + "queryRate" : 0.0, + "growthRateHeadroom" : 0.0, + "cpuCostPerQuery" : 0.0 } }, "scalingEvents" : [ |