Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2907C200B55 for ; Sun, 17 Jul 2016 01:37:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 277AB160A7C; Sat, 16 Jul 2016 23:37:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6DD27160A6C for ; Sun, 17 Jul 2016 01:37:21 +0200 (CEST) Received: (qmail 19621 invoked by uid 500); 16 Jul 2016 23:37:20 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 19610 invoked by uid 99); 16 Jul 2016 23:37:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jul 2016 23:37:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6006AE04AC; Sat, 16 Jul 2016 23:37:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tedyu@apache.org To: commits@hbase.apache.org Message-Id: <084128881a2c43098f42014e1471eb24@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-16235 TestSnapshotFromMaster#testSnapshotHFileArchiving will fail if there are too many hfiles (ChiaPing Tsai) Date: Sat, 16 Jul 2016 23:37:20 +0000 (UTC) archived-at: Sat, 16 Jul 2016 23:37:22 -0000 Repository: hbase Updated Branches: refs/heads/branch-1 9dbeb593b -> 40204eb0c HBASE-16235 TestSnapshotFromMaster#testSnapshotHFileArchiving will fail if there are too many hfiles (ChiaPing Tsai) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/40204eb0 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/40204eb0 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/40204eb0 Branch: refs/heads/branch-1 Commit: 40204eb0c1eb8c83700f8d27d9ac63c518c71a60 Parents: 9dbeb59 Author: tedyu Authored: Sat Jul 16 16:36:55 2016 -0700 Committer: tedyu Committed: Sat Jul 16 16:36:55 2016 -0700 ---------------------------------------------------------------------- .../master/cleaner/TestSnapshotFromMaster.java | 32 ++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/40204eb0/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java index 0bffa92..1d3b9f1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java @@ -279,6 +279,7 @@ public class TestSnapshotFromMaster { */ @Test(timeout = 300000) public void testSnapshotHFileArchiving() throws Exception { + int hfileCount = 20; Admin admin = UTIL.getHBaseAdmin(); // make sure we don't fail on listing snapshots SnapshotTestingUtils.assertNoSnapshots(admin); @@ -291,10 +292,14 @@ public class TestSnapshotFromMaster { UTIL.createTable(htd, new byte[][] { TEST_FAM }, null); - // load the table (creates at least 4 hfiles) - for ( int i = 0; i < 5; i++) { + // load the table + while(true) { UTIL.loadTable(UTIL.getConnection().getTable(TABLE_NAME), TEST_FAM); UTIL.flush(TABLE_NAME); + Collection hfiles = getHFiles(rootDir, fs, TABLE_NAME); + if (hfiles.size() >= hfileCount) { + break; + } } // disable the table so we can take a snapshot @@ -354,12 +359,16 @@ public class TestSnapshotFromMaster { LOG.debug(fileName); } // get the archived files for the table - Collection files = getArchivedHFiles(archiveDir, rootDir, fs, TABLE_NAME); + Collection archives = getHFiles(archiveDir, fs, TABLE_NAME); + + // get the hfiles for the table + Collection hfiles = getHFiles(rootDir, fs, TABLE_NAME); // and make sure that there is a proper subset for (String fileName : snapshotHFiles) { - assertTrue("Archived hfiles " + files + " is missing snapshot file:" + fileName, - files.contains(fileName)); + boolean exist = archives.contains(fileName) || hfiles.contains(fileName); + assertTrue("Archived hfiles " + archives + + " and table hfiles " + hfiles + " is missing snapshot file:" + fileName, exist); } // delete the existing snapshot @@ -381,19 +390,18 @@ public class TestSnapshotFromMaster { LOG.info("After delete snapshot cleaners run File-System state"); FSUtils.logFileSystemState(fs, rootDir, LOG); - files = getArchivedHFiles(archiveDir, rootDir, fs, TABLE_NAME); + archives = getHFiles(archiveDir, fs, TABLE_NAME); assertEquals("Still have some hfiles in the archive, when their snapshot has been deleted.", 0, - files.size()); + archives.size()); } /** - * @return all the HFiles for a given table that have been archived + * @return all the HFiles for a given table in the specified dir * @throws IOException on expected failure */ - private final Collection getArchivedHFiles(Path archiveDir, Path rootDir, - FileSystem fs, TableName tableName) throws IOException { - Path tableArchive = FSUtils.getTableDir(archiveDir, tableName); - return SnapshotTestingUtils.listHFileNames(fs, tableArchive); + private final Collection getHFiles(Path dir, FileSystem fs, TableName tableName) throws IOException { + Path tableDir = FSUtils.getTableDir(dir, tableName); + return SnapshotTestingUtils.listHFileNames(fs, tableDir); } /**