hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
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 GMT
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 <yuzhihong@gmail.com>
Authored: Sat Jul 16 16:36:55 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
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<String> 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<String> files = getArchivedHFiles(archiveDir, rootDir, fs, TABLE_NAME);
+    Collection<String> archives = getHFiles(archiveDir, fs, TABLE_NAME);
+
+    // get the hfiles for the table
+    Collection<String> 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<String> 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<String> getHFiles(Path dir, FileSystem fs, TableName tableName)
throws IOException {
+    Path tableDir = FSUtils.getTableDir(dir, tableName);
+    return SnapshotTestingUtils.listHFileNames(fs, tableDir);
   }
 
   /**


Mime
View raw message