You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by co...@apache.org on 2015/04/25 02:08:35 UTC
phoenix git commit: PHOENIX-1728 - Pherf - Make tests use mini
cluster. Removed extra files
Repository: phoenix
Updated Branches:
refs/heads/master d28bb5f85 -> 235735872
PHOENIX-1728 - Pherf - Make tests use mini cluster. Removed extra files
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/23573587
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/23573587
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/23573587
Branch: refs/heads/master
Commit: 235735872bd171c10b3676ad0be6fe958a12e7a3
Parents: d28bb5f
Author: Cody Marcel <co...@apache.org>
Authored: Fri Apr 24 17:06:04 2015 -0700
Committer: Cody Marcel <co...@apache.org>
Committed: Fri Apr 24 17:06:04 2015 -0700
----------------------------------------------------------------------
.../phoenix/pherf/BaseTestWithCluster.java | 45 ----------
.../apache/phoenix/pherf/DataIngestTest.java | 78 ----------------
.../apache/phoenix/pherf/DataLoaderTest.java | 94 --------------------
.../apache/phoenix/pherf/SchemaReaderTest.java | 73 ---------------
4 files changed, 290 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/23573587/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/BaseTestWithCluster.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/BaseTestWithCluster.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/BaseTestWithCluster.java
deleted file mode 100644
index 8e33a15..0000000
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/BaseTestWithCluster.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.util.PhoenixUtil;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static org.junit.Assert.assertNotNull;
-
-public class BaseTestWithCluster {
- static final String matcherScenario = PherfConstants.SCENARIO_ROOT_PATTERN + ".xml";
- private static final Logger logger = LoggerFactory.getLogger(BaseTestWithCluster.class);
- protected static PhoenixUtil util;
-
- @BeforeClass
- public static void initQuorum() {
- util = new PhoenixUtil();
- String zookeeper = ((System.getProperty("ZK_QUORUM") == null) || System.getProperty("ZK_QUORUM").equals("")) ? "localhost" : System.getProperty("ZK_QUORUM");
- PhoenixUtil.setZookeeper(zookeeper);
- logger.info("Using quorum:" + zookeeper);
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/23573587/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataIngestTest.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataIngestTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataIngestTest.java
deleted file mode 100644
index 0fc0dd9..0000000
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataIngestTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.configuration.Column;
-import org.apache.phoenix.pherf.configuration.DataTypeMapping;
-import org.apache.phoenix.pherf.configuration.Scenario;
-import org.apache.phoenix.pherf.configuration.XMLConfigParser;
-import org.apache.phoenix.pherf.loaddata.DataLoader;
-import org.apache.phoenix.pherf.rules.DataValue;
-import org.apache.phoenix.pherf.rules.RulesApplier;
-import org.apache.phoenix.pherf.schema.SchemaReader;
-import org.junit.Test;
-
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class DataIngestTest extends BaseTestWithCluster {
- static final String matcherScenario = ".*scenario/.*test.*xml";
- static final String matcherSchema = ".*datamodel/.*test.*sql";
-
- @Test
- public void generateData() throws Exception {
- SchemaReader reader = new SchemaReader(matcherSchema);
- XMLConfigParser parser = new XMLConfigParser(matcherScenario);
-
- // 1. Generate table schema from file
- List<Path> resources = new ArrayList<>(reader.getResourceList());
- assertTrue("Could not pull list of schema files.", resources.size() > 0);
- assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
- reader.applySchema();
-
- // 2. Load the metadata of for the test tables
- Scenario scenario = parser.getScenarios().get(0);
- List<Column> columnListFromPhoenix = util.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), util.getConnection());
- assertTrue("Could not get phoenix columns.", columnListFromPhoenix.size() > 0);
- DataLoader loader = new DataLoader(parser);
- RulesApplier rulesApplier = loader.getRulesApplier();
- List<Map> modelList = rulesApplier.getModelList();
- assertTrue("Could not generate the modelList", modelList.size() > 0);
-
- for (Column column : columnListFromPhoenix) {
- DataValue data = rulesApplier.getDataForRule(scenario, column);
-
- // We are generating data values so the value should have been specified by this point.
- assertTrue("Failed to retrieve data for column type: " + column.getType(), data != null);
-
- // Test that we still retrieve the GENERAL_CHAR rule even after an override is applied to another CHAR type.
- // FIELD_HISTORY_ARCHIVE_ID Column does not specify an override so we should get the default rule.
- if ((column.getType() == DataTypeMapping.CHAR) && (column.getName().equals("FIELD_HISTORY_ARCHIVE_ID"))) {
- assertTrue("Failed to retrieve data for column type: ", data.getDistribution() == Integer.MIN_VALUE);
- }
- }
-
- loader.execute();
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/23573587/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataLoaderTest.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataLoaderTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataLoaderTest.java
deleted file mode 100644
index f4d676e..0000000
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/DataLoaderTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.configuration.DataModel;
-import org.apache.phoenix.pherf.configuration.XMLConfigParser;
-import org.apache.phoenix.pherf.loaddata.DataLoader;
-import org.apache.phoenix.pherf.util.RowCalculator;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
-
-public class DataLoaderTest extends BaseTestWithCluster {
-
- /**
- * Test rows divide evenly with large rows and small threadpool
- * @throws Exception
- */
- @Test
- public void testRowsEvenDivide() throws Exception {
- int threadPoolSize = 10;
- int tableRowCount = 100;
- assertRowsSum(threadPoolSize, tableRowCount);
- }
-
- /**
- * Test rows add up when not divided evenly with large rows and small threadpool
- *
- * @throws Exception
- */
- @Test
- public void testRowsNotEvenDivide() throws Exception {
- int threadPoolSize = 9;
- int tableRowCount = 100;
- assertRowsSum(threadPoolSize, tableRowCount);
- }
-
- /**
- * Test rows add up when not divided evenly with large threadpool and small rowcount
- *
- * @throws Exception
- */
- @Test
- public void testRowsNotEvenDivideSmallRC() throws Exception {
- int threadPoolSize = 50;
- int tableRowCount = 21;
- assertRowsSum(threadPoolSize, tableRowCount);
- }
-
- /**
- * Test rows count equal to thread pool
- *
- * @throws Exception
- */
- @Test
- public void testRowsEqualToPool() throws Exception {
- int threadPoolSize = 50;
- int tableRowCount = 50;
- assertRowsSum(threadPoolSize, tableRowCount);
- }
-
- private void assertRowsSum(int threadPoolSize, int tableRowCount) {
- int sum = 0;
- RowCalculator rc = new RowCalculator(threadPoolSize, tableRowCount);
- assertEquals("Rows generated did not match expected count! ", threadPoolSize, rc.size());
-
- // Sum of all rows should equal expected row count
- for (int i = 0; i < threadPoolSize; i++) {
- sum += rc.getNext();
- }
- assertEquals("Rows did not sum up correctly", tableRowCount, sum);
-
- // Ensure rows were removed from list
- assertEquals(rc.size(), 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/23573587/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/SchemaReaderTest.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/SchemaReaderTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/SchemaReaderTest.java
deleted file mode 100644
index e8d1321..0000000
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/SchemaReaderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.configuration.Column;
-import org.apache.phoenix.pherf.configuration.DataModel;
-import org.apache.phoenix.pherf.configuration.Scenario;
-import org.apache.phoenix.pherf.configuration.XMLConfigParser;
-import org.apache.phoenix.pherf.schema.SchemaReader;
-import org.junit.Test;
-
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.sql.Connection;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class SchemaReaderTest extends BaseTestWithCluster {
-
- @Test
- public void testSchemaReader() {
- // Test for the unit test version of the schema files.
- assertApplySchemaTest();
- }
-
- private void assertApplySchemaTest() {
- try {
- SchemaReader reader = new SchemaReader(".*datamodel/.*test.*sql");
-
- List<Path> resources = new ArrayList<>(reader.getResourceList());
- assertTrue("Could not pull list of schema files.", resources.size() > 0);
- assertNotNull("Could not read schema file.", this.getClass().getResourceAsStream(
- PherfConstants.RESOURCE_DATAMODEL + "/" + resources.get(0).getFileName().toString()));
- assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
- reader.applySchema();
-
- Connection connection = null;
- URL resourceUrl = getClass().getResource("/scenario/test_scenario.xml");
- assertNotNull("Test data XML file is missing", resourceUrl);
- connection = util.getConnection();
- Path resourcePath = Paths.get(resourceUrl.toURI());
- DataModel data = XMLConfigParser.readDataModel(resourcePath);
- List<Scenario> scenarioList = data.getScenarios();
- Scenario scenario = scenarioList.get(0);
- List<Column> columnList = util.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), connection);
- assertTrue("Could not retrieve Metadata from Phoenix", columnList.size() > 0);
- } catch (Exception e) {
- fail("Could not initialize SchemaReader");
- e.printStackTrace();
- }
- }
-}