You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2017/11/21 18:19:36 UTC
[21/29] hadoop git commit: YARN-7529.
TestYarnNativeServices#testRecoverComponentsAfterRMRestart() fails
intermittently. Contributed by Chandni Singh
YARN-7529. TestYarnNativeServices#testRecoverComponentsAfterRMRestart() fails intermittently. Contributed by Chandni Singh
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/6f9d7a14
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/6f9d7a14
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/6f9d7a14
Branch: refs/heads/HDFS-7240
Commit: 6f9d7a146d5940a9e8a7913c19b43b265d6bfa32
Parents: 6903cf0
Author: Billie Rinaldi <bi...@apache.org>
Authored: Mon Nov 20 07:37:04 2017 -0800
Committer: Billie Rinaldi <bi...@apache.org>
Committed: Mon Nov 20 07:37:04 2017 -0800
----------------------------------------------------------------------
.../yarn/service/TestYarnNativeServices.java | 42 +++++++++-----------
1 file changed, 18 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/6f9d7a14/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java
index f98d90a..1c517d9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/TestYarnNativeServices.java
@@ -176,7 +176,8 @@ public class TestYarnNativeServices extends ServiceTestUtils {
ServiceClient client = createClient();
Service exampleApp = createExampleApplication();
client.actionCreate(exampleApp);
- waitForAllCompToBeReady(client, exampleApp);
+ Multimap<String, String> containersBeforeFailure =
+ waitForAllCompToBeReady(client, exampleApp);
LOG.info("Restart the resource manager");
getYarnCluster().restartResourceManager(
@@ -191,9 +192,6 @@ public class TestYarnNativeServices extends ServiceTestUtils {
ApplicationAttemptId applicationAttemptId = client.getYarnClient()
.getApplicationReport(exampleAppId).getCurrentApplicationAttemptId();
- Multimap<String, String> containersBeforeFailure = getContainersForAllComp(
- client, exampleApp);
-
LOG.info("Fail the application attempt {}", applicationAttemptId);
client.getYarnClient().failApplicationAttempt(applicationAttemptId);
//wait until attempt 2 is running
@@ -208,7 +206,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
}
}, 2000, 200000);
- Multimap<String, String> containersAfterFailure = getContainersForAllComp(
+ Multimap<String, String> containersAfterFailure = waitForAllCompToBeReady(
client, exampleApp);
Assert.assertEquals("component container affected by restart",
containersBeforeFailure, containersAfterFailure);
@@ -318,14 +316,26 @@ public class TestYarnNativeServices extends ServiceTestUtils {
}, 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 {
int expectedTotalContainers = countTotalContainers(exampleApp);
+
+ Multimap<String, String> allContainers = HashMultimap.create();
+
GenericTestUtils.waitFor(() -> {
try {
Service retrievedApp = client.getStatus(exampleApp.getName());
int totalReadyContainers = 0;
+ allContainers.clear();
LOG.info("Num Components " + retrievedApp.getComponents().size());
for (Component component : retrievedApp.getComponents()) {
LOG.info("looking for " + component.getName());
@@ -339,6 +349,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
+ component.getName());
if (container.getState() == ContainerState.READY) {
totalReadyContainers++;
+ allContainers.put(component.getName(), container.getId());
LOG.info("Found 1 ready container " + container.getId());
}
}
@@ -358,23 +369,6 @@ public class TestYarnNativeServices extends ServiceTestUtils {
return false;
}
}, 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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org