use of akka.testkit.JavaTestKit in project flink by apache.
the class ClusterShutdownITCase method testClusterShutdownWithoutResourceManager.
/**
* Tests a faked cluster shutdown procedure without the ResourceManager.
*/
@Test
public void testClusterShutdownWithoutResourceManager() {
new JavaTestKit(system) {
{
new Within(duration("30 seconds")) {
@Override
protected void run() {
ActorGateway me = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
// start job manager which doesn't shutdown the actor system
ActorGateway jobManager = TestingUtils.createJobManager(system, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), config, "jobmanager1");
// Tell the JobManager to inform us of shutdown actions
jobManager.tell(TestingMessages.getNotifyOfComponentShutdown(), me);
// Register a TaskManager
ActorGateway taskManager = TestingUtils.createTaskManager(system, jobManager, config, true, true);
// Tell the TaskManager to inform us of TaskManager shutdowns
taskManager.tell(TestingMessages.getNotifyOfComponentShutdown(), me);
// No resource manager connected
jobManager.tell(new StopCluster(ApplicationStatus.SUCCEEDED, "Shutting down."), me);
expectMsgAllOf(new TestingMessages.ComponentShutdown(taskManager.actor()), new TestingMessages.ComponentShutdown(jobManager.actor()), StopClusterSuccessful.getInstance());
}
};
}
};
}
use of akka.testkit.JavaTestKit in project flink by apache.
the class ResourceManagerITCase method testResourceManagerTaskManagerRegistration.
/**
* Tests whether the resource manager gets informed upon TaskManager registration.
*/
@Test
public void testResourceManagerTaskManagerRegistration() {
new JavaTestKit(system) {
{
new Within(duration("30 seconds")) {
@Override
protected void run() {
ActorGateway jobManager = TestingUtils.createJobManager(system, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), config, "RegTest");
ActorGateway me = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
// start the resource manager
ActorGateway resourceManager = TestingUtils.createResourceManager(system, jobManager.actor(), config);
// notify about a resource manager registration at the job manager
resourceManager.tell(new TestingResourceManager.NotifyWhenResourceManagerConnected(), me);
// Wait for resource manager
expectMsgEquals(Acknowledge.get());
// start task manager and wait for registration
ActorGateway taskManager = TestingUtils.createTaskManager(system, jobManager.actor(), config, true, true);
// check if we registered the task manager resource
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), me);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
}
};
}
};
}
use of akka.testkit.JavaTestKit in project flink by apache.
the class ResourceManagerTest method testJobManagerRegistrationAndReconciliation.
/**
* Tests the registration and reconciliation of the ResourceManager with the JobManager
*/
@Test
public void testJobManagerRegistrationAndReconciliation() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), config);
expectMsgClass(RegisterResourceManager.class);
List<ResourceID> resourceList = new ArrayList<>();
resourceList.add(ResourceID.generate());
resourceList.add(ResourceID.generate());
resourceList.add(ResourceID.generate());
resourceManager.tell(new RegisterResourceManagerSuccessful(fakeJobManager.actor(), resourceList), fakeJobManager);
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
for (ResourceID id : resourceList) {
if (!reply.resources.contains(id)) {
fail("Expected to find all resources that were provided during registration.");
}
}
}
};
}
};
}
use of akka.testkit.JavaTestKit in project flink by apache.
the class ResourceManagerTest method testResourceRemoval.
@Test
public void testResourceRemoval() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), config);
// register with JM
expectMsgClass(RegisterResourceManager.class);
resourceManager.tell(new RegisterResourceManagerSuccessful(fakeJobManager.actor(), Collections.<ResourceID>emptyList()), fakeJobManager);
ResourceID resourceID = ResourceID.generate();
// remove unknown resource
resourceManager.tell(new RemoveResource(resourceID), fakeJobManager);
// Send task manager registration
resourceManager.tell(new NotifyResourceStarted(resourceID), fakeJobManager);
expectMsgClass(Acknowledge.class);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
TestingResourceManager.GetRegisteredResourcesReply reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(1, reply.resources.size());
assertTrue(reply.resources.contains(resourceID));
// remove resource
resourceManager.tell(new RemoveResource(resourceID), fakeJobManager);
// check for number registration of registered resources
resourceManager.tell(new TestingResourceManager.GetRegisteredResources(), fakeJobManager);
reply = expectMsgClass(TestingResourceManager.GetRegisteredResourcesReply.class);
assertEquals(0, reply.resources.size());
}
};
}
};
}
use of akka.testkit.JavaTestKit in project flink by apache.
the class ResourceManagerTest method testDelayedJobManagerRegistration.
/**
* Tests delayed or erroneous registration of the ResourceManager with the JobManager
*/
@Test
public void testDelayedJobManagerRegistration() {
new JavaTestKit(system) {
{
new Within(duration("10 seconds")) {
@Override
protected void run() {
// set a short timeout for lookups
Configuration shortTimeoutConfig = config.clone();
shortTimeoutConfig.setString(ConfigConstants.AKKA_LOOKUP_TIMEOUT, "1 s");
fakeJobManager = TestingUtils.createForwardingActor(system, getTestActor(), Option.<String>empty());
resourceManager = TestingUtils.createResourceManager(system, fakeJobManager.actor(), shortTimeoutConfig);
// wait for registration message
RegisterResourceManager msg = expectMsgClass(RegisterResourceManager.class);
// give wrong response
getLastSender().tell(new JobManagerMessages.LeaderSessionMessage(null, new Object()), fakeJobManager.actor());
// expect another retry and let it time out
expectMsgClass(RegisterResourceManager.class);
// wait for next try after timeout
expectMsgClass(RegisterResourceManager.class);
}
};
}
};
}
Aggregations