From common-commits-return-97851-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Fri Jan 10 18:45:34 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 41120180657 for ; Fri, 10 Jan 2020 19:45:34 +0100 (CET) Received: (qmail 42780 invoked by uid 500); 10 Jan 2020 18:45:33 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 42771 invoked by uid 99); 10 Jan 2020 18:45:33 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jan 2020 18:45:33 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 577EA81F11; Fri, 10 Jan 2020 18:45:33 +0000 (UTC) Date: Fri, 10 Jan 2020 18:45:33 +0000 To: "common-commits@hadoop.apache.org" Subject: [hadoop] branch trunk updated: HDFS-15095. Fix TestDecommissioningStatus. Contributed by Ahmed Hussein. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <157868193280.28191.5917820249182156216@gitbox.apache.org> From: kihwal@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hadoop X-Git-Refname: refs/heads/trunk X-Git-Reftype: branch X-Git-Oldrev: c4fb43c94259546f2c96b50ceae9cd3adb726166 X-Git-Newrev: 5fb901ac4017b4f13b089ecd920e864cd53ad3a6 X-Git-Rev: 5fb901ac4017b4f13b089ecd920e864cd53ad3a6 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. kihwal pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git The following commit(s) were added to refs/heads/trunk by this push: new 5fb901a HDFS-15095. Fix TestDecommissioningStatus. Contributed by Ahmed Hussein. 5fb901a is described below commit 5fb901ac4017b4f13b089ecd920e864cd53ad3a6 Author: Kihwal Lee AuthorDate: Fri Jan 10 12:43:21 2020 -0600 HDFS-15095. Fix TestDecommissioningStatus. Contributed by Ahmed Hussein. --- .../server/namenode/TestDecommissioningStatus.java | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDecommissioningStatus.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDecommissioningStatus.java index ad99c11..800f273 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDecommissioningStatus.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestDecommissioningStatus.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.TimeoutException; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.BlockLocation; @@ -55,6 +56,7 @@ import org.apache.hadoop.hdfs.server.datanode.DataNode; import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils; import org.apache.hadoop.hdfs.tools.DFSAdmin; import org.apache.hadoop.hdfs.util.HostsFileWriter; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.junit.After; @@ -220,6 +222,23 @@ public class TestDecommissioningStatus { } /** + * Allows the main thread to block until the decommission is checked by the + * admin manager. + * @param dnAdminMgr admin instance in the datanode manager. + * @param trackedNumber number of nodes expected to be DECOMMISSIONED or + * IN_MAINTENANCE. + * @throws TimeoutException + * @throws InterruptedException + */ + private void waitForDecommissionedNodes(final DatanodeAdminManager dnAdminMgr, + final int trackedNumber) + throws TimeoutException, InterruptedException { + GenericTestUtils + .waitFor(() -> dnAdminMgr.getNumTrackedNodes() == trackedNumber, + 100, 2000); + } + + /** * Tests Decommissioning Status in DFS. */ @Test @@ -254,11 +273,13 @@ public class TestDecommissioningStatus { dm.refreshNodes(conf); decommissionedNodes.add(downnode); BlockManagerTestUtil.recheckDecommissionState(dm); + // Block until the admin's monitor updates the number of tracked nodes. + waitForDecommissionedNodes(dm.getDatanodeAdminManager(), iteration + 1); final List decommissioningNodes = dm.getDecommissioningNodes(); if (iteration == 0) { assertEquals(decommissioningNodes.size(), 1); DatanodeDescriptor decommNode = decommissioningNodes.get(0); - // checkDecommissionStatus(decommNode, 3, 0, 1); + checkDecommissionStatus(decommNode, 3, 0, 1); checkDFSAdminDecommissionStatus(decommissioningNodes.subList(0, 1), fileSys, admin); } else { @@ -330,11 +351,11 @@ public class TestDecommissioningStatus { // Force DatanodeManager to check decommission state. BlockManagerTestUtil.recheckDecommissionState(dm); - + // Block until the admin's monitor updates the number of tracked nodes. + waitForDecommissionedNodes(dm.getDatanodeAdminManager(), 1); // Verify that the DN remains in DECOMMISSION_INPROGRESS state. assertTrue("the node should be DECOMMISSION_IN_PROGRESSS", dead.get(0).isDecommissionInProgress()); - // Check DatanodeManager#getDecommissionNodes, make sure it returns // the node as decommissioning, even if it's dead List decomlist = dm.getDecommissioningNodes(); @@ -344,6 +365,8 @@ public class TestDecommissioningStatus { // DECOMMISSION_IN_PROGRESS node become DECOMMISSIONED AdminStatesBaseTest.cleanupFile(fileSys, f); BlockManagerTestUtil.recheckDecommissionState(dm); + // Block until the admin's monitor updates the number of tracked nodes. + waitForDecommissionedNodes(dm.getDatanodeAdminManager(), 0); assertTrue("the node should be decommissioned", dead.get(0).isDecommissioned()); @@ -378,6 +401,8 @@ public class TestDecommissioningStatus { decommissionNode(dnName); dm.refreshNodes(conf); BlockManagerTestUtil.recheckDecommissionState(dm); + // Block until the admin's monitor updates the number of tracked nodes. + waitForDecommissionedNodes(dm.getDatanodeAdminManager(), 0); assertTrue(dnDescriptor.isDecommissioned()); // Add the node back @@ -426,6 +451,8 @@ public class TestDecommissioningStatus { hostsFileWriter.initExcludeHosts(nodes); dm.refreshNodes(conf); BlockManagerTestUtil.recheckDecommissionState(dm); + // Block until the admin's monitor updates the number of tracked nodes. + waitForDecommissionedNodes(dm.getDatanodeAdminManager(), 0); assertTrue(dnDescriptor0.isDecommissioned()); assertTrue(dnDescriptor1.isDecommissioned()); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org