use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardManagerTest method testServerRemovedShardActorRunning.
@Test
public void testServerRemovedShardActorRunning() throws Exception {
LOG.info("testServerRemovedShardActorRunning starting");
new TestKit(getSystem()) {
{
MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder().put("default", Arrays.asList("member-1", "member-2")).put("astronauts", Arrays.asList("member-2")).put("people", Arrays.asList("member-1", "member-2")).build());
String shardId = ShardIdentifier.create("default", MEMBER_1, shardMrgIDSuffix).toString();
ActorRef shard = actorFactory.createActor(MessageCollectorActor.props(), shardId);
TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(newTestShardMgrBuilder(mockConfig).addShardActor("default", shard).props().withDispatcher(Dispatchers.DefaultDispatcherId()));
shardManager.underlyingActor().waitForRecoveryComplete();
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new ActorInitialized(), shard);
waitForShardInitialized(shardManager, "people", this);
waitForShardInitialized(shardManager, "default", this);
// Removed the default shard replica from member-1
shardManager.tell(new ServerRemoved(shardId), getRef());
shardManager.underlyingActor().verifySnapshotPersisted(Sets.newHashSet("people"));
MessageCollectorActor.expectFirstMatching(shard, Shutdown.class);
}
};
LOG.info("testServerRemovedShardActorRunning ending");
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardManagerTest method testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard.
@Test
public void testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard() throws Exception {
LOG.info("testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard starting");
new TestKit(getSystem()) {
{
final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new ActorInitialized(), mockShardActor);
shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), getRef());
expectMsgClass(duration("2 seconds"), NoShardLeaderException.class);
}
};
LOG.info("testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard ending");
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardManagerTest method testOnReceiveFindLocalShardForNotInitializedShard.
@Test
public void testOnReceiveFindLocalShardForNotInitializedShard() throws Exception {
new TestKit(getSystem()) {
{
final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());
shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), getRef());
expectMsgClass(duration("5 seconds"), NotInitializedException.class);
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardManagerTest method testReadyCountDownForMemberUpAfterLeaderStateChanged.
@Test
public void testReadyCountDownForMemberUpAfterLeaderStateChanged() throws Exception {
new TestKit(getSystem()) {
{
TestShardManager shardManager = newTestShardManager();
String memberId = "member-1-shard-default-" + shardMrgIDSuffix;
shardManager.onReceiveCommand(new RoleChangeNotification(memberId, null, RaftState.Follower.name()));
verify(ready, never()).countDown();
shardManager.onReceiveCommand(new ShardLeaderStateChanged(memberId, "member-2-shard-default-" + shardMrgIDSuffix, mock(DataTree.class), DataStoreVersions.CURRENT_VERSION));
shardManager.onReceiveCommand(MockClusterWrapper.createMemberUp("member-2", getRef().path().toString()));
verify(ready, times(1)).countDown();
}
};
}
use of akka.testkit.javadsl.TestKit in project controller by opendaylight.
the class ShardManagerTest method testOnReceiveFindLocalShardForNonExistentShard.
@Test
public void testOnReceiveFindLocalShardForNonExistentShard() throws Exception {
new TestKit(getSystem()) {
{
final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor());
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
shardManager.tell(new FindLocalShard("non-existent", false), getRef());
LocalShardNotFound notFound = expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
assertEquals("getShardName", "non-existent", notFound.getShardName());
}
};
}
Aggregations