You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2010/08/09 03:55:39 UTC

svn commit: r983498 - in /hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase: HBaseTestingUtility.java TestHBaseTestingUtility.java

Author: stack
Date: Mon Aug  9 01:55:39 2010
New Revision: 983498

URL: http://svn.apache.org/viewvc?rev=983498&view=rev
Log:

Adding test of HBaseTestingUtility as way to elicit what is and what is
not working in new master rewrite stuff.

M src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
  Javadoc and formatting.
M src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
  Added a few small tests.

Modified:
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=983498&r1=983497&r2=983498&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Mon Aug  9 01:55:39 2010
@@ -93,11 +93,9 @@ public class HBaseTestingUtility {
   public static final String TEST_DIRECTORY_KEY = "test.build.data";
 
   /**
-   * Default parent direccounttory for test output.
-   * Target is at it is because minidfscluster has hard-codings to put its data
-   * here.
+   * Default parent directory for test output.
    */
-  public static final String DEFAULT_TEST_DIRECTORY = "target/build/data";
+  public static final String DEFAULT_TEST_DIRECTORY = "target/test-data";
 
   public HBaseTestingUtility() {
     this(HBaseConfiguration.create());
@@ -291,9 +289,8 @@ public class HBaseTestingUtility {
     }
     // Make a new random dir to home everything in.  Set it as system property.
     // minidfs reads home from system property.
-    this.clusterTestBuildDir =
-      testBuildPath == null ?
-          setupClusterTestBuildDir() : new File(testBuildPath);
+    this.clusterTestBuildDir = testBuildPath == null?
+      setupClusterTestBuildDir() : new File(testBuildPath);
     System.setProperty(TEST_DIRECTORY_KEY, this.clusterTestBuildDir.getPath());
     // Bring up mini dfs cluster. This spews a bunch of warnings about missing
     // scheme. Complaints are 'Scheme is undefined for build/test/data/dfs/name1'.

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java?rev=983498&r1=983497&r2=983498&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java Mon Aug  9 01:55:39 2010
@@ -22,10 +22,14 @@ package org.apache.hadoop.hbase;
 
 import static org.junit.Assert.*;
 
+import java.io.File;
 import java.io.IOException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -36,6 +40,8 @@ import org.junit.Test;
  * Test our testing utility class
  */
 public class TestHBaseTestingUtility {
+  private final Log LOG = LogFactory.getLog(this.getClass());
+
   private HBaseTestingUtility hbt;
 
   @BeforeClass
@@ -56,8 +62,41 @@ public class TestHBaseTestingUtility {
   public void tearDown() throws Exception {
   }
 
+  @Test public void testMiniCluster() throws Exception {
+    MiniHBaseCluster cluster = this.hbt.startMiniCluster();
+    try {
+      
+    } finally {
+      cluster.shutdown();
+    }
+  }
+
+  @Test public void testMiniDFSCluster() throws Exception {
+    MiniDFSCluster cluster = this.hbt.startMiniDFSCluster(1);
+    FileSystem dfs = cluster.getFileSystem();
+    Path dir = new Path("dir");
+    Path qualifiedDir = dfs.makeQualified(dir);
+    LOG.info("dir=" + dir + ", qualifiedDir=" + qualifiedDir);
+    assertFalse(dfs.exists(qualifiedDir));
+    assertTrue(dfs.mkdirs(qualifiedDir));
+    assertTrue(dfs.delete(qualifiedDir, true));
+    try {
+    } finally {
+      cluster.shutdown();
+    }
+  }
+
+  @Test public void testSetupClusterTestBuildDir() {
+    File testdir = this.hbt.setupClusterTestBuildDir();
+    LOG.info("uuid-subdir=" + testdir);
+    assertFalse(testdir.exists());
+    assertTrue(testdir.mkdirs());
+    assertTrue(testdir.exists());
+  }
+
   @Test public void testTestDir() throws IOException {
     Path testdir = HBaseTestingUtility.getTestDir();
+    LOG.info("testdir=" + testdir);
     FileSystem fs = this.hbt.getTestFileSystem();
     assertTrue(!fs.exists(testdir));
     assertTrue(fs.mkdirs(testdir));