Return-Path: Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: (qmail 1928 invoked from network); 9 Aug 2010 01:56:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Aug 2010 01:56:57 -0000 Received: (qmail 34882 invoked by uid 500); 9 Aug 2010 01:56:57 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 34837 invoked by uid 500); 9 Aug 2010 01:56:57 -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 34830 invoked by uid 99); 9 Aug 2010 01:56:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 01:56:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Mon, 09 Aug 2010 01:56:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6AEFA23889E1; Mon, 9 Aug 2010 01:55:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r983498 - in /hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase: HBaseTestingUtility.java TestHBaseTestingUtility.java Date: Mon, 09 Aug 2010 01:55:39 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100809015539.6AEFA23889E1@eris.apache.org> 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));