Search in sources :

Example 6 with AssertWithBackoff

use of org.apache.gobblin.testing.AssertWithBackoff in project incubator-gobblin by apache.

the class GobblinAWSClusterLauncherTest method testSendShutdownRequest.

@Test(dependsOnMethods = "testGetReconnectableApplicationId")
public void testSendShutdownRequest() throws Exception {
    // Connect to Helix as Controller and register a shutdown request handler
    this.helixManager.connect();
    this.helixManager.getMessagingService().registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new TestShutdownMessageHandlerFactory(this));
    // Make Gobblin AWS Cluster launcher start a shutdown
    this.gobblinAwsClusterLauncher.connectHelixManager();
    this.gobblinAwsClusterLauncher.sendShutdownRequest();
    Assert.assertEquals(this.curatorFramework.checkExists().forPath(String.format("/%s/CONTROLLER/MESSAGES", this.helixClusterName)).getVersion(), 0);
    GetControllerMessageNumFunc getCtrlMessageNum = new GetControllerMessageNumFunc(this.helixClusterName, this.curatorFramework);
    // Assert to check if shutdown message was issued
    AssertWithBackoff assertWithBackoff = AssertWithBackoff.create().logger(LoggerFactory.getLogger("testSendShutdownRequest")).timeoutMs(20000);
    assertWithBackoff.assertEquals(getCtrlMessageNum, 1, "1 controller message queued");
    // Assert to check if shutdown message was processed
    // Give Helix sometime to handle the message
    assertWithBackoff.assertEquals(getCtrlMessageNum, 0, "all controller messages processed");
}
Also used : AssertWithBackoff(org.apache.gobblin.testing.AssertWithBackoff) TestShutdownMessageHandlerFactory(org.apache.gobblin.cluster.TestShutdownMessageHandlerFactory) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with AssertWithBackoff

use of org.apache.gobblin.testing.AssertWithBackoff in project incubator-gobblin by apache.

the class GobblinYarnAppLauncherTest method testSendShutdownRequest.

@Test(dependsOnMethods = "testCreateHelixCluster")
public void testSendShutdownRequest() throws Exception {
    this.helixManager.connect();
    this.helixManager.getMessagingService().registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new TestShutdownMessageHandlerFactory(this));
    this.gobblinYarnAppLauncher.connectHelixManager();
    this.gobblinYarnAppLauncher.sendShutdownRequest();
    Assert.assertEquals(this.curatorFramework.checkExists().forPath(String.format("/%s/CONTROLLER/MESSAGES", GobblinYarnAppLauncherTest.class.getSimpleName())).getVersion(), 0);
    YarnSecurityManagerTest.GetControllerMessageNumFunc getCtrlMessageNum = new YarnSecurityManagerTest.GetControllerMessageNumFunc(GobblinYarnAppLauncherTest.class.getSimpleName(), this.curatorFramework);
    AssertWithBackoff assertWithBackoff = AssertWithBackoff.create().logger(LoggerFactory.getLogger("testSendShutdownRequest")).timeoutMs(20000);
    assertWithBackoff.assertEquals(getCtrlMessageNum, 1, "1 controller message queued");
    // Give Helix sometime to handle the message
    assertWithBackoff.assertEquals(getCtrlMessageNum, 0, "all controller messages processed");
}
Also used : AssertWithBackoff(org.apache.gobblin.testing.AssertWithBackoff) TestShutdownMessageHandlerFactory(org.apache.gobblin.cluster.TestShutdownMessageHandlerFactory) Test(org.testng.annotations.Test)

Aggregations

AssertWithBackoff (org.apache.gobblin.testing.AssertWithBackoff)7 Test (org.testng.annotations.Test)6 Logger (org.slf4j.Logger)3 TestShutdownMessageHandlerFactory (org.apache.gobblin.cluster.TestShutdownMessageHandlerFactory)2 JobExecutionLauncher (org.apache.gobblin.runtime.api.JobExecutionLauncher)2 JobSpec (org.apache.gobblin.runtime.api.JobSpec)2 Closer (com.google.common.io.Closer)1 File (java.io.File)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 Properties (java.util.Properties)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 Configurable (org.apache.gobblin.runtime.api.Configurable)1 GobblinInstanceDriver (org.apache.gobblin.runtime.api.GobblinInstanceDriver)1 JobSpecScheduler (org.apache.gobblin.runtime.api.JobSpecScheduler)1 InMemoryJobCatalog (org.apache.gobblin.runtime.job_catalog.InMemoryJobCatalog)1 ResolvedJobSpec (org.apache.gobblin.runtime.job_spec.ResolvedJobSpec)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1