use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class LocalTransactionContextTest method testWrite.
@Test
public void testWrite() {
YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY;
NormalizedNode<?, ?> normalizedNode = mock(NormalizedNode.class);
localTransactionContext.executeModification(new WriteModification(yangInstanceIdentifier, normalizedNode));
verify(readWriteTransaction).write(yangInstanceIdentifier, normalizedNode);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class LocalTransactionContextTest method testReadyWithDeleteError.
@Test
public void testReadyWithDeleteError() {
YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY;
RuntimeException error = new RuntimeException("mock");
doThrow(error).when(readWriteTransaction).delete(yangInstanceIdentifier);
localTransactionContext.executeModification(new DeleteModification(yangInstanceIdentifier));
localTransactionContext.executeModification(new DeleteModification(yangInstanceIdentifier));
verify(readWriteTransaction).delete(yangInstanceIdentifier);
doReadyWithExpectedError(error);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class LocalTransactionContextTest method testRead.
@Test
public void testRead() {
YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY;
NormalizedNode<?, ?> normalizedNode = mock(NormalizedNode.class);
doReturn(Futures.immediateCheckedFuture(Optional.of(normalizedNode))).when(readWriteTransaction).read(yangInstanceIdentifier);
localTransactionContext.executeRead(new ReadData(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.<Optional<NormalizedNode<?, ?>>>create());
verify(readWriteTransaction).read(yangInstanceIdentifier);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class LocalTransactionContextTest method testExists.
@Test
public void testExists() {
YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.EMPTY;
doReturn(Futures.immediateCheckedFuture(true)).when(readWriteTransaction).exists(yangInstanceIdentifier);
localTransactionContext.executeRead(new DataExists(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.<Boolean>create());
verify(readWriteTransaction).exists(yangInstanceIdentifier);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier in project controller by opendaylight.
the class EntityOwnershipShardTest method testOnRegisterCandidateLocalWithNoInitialConsensus.
@Test
public void testOnRegisterCandidateLocalWithNoInitialConsensus() throws Exception {
testLog.info("testOnRegisterCandidateLocalWithNoInitialConsensus starting");
final ShardTestKit kit = new ShardTestKit(getSystem());
dataStoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(2).shardTransactionCommitTimeoutInSeconds(1);
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);
// Drop AppendEntries so consensus isn't reached.
peerShard.startDroppingMessagesOfType(AppendEntries.class);
TestActorRef<EntityOwnershipShard> leader = actorFactory.createTestActor(newShardProps(leaderId, peerMap(peerId.toString()), LOCAL_MEMBER_NAME), leaderId.toString());
ShardTestKit.waitUntilLeader(leader);
YangInstanceIdentifier entityId = ENTITY_ID1;
DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
leader.tell(new RegisterCandidateLocal(entity), kit.getRef());
kit.expectMsgClass(SuccessReply.class);
// Wait enough time for the commit to timeout.
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
// Resume AppendEntries - the follower should ack the commit which should then result in the candidate
// write being applied to the state.
peerShard.stopDroppingMessagesOfType(AppendEntries.class);
verifyCommittedEntityCandidate(leader, ENTITY_TYPE, entityId, LOCAL_MEMBER_NAME);
verifyOwner(leader, ENTITY_TYPE, entityId, LOCAL_MEMBER_NAME);
testLog.info("testOnRegisterCandidateLocalWithNoInitialConsensus ending");
}
Aggregations