Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 46698 invoked from network); 4 Mar 2011 03:44:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Mar 2011 03:44:38 -0000 Received: (qmail 87345 invoked by uid 500); 4 Mar 2011 03:44:38 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 87302 invoked by uid 500); 4 Mar 2011 03:44:37 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 87188 invoked by uid 99); 4 Mar 2011 03:44:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 03:44:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 03:44:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0A2682388901; Fri, 4 Mar 2011 03:44:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1077132 - /hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java Date: Fri, 04 Mar 2011 03:44:12 -0000 To: common-commits@hadoop.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110304034413.0A2682388901@eris.apache.org> Author: omalley Date: Fri Mar 4 03:44:12 2011 New Revision: 1077132 URL: http://svn.apache.org/viewvc?rev=1077132&view=rev Log: commit f64a958be42c7ebe56a727d2a085239d2397e7c7 Author: Konstantin Boudnik Date: Wed Jan 27 16:30:09 2010 -0800 HDFS-919 from https://issues.apache.org/jira/secure/attachment/12431381/HDFS-919_0.20.patch +++ b/YAHOO-CHANGES.txt + HDFS-919. Create test to validate the BlocksVerified metric (Gary Murry + via cos) + Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java?rev=1077132&r1=1077131&r2=1077132&view=diff ============================================================================== --- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java (original) +++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java Fri Mar 4 03:44:12 2011 @@ -50,12 +50,15 @@ public class TestDatanodeBlockScanner ex private static Pattern pattern = Pattern.compile(".*?(blk_[-]*\\d+).*?scan time\\s*:\\s*(\\d+)"); + + private static Pattern pattern_blockVerify = + Pattern.compile(".*?(SCAN_PERIOD)\\s*:\\s*(\\d+.*?)"); /** * This connects to datanode and fetches block verification data. * It repeats this until the given block has a verification time > 0. */ private static long waitForVerification(DatanodeInfo dn, FileSystem fs, - Path file) throws IOException { + Path file, int blocksValidated) throws IOException { URL url = new URL("http://localhost:" + dn.getInfoPort() + "/blockScannerReport?listblocks"); long lastWarnTime = System.currentTimeMillis(); @@ -65,6 +68,14 @@ public class TestDatanodeBlockScanner ex while (verificationTime <= 0) { String response = DFSTestUtil.urlGet(url); + if(blocksValidated >= 0) { + for(Matcher matcher = pattern_blockVerify.matcher(response); matcher.find();) { + if (block.equals(matcher.group(1))) { + assertEquals("Wrong number of blocks reported for validation.", blocksValidated, Long.parseLong(matcher.group(2))); + break; + } + } + } for(Matcher matcher = pattern.matcher(response); matcher.find();) { if (block.equals(matcher.group(1))) { verificationTime = Long.parseLong(matcher.group(2)); @@ -115,7 +126,7 @@ public class TestDatanodeBlockScanner ex /* * The cluster restarted. The block should be verified by now. */ - assertTrue(waitForVerification(dn, fs, file1) > startTime); + assertTrue(waitForVerification(dn, fs, file1, 1) > startTime); /* * Create a new file and read the block. The block should be marked @@ -124,7 +135,7 @@ public class TestDatanodeBlockScanner ex DFSTestUtil.createFile(fs, file2, 10, (short)1, 0); IOUtils.copyBytes(fs.open(file2), new IOUtils.NullOutputStream(), conf, true); - assertTrue(waitForVerification(dn, fs, file2) > startTime); + assertTrue(waitForVerification(dn, fs, file2, 2) > startTime); cluster.shutdown(); }