Search in sources :

Example 1 with TestingClusterClient

use of org.apache.flink.client.program.TestingClusterClient in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithExplicitSavepointType.

@Test
public void testStopWithExplicitSavepointType() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { "-p", "test-target-dir", jid.toString(), "-type", SavepointFormatType.NATIVE.toString() };
    OneShotLatch stopWithSavepointLatch = new OneShotLatch();
    TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
    clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
        assertThat(jobID, is(jid));
        assertThat(advanceToEndOfEventTime, is(false));
        assertThat(savepointDirectory, is("test-target-dir"));
        stopWithSavepointLatch.trigger();
        return CompletableFuture.completedFuture(savepointDirectory);
    });
    MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
    testFrontend.stop(parameters);
    stopWithSavepointLatch.await();
}
Also used : MockedCliFrontend(org.apache.flink.client.cli.util.MockedCliFrontend) TestingClusterClient(org.apache.flink.client.program.TestingClusterClient) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 2 with TestingClusterClient

use of org.apache.flink.client.program.TestingClusterClient in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithExplicitSavepointDir.

@Test
public void testStopWithExplicitSavepointDir() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { "-p", "test-target-dir", jid.toString() };
    OneShotLatch stopWithSavepointLatch = new OneShotLatch();
    TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
    clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
        assertThat(jobID, is(jid));
        assertThat(advanceToEndOfEventTime, is(false));
        assertThat(savepointDirectory, is("test-target-dir"));
        stopWithSavepointLatch.trigger();
        return CompletableFuture.completedFuture(savepointDirectory);
    });
    MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
    testFrontend.stop(parameters);
    stopWithSavepointLatch.await();
}
Also used : MockedCliFrontend(org.apache.flink.client.cli.util.MockedCliFrontend) TestingClusterClient(org.apache.flink.client.program.TestingClusterClient) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 3 with TestingClusterClient

use of org.apache.flink.client.program.TestingClusterClient in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithMaxWMAndExplicitSavepointDir.

@Test
public void testStopWithMaxWMAndExplicitSavepointDir() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { "-d", "-p", "test-target-dir", jid.toString() };
    OneShotLatch stopWithSavepointLatch = new OneShotLatch();
    TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
    clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
        assertThat(jobID, is(jid));
        assertThat(advanceToEndOfEventTime, is(true));
        assertThat(savepointDirectory, is("test-target-dir"));
        stopWithSavepointLatch.trigger();
        return CompletableFuture.completedFuture(savepointDirectory);
    });
    MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
    testFrontend.stop(parameters);
    stopWithSavepointLatch.await();
}
Also used : MockedCliFrontend(org.apache.flink.client.cli.util.MockedCliFrontend) TestingClusterClient(org.apache.flink.client.program.TestingClusterClient) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 4 with TestingClusterClient

use of org.apache.flink.client.program.TestingClusterClient in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithOnlyJobId.

@Test
public void testStopWithOnlyJobId() throws Exception {
    // test stop properly
    JobID jid = new JobID();
    String jidString = jid.toString();
    String[] parameters = { jidString };
    OneShotLatch stopWithSavepointLatch = new OneShotLatch();
    TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
    clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory, formatType) -> {
        assertThat(jobID, is(jid));
        assertThat(advanceToEndOfEventTime, is(false));
        assertNull(savepointDirectory);
        stopWithSavepointLatch.trigger();
        return CompletableFuture.completedFuture(savepointDirectory);
    });
    MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
    testFrontend.stop(parameters);
    stopWithSavepointLatch.await();
}
Also used : MockedCliFrontend(org.apache.flink.client.cli.util.MockedCliFrontend) TestingClusterClient(org.apache.flink.client.program.TestingClusterClient) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 5 with TestingClusterClient

use of org.apache.flink.client.program.TestingClusterClient in project flink by apache.

the class CliFrontendStopWithSavepointTest method testWrongSavepointDirOrder.

@Test(expected = CliArgsException.class)
public void testWrongSavepointDirOrder() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { "-s", "-d", "test-target-dir", jid.toString() };
    MockedCliFrontend testFrontend = new MockedCliFrontend(new TestingClusterClient());
    testFrontend.stop(parameters);
}
Also used : MockedCliFrontend(org.apache.flink.client.cli.util.MockedCliFrontend) TestingClusterClient(org.apache.flink.client.program.TestingClusterClient) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

JobID (org.apache.flink.api.common.JobID)10 MockedCliFrontend (org.apache.flink.client.cli.util.MockedCliFrontend)10 TestingClusterClient (org.apache.flink.client.program.TestingClusterClient)10 Test (org.junit.Test)10 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)8 FlinkException (org.apache.flink.util.FlinkException)1