private void doSubmitAndAssert() throws Exception {
YarnClient client = (YarnClient) ctx.getBean("yarnClient");
assertThat(client, notNullValue());
ApplicationId applicationId = client.submitApplication();
assertThat(applicationId, notNullValue());
YarnApplicationState state = null;
for (int i = 0; i<120; i++) {
state = findState(client, applicationId);
if (state == null) {
break;
}
if (state.equals(YarnApplicationState.FINISHED) || state.equals(YarnApplicationState.FAILED)) {
break;
}
Thread.sleep(1000);
}
assertThat(state, notNullValue());
YarnCluster cluster = (YarnCluster) ctx.getBean("yarnCluster");
File testWorkDir = cluster.getYarnWorkDir();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
String locationPattern = "file:" + testWorkDir.getAbsolutePath() + "/**/" + applicationId.toString() + "/**/*.std*";
Resource[] resources = resolver.getResources(locationPattern);
// get possible appmaster error from stderr file
StringBuilder masterFailReason = new StringBuilder();
for (Resource res : resources) {