use of org.opendaylight.mdsal.eos.dom.api.DOMEntity in project controller by opendaylight.
the class EntityOwnershipShardTest method testOnRegisterCandidateLocalWithIsolatedLeader.
@Test
public void testOnRegisterCandidateLocalWithIsolatedLeader() throws Exception {
testLog.info("testOnRegisterCandidateLocalWithIsolatedLeader starting");
final ShardTestKit kit = new ShardTestKit(getSystem());
dataStoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(2).shardIsolatedLeaderCheckIntervalInMillis(50);
ShardIdentifier leaderId = newShardId(LOCAL_MEMBER_NAME);
ShardIdentifier peerId = newShardId(PEER_MEMBER_1_NAME);
TestActorRef<TestEntityOwnershipShard> peer = actorFactory.createTestActor(TestEntityOwnershipShard.props(newShardBuilder(peerId, peerMap(leaderId.toString()), PEER_MEMBER_1_NAME)), peerId.toString());
TestEntityOwnershipShard peerShard = peer.underlyingActor();
peerShard.startDroppingMessagesOfType(ElectionTimeout.class);
TestActorRef<EntityOwnershipShard> leader = actorFactory.createTestActor(newShardProps(leaderId, peerMap(peerId.toString()), LOCAL_MEMBER_NAME));
ShardTestKit.waitUntilLeader(leader);
// Drop AppendEntries and wait enough time for the shard to switch to IsolatedLeader.
peerShard.startDroppingMessagesOfType(AppendEntries.class);
verifyRaftState(leader, state -> assertEquals("getRaftState", RaftState.IsolatedLeader.toString(), state.getRaftState()));
YangInstanceIdentifier entityId = ENTITY_ID1;
DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
leader.tell(new RegisterCandidateLocal(entity), kit.getRef());
kit.expectMsgClass(SuccessReply.class);
// Resume AppendEntries - the candidate write should now be committed.
peerShard.stopDroppingMessagesOfType(AppendEntries.class);
verifyCommittedEntityCandidate(leader, ENTITY_TYPE, entityId, LOCAL_MEMBER_NAME);
verifyOwner(leader, ENTITY_TYPE, entityId, LOCAL_MEMBER_NAME);
testLog.info("testOnRegisterCandidateLocalWithIsolatedLeader ending");
}
Aggregations