From 3c55ae85c463ca4e32c9df09a87da5c2d9eb00a2 Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Thu, 7 Nov 2013 19:10:25 +0000 Subject: [PATCH] HBASE-9909 TestHFilePerformance should not be a unit test, but a tool git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1539766 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/io/hfile/TestHFilePerformance.java | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFilePerformance.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFilePerformance.java index 3ccfec2fc08..b8c37565fe6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFilePerformance.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFilePerformance.java @@ -23,21 +23,21 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Random; -import junit.framework.TestCase; - +import org.apache.commons.cli.CommandLine; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.KeyValue; -import org.apache.hadoop.hbase.MediumTests; +import org.apache.hadoop.hbase.util.AbstractHBaseTool; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.GzipCodec; -import org.junit.experimental.categories.Category; +import org.apache.hadoop.util.ToolRunner; /** * Set of long-running tests to measure performance of HFile. @@ -47,22 +47,25 @@ import org.junit.experimental.categories.Category; * Remove after tfile is committed and use the tfile version of this class * instead.

*/ -@Category(MediumTests.class) -public class TestHFilePerformance extends TestCase { - private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private static String ROOT_DIR = - TEST_UTIL.getDataTestDir("TestHFilePerformance").toString(); +public class TestHFilePerformance extends AbstractHBaseTool { + private HBaseTestingUtility TEST_UTIL; + private static String ROOT_DIR; private FileSystem fs; - private Configuration conf; private long startTimeEpoch; private long finishTimeEpoch; private DateFormat formatter; @Override - public void setUp() throws IOException { - conf = new Configuration(); - fs = FileSystem.get(conf); + public void setConf(Configuration conf) { + super.setConf(conf); + try { + fs = FileSystem.get(conf); + } catch (IOException e) { + throw new RuntimeException(e); + } formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + TEST_UTIL = new HBaseTestingUtility(conf); + ROOT_DIR = TEST_UTIL.getDataTestDir("TestHFilePerformance").toString(); } public void startTime() { @@ -394,5 +397,22 @@ public class TestHFilePerformance extends TestCase { " better number."); } -} + @Override + protected void addOptions() { + } + @Override + protected void processOptions(CommandLine cmd) { + } + + @Override + protected int doWork() throws Exception { + testRunComparisons(); + return 0; + } + + public static void main(String[] args) throws Exception { + int ret = ToolRunner.run(HBaseConfiguration.create(), new TestHFilePerformance(), args); + System.exit(ret); + } +} \ No newline at end of file