Search in sources :

Example 21 with JavaTestKit

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());
                }
            };
        }
    };
}
Also used : TestingMessages(org.apache.flink.runtime.testingUtils.TestingMessages) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) StopCluster(org.apache.flink.runtime.clusterframework.messages.StopCluster) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 22 with JavaTestKit

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());
                }
            };
        }
    };
}
Also used : TestingResourceManager(org.apache.flink.runtime.testutils.TestingResourceManager) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 23 with JavaTestKit

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.");
                        }
                    }
                }
            };
        }
    };
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TestingResourceManager(org.apache.flink.runtime.testutils.TestingResourceManager) ArrayList(java.util.ArrayList) RegisterResourceManagerSuccessful(org.apache.flink.runtime.clusterframework.messages.RegisterResourceManagerSuccessful) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 24 with JavaTestKit

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());
                }
            };
        }
    };
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TestingResourceManager(org.apache.flink.runtime.testutils.TestingResourceManager) RegisterResourceManagerSuccessful(org.apache.flink.runtime.clusterframework.messages.RegisterResourceManagerSuccessful) RemoveResource(org.apache.flink.runtime.clusterframework.messages.RemoveResource) NotifyResourceStarted(org.apache.flink.runtime.clusterframework.messages.NotifyResourceStarted) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 25 with JavaTestKit

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);
                }
            };
        }
    };
}
Also used : Configuration(org.apache.flink.configuration.Configuration) JobManagerMessages(org.apache.flink.runtime.messages.JobManagerMessages) JavaTestKit(akka.testkit.JavaTestKit) RegisterResourceManager(org.apache.flink.runtime.clusterframework.messages.RegisterResourceManager) Test(org.junit.Test)

Aggregations

JavaTestKit (akka.testkit.JavaTestKit)49 Test (org.junit.Test)47 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)34 Configuration (org.apache.flink.configuration.Configuration)26 AkkaActorGateway (org.apache.flink.runtime.instance.AkkaActorGateway)23 JobID (org.apache.flink.api.common.JobID)17 ActorRef (akka.actor.ActorRef)16 TaskManagerServicesConfiguration (org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration)13 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)12 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)12 IOException (java.io.IOException)11 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)11 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)11 FiniteDuration (scala.concurrent.duration.FiniteDuration)11 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)10 PartitionNotFoundException (org.apache.flink.runtime.io.network.partition.PartitionNotFoundException)10 SubmitTask (org.apache.flink.runtime.messages.TaskMessages.SubmitTask)10 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)9 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)9 TestingTaskManagerMessages (org.apache.flink.runtime.testingUtils.TestingTaskManagerMessages)9