Java Code Examples for org.apache.flink.client.cli.util.MockedCliFrontend#stop()

The following examples show how to use org.apache.flink.client.cli.util.MockedCliFrontend#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnknownJobId() throws Exception {
	// test unknown job Id
	JobID jid = new JobID();

	String[] parameters = { "-p", "test-target-dir", jid.toString() };
	String expectedMessage = "Test exception";
	FlinkException testException = new FlinkException(expectedMessage);
	final ClusterClient<String> clusterClient = createClusterClient(testException);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);

	try {
		testFrontend.stop(parameters);
		fail("Should have failed.");
	} catch (FlinkException e) {
		assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedMessage).isPresent());
	}
}
 
Example 2
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnknownJobId() throws Exception {
	// test unknown job Id
	JobID jid = new JobID();

	String[] parameters = { "-p", "test-target-dir", jid.toString() };
	String expectedMessage = "Test exception";
	FlinkException testException = new FlinkException(expectedMessage);
	TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
	clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory) -> FutureUtils.completedExceptionally(testException));
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);

	try {
		testFrontend.stop(parameters);
		fail("Should have failed.");
	} catch (FlinkException e) {
		assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedMessage).isPresent());
	}
}
 
Example 3
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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) -> {
		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();
}
 
Example 4
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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) -> {
		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();
}
 
Example 5
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testStopOnlyWithMaxWM() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-d", jid.toString() };
	OneShotLatch stopWithSavepointLatch = new OneShotLatch();
	TestingClusterClient<String> clusterClient = new TestingClusterClient<>();
	clusterClient.setStopWithSavepointFunction((jobID, advanceToEndOfEventTime, savepointDirectory) -> {
		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();
}
 
Example 6
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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) -> {
		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();
}
 
Example 7
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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) -> {
		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();
}
 
Example 8
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@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) -> {
		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();
}
 
Example 9
Source File: CliFrontendStopTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnknownJobId() throws Exception {
	// test unknown job Id
	JobID jid = new JobID();

	String[] parameters = { jid.toString() };
	String expectedMessage = "Test exception";
	FlinkException testException = new FlinkException(expectedMessage);
	final ClusterClient<String> clusterClient = createClusterClient(testException);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);

	try {
		testFrontend.stop(parameters);
		fail("Should have failed.");
	} catch (FlinkException e) {
		assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedMessage).isPresent());
	}
}
 
Example 10
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = CliArgsException.class)
public void testWrongSavepointDirOrder() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-s", "-d", "test-target-dir", jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(false), eq("test-target-dir"));
}
 
Example 11
Source File: CliFrontendStopTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testStop() throws Exception {
	// test stop properly
	JobID jid = new JobID();
	String jidString = jid.toString();

	String[] parameters = { jidString };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);

	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1)).stop(any(JobID.class));
}
 
Example 12
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopWithMaxWMAndExplicitSavepointDir() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-d", "-p", "test-target-dir", jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(true), eq("test-target-dir"));
}
 
Example 13
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopWithMaxWMAndDefaultSavepointDir() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-p", "-d", jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(true), isNull());
}
 
Example 14
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopOnlyWithMaxWM() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-d", jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(true), isNull());
}
 
Example 15
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopWithExplicitSavepointDir() throws Exception {
	JobID jid = new JobID();

	String[] parameters = { "-p", "test-target-dir", jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(false), eq("test-target-dir"));
}
 
Example 16
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopWithDefaultSavepointDir() throws Exception {
	JobID jid = new JobID();

	String[] parameters = {jid.toString() };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);
	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(false), isNull());
}
 
Example 17
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStopWithOnlyJobId() throws Exception {
	// test stop properly
	JobID jid = new JobID();
	String jidString = jid.toString();

	String[] parameters = { jidString };
	final ClusterClient<String> clusterClient = createClusterClient(null);
	MockedCliFrontend testFrontend = new MockedCliFrontend(clusterClient);

	testFrontend.stop(parameters);

	Mockito.verify(clusterClient, times(1))
			.stopWithSavepoint(eq(jid), eq(false), isNull());
}
 
Example 18
Source File: CliFrontendStopWithSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}