use of akka.actor.Status.Failure in project controller by opendaylight.
the class ShardManagerGetSnapshotReplyActorTest method testGetSnapshotTimeout.
@Test
public void testGetSnapshotTimeout() {
TestKit kit = new TestKit(getSystem());
ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(Arrays.asList("shard1"), "config", null, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
kit.watch(replyActor);
Failure failure = kit.expectMsgClass(Failure.class);
assertEquals("Failure cause type", TimeoutException.class, failure.cause().getClass());
kit.expectTerminated(replyActor);
}
use of akka.actor.Status.Failure in project controller by opendaylight.
the class ShardManagerTest method testAddShardReplicaWithFindPrimaryTimeout.
@Test
public void testAddShardReplicaWithFindPrimaryTimeout() throws Exception {
LOG.info("testAddShardReplicaWithFindPrimaryTimeout starting");
datastoreContextBuilder.shardInitializationTimeout(100, TimeUnit.MILLISECONDS);
new TestKit(getSystem()) {
{
MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder().put("astronauts", Arrays.asList("member-2")).build());
final ActorRef newReplicaShardManager = actorFactory.createActor(newTestShardMgrBuilder(mockConfig).shardActor(mockShardActor).props().withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);
newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
MockClusterWrapper.sendMemberUp(newReplicaShardManager, "member-2", AddressFromURIString.parse("akka://non-existent@127.0.0.1:5").toString());
newReplicaShardManager.tell(new AddShardReplica("astronauts"), getRef());
Status.Failure resp = expectMsgClass(duration("5 seconds"), Status.Failure.class);
assertEquals("Failure obtained", true, resp.cause() instanceof RuntimeException);
}
};
LOG.info("testAddShardReplicaWithFindPrimaryTimeout ending");
}
use of akka.actor.Status.Failure in project controller by opendaylight.
the class ShardManagerTest method testRemoveShardReplicaForNonExistentShard.
@Test
public void testRemoveShardReplicaForNonExistentShard() throws Exception {
new TestKit(getSystem()) {
{
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
shardManager.tell(new RemoveShardReplica("model-inventory", MEMBER_1), getRef());
Status.Failure resp = expectMsgClass(duration("10 seconds"), Status.Failure.class);
assertEquals("Failure obtained", true, resp.cause() instanceof PrimaryNotFoundException);
}
};
}
use of akka.actor.Status.Failure in project controller by opendaylight.
the class ShardManagerTest method testAddShardReplicaWithAddServerReplyFailure.
@Test
public void testAddShardReplicaWithAddServerReplyFailure() throws Exception {
LOG.info("testAddShardReplicaWithAddServerReplyFailure starting");
new TestKit(getSystem()) {
{
TestKit mockShardLeaderKit = new TestKit(getSystem());
MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.<String, List<String>>builder().put("astronauts", Arrays.asList("member-2")).build());
ActorRef mockNewReplicaShardActor = newMockShardActor(getSystem(), "astronauts", "member-1");
final TestActorRef<TestShardManager> shardManager = actorFactory.createTestActor(newTestShardMgrBuilder(mockConfig).shardActor(mockNewReplicaShardActor).props().withDispatcher(Dispatchers.DefaultDispatcherId()), shardMgrID);
shardManager.underlyingActor().setMessageInterceptor(newFindPrimaryInterceptor(mockShardLeaderKit.getRef()));
shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
TestKit terminateWatcher = new TestKit(getSystem());
terminateWatcher.watch(mockNewReplicaShardActor);
shardManager.tell(new AddShardReplica("astronauts"), getRef());
AddServer addServerMsg = mockShardLeaderKit.expectMsgClass(AddServer.class);
assertEquals("AddServer serverId", "member-1-shard-astronauts-" + shardMrgIDSuffix, addServerMsg.getNewServerId());
mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.TIMEOUT, null));
Failure failure = expectMsgClass(duration("5 seconds"), Failure.class);
assertEquals("Failure cause", TimeoutException.class, failure.cause().getClass());
shardManager.tell(new FindLocalShard("astronauts", false), getRef());
expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
terminateWatcher.expectTerminated(mockNewReplicaShardActor);
shardManager.tell(new AddShardReplica("astronauts"), getRef());
mockShardLeaderKit.expectMsgClass(AddServer.class);
mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.NO_LEADER, null));
failure = expectMsgClass(duration("5 seconds"), Failure.class);
assertEquals("Failure cause", NoShardLeaderException.class, failure.cause().getClass());
}
};
LOG.info("testAddShardReplicaWithAddServerReplyFailure ending");
}
use of akka.actor.Status.Failure in project controller by opendaylight.
the class ShardManagerTest method testAddShardReplicaForNonExistentShardConfig.
@Test
public void testAddShardReplicaForNonExistentShardConfig() throws Exception {
new TestKit(getSystem()) {
{
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
shardManager.tell(new AddShardReplica("model-inventory"), getRef());
Status.Failure resp = expectMsgClass(duration("2 seconds"), Status.Failure.class);
assertEquals("Failure obtained", true, resp.cause() instanceof IllegalArgumentException);
}
};
}
Aggregations