diff options
author | Jon Bratseth <bratseth@oath.com> | 2021-02-24 17:22:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 17:22:31 +0100 |
commit | eafeefded12aeda595ffcd9e5028ed2303090b64 (patch) | |
tree | 3fcbe015df07b3a4a50dfffd03413c7b9da93291 /node-repository/src/test/java/com/yahoo | |
parent | db0fcba270059f327d66256f02c4e105d1d45d08 (diff) | |
parent | 4c12b3aa80e7a08590727adcf11718b45821cb3b (diff) |
Merge pull request #16657 from vespa-engine/jonmv/mind-the-gaps
Jonmv/mind the gaps
Diffstat (limited to 'node-repository/src/test/java/com/yahoo')
2 files changed, 73 insertions, 1 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java index f4d8bbfcb21..6f50cbf9803 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java @@ -150,7 +150,7 @@ public class InfraDeployerImplTest { Node node = tester.addHost("id-" + id, "node-" + id, "default", nodeType); Optional<Node> nodeWithAllocation = wantedVespaVersion.map(version -> { ClusterSpec clusterSpec = application.getClusterSpecWithVersion(version).with(Optional.of(ClusterSpec.Group.from(0))); - ClusterMembership membership = ClusterMembership.from(clusterSpec, 1); + ClusterMembership membership = ClusterMembership.from(clusterSpec, 0); Allocation allocation = new Allocation(application.getApplicationId(), membership, node.resources(), Generation.initial(), false); return node.with(allocation); }); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIncidesTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIncidesTest.java new file mode 100644 index 00000000000..eee9c2ffc01 --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIncidesTest.java @@ -0,0 +1,72 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.provision.provisioning; + +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +/** + * @author jonmv + */ +public class NodeIncidesTest { + + @Test + public void testNonCompactIndices() { + NodeIndices indices = new NodeIndices(List.of(1, 3, 4), false); + assertEquals(5, indices.probeNext()); + assertEquals(6, indices.probeNext()); + + indices.resetProbe(); + assertEquals(5, indices.probeNext()); + assertEquals(6, indices.probeNext()); + + indices.commitProbe(); + assertEquals(7, indices.probeNext()); + assertEquals(8, indices.probeNext()); + + indices.resetProbe(); + assertEquals(7, indices.next()); + assertEquals(8, indices.next()); + + assertEquals(9, indices.probeNext()); + try { + indices.next(); + } + catch (IllegalStateException e) { + assertEquals("Must commit ongoing probe before calling 'next'", e.getMessage()); + } + } + + + @Test + public void testCompactIndices() { + NodeIndices indices = new NodeIndices(List.of(1, 3, 4), true); + assertEquals(0, indices.probeNext()); + assertEquals(2, indices.probeNext()); + assertEquals(5, indices.probeNext()); + assertEquals(6, indices.probeNext()); + + indices.resetProbe(); + assertEquals(0, indices.probeNext()); + assertEquals(2, indices.probeNext()); + + indices.commitProbe(); + assertEquals(5, indices.probeNext()); + assertEquals(6, indices.probeNext()); + + indices.resetProbe(); + assertEquals(5, indices.next()); + assertEquals(6, indices.next()); + + assertEquals(7, indices.probeNext()); + try { + indices.next(); + } + catch (IllegalStateException e) { + assertEquals("Must commit ongoing probe before calling 'next'", e.getMessage()); + } + } + +} |