From 678a53a6d2910db1fa55a3eaa3e4688a8bfcae2f Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sun, 7 Aug 2011 05:52:54 +0000 Subject: [PATCH] HBASE-4162 Fix TestHRegionInfo.testGetSetOfHTD: delete /tmp/hbase- if it already exists. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1154658 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../java/org/apache/hadoop/hbase/util/FSUtils.java | 12 ++++++++++++ .../hadoop/hbase/regionserver/TestHRegionInfo.java | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index b3c1aa3709d..0f2e3b2dcac 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -190,6 +190,8 @@ Release 0.91.0 - Unreleased HBASE-4159 HBaseServer - IPC Reader threads are not daemons (Douglas Campbell) HBASE-4171 HBase shell broken in trunk (Lars Hofhansl) + HBASE-4162 Fix TestHRegionInfo.testGetSetOfHTD: delete /tmp/hbase- + if it already exists (Mikhail Bautin) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index 3c361de0149..81978d212de 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -1003,6 +1003,18 @@ public class FSUtils { } } + /** + * Deletes a table's directory from the file system if exists. Used in unit + * tests. + */ + public static void deleteTableDescriptorIfExists(String tableName, + Configuration conf) throws IOException { + FileSystem fs = getCurrentFileSystem(conf); + Path tableInfoPath = getTableInfoPath(getRootDir(conf), tableName); + if (fs.exists(tableInfoPath)) + deleteDirectory(fs, tableInfoPath); + } + /** * Called when we are creating a table to write out the tables' descriptor. * @param fs diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java index fcd5518a100..6d83b000cc2 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java @@ -25,6 +25,8 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.IOException; + import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; @@ -60,9 +62,15 @@ public class TestHRegionInfo { } @Test - public void testGetSetOfHTD() { + public void testGetSetOfHTD() throws IOException { HBaseTestingUtility HTU = new HBaseTestingUtility(); final String tablename = "testGetSetOfHTD"; + + // Delete the temporary table directory that might still be there from the + // previous test run. + FSUtils.deleteTableDescriptorIfExists(tablename, + HTU.getConfiguration()); + HTableDescriptor htd = new HTableDescriptor(tablename); FSUtils.createTableDescriptor(htd, HTU.getConfiguration()); HRegionInfo hri = new HRegionInfo(Bytes.toBytes("testGetSetOfHTD"),