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

The following examples show how to use org.apache.flink.client.cli.util.MockedCliFrontend#savepoint() . 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: CliFrontendSavepointTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointSuccess() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointPath = "expectedSavepointPath";

	final ClusterClient<String> clusterClient = createClusterClient(savepointPath);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), isNull(String.class));

		assertTrue(buffer.toString().contains(savepointPath));
	}
	finally {
		clusterClient.shutdown();
		restoreStdOutAndStdErr();
	}
}
 
Example 2
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointSuccess() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointPath = "expectedSavepointPath";

	final ClusterClient<String> clusterClient = createClusterClient(savepointPath);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), isNull(String.class));

		assertTrue(buffer.toString().contains(savepointPath));
	}
	finally {
		clusterClient.shutdown();
		restoreStdOutAndStdErr();
	}
}
 
Example 3
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTriggerSavepointSuccess() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointPath = "expectedSavepointPath";

	final ClusterClient<String> clusterClient = createClusterClient(savepointPath);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), isNull(String.class));

		assertTrue(buffer.toString().contains(savepointPath));
	}
	finally {
		clusterClient.close();
		restoreStdOutAndStdErr();
	}
}
 
Example 4
Source File: CliFrontendSavepointTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String expectedTestException = "expectedTestException";
	Exception testException = new Exception(expectedTestException);

	final ClusterClient<String> clusterClient = createFailingClusterClient(testException);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };

		try {
			frontend.savepoint(parameters);

			fail("Savepoint should have failed.");
		} catch (FlinkException e) {
			assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent());
		}
	}
	finally {
		clusterClient.shutdown();
		restoreStdOutAndStdErr();
	}
}
 
Example 5
Source File: CliFrontendSavepointTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a CLI call with a custom savepoint directory target is
 * forwarded correctly to the cluster client.
 */
@Test
public void testTriggerSavepointCustomTarget() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointDirectory = "customTargetDirectory";

	final ClusterClient<String> clusterClient = createClusterClient(savepointDirectory);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString(), savepointDirectory };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), eq(savepointDirectory));

		assertTrue(buffer.toString().contains(savepointDirectory));
	}
	finally {
		clusterClient.shutdown();

		restoreStdOutAndStdErr();
	}
}
 
Example 6
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String expectedTestException = "expectedTestException";
	Exception testException = new Exception(expectedTestException);

	final ClusterClient<String> clusterClient = createFailingClusterClient(testException);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };

		try {
			frontend.savepoint(parameters);

			fail("Savepoint should have failed.");
		} catch (FlinkException e) {
			assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent());
		}
	}
	finally {
		clusterClient.shutdown();
		restoreStdOutAndStdErr();
	}
}
 
Example 7
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a CLI call with a custom savepoint directory target is
 * forwarded correctly to the cluster client.
 */
@Test
public void testTriggerSavepointCustomTarget() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointDirectory = "customTargetDirectory";

	final ClusterClient<String> clusterClient = createClusterClient(savepointDirectory);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString(), savepointDirectory };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), eq(savepointDirectory));

		assertTrue(buffer.toString().contains(savepointDirectory));
	}
	finally {
		clusterClient.shutdown();

		restoreStdOutAndStdErr();
	}
}
 
Example 8
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTriggerSavepointFailure() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String expectedTestException = "expectedTestException";
	Exception testException = new Exception(expectedTestException);

	final ClusterClient<String> clusterClient = createFailingClusterClient(testException);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString() };

		try {
			frontend.savepoint(parameters);

			fail("Savepoint should have failed.");
		} catch (FlinkException e) {
			assertTrue(ExceptionUtils.findThrowableWithMessage(e, expectedTestException).isPresent());
		}
	}
	finally {
		clusterClient.close();
		restoreStdOutAndStdErr();
	}
}
 
Example 9
Source File: CliFrontendSavepointTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a CLI call with a custom savepoint directory target is
 * forwarded correctly to the cluster client.
 */
@Test
public void testTriggerSavepointCustomTarget() throws Exception {
	replaceStdOutAndStdErr();

	JobID jobId = new JobID();

	String savepointDirectory = "customTargetDirectory";

	final ClusterClient<String> clusterClient = createClusterClient(savepointDirectory);

	try {
		MockedCliFrontend frontend = new MockedCliFrontend(clusterClient);

		String[] parameters = { jobId.toString(), savepointDirectory };
		frontend.savepoint(parameters);

		verify(clusterClient, times(1))
			.triggerSavepoint(eq(jobId), eq(savepointDirectory));

		assertTrue(buffer.toString().contains(savepointDirectory));
	}
	finally {
		clusterClient.close();

		restoreStdOutAndStdErr();
	}
}