YARN-7529. TestYarnNativeServices#testRecoverComponentsAfterRMRestart() fails intermittently. Contributed by Chandni Singh
This commit is contained in:
parent
6903cf096e
commit
6f9d7a146d
@ -176,7 +176,8 @@ public void testRecoverComponentsAfterRMRestart() throws Exception {
|
|||||||
ServiceClient client = createClient();
|
ServiceClient client = createClient();
|
||||||
Service exampleApp = createExampleApplication();
|
Service exampleApp = createExampleApplication();
|
||||||
client.actionCreate(exampleApp);
|
client.actionCreate(exampleApp);
|
||||||
waitForAllCompToBeReady(client, exampleApp);
|
Multimap<String, String> containersBeforeFailure =
|
||||||
|
waitForAllCompToBeReady(client, exampleApp);
|
||||||
|
|
||||||
LOG.info("Restart the resource manager");
|
LOG.info("Restart the resource manager");
|
||||||
getYarnCluster().restartResourceManager(
|
getYarnCluster().restartResourceManager(
|
||||||
@ -191,9 +192,6 @@ public void testRecoverComponentsAfterRMRestart() throws Exception {
|
|||||||
ApplicationAttemptId applicationAttemptId = client.getYarnClient()
|
ApplicationAttemptId applicationAttemptId = client.getYarnClient()
|
||||||
.getApplicationReport(exampleAppId).getCurrentApplicationAttemptId();
|
.getApplicationReport(exampleAppId).getCurrentApplicationAttemptId();
|
||||||
|
|
||||||
Multimap<String, String> containersBeforeFailure = getContainersForAllComp(
|
|
||||||
client, exampleApp);
|
|
||||||
|
|
||||||
LOG.info("Fail the application attempt {}", applicationAttemptId);
|
LOG.info("Fail the application attempt {}", applicationAttemptId);
|
||||||
client.getYarnClient().failApplicationAttempt(applicationAttemptId);
|
client.getYarnClient().failApplicationAttempt(applicationAttemptId);
|
||||||
//wait until attempt 2 is running
|
//wait until attempt 2 is running
|
||||||
@ -208,7 +206,7 @@ public void testRecoverComponentsAfterRMRestart() throws Exception {
|
|||||||
}
|
}
|
||||||
}, 2000, 200000);
|
}, 2000, 200000);
|
||||||
|
|
||||||
Multimap<String, String> containersAfterFailure = getContainersForAllComp(
|
Multimap<String, String> containersAfterFailure = waitForAllCompToBeReady(
|
||||||
client, exampleApp);
|
client, exampleApp);
|
||||||
Assert.assertEquals("component container affected by restart",
|
Assert.assertEquals("component container affected by restart",
|
||||||
containersBeforeFailure, containersAfterFailure);
|
containersBeforeFailure, containersAfterFailure);
|
||||||
@ -318,14 +316,26 @@ private void waitForOneCompToBeReady(ServiceClient client,
|
|||||||
}, 2000, 200000);
|
}, 2000, 200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until all the containers for all components become ready state
|
/**
|
||||||
private void waitForAllCompToBeReady(ServiceClient client,
|
* Wait until all the containers for all components become ready state.
|
||||||
|
*
|
||||||
|
* @param client
|
||||||
|
* @param exampleApp
|
||||||
|
* @return all ready containers of a service.
|
||||||
|
* @throws TimeoutException
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
private Multimap<String, String> waitForAllCompToBeReady(ServiceClient client,
|
||||||
Service exampleApp) throws TimeoutException, InterruptedException {
|
Service exampleApp) throws TimeoutException, InterruptedException {
|
||||||
int expectedTotalContainers = countTotalContainers(exampleApp);
|
int expectedTotalContainers = countTotalContainers(exampleApp);
|
||||||
|
|
||||||
|
Multimap<String, String> allContainers = HashMultimap.create();
|
||||||
|
|
||||||
GenericTestUtils.waitFor(() -> {
|
GenericTestUtils.waitFor(() -> {
|
||||||
try {
|
try {
|
||||||
Service retrievedApp = client.getStatus(exampleApp.getName());
|
Service retrievedApp = client.getStatus(exampleApp.getName());
|
||||||
int totalReadyContainers = 0;
|
int totalReadyContainers = 0;
|
||||||
|
allContainers.clear();
|
||||||
LOG.info("Num Components " + retrievedApp.getComponents().size());
|
LOG.info("Num Components " + retrievedApp.getComponents().size());
|
||||||
for (Component component : retrievedApp.getComponents()) {
|
for (Component component : retrievedApp.getComponents()) {
|
||||||
LOG.info("looking for " + component.getName());
|
LOG.info("looking for " + component.getName());
|
||||||
@ -339,6 +349,7 @@ private void waitForAllCompToBeReady(ServiceClient client,
|
|||||||
+ component.getName());
|
+ component.getName());
|
||||||
if (container.getState() == ContainerState.READY) {
|
if (container.getState() == ContainerState.READY) {
|
||||||
totalReadyContainers++;
|
totalReadyContainers++;
|
||||||
|
allContainers.put(component.getName(), container.getId());
|
||||||
LOG.info("Found 1 ready container " + container.getId());
|
LOG.info("Found 1 ready container " + container.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,23 +369,6 @@ private void waitForAllCompToBeReady(ServiceClient client,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, 2000, 200000);
|
}, 2000, 200000);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all containers of a service.
|
|
||||||
*/
|
|
||||||
private Multimap<String, String> getContainersForAllComp(ServiceClient client,
|
|
||||||
Service example) throws IOException, YarnException {
|
|
||||||
|
|
||||||
Multimap<String, String> allContainers = HashMultimap.create();
|
|
||||||
Service retrievedApp = client.getStatus(example.getName());
|
|
||||||
retrievedApp.getComponents().forEach(component -> {
|
|
||||||
if (component.getContainers() != null) {
|
|
||||||
component.getContainers().forEach(container -> {
|
|
||||||
allContainers.put(component.getName(), container.getId());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return allContainers;
|
return allContainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user