diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-03-05 15:58:24 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2019-03-14 14:43:02 +0000 |
commit | a925ce4a159ff5baf1e6e4cac632794fa2ba6547 (patch) | |
tree | c2fb7963644f2783f1ebaccae7815930c1bbccae /clustercontroller-core/src/test | |
parent | ff201447a3e3d1ef22232742c99ea0aa7ab72718 (diff) |
Include deferred activation flag with cluster state bundles
Bundles including this flag from the cluster controller indicate to
receiver nodes that an explicit activation RPC will follow. When it
is not present, nodes must activate the cluster state at their own
leisure as they have done historically.
Diffstat (limited to 'clustercontroller-core/src/test')
3 files changed, 46 insertions, 3 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java index 7dccae988df..fa802f7fd71 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleTest.java @@ -19,7 +19,7 @@ public class ClusterStateBundleTest { return AnnotatedClusterState.withoutAnnotations(stateOf(state)); } - private static ClusterStateBundle createTestBundle(boolean modifyDefaultSpace) { + private static ClusterStateBundle.Builder createTestBundleBuilder(boolean modifyDefaultSpace) { return ClusterStateBundle .builder(annotatedStateOf("distributor:2 storage:2")) .bucketSpaces("default", "global", "narnia") @@ -33,8 +33,11 @@ public class ClusterStateBundleTest { .setNodeState(Node.ofDistributor(0), new NodeState(NodeType.DISTRIBUTOR, State.DOWN)); } return derived; - }) - .deriveAndBuild(); + }); + } + + private static ClusterStateBundle createTestBundle(boolean modifyDefaultSpace) { + return createTestBundleBuilder(modifyDefaultSpace).deriveAndBuild(); } private static ClusterStateBundle createTestBundle() { @@ -96,4 +99,22 @@ public class ClusterStateBundleTest { "narnia 'distributor:2 .0.s:d storage:2')")); } + @Test + public void deferred_activation_is_enabled_by_default() { + ClusterStateBundle bundle = createTestBundle(); + assertTrue(bundle.deferredActivation()); + } + + @Test + public void can_build_bundle_with_deferred_activation_enabled() { + var bundle = createTestBundleBuilder(false).deferredActivation(true).deriveAndBuild(); + assertTrue(bundle.deferredActivation()); + } + + @Test + public void can_build_bundle_with_deferred_activation_disabled() { + var bundle = createTestBundleBuilder(false).deferredActivation(false).deriveAndBuild(); + assertFalse(bundle.deferredActivation()); + } + } diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleUtil.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleUtil.java index 00c2194205d..cceb6d6f03f 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleUtil.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterStateBundleUtil.java @@ -12,6 +12,12 @@ import java.util.stream.Stream; */ public class ClusterStateBundleUtil { + public static ClusterStateBundle.Builder makeBundleBuilder(String baselineState, StateMapping... bucketSpaceStates) { + return ClusterStateBundle.builder(AnnotatedClusterState.withoutAnnotations(ClusterState.stateFromString(baselineState))) + .explicitDerivedStates(Stream.of(bucketSpaceStates).collect(Collectors.toMap(sm -> sm.bucketSpace, + sm -> AnnotatedClusterState.withoutAnnotations(sm.state)))); + } + public static ClusterStateBundle makeBundle(String baselineState, StateMapping... bucketSpaceStates) { return ClusterStateBundle.of(AnnotatedClusterState.withoutAnnotations(ClusterState.stateFromString(baselineState)), Stream.of(bucketSpaceStates).collect(Collectors.toMap(sm -> sm.bucketSpace, diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java index b19b1d780bf..3dce1153685 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodecTest.java @@ -72,4 +72,20 @@ public class SlimeClusterStateBundleCodecTest { assertThat(roundtripEncodeWithEnvelope(stateBundle), equalTo(stateBundle)); } + @Test + public void can_roundtrip_encode_bundle_with_deferred_activation_enabled() { + var stateBundle = ClusterStateBundleUtil.makeBundleBuilder("distributor:2 storage:2") + .deferredActivation(true) + .deriveAndBuild(); + assertThat(roundtripEncode(stateBundle), equalTo(stateBundle)); + } + + @Test + public void can_roundtrip_encode_bundle_with_deferred_activation_disabled() { + var stateBundle = ClusterStateBundleUtil.makeBundleBuilder("distributor:2 storage:2") + .deferredActivation(false) + .deriveAndBuild(); + assertThat(roundtripEncode(stateBundle), equalTo(stateBundle)); + } + } |