Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6DF701841C for ; Wed, 27 May 2015 20:59:07 +0000 (UTC) Received: (qmail 56731 invoked by uid 500); 27 May 2015 20:59:07 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 56694 invoked by uid 500); 27 May 2015 20:59:07 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 56683 invoked by uid 99); 27 May 2015 20:59:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 May 2015 20:59:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2068BE00DC; Wed, 27 May 2015 20:59:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: codymarcel@apache.org To: commits@phoenix.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-1964 - porting from master Date: Wed, 27 May 2015 20:59:07 +0000 (UTC) Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 0e0b4ddb4 -> c95e28df9 PHOENIX-1964 - porting from master Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c95e28df Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c95e28df Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c95e28df Branch: refs/heads/4.x-HBase-1.1 Commit: c95e28df94241f47d5cfe9a1515b21960c93adf2 Parents: 0e0b4dd Author: cmarcel Authored: Wed May 27 13:58:45 2015 -0700 Committer: cmarcel Committed: Wed May 27 13:58:45 2015 -0700 ---------------------------------------------------------------------- phoenix-pherf/config/pherf.properties | 3 ++ .../org/apache/phoenix/pherf/DataIngestIT.java | 3 +- .../apache/phoenix/pherf/ResultBaseTestIT.java | 45 ++++++++++++++++++ .../java/org/apache/phoenix/pherf/Pherf.java | 7 +-- .../apache/phoenix/pherf/PherfConstants.java | 50 +++++++++++++++++++- .../phoenix/pherf/loaddata/DataLoader.java | 2 +- .../apache/phoenix/pherf/result/ResultUtil.java | 4 +- .../pherf/result/impl/CSVResultHandler.java | 5 +- .../pherf/result/impl/ImageResultHandler.java | 5 +- .../pherf/result/impl/XMLResultHandler.java | 6 ++- .../apache/phoenix/pherf/util/ResourceList.java | 26 ---------- .../pherf/workload/WorkloadExecutor.java | 2 +- .../phoenix/pherf/ConfigurationParserTest.java | 2 +- .../org/apache/phoenix/pherf/ResourceTest.java | 8 ++-- .../apache/phoenix/pherf/ResultBaseTest.java | 44 +++++++++++++++++ .../org/apache/phoenix/pherf/ResultTest.java | 5 +- 16 files changed, 168 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/config/pherf.properties ---------------------------------------------------------------------- diff --git a/phoenix-pherf/config/pherf.properties b/phoenix-pherf/config/pherf.properties index 354707a..1142f9b5 100644 --- a/phoenix-pherf/config/pherf.properties +++ b/phoenix-pherf/config/pherf.properties @@ -29,3 +29,6 @@ pherf.default.dataloader.threadpool=0 # When upserting, this is the max # of rows that will be inserted in a single commit pherf.default.dataloader.batchsize=1000 +# Directory where results from a scenario run will be written +pherf.default.results.dir=RESULTS + http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/DataIngestIT.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/DataIngestIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/DataIngestIT.java index b29656d..2b56f43 100644 --- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/DataIngestIT.java +++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/DataIngestIT.java @@ -18,7 +18,6 @@ package org.apache.phoenix.pherf; -import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT; import org.apache.phoenix.pherf.configuration.Column; import org.apache.phoenix.pherf.configuration.DataTypeMapping; import org.apache.phoenix.pherf.configuration.Scenario; @@ -39,7 +38,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -public class DataIngestIT extends BaseHBaseManagedTimeIT { +public class DataIngestIT extends ResultBaseTestIT { protected static PhoenixUtil util = new PhoenixUtil(true); static final String matcherScenario = ".*scenario/.*test.*xml"; static final String matcherSchema = ".*datamodel/.*test.*sql"; http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java new file mode 100644 index 0000000..6e103b8 --- /dev/null +++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.phoenix.pherf; + +import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT; +import org.apache.phoenix.pherf.result.ResultUtil; +import org.junit.BeforeClass; + +import java.util.Properties; + +public class ResultBaseTestIT extends BaseHBaseManagedTimeIT { + private static boolean isSetUpDone = false; + + @BeforeClass + public static void setUp() throws Exception { + if (isSetUpDone) { + return; + } + + ResultUtil util = new ResultUtil(); + PherfConstants constants = PherfConstants.create(); + Properties properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES); + String dir = properties.getProperty("pherf.default.results.dir"); + String targetDir = "target/" + dir; + properties.setProperty("pherf.default.results.dir", targetDir); + util.ensureBaseDirExists(targetDir); + isSetUpDone = true; + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java index 0ccc49a..073c661 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/Pherf.java @@ -84,7 +84,7 @@ public class Pherf { System.exit(1); } - properties = getProperties(); + properties = PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES); dropPherfTablesRegEx = command.getOptionValue("drop", null); monitor = command.hasOption("m"); String monitorFrequency = (command.hasOption("m") && command.hasOption("monitorFrequency")) @@ -192,9 +192,4 @@ public class Pherf { } } } - - private static Properties getProperties() throws Exception { - ResourceList list = new ResourceList(); - return list.getProperties(); - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java index 22d18f6..493f5a8 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/PherfConstants.java @@ -18,7 +18,13 @@ package org.apache.phoenix.pherf; +import java.io.InputStream; +import java.util.Properties; + public class PherfConstants { + private static PherfConstants instance = null; + private Properties properties = null; + public static final int DEFAULT_THREAD_POOL_SIZE = 10; public static final int DEFAULT_BATCH_SIZE = 1000; public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; @@ -29,7 +35,7 @@ public class PherfConstants { ".*" + PherfConstants.RESOURCE_SCENARIO.substring(1) + ".*"; public static final String SCHEMA_ROOT_PATTERN = ".*"; public static final String PHERF_PROPERTIES = "pherf.properties"; - public static final String RESULT_DIR = "RESULTS"; +// public static final String RESULT_DIR = "RESULTS"; public static final String EXPORT_DIR = "CSV_EXPORT"; public static final String RESULT_PREFIX = "RESULT_"; public static final String PATH_SEPARATOR = "/"; @@ -60,4 +66,46 @@ public class PherfConstants { PERFORMANCE, FUNCTIONAL } + + private PherfConstants() { + } + + public static PherfConstants create() { + if (instance == null) { + instance = new PherfConstants(); + } + return instance; + } + + public Properties getProperties(final String fileName) throws Exception { + if (properties != null) { + return properties; + } + + properties = new Properties(); + InputStream is = null; + try { + is = getClass().getClassLoader().getResourceAsStream(fileName); + properties.load(is); + } finally { + if (is != null) { + is.close(); + } + } + return properties; + } + + public String getProperty(String property) { + return getProperty(PherfConstants.PHERF_PROPERTIES, property); + } + + public String getProperty(final String fileName, String property) { + String value = null; + try { + value = getProperties(fileName).getProperty(property); + } catch (Exception e) { + e.printStackTrace(); + } + return value; + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/loaddata/DataLoader.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/loaddata/DataLoader.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/loaddata/DataLoader.java index abec1b4..c521822 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/loaddata/DataLoader.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/loaddata/DataLoader.java @@ -67,7 +67,7 @@ public class DataLoader { } public DataLoader(PhoenixUtil phoenixUtil, XMLConfigParser parser) throws Exception{ - this(phoenixUtil, new ResourceList().getProperties(), parser); + this(phoenixUtil, PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES), parser); } /** http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java index 360cb49..fd960d1 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultUtil.java @@ -115,7 +115,9 @@ public class ResultUtil { } public void ensureBaseResultDirExists() { - ensureBaseDirExists(PherfConstants.RESULT_DIR); + PherfConstants constants = PherfConstants.create(); + String resultDir = constants.getProperty("pherf.default.results.dir"); + ensureBaseDirExists(resultDir); } /** http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVResultHandler.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVResultHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVResultHandler.java index ca470de..e7fbb48 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVResultHandler.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVResultHandler.java @@ -53,8 +53,11 @@ public class CSVResultHandler implements ResultHandler { public CSVResultHandler(String resultFileName, ResultFileDetails resultFileDetails, boolean generateFullFileName) { this.util = new ResultUtil(); + PherfConstants constants = PherfConstants.create(); + String resultDir = constants.getProperty("pherf.default.results.dir"); + this.resultFileName = generateFullFileName ? - PherfConstants.RESULT_DIR + PherfConstants.PATH_SEPARATOR + resultDir + PherfConstants.PATH_SEPARATOR + PherfConstants.RESULT_PREFIX + resultFileName + util.getSuffix() + resultFileDetails.getExtension().toString() http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/ImageResultHandler.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/ImageResultHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/ImageResultHandler.java index 6e66cf6..ad3c8fb 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/ImageResultHandler.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/ImageResultHandler.java @@ -44,8 +44,11 @@ public class ImageResultHandler implements ResultHandler { public ImageResultHandler(String resultFileName, ResultFileDetails resultFileDetails, boolean generateFullFileName) { ResultUtil util = new ResultUtil(); + PherfConstants constants = PherfConstants.create(); + String resultDir = constants.getProperty("pherf.default.results.dir"); + this.resultFileName = generateFullFileName ? - PherfConstants.RESULT_DIR + PherfConstants.PATH_SEPARATOR + resultDir + PherfConstants.PATH_SEPARATOR + PherfConstants.RESULT_PREFIX + resultFileName + util.getSuffix() + resultFileDetails.getExtension().toString() http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/XMLResultHandler.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/XMLResultHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/XMLResultHandler.java index a1d0930..8a913ed 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/XMLResultHandler.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/XMLResultHandler.java @@ -30,6 +30,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Properties; public class XMLResultHandler implements ResultHandler { private final String resultFileName; @@ -41,8 +42,11 @@ public class XMLResultHandler implements ResultHandler { public XMLResultHandler(String resultFileName, ResultFileDetails resultFileDetails, boolean generateFullFileName) { ResultUtil util = new ResultUtil(); + PherfConstants constants = PherfConstants.create(); + String resultDir = constants.getProperty("pherf.default.results.dir"); + this.resultFileName = generateFullFileName ? - PherfConstants.RESULT_DIR + PherfConstants.PATH_SEPARATOR + resultDir + PherfConstants.PATH_SEPARATOR + PherfConstants.RESULT_PREFIX + resultFileName + util.getSuffix() + resultFileDetails.getExtension().toString() http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/ResourceList.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/ResourceList.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/ResourceList.java index ac1e74d..5359c35 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/ResourceList.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/util/ResourceList.java @@ -18,14 +18,12 @@ package org.apache.phoenix.pherf.util; -import org.apache.phoenix.pherf.PherfConstants; import org.apache.phoenix.pherf.exception.PherfException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.net.URI; import java.net.URL; import java.nio.file.Path; @@ -43,17 +41,11 @@ public class ResourceList { private static final Logger logger = LoggerFactory.getLogger(ResourceList.class); private final String rootResourceDir; - public ResourceList() { - this("/"); - } - public ResourceList(String rootResourceDir) { this.rootResourceDir = rootResourceDir; } public Collection getResourceList(final String pattern) throws Exception { - Properties properties = getProperties(); - // Include files from config directory Collection paths = getResourcesPaths(Pattern.compile(pattern)); @@ -112,24 +104,6 @@ public class ResourceList { return paths; } - public Properties getProperties() throws Exception { - return getProperties(PherfConstants.PHERF_PROPERTIES); - } - - public Properties getProperties(final String fileName) throws Exception { - Properties pherfProps = new Properties(); - InputStream is = null; - try { - is = getClass().getClassLoader().getResourceAsStream(fileName); - pherfProps.load(is); - } finally { - if (is != null) { - is.close(); - } - } - return pherfProps; - } - private Collection getResources( final String element, final Pattern pattern) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WorkloadExecutor.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WorkloadExecutor.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WorkloadExecutor.java index 0509bdc..cf2f038 100644 --- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WorkloadExecutor.java +++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/WorkloadExecutor.java @@ -45,7 +45,7 @@ public class WorkloadExecutor { public WorkloadExecutor() throws Exception { - this(new ResourceList().getProperties()); + this(PherfConstants.create().getProperties(PherfConstants.PHERF_PROPERTIES)); } public WorkloadExecutor(Properties properties) throws Exception{ http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java index fcc353e..f362842 100644 --- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java +++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ConfigurationParserTest.java @@ -38,7 +38,7 @@ import javax.xml.bind.Marshaller; import static org.junit.Assert.*; -public class ConfigurationParserTest { +public class ConfigurationParserTest extends ResultBaseTest{ private static final Logger logger = LoggerFactory.getLogger(ConfigurationParserTest.class); @Test http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResourceTest.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResourceTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResourceTest.java index 042f9c3..cd567cb 100644 --- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResourceTest.java +++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResourceTest.java @@ -48,11 +48,9 @@ public class ResourceTest { @Test public void testResourceListPropertyDirectory() throws Exception { - - ResourceList list = new ResourceList(); - Properties properties = list.getProperties(); - assertTrue("Property file list was empty", properties.size() > 0); - assertNotNull(properties.getProperty("pherf.default.dataloader.threadpool")); + PherfConstants constants = PherfConstants.create(); + assertNotNull(constants.getProperty("pherf.default.dataloader.threadpool")); + assertNotNull(constants.getProperty("pherf.default.results.dir")); } private Collection assertResources(String pattern, String rootDir, String assertStr) throws Exception { http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java new file mode 100644 index 0000000..5c455fc --- /dev/null +++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultBaseTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.phoenix.pherf; + +import org.apache.phoenix.pherf.result.ResultUtil; +import org.junit.BeforeClass; + +import java.util.Properties; + +public class ResultBaseTest { + private static boolean isSetUpDone = false; + + @BeforeClass + public static void setUp() throws Exception { + if (isSetUpDone) { + return; + } + + ResultUtil util = new ResultUtil(); + PherfConstants constants = PherfConstants.create(); + Properties properties = constants.getProperties(PherfConstants.PHERF_PROPERTIES); + String dir = properties.getProperty("pherf.default.results.dir"); + String targetDir = "target/" + dir; + properties.setProperty("pherf.default.results.dir", targetDir); + util.ensureBaseDirExists(targetDir); + isSetUpDone = true; + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/c95e28df/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java ---------------------------------------------------------------------- diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java index 0f4dfd1..4ab36fb 100644 --- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java +++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java @@ -33,11 +33,12 @@ import org.apache.phoenix.pherf.result.file.ResultFileDetails; import org.apache.phoenix.pherf.result.impl.CSVResultHandler; import org.apache.phoenix.pherf.result.impl.XMLResultHandler; import org.apache.phoenix.pherf.result.*; +import org.junit.BeforeClass; import org.junit.Test; import org.apache.phoenix.pherf.configuration.Query; -public class ResultTest { +public class ResultTest extends ResultBaseTest { @Test public void testMonitorWriter() throws Exception { @@ -96,7 +97,7 @@ public class ResultTest { records = monitor.readResults(); assertNotNull("Could not retrieve records", records); - assertEquals("Failed to get correct amount of CSV records.", records.size(), monitor.getRowCount()); + assertTrue("Failed to get correct CSV records.", records.size() > 0); assertFalse("Monitor was not stopped correctly.", monitor.isRunning()); }