Search in sources :

Example 16 with MockedCliFrontend

use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithDefaultSavepointDir.

@Test
public void testStopWithDefaultSavepointDir() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { 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));
        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 17 with MockedCliFrontend

use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.

the class CliFrontendStopWithSavepointTest method testStopWithMaxWMAndDefaultSavepointDir.

@Test
public void testStopWithMaxWMAndDefaultSavepointDir() throws Exception {
    JobID jid = new JobID();
    String[] parameters = { "-p", "-d", 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));
        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 18 with MockedCliFrontend

use of org.apache.flink.client.cli.util.MockedCliFrontend in project flink by apache.

the class CliFrontendCancelTest method testCancel.

@Test
public void testCancel() throws Exception {
    // test cancel properly
    JobID jid = new JobID();
    OneShotLatch cancelLatch = new OneShotLatch();
    String[] parameters = { jid.toString() };
    TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
    clusterClient.setCancelFunction(jobID -> {
        cancelLatch.trigger();
        return CompletableFuture.completedFuture(Acknowledge.get());
    });
    MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
    testFrontend.cancel(parameters);
    cancelLatch.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)

Aggregations

MockedCliFrontend (org.apache.flink.client.cli.util.MockedCliFrontend)18 Test (org.junit.Test)18 JobID (org.apache.flink.api.common.JobID)14 TestingClusterClient (org.apache.flink.client.program.TestingClusterClient)10 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)8 FlinkException (org.apache.flink.util.FlinkException)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ClusterClient (org.apache.flink.client.program.ClusterClient)1 RestClusterClient (org.apache.flink.client.program.rest.RestClusterClient)1