shuai-xu commented on a change in pull request #9175: [FLINK-12038] [test] fix
YARNITCase random fail
URL: https://github.com/apache/flink/pull/9175#discussion_r308049271
##########
File path: flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNITCase.java
##########
@@ -117,17 +122,35 @@ public void testPerJobMode() throws Exception {
assertThat(jobResult,
is(notNullValue()));
assertThat(jobResult.getSerializedThrowable().isPresent(), is(false));
-
waitUntilApplicationFinished(applicationId, yarnAppTerminateTimeout);
+
waitApplicationFinishedElseKillIt(applicationId, yarnAppTerminateTimeout,
yarnClusterDescriptor);
} finally {
if (clusterClient != null) {
clusterClient.shutdown();
}
-
- if (applicationId != null) {
-
yarnClusterDescriptor.killCluster(applicationId);
- }
}
}
});
}
+
+ private void waitApplicationFinishedElseKillIt(
+ ApplicationId applicationId,
+ Duration timeout,
+ YarnClusterDescriptor yarnClusterDescriptor) throws
Exception {
+ Deadline deadline = Deadline.now().plus(timeout);
+ YarnApplicationState state =
yarnClient.getApplicationReport(applicationId).getYarnApplicationState();
+
+ while (state != YarnApplicationState.FINISHED) {
+ if (state == YarnApplicationState.FAILED || state ==
YarnApplicationState.KILLED) {
+ Assert.fail("Application became FAILED or
KILLED while expecting FINISHED");
+ } else {
+ sleep(sleepIntervalInMS);
+ }
+ if (deadline.isOverdue()) {
+
yarnClusterDescriptor.killCluster(applicationId);
+ Assert.fail("Application didn't finish before
timeout");
+ }
+ state =
yarnClient.getApplicationReport(applicationId).getYarnApplicationState();
Review comment:
OK
----------------------------------------------------------------
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