return 0; case ACTION_SAVEPOINT: savepoint(params); return 0; case ACTION_MODIFY:
/** * Tests disposal with a JAR file. */ @Test public void testDisposeWithJar() throws Exception { replaceStdOutAndStdErr(); final CompletableFuture<String> disposeSavepointFuture = new CompletableFuture<>(); final DisposeSavepointClusterClient clusterClient = new DisposeSavepointClusterClient( (String savepointPath) -> { disposeSavepointFuture.complete(savepointPath); return CompletableFuture.completedFuture(Acknowledge.get()); }, getConfiguration()); try { CliFrontend frontend = new MockedCliFrontend(clusterClient); // Fake JAR file File f = tmp.newFile(); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f)); out.close(); final String disposePath = "any-path"; String[] parameters = { "-d", disposePath, "-j", f.getAbsolutePath() }; frontend.savepoint(parameters); final String actualSavepointPath = disposeSavepointFuture.get(); assertEquals(disposePath, actualSavepointPath); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testDisposeSavepointSuccess() throws Exception { replaceStdOutAndStdErr(); String savepointPath = "expectedSavepointPath"; ClusterClient clusterClient = new DisposeSavepointClusterClient( (String path) -> CompletableFuture.completedFuture(Acknowledge.get()), getConfiguration()); try { CliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { "-d", savepointPath }; frontend.savepoint(parameters); String outMsg = buffer.toString(); assertTrue(outMsg.contains(savepointPath)); assertTrue(outMsg.contains("disposed")); } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testDisposeSavepointFailure() throws Exception { replaceStdOutAndStdErr(); String savepointPath = "expectedSavepointPath"; Exception testException = new Exception("expectedTestException"); DisposeSavepointClusterClient clusterClient = new DisposeSavepointClusterClient((String path) -> FutureUtils.completedExceptionally(testException), getConfiguration()); try { CliFrontend frontend = new MockedCliFrontend(clusterClient); String[] parameters = { "-d", savepointPath }; try { frontend.savepoint(parameters); fail("Savepoint should have failed."); } catch (Exception e) { assertTrue(ExceptionUtils.findThrowableWithMessage(e, testException.getMessage()).isPresent()); } } finally { clusterClient.shutdown(); restoreStdOutAndStdErr(); } }
@Test public void testTriggerSavepointFailureIllegalJobID() throws Exception { replaceStdOutAndStdErr(); try { CliFrontend frontend = new MockedCliFrontend(new StandaloneClusterClient( getConfiguration(), new TestingHighAvailabilityServices(), false)); String[] parameters = { "invalid job id" }; try { frontend.savepoint(parameters); fail("Should have failed."); } catch (CliArgsException e) { assertThat(e.getMessage(), Matchers.containsString("Cannot parse JobID")); } } finally { restoreStdOutAndStdErr(); } }
return 0; case ACTION_SAVEPOINT: savepoint(params); return 0; case ACTION_MODIFY:
return 0; case ACTION_SAVEPOINT: savepoint(params); return 0; case ACTION_MODIFY: