kl0u commented on a change in pull request #10069: [FLINK-14593][client] Port
ClusterClient to asynchronous interface version
URL: https://github.com/apache/flink/pull/10069#discussion_r343036346
##########
File path:
flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendStopWithSavepointTest.java
##########
@@ -67,78 +62,119 @@ public void testStopWithOnlyJobId() throws Exception {
String jidString = jid.toString();
String[] parameters = { jidString };
- final ClusterClient<String> clusterClient =
createClusterClient(null);
+ 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);
- Mockito.verify(clusterClient, times(1))
- .stopWithSavepoint(eq(jid), eq(false),
isNull());
+ stopWithSavepointLatch.await();
}
@Test
public void testStopWithDefaultSavepointDir() throws Exception {
JobID jid = new JobID();
String[] parameters = {jid.toString() };
- final ClusterClient<String> clusterClient =
createClusterClient(null);
+ 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);
- Mockito.verify(clusterClient, times(1))
- .stopWithSavepoint(eq(jid), eq(false),
isNull());
+ stopWithSavepointLatch.await();
}
@Test
public void testStopWithExplicitSavepointDir() throws Exception {
JobID jid = new JobID();
String[] parameters = { "-p", "test-target-dir", jid.toString()
};
- final ClusterClient<String> clusterClient =
createClusterClient(null);
+ 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);
-
- Mockito.verify(clusterClient, times(1))
- .stopWithSavepoint(eq(jid), eq(false),
eq("test-target-dir"));
+ stopWithSavepointLatch.await();
}
@Test
public void testStopOnlyWithMaxWM() throws Exception {
JobID jid = new JobID();
String[] parameters = { "-d", jid.toString() };
- final ClusterClient<String> clusterClient =
createClusterClient(null);
+ OneShotLatch stopWithSavepointLatch = new OneShotLatch();
+ TestingClusterClient<String> clusterClient = new
TestingClusterClient<>();
+ clusterClient.setStopWithSavepointFunction((jobID,
advanceToEndOfEventTime, savepointDirectory) -> {
+ assertThat(jobID, is(jid));
Review comment:
Remove a tab from all these lines for uniformity.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services