+ public void testServerConfigurationPayloadApplied() {
+ String follower1 = "follower1";
+ String follower2 = "follower2";
+ String follower3 = "follower3";
+
+ context.addToPeers(follower1, null, VotingState.VOTING);
+ context.addToPeers(follower2, null, VotingState.VOTING);
+
+ //add new Server
+ ServerConfigurationPayload obj = new ServerConfigurationPayload(Arrays.asList(
+ new ServerInfo(localId, true),
+ new ServerInfo(follower1, true),
+ new ServerInfo(follower2, false),
+ new ServerInfo(follower3, true)));
+
+ sendMessageToSupport(new SimpleReplicatedLogEntry(0, 1, obj));
+
+ //verify new peers
+ assertTrue("Dynamic server configuration", context.isDynamicServerConfigurationInUse());
+ assertEquals("New peer Ids", Sets.newHashSet(follower1, follower2, follower3),
+ Sets.newHashSet(context.getPeerIds()));
+ assertEquals("follower1 isVoting", true, context.getPeerInfo(follower1).isVoting());
+ assertEquals("follower2 isVoting", false, context.getPeerInfo(follower2).isVoting());
+ assertEquals("follower3 isVoting", true, context.getPeerInfo(follower3).isVoting());
+
+ sendMessageToSupport(new ApplyJournalEntries(0));
+
+ verify(mockCohort, never()).startLogRecoveryBatch(anyInt());
+ verify(mockCohort, never()).appendRecoveredLogEntry(any(Payload.class));
+
+ //remove existing follower1
+ obj = new ServerConfigurationPayload(Arrays.asList(
+ new ServerInfo(localId, true),
+ new ServerInfo("follower2", true),
+ new ServerInfo("follower3", true)));
+
+ sendMessageToSupport(new SimpleReplicatedLogEntry(1, 1, obj));
+
+ //verify new peers
+ assertTrue("Dynamic server configuration", context.isDynamicServerConfigurationInUse());
+ assertEquals("New peer Ids", Sets.newHashSet(follower2, follower3), Sets.newHashSet(context.getPeerIds()));
+ }