PHOENIX-3327 Use same driver for all tests within a group
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/dab38434 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/dab38434 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/dab38434 Branch: refs/heads/4.x-HBase-1.1 Commit: dab3843459c9227dd2945047d5220a0b7b632d32 Parents: 44e43d7 Author: James Taylor <jamestay...@apache.org> Authored: Fri Sep 23 13:13:41 2016 -0700 Committer: James Taylor <jamestay...@apache.org> Committed: Fri Sep 23 13:21:19 2016 -0700 ---------------------------------------------------------------------- .../StatisticsCollectionRunTrackerIT.java | 15 ---- .../apache/phoenix/end2end/AlterSessionIT.java | 59 ++++++------- .../apache/phoenix/end2end/AlterTableIT.java | 9 +- .../phoenix/end2end/AlterTableWithViewsIT.java | 14 ---- .../phoenix/end2end/ArrayFillFunctionIT.java | 66 ++++++++------- .../apache/phoenix/end2end/BaseParallelIT.java | 69 ---------------- .../org/apache/phoenix/end2end/BaseViewIT.java | 15 ---- .../phoenix/end2end/CbrtFunctionEnd2EndIT.java | 27 +++--- .../phoenix/end2end/DisableLocalIndexIT.java | 24 ++---- .../phoenix/end2end/DistinctPrefixFilterIT.java | 24 +++--- .../apache/phoenix/end2end/DynamicColumnIT.java | 19 +++-- .../end2end/GetSetByteBitFunctionEnd2EndIT.java | 8 +- .../apache/phoenix/end2end/HashJoinMoreIT.java | 16 ---- .../phoenix/end2end/InMemoryOrderByIT.java | 42 ---------- .../apache/phoenix/end2end/IndexExtendedIT.java | 4 +- .../phoenix/end2end/LikeExpressionIT.java | 16 ++-- .../end2end/ParallelStatsDisabledIT.java | 14 +++- .../phoenix/end2end/ParallelStatsEnabledIT.java | 12 +-- .../phoenix/end2end/PowerFunctionEnd2EndIT.java | 19 +++-- .../phoenix/end2end/QueryWithOffsetIT.java | 14 ---- .../phoenix/end2end/SerialIteratorsIT.java | 19 ++--- .../phoenix/end2end/SignFunctionEnd2EndIT.java | 27 +++--- .../end2end/SkipScanAfterManualSplitIT.java | 33 +++----- .../phoenix/end2end/SortMergeJoinMoreIT.java | 16 ---- .../phoenix/end2end/SpooledOrderByIT.java | 40 --------- .../phoenix/end2end/SpooledSortMergeJoinIT.java | 45 ---------- .../phoenix/end2end/SpooledTmpFileDeleteIT.java | 62 +++++++------- .../phoenix/end2end/StatsCollectorIT.java | 61 ++++---------- .../end2end/StringToArrayFunctionIT.java | 87 +++++++++++--------- .../phoenix/end2end/TransactionalViewIT.java | 15 ---- .../end2end/index/AsyncIndexDisabledIT.java | 13 --- .../phoenix/end2end/index/DropMetadataIT.java | 50 +++++------ .../index/GlobalIndexOptimizationIT.java | 20 +---- .../apache/phoenix/end2end/index/IndexIT.java | 15 ---- .../phoenix/end2end/index/LocalIndexIT.java | 2 +- .../end2end/index/MutableIndexFailureIT.java | 2 +- .../phoenix/end2end/index/MutableIndexIT.java | 55 +++++-------- .../phoenix/end2end/index/SaltedIndexIT.java | 31 +++---- .../phoenix/end2end/index/ViewIndexIT.java | 2 +- .../end2end/index/txn/MutableRollbackIT.java | 34 +++----- .../phoenix/end2end/index/txn/RollbackIT.java | 25 ++---- .../phoenix/iterate/PhoenixQueryTimeoutIT.java | 52 ++++++------ .../iterate/RoundRobinResultIteratorIT.java | 38 ++++----- .../org/apache/phoenix/rpc/UpdateCacheIT.java | 15 ---- .../phoenix/tx/NotThreadSafeTransactionIT.java | 62 ++++++++++---- .../org/apache/phoenix/tx/TransactionIT.java | 54 ------------ .../org/apache/phoenix/tx/TxCheckpointIT.java | 29 +++---- .../phoenix/query/QueryServicesOptions.java | 8 +- .../java/org/apache/phoenix/util/QueryUtil.java | 2 +- .../apache/phoenix/jdbc/PhoenixDriverTest.java | 2 + .../java/org/apache/phoenix/query/BaseTest.java | 4 +- .../phoenix/query/QueryServicesTestImpl.java | 2 + 52 files changed, 481 insertions(+), 927 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java index 759ad4f..cf475f9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java @@ -26,7 +26,6 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.util.List; -import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HRegionInfo; @@ -35,33 +34,19 @@ import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.end2end.ParallelStatsEnabledIT; import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.stats.StatisticsCollectionRunTracker; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Assert; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class StatisticsCollectionRunTrackerIT extends ParallelStatsEnabledIT { private static final StatisticsCollectionRunTracker tracker = StatisticsCollectionRunTracker .getInstance(new Configuration()); private String fullTableName; - @BeforeClass - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - // Must update config before starting server - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); - props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - @Before public void generateTableNames() { String schemaName = TestUtil.DEFAULT_SCHEMA_NAME; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java index ffd9656..bf666e4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java @@ -17,13 +17,9 @@ */ package org.apache.phoenix.end2end; -import org.apache.hadoop.hbase.client.Consistency; -import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.util.PhoenixRuntime; -import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.QueryUtil; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.sql.Connection; import java.sql.DriverManager; @@ -31,9 +27,13 @@ import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties; -import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.apache.hadoop.hbase.client.Consistency; +import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.QueryUtil; +import org.junit.Before; +import org.junit.Test; /** * @@ -42,53 +42,48 @@ import static org.junit.Assert.assertTrue; */ public class AlterSessionIT extends ParallelStatsDisabledIT { - private static final String TABLE_NAME = generateUniqueName(); - private static Connection testConn; + private String tableName; - @BeforeClass - public static void initTable() throws Exception { + @Before + public void initTable() throws Exception { + tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - testConn = DriverManager.getConnection(getUrl(), props); - assertEquals(Consistency.STRONG, ((PhoenixConnection)testConn).getConsistency()); - testConn.createStatement().execute( - "create table " + TABLE_NAME + " (col1 varchar primary key)"); - testConn.commit(); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + conn.createStatement().execute( + "create table " + tableName + " (col1 varchar primary key)"); + } } @Test public void testUpdateConsistency() throws Exception { - try { - Statement st = testConn.createStatement(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + Statement st = conn.createStatement(); st.execute("alter session set Consistency = 'timeline'"); - ResultSet rs = st.executeQuery("explain select * from " + TABLE_NAME); - assertEquals(Consistency.TIMELINE, ((PhoenixConnection)testConn).getConsistency()); + ResultSet rs = st.executeQuery("explain select * from " + tableName); + assertEquals(Consistency.TIMELINE, conn.unwrap(PhoenixConnection.class).getConsistency()); String queryPlan = QueryUtil.getExplainPlan(rs); assertTrue(queryPlan.indexOf("TIMELINE") > 0); // turn off timeline read consistency st.execute("alter session set Consistency = 'strong'"); - rs = st.executeQuery("explain select * from " + TABLE_NAME); + rs = st.executeQuery("explain select * from " + tableName); queryPlan = QueryUtil.getExplainPlan(rs); assertTrue(queryPlan.indexOf("TIMELINE") < 0); - } finally { - this.testConn.close(); } } @Test public void testSetConsistencyInURL() throws Exception { - try { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl() + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR + - "Consistency=TIMELINE", props); + try (Connection conn = DriverManager.getConnection(getUrl() + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR + + "Consistency=TIMELINE", props)) { assertEquals(Consistency.TIMELINE, ((PhoenixConnection)conn).getConsistency()); Statement st = conn.createStatement(); - ResultSet rs = st.executeQuery("explain select * from " + TABLE_NAME); + ResultSet rs = st.executeQuery("explain select * from " + tableName); String queryPlan = QueryUtil.getExplainPlan(rs); assertTrue(queryPlan.indexOf("TIMELINE") > 0); conn.close(); - } finally { - this.testConn.close(); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java index 031fd5c..0125a63 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java @@ -51,6 +51,7 @@ import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryConstants; +import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.TableNotFoundException; @@ -2146,8 +2147,8 @@ public class AlterTableIT extends ParallelStatsDisabledIT { assertTrue(t.isMultiTenant()); // check table metadata updated server side - ResultSet rs = conn.createStatement().executeQuery("SELECT DISABLE_WAL, MULTI_TENANT FROM SYSTEM.CATALOG " + - "WHERE table_name = '" + ResultSet rs = conn.createStatement().executeQuery("SELECT DISABLE_WAL, MULTI_TENANT FROM SYSTEM.CATALOG " + + "WHERE table_name = '" + dataTableFullName + "' AND DISABLE_WAL IS NOT NULL AND MULTI_TENANT IS NOT NULL"); assertTrue(rs.next()); assertFalse(rs.getBoolean(1)); @@ -2234,7 +2235,9 @@ public class AlterTableIT extends ParallelStatsDisabledIT { @Test public void testCreatingTxnTableFailsIfTxnsDisabled() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(false)); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { // creating a transactional table should fail if transactions are disabled try { conn.createStatement().execute("CREATE TABLE " + dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR) TRANSACTIONAL=true"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java index c9e2f26..e6bf2d2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java @@ -32,7 +32,6 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import org.apache.commons.lang.ArrayUtils; import org.apache.hadoop.hbase.client.HTableInterface; @@ -41,20 +40,15 @@ import org.apache.phoenix.coprocessor.PhoenixTransactionalProcessor; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryConstants; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.PNameFactory; import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.PTableType; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.google.common.collect.Maps; - @RunWith(Parameterized.class) public class AlterTableWithViewsIT extends ParallelStatsDisabledIT { @@ -72,14 +66,6 @@ public class AlterTableWithViewsIT extends ParallelStatsDisabledIT { return Arrays.asList(false, true); } - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - private String generateDDL(String format) { return String.format(format, isMultiTenant ? "TENANT_ID VARCHAR NOT NULL, " : "", isMultiTenant ? "TENANT_ID, " : "", isMultiTenant ? "MULTI_TENANT=true" : ""); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java index 4680998..96bafad 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java @@ -23,22 +23,30 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.math.BigDecimal; -import java.sql.*; - -import org.junit.BeforeClass; +import java.sql.Array; +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Time; +import java.sql.Timestamp; + +import org.junit.Before; import org.junit.Test; public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { - private static final String REGIONS = generateUniqueName(); + private String tableName; - @BeforeClass - public static void initTables() throws Exception { + @Before + public void initTable() throws Exception { + tableName = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE " + REGIONS + String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,date DATE,time TIME,timestamp TIMESTAMP,varchar VARCHAR,integer INTEGER,double DOUBLE,bigint BIGINT,char CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; conn.createStatement().execute(ddl); - String dml = "UPSERT INTO " + REGIONS + String dml = "UPSERT INTO " + tableName + "(region_name,length1,length2,date,time,timestamp,varchar,integer,double,bigint,char,double1,char1,nullcheck,chars2,varchars2) VALUES('SF Bay Area'," + "0," + @@ -68,7 +76,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(varchar,5) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(varchar,5) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); String[] strings = new String[]{"foo", "foo", "foo", "foo", "foo"}; @@ -85,7 +93,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(integer,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(integer,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34, 34, 34, 34}; @@ -103,7 +111,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(double,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(double,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{23.45, 23.45, 23.45, 23.45}; @@ -121,7 +129,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(bigint,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(bigint,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{34567l, 34567l, 34567l, 34567l}; @@ -139,7 +147,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(char,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(char,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -156,7 +164,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(varchar,4) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(varchar,4) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{"foo", "foo", "foo", "foo"}; @@ -173,7 +181,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(date,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(date,3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Date(1432102334184l), new Date(1432102334184l), new Date(1432102334184l)}; @@ -190,7 +198,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(time,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(time,3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Time(1432102334184l), new Time(1432102334184l), new Time(1432102334184l)}; @@ -207,7 +215,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,3) FROM " + REGIONS + " WHERE region_name = 'SF Bay Area'"); + "SELECT ARRAY_FILL(timestamp,3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); Object[] objects = new Object[]{new Timestamp(1432102334184l), new Timestamp(1432102334184l), new Timestamp(1432102334184l)}; @@ -224,7 +232,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,length2) FROM " + REGIONS + "SELECT ARRAY_FILL(timestamp,length2) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -242,7 +250,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(timestamp,length1) FROM " + REGIONS + "SELECT ARRAY_FILL(timestamp,length1) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -260,7 +268,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(ARRAY_ELEM(ARRAY[23,45],1),3) FROM " + REGIONS + "SELECT ARRAY_FILL(ARRAY_ELEM(ARRAY[23,45],1),3) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -279,7 +287,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL('hello', ARRAY_LENGTH(ARRAY[34, 45])) FROM " + REGIONS + "SELECT ARRAY_FILL('hello', ARRAY_LENGTH(ARRAY[34, 45])) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -298,7 +306,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_FILL(3.4, ARRAY_LENGTH(ARRAY[34, 45])) FROM " + REGIONS + "SELECT ARRAY_FILL(3.4, ARRAY_LENGTH(ARRAY[34, 45])) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -491,7 +499,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT region_name FROM " + REGIONS + " WHERE ARRAY[12, 12, 12, 12]=ARRAY_FILL(12,4)"); + "SELECT region_name FROM " + tableName + " WHERE ARRAY[12, 12, 12, 12]=ARRAY_FILL(12,4)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -505,7 +513,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT region_name FROM " + REGIONS + " WHERE varchar=ANY(ARRAY_FILL('foo',3))"); + "SELECT region_name FROM " + tableName + " WHERE varchar=ANY(ARRAY_FILL('foo',3))"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -518,7 +526,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE ARRAY['2345', '2345', '2345', '2345']=ARRAY_FILL('2345', 4)"); assertTrue(rs.next()); @@ -532,7 +540,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE ARRAY[23.45, 23.45, 23.45]=ARRAY_FILL(23.45, 3)"); assertTrue(rs.next()); @@ -546,7 +554,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + REGIONS + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE ARRAY['foo','foo','foo','foo','foo']=ARRAY_FILL(varchar,5)"); assertTrue(rs.next()); @@ -561,7 +569,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT region_name FROM " + REGIONS + " WHERE varchars2=ARRAY_FILL('hello',3)"); + "SELECT region_name FROM " + tableName + " WHERE varchars2=ARRAY_FILL('hello',3)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); @@ -575,7 +583,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT region_name FROM " + REGIONS + " WHERE ARRAY[2,2,2,2]=ARRAY_FILL(2,4)"); + "SELECT region_name FROM " + tableName + " WHERE ARRAY[2,2,2,2]=ARRAY_FILL(2,4)"); assertTrue(rs.next()); assertEquals("SF Bay Area", rs.getString(1)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseParallelIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseParallelIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseParallelIT.java deleted file mode 100644 index 14473f1..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseParallelIT.java +++ /dev/null @@ -1,69 +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.end2end; - -import org.apache.hadoop.conf.Configuration; -import org.apache.phoenix.query.BaseTest; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * Base class for tests that create unique tables for - * every test enabling them to be - * 1) run in parallel - * 2) not have to delete any tables - * - * We need to separate these from tests that rely on clients - * to set timestamps, because we create/destroy the Phoenix tables - * between tests and only allow a table time stamp to increase. - * Without this separation table deletion/creation would fail. - * - * All tests extending this class use the mini cluster that is - * shared by all classes extending this class - * - * Remember to use BaseTest.generateRandomString() to generate table - * names for your tests otherwise there might be naming collisions between - * other tests. - */ -public abstract class BaseParallelIT extends BaseTest { - protected static Configuration getTestClusterConfig() { - // don't want callers to modify config. - return new Configuration(config); - } - - @BeforeClass - public static void doSetup() throws Exception { - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); - } - - @AfterClass - public static void doTeardown() throws Exception { - // no teardown since we are creating unique table names - // just destroy our test driver - destroyDriver(); - } - - @After - public void cleanUpAfterTest() throws Exception { - // no cleanup since we are using unique table names - } - -} http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java index 686b39f..478b234 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java @@ -31,7 +31,6 @@ import java.sql.Statement; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.client.HTableInterface; @@ -43,20 +42,15 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.KeyRange; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.ScanUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; -import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.google.common.collect.Maps; - @RunWith(Parameterized.class) public abstract class BaseViewIT extends ParallelStatsEnabledIT { @@ -66,15 +60,6 @@ public abstract class BaseViewIT extends ParallelStatsEnabledIT { protected String tableDDLOptions; protected boolean transactional; - @BeforeClass - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - // TODO: don't repeat this - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - public BaseViewIT( boolean transactional) { StringBuilder optionBuilder = new StringBuilder(); this.transactional = transactional; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java index 98aa819..d34b6ae 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CbrtFunctionEnd2EndIT.java @@ -28,7 +28,6 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.CbrtFunction; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -38,20 +37,22 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { private static final String KEY = "key"; private static final double ZERO = 1e-8; - private static final String TEST_SIGNED = generateUniqueName(); - private static final String TEST_UNSIGNED = generateUniqueName(); + private String signedTableName; + private String unsignedTableName; - @BeforeClass - public static void initTable() throws Exception { + @Before + public void initTable() throws Exception { + signedTableName = generateUniqueName(); + unsignedTableName = generateUniqueName(); Connection conn = null; PreparedStatement stmt = null; try { conn = DriverManager.getConnection(getUrl()); String ddl; - ddl = "CREATE TABLE " + TEST_SIGNED + ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); - ddl = "CREATE TABLE " + TEST_UNSIGNED + ddl = "CREATE TABLE " + unsignedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub UNSIGNED_DOUBLE, fl UNSIGNED_FLOAT, inte UNSIGNED_INT, lon UNSIGNED_LONG, smalli UNSIGNED_SMALLINT, tinyi UNSIGNED_TINYINT)"; conn.createStatement().execute(ddl); conn.commit(); @@ -62,7 +63,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { private void updateSignedTable(Connection conn, double data) throws Exception { PreparedStatement stmt = conn.prepareStatement( - "UPSERT INTO " + TEST_SIGNED + " VALUES (?, ?, ?, ?, ?, ?, ?)"); + "UPSERT INTO " + signedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)"); stmt.setString(1, KEY); Double d = Double.valueOf(data); stmt.setDouble(2, d.doubleValue()); @@ -77,7 +78,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { private void updateUnsignedTable(Connection conn, double data) throws Exception { PreparedStatement stmt = conn.prepareStatement( - "UPSERT INTO " + TEST_UNSIGNED + " VALUES (?, ?, ?, ?, ?, ?, ?)"); + "UPSERT INTO " + unsignedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)"); stmt.setString(1, KEY); Double d = Double.valueOf(data); stmt.setDouble(2, d.doubleValue()); @@ -94,7 +95,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { updateSignedTable(conn, data); ResultSet rs = conn.createStatement().executeQuery( "SELECT CBRT(doub),CBRT(fl),CBRT(inte),CBRT(lon),CBRT(smalli),CBRT(tinyi) FROM " - + TEST_SIGNED); + + signedTableName); assertTrue(rs.next()); Double d = Double.valueOf(data); assertTrue(Math.abs(rs.getDouble(1) - Math.cbrt(d.doubleValue())) < ZERO); @@ -104,7 +105,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { assertTrue(Math.abs(rs.getDouble(5) - Math.cbrt(d.shortValue())) < ZERO); assertTrue(Math.abs(rs.getDouble(6) - Math.cbrt(d.byteValue())) < ZERO); assertTrue(!rs.next()); - PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + TEST_SIGNED + PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + signedTableName + " WHERE CBRT(doub)>0 AND CBRT(fl)>0 AND CBRT(inte)>0 AND CBRT(lon)>0 AND CBRT(smalli)>0 AND CBRT(tinyi)>0"); rs = stmt.executeQuery(); if (data > 0) { @@ -118,7 +119,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { updateUnsignedTable(conn, data); ResultSet rs = conn.createStatement().executeQuery( "SELECT CBRT(doub),CBRT(fl),CBRT(inte),CBRT(lon),CBRT(smalli),CBRT(tinyi) FROM " - + TEST_UNSIGNED); + + unsignedTableName); assertTrue(rs.next()); Double d = Double.valueOf(data); assertTrue(Math.abs(rs.getDouble(1) - Math.cbrt(d.doubleValue())) < ZERO); @@ -128,7 +129,7 @@ public class CbrtFunctionEnd2EndIT extends ParallelStatsDisabledIT { assertTrue(Math.abs(rs.getDouble(5) - Math.cbrt(d.shortValue())) < ZERO); assertTrue(Math.abs(rs.getDouble(6) - Math.cbrt(d.byteValue())) < ZERO); assertTrue(!rs.next()); - PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + TEST_UNSIGNED + PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + unsignedTableName + " WHERE CBRT(doub)>0 AND CBRT(fl)>0 AND CBRT(inte)>0 AND CBRT(lon)>0 AND CBRT(smalli)>0 AND CBRT(tinyi)>0"); rs = stmt.executeQuery(); if (data > 0) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java index 10f970f..8eab9e2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java @@ -24,7 +24,6 @@ import static org.junit.Assert.fail; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.Map; import java.util.Properties; import org.apache.hadoop.hbase.client.HBaseAdmin; @@ -36,26 +35,16 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class DisableLocalIndexIT extends ParallelStatsDisabledIT { - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - // Must update config before starting server - props.put(QueryServices.ALLOW_LOCAL_INDEX_ATTRIB, Boolean.FALSE.toString()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } @Test public void testDisabledLocalIndexes() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + props.setProperty(QueryServices.ALLOW_LOCAL_INDEX_ATTRIB, Boolean.FALSE.toString()); + Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); String baseName = generateUniqueName(); String tableName = baseName+ "_TABLE"; @@ -78,9 +67,10 @@ public class DisableLocalIndexIT extends ParallelStatsDisabledIT { admin.close(); } - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "t1"); - Connection tsconn = DriverManager.getConnection(getUrl(), props); + Properties tsconnProps = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + tsconnProps.setProperty(QueryServices.ALLOW_LOCAL_INDEX_ATTRIB, Boolean.FALSE.toString()); + tsconnProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "t1"); + Connection tsconn = DriverManager.getConnection(getUrl(), tsconnProps); tsconn.createStatement().execute("CREATE VIEW " + viewName + "(V1 VARCHAR) AS SELECT * FROM " + tableName); tsconn.createStatement().execute("CREATE INDEX " + indexName1 + " ON " + viewName + "(V1)"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java index 87edc25..3d88a43 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java @@ -32,19 +32,21 @@ import java.util.Properties; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; public class DistinctPrefixFilterIT extends ParallelStatsDisabledIT { - private static final String testTableF = generateUniqueName(); - private static final String testTableV = generateUniqueName(); - private static final String testSeq = testTableF + "_seq"; private static final String PREFIX = "SERVER DISTINCT PREFIX"; - private static Connection conn; + private String testTableF; + private String testTableV; + private String testSeq; + private Connection conn; - @BeforeClass - public static void doSetup() throws Exception { - ParallelStatsDisabledIT.doSetup(); + @Before + public void initTables() throws Exception { + testTableF = generateUniqueName(); + testTableV = generateUniqueName(); + testSeq = "SEQ_" + generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); conn = DriverManager.getConnection(getUrl(), props); @@ -367,7 +369,7 @@ public class DistinctPrefixFilterIT extends ParallelStatsDisabledIT { assertFalse(res.next()); } - private static void insertPrefixF(int prefix1, int prefix2) throws SQLException { + private void insertPrefixF(int prefix1, int prefix2) throws SQLException { String query = "UPSERT INTO " + testTableF + "(prefix1, prefix2, prefix3, col1, col2) VALUES(?,?,NEXT VALUE FOR "+testSeq+",rand(), trunc(rand()*1000))"; PreparedStatement stmt = conn.prepareStatement(query); @@ -376,7 +378,7 @@ public class DistinctPrefixFilterIT extends ParallelStatsDisabledIT { stmt.execute(); } - private static void insertPrefixV(String prefix1, String prefix2) throws SQLException { + private void insertPrefixV(String prefix1, String prefix2) throws SQLException { String query = "UPSERT INTO " + testTableV + "(prefix1, prefix2, prefix3, col1, col2) VALUES(?,?,NEXT VALUE FOR "+testSeq+",rand(), trunc(rand()*1000))"; PreparedStatement stmt = conn.prepareStatement(query); @@ -385,7 +387,7 @@ public class DistinctPrefixFilterIT extends ParallelStatsDisabledIT { stmt.execute(); } - private static void multiply() throws SQLException { + private void multiply() throws SQLException { conn.prepareStatement("UPSERT INTO " + testTableF + " SELECT prefix1,prefix2,NEXT VALUE FOR "+testSeq+",rand(), trunc(rand()*1000) FROM "+testTableF).execute(); conn.prepareStatement("UPSERT INTO " + testTableV http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java index 3fc05a7..25e7230 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java @@ -18,7 +18,6 @@ package org.apache.phoenix.end2end; -import static org.apache.phoenix.util.TestUtil.HBASE_DYNAMIC_COLUMNS; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -48,7 +47,6 @@ import org.apache.phoenix.schema.ColumnFamilyNotFoundException; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -63,14 +61,15 @@ public class DynamicColumnIT extends ParallelStatsDisabledIT { private static final byte[] FAMILY_NAME_A = Bytes.toBytes(SchemaUtil.normalizeIdentifier("A")); private static final byte[] FAMILY_NAME_B = Bytes.toBytes(SchemaUtil.normalizeIdentifier("B")); - private static String tableName = "TESTTBL"; + private String tableName; - @BeforeClass - public static void doBeforeTestSetup() throws Exception { + @Before + public void initTable() throws Exception { + tableName = generateUniqueName(); try (PhoenixConnection pconn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class)) { ConnectionQueryServices services = pconn.getQueryServices(); try (HBaseAdmin admin = services.getAdmin()) { - HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TESTTBL")); + HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); htd.addFamily(new HColumnDescriptor(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES)); htd.addFamily(new HColumnDescriptor(FAMILY_NAME_A)); htd.addFamily(new HColumnDescriptor(FAMILY_NAME_B)); @@ -101,7 +100,13 @@ public class DynamicColumnIT extends ParallelStatsDisabledIT { // Create Phoenix table after HBase table was created through the native APIs // The timestamp of the table creation must be later than the timestamp of the data - ensureTableCreated(getUrl(), tableName, HBASE_DYNAMIC_COLUMNS); + pconn.createStatement().execute("create table " + tableName + + " (entry varchar not null," + + " F varchar," + + " A.F1v1 varchar," + + " A.F1v2 varchar," + + " B.F2v1 varchar" + + " CONSTRAINT pk PRIMARY KEY (entry))"); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java index 98d1478..31afb49 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java @@ -32,7 +32,6 @@ import org.apache.phoenix.expression.function.GetByteFunction; import org.apache.phoenix.expression.function.SetBitFunction; import org.apache.phoenix.expression.function.SetByteFunction; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -42,10 +41,11 @@ import org.junit.Test; public class GetSetByteBitFunctionEnd2EndIT extends ParallelStatsDisabledIT { private static final String KEY = "key"; - private static final String TABLE_NAME = generateUniqueName(); + private String TABLE_NAME; - @BeforeClass - public static void initTable() throws Exception { + @Before + public void initTable() throws Exception { + TABLE_NAME = generateUniqueName(); Connection conn = null; PreparedStatement stmt = null; try { http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java index 5f04ead..52e8006 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinMoreIT.java @@ -28,18 +28,12 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; -import java.util.Map; import java.util.Properties; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class HashJoinMoreIT extends ParallelStatsDisabledIT { private final String[] plans = new String[] { /* @@ -91,16 +85,6 @@ public class HashJoinMoreIT extends ParallelStatsDisabledIT { " DYNAMIC SERVER FILTER BY (LHS.COL0, LHS.COL1, LHS.COL2) IN ((RHS.COL1, RHS.COL2, TO_INTEGER((RHS.COL3 - 1))))", }; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - // Forces server cache to be used - props.put(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(2)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - @Test public void testJoinOverSaltedTables() throws Exception { String tempTableNoSalting = generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/InMemoryOrderByIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InMemoryOrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InMemoryOrderByIT.java deleted file mode 100644 index 87a0b4b..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InMemoryOrderByIT.java +++ /dev/null @@ -1,42 +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.end2end; - -import java.util.Map; - -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; - -import com.google.common.collect.Maps; - - -public class InMemoryOrderByIT extends OrderByIT { - - public InMemoryOrderByIT() { - } - - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1024*1024)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } -} http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java index e3a541d..cfbc9eb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java @@ -374,9 +374,9 @@ public class IndexExtendedIT extends BaseOwnClusterIT { } } - private Connection getConnectionForLocalIndexTest() throws SQLException{ + private static Connection getConnectionForLocalIndexTest() throws SQLException{ Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); return DriverManager.getConnection(getUrl(),props); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java index f522817..3dba4d5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java @@ -30,21 +30,21 @@ import java.sql.SQLException; import java.sql.Statement; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; public class LikeExpressionIT extends ParallelStatsDisabledIT { - private static final String TEST_TABLE = generateUniqueName(); + private String tableName; - @BeforeClass - public static void doBeforeTestSetup() throws Exception { + @Before + public void initTable() throws Exception { + tableName = generateUniqueName(); Connection conn = null; PreparedStatement stmt = null; try { conn = DriverManager.getConnection(getUrl()); String ddl; - ddl = "CREATE TABLE " + TEST_TABLE + " (k VARCHAR NOT NULL PRIMARY KEY, i INTEGER)"; + ddl = "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, i INTEGER)"; conn.createStatement().execute(ddl); conn.commit(); } finally { @@ -58,9 +58,9 @@ public class LikeExpressionIT extends ParallelStatsDisabledIT { insertRow(conn, "321n7-App-2-", 32); } - private static void insertRow(Connection conn, String k, int i) throws SQLException { + private void insertRow(Connection conn, String k, int i) throws SQLException { PreparedStatement stmt = conn.prepareStatement( - "UPSERT INTO " + TEST_TABLE + " VALUES (?, ?)"); + "UPSERT INTO " + tableName + " VALUES (?, ?)"); stmt.setString(1, k); stmt.setInt(2, i); stmt.executeUpdate(); @@ -69,7 +69,7 @@ public class LikeExpressionIT extends ParallelStatsDisabledIT { private void testLikeExpression(Connection conn, String likeStr, int numResult, int expectedSum) throws Exception { - String cmd = "select k, i from " + TEST_TABLE + " where k like '" + likeStr + "'"; + String cmd = "select k, i from " + tableName + " where k like '" + likeStr + "'"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(cmd); int sum = 0; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java index 4575867..19a208d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java @@ -18,13 +18,21 @@ package org.apache.phoenix.end2end; +import org.apache.phoenix.query.BaseTest; +import org.apache.phoenix.util.ReadOnlyProps; +import org.junit.BeforeClass; import org.junit.experimental.categories.Category; /** - * Base class for tests that do not have statistics enabled. - * + * Base class for tests whose methods run in parallel with statistics disabled. + * You must create unique names using {@link #generateUniqueName()} for each + * table and sequence used to prevent collisions. */ @Category(ParallelStatsDisabledTest.class) -public abstract class ParallelStatsDisabledIT extends BaseParallelIT { +public abstract class ParallelStatsDisabledIT extends BaseTest { + @BeforeClass + public static void doSetup() throws Exception { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java index 322cb9e..312b49d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java @@ -20,6 +20,7 @@ package org.apache.phoenix.end2end; import java.util.Map; +import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; @@ -28,17 +29,16 @@ import org.junit.experimental.categories.Category; import com.google.common.collect.Maps; /** - * - * Base class for tests that have statistics enabled. - * + * Base class for tests whose methods run in parallel with statistics enabled. + * You must create unique names using {@link #generateUniqueName()} for each + * table and sequence used to prevent collisions. */ @Category(ParallelStatsEnabledTest.class) -public abstract class ParallelStatsEnabledIT extends BaseParallelIT { +public abstract class ParallelStatsEnabledIT extends BaseTest { @BeforeClass - @Shadower(classBeingShadowed = BaseParallelIT.class) public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(5); + Map<String,String> props = Maps.newHashMapWithExpectedSize(1); props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java index 1fb45c7..2d26be8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java @@ -27,7 +27,6 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.PowerFunction; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -37,8 +36,8 @@ public class PowerFunctionEnd2EndIT extends ParallelStatsDisabledIT { private static final String KEY = "key"; private static final double ZERO = 1e-9; - private static final String TEST_SIGNED = generateUniqueName(); - private static final String TEST_UNSIGNED = generateUniqueName(); + private String signedTableName; + private String unsignedTableName; private static boolean twoDoubleEquals(double a, double b) { if (Double.isNaN(a) ^ Double.isNaN(b)) return false; @@ -55,17 +54,19 @@ public class PowerFunctionEnd2EndIT extends ParallelStatsDisabledIT { } } - @BeforeClass - public static void initTable() throws Exception { + @Before + public void initTable() throws Exception { + signedTableName = generateUniqueName(); + unsignedTableName = generateUniqueName(); Connection conn = null; PreparedStatement stmt = null; try { conn = DriverManager.getConnection(getUrl()); String ddl; - ddl = "CREATE TABLE " + TEST_SIGNED + ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); - ddl = "CREATE TABLE " + TEST_UNSIGNED + ddl = "CREATE TABLE " + unsignedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub UNSIGNED_DOUBLE, fl UNSIGNED_FLOAT, inte UNSIGNED_INT, lon UNSIGNED_LONG, smalli UNSIGNED_SMALLINT, tinyi UNSIGNED_TINYINT)"; conn.createStatement().execute(ddl); conn.commit(); @@ -140,8 +141,8 @@ public class PowerFunctionEnd2EndIT extends ParallelStatsDisabledIT { public void test() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); for (double d : new double[] { 0.0, 1.0, -1.0, 123.1234, -123.1234 }) { - testNumberSpec(conn, d, TEST_SIGNED); - if (d >= 0) testNumberSpec(conn, d, TEST_UNSIGNED); + testNumberSpec(conn, d, signedTableName); + if (d >= 0) testNumberSpec(conn, d, unsignedTableName); } } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java index c60b403..04d1126 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java @@ -31,22 +31,17 @@ import java.sql.SQLException; import java.sql.Types; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.google.common.collect.Maps; - @RunWith(Parameterized.class) public class QueryWithOffsetIT extends ParallelStatsDisabledIT { @@ -57,15 +52,6 @@ public class QueryWithOffsetIT extends ParallelStatsDisabledIT { private String ddl; private String tableName; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String, String> props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(true)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - public QueryWithOffsetIT(String preSplit) { this.isSalted = preSplit.startsWith(" SALT_BUCKETS"); this.preSplit = preSplit; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java index 37da39e..1360a08 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java @@ -25,18 +25,13 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class SerialIteratorsIT extends ParallelStatsDisabledIT { private String tableName = generateUniqueName(); private final String[] strings = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", @@ -45,19 +40,17 @@ public class SerialIteratorsIT extends ParallelStatsDisabledIT { + "k2 INTEGER NOT NULL,\n" + "C3.k3 INTEGER,\n" + "C2.v1 VARCHAR,\n" + "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2)) SPLIT ON ('e','i','o')"; - @BeforeClass - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - // Don't force row key order - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } @Test public void testConcatenatingSerialIterators() throws Exception { Connection conn; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + conn = getConnection(); createTestTable(getUrl(), ddl); initTableValues(conn); String query = "SELECT t_id from " + tableName + " order by t_id desc limit " + 10; http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java index 34ccdde..e3458dd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java @@ -29,7 +29,6 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.SignFunction; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; /** @@ -39,20 +38,22 @@ import org.junit.Test; public class SignFunctionEnd2EndIT extends ParallelStatsDisabledIT { private static final String KEY = "key"; - private static final String TEST_SIGNED = generateUniqueName(); - private static final String TEST_UNSIGNED = generateUniqueName(); + private String signedTableName; + private String unsignedTableName; - @BeforeClass - public static void initTable() throws Exception { + @Before + public void initTable() throws Exception { + signedTableName = generateUniqueName(); + unsignedTableName = generateUniqueName(); Connection conn = null; PreparedStatement stmt = null; try { conn = DriverManager.getConnection(getUrl()); String ddl; - ddl = "CREATE TABLE " + TEST_SIGNED + ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, dec DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); - ddl = "CREATE TABLE " + TEST_UNSIGNED + ddl = "CREATE TABLE " + unsignedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub UNSIGNED_DOUBLE, fl UNSIGNED_FLOAT, inte UNSIGNED_INT, lon UNSIGNED_LONG, smalli UNSIGNED_SMALLINT, tinyi UNSIGNED_TINYINT)"; conn.createStatement().execute(ddl); conn.commit(); @@ -63,7 +64,7 @@ public class SignFunctionEnd2EndIT extends ParallelStatsDisabledIT { private void updateSignedTable(Connection conn, double data) throws Exception { PreparedStatement stmt = conn.prepareStatement( - "UPSERT INTO " + TEST_SIGNED + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); + "UPSERT INTO " + signedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); stmt.setString(1, KEY); Double d = Double.valueOf(data); stmt.setBigDecimal(2, BigDecimal.valueOf(data)); @@ -79,7 +80,7 @@ public class SignFunctionEnd2EndIT extends ParallelStatsDisabledIT { private void updateUnsignedTable(Connection conn, double data) throws Exception { PreparedStatement stmt = conn.prepareStatement( - "UPSERT INTO " + TEST_UNSIGNED + " VALUES (?, ?, ?, ?, ?, ?, ?)"); + "UPSERT INTO " + unsignedTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)"); stmt.setString(1, KEY); Double d = Double.valueOf(data); stmt.setDouble(2, d.doubleValue()); @@ -96,14 +97,14 @@ public class SignFunctionEnd2EndIT extends ParallelStatsDisabledIT { updateSignedTable(conn, data); ResultSet rs = conn.createStatement().executeQuery( "SELECT SIGN(dec),SIGN(doub),SIGN(fl),SIGN(inte),SIGN(lon),SIGN(smalli),SIGN(tinyi) FROM " - + TEST_SIGNED); + + signedTableName); assertTrue(rs.next()); for (int i = 1; i <= 7; ++i) { assertEquals(rs.getInt(i), expected); } assertTrue(!rs.next()); - PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + TEST_SIGNED + PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + signedTableName + " WHERE SIGN(dec)=? AND SIGN(doub)=? AND SIGN(fl)=? AND SIGN(inte)=? AND SIGN(lon)=? AND SIGN(smalli)=? AND SIGN(tinyi)=?"); for (int i = 1; i <= 7; ++i) stmt.setInt(i, expected); @@ -117,14 +118,14 @@ public class SignFunctionEnd2EndIT extends ParallelStatsDisabledIT { updateUnsignedTable(conn, data); ResultSet rs = conn.createStatement().executeQuery( "SELECT SIGN(doub),SIGN(fl),SIGN(inte),SIGN(lon),SIGN(smalli),SIGN(tinyi) FROM " - + TEST_UNSIGNED); + + unsignedTableName); assertTrue(rs.next()); for (int i = 1; i <= 6; ++i) { assertEquals(rs.getInt(i), expected); } assertTrue(!rs.next()); - PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + TEST_UNSIGNED + PreparedStatement stmt = conn.prepareStatement("SELECT k FROM " + unsignedTableName + " WHERE SIGN(doub)=? AND SIGN(fl)=? AND SIGN(inte)=? AND SIGN(lon)=? AND SIGN(smalli)=? AND SIGN(tinyi)=?"); for (int i = 1; i <= 6; ++i) stmt.setInt(i, expected); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java index efb662b..e4add9a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java @@ -28,7 +28,7 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map; +import java.util.Properties; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.client.HBaseAdmin; @@ -36,12 +36,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.TestUtil; import org.junit.Test; -import com.google.common.collect.Maps; - public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { @@ -59,22 +57,15 @@ public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { private static final int MIN_CHAR = 'a'; private static final int MAX_CHAR = 'z'; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(2); - // needed for 64 region parallelization due to splitting - // props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(64)); - props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(32)); - // enables manual splitting on salted tables - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); - props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1000)); - props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } private static void initTable(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + "a VARCHAR PRIMARY KEY, b VARCHAR) " + HTableDescriptor.MAX_FILESIZE + "=" + MAX_FILESIZE + "," @@ -109,7 +100,7 @@ public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); byte[] tableNameBytes = Bytes.toBytes(tableName); initTable(tableName); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); int nRegions = services.getAllTableRegions(tableNameBytes).size(); int nInitialRegions = nRegions; @@ -280,7 +271,7 @@ public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { */ @Test public void testSkipScanInListOfRVCAfterManualSplit() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( " + "organization_id CHAR(15) NOT NULL, " @@ -349,7 +340,7 @@ public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { @Test public void testMinMaxRangeIntersection() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); String tableName = generateUniqueName(); PreparedStatement stmt = conn.prepareStatement("create table " + tableName + "(pk1 UNSIGNED_TINYINT NOT NULL, pk2 UNSIGNED_TINYINT NOT NULL, kv VARCHAR " http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java index df18093..a08ba39 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java @@ -27,30 +27,14 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; -import java.util.Map; import java.util.Properties; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - // Forces server cache to be used - props.put(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(2)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - @Test public void testJoinOverSaltedTables() throws Exception { String tempTableNoSalting = "TEMP_TABLE_NO_SALTING" + generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java deleted file mode 100644 index 2f0bc61..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java +++ /dev/null @@ -1,40 +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.end2end; - -import java.util.Map; - -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; - -import com.google.common.collect.Maps; - - -public class SpooledOrderByIT extends OrderByIT { - - @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(100)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - -} http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java deleted file mode 100644 index c646622..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.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.end2end; - -import java.util.Map; - -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; - -import com.google.common.collect.Maps; - - -public class SpooledSortMergeJoinIT extends SortMergeJoinIT { - - public SpooledSortMergeJoinIT(String[] indexDDL, String[] plans) { - super(indexDDL, plans); - } - - @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1);; - props.put(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(100)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - -} - http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab38434/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java index 51bcb31..9dc82bf 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java @@ -23,53 +23,50 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.QueryUtil; +import org.apache.phoenix.util.StringUtil; +import org.apache.phoenix.util.TestUtil; import org.junit.After; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; import com.google.common.io.Files; - - public class SpooledTmpFileDeleteIT extends ParallelStatsDisabledIT { - - private Connection conn = null; - private Properties props = null; + private static final String PRINCIPAL = "noRenewLease"; private File spoolDir; private String tableName; - @BeforeClass - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) - public static void doSetup() throws Exception { - Map<String, String> props = Maps.newHashMapWithExpectedSize(1); - // disable renewing leases. This will force spooling to happen. - props.put(QueryServices.RENEW_LEASE_ENABLED, Boolean.toString(false)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private Connection getConnection() throws Exception { + Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + props.setProperty(QueryServices.SPOOL_DIRECTORY, spoolDir.getPath()); + props.setProperty(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1)); + props.setProperty(QueryServices.RENEW_LEASE_ENABLED, Boolean.toString(false)); + // Ensures round robin off so that spooling is used. + // TODO: review with Samarth - should a Noop iterator be used if pacing is not possible? + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(true)); + props.setProperty(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, StringUtil.EMPTY_STRING); + String url = QueryUtil.getConnectionUrl(props, config, PRINCIPAL); + return DriverManager.getConnection(url, props); } - + @Before - public void setup() throws SQLException { + public void setup() throws Exception { tableName = generateUniqueName(); - props = new Properties(); spoolDir = Files.createTempDir(); - props.put(QueryServices.SPOOL_DIRECTORY, spoolDir.getPath()); - props.setProperty(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1)); - conn = DriverManager.getConnection(getUrl(), props); - Statement stmt = conn.createStatement(); - stmt.execute("CREATE TABLE " + tableName + " (ID varchar NOT NULL PRIMARY KEY) SPLIT ON ('EA','EZ')"); - stmt.execute("UPSERT INTO " + tableName + " VALUES ('AA')"); - stmt.execute("UPSERT INTO " + tableName + " VALUES ('EB')"); - stmt.execute("UPSERT INTO " + tableName + " VALUES ('FA')"); - stmt.close(); - conn.commit(); + try (Connection conn = getConnection()) { + Statement stmt = conn.createStatement(); + stmt.execute("CREATE TABLE " + tableName + " (ID varchar NOT NULL PRIMARY KEY) SPLIT ON ('EA','EZ')"); + stmt.execute("UPSERT INTO " + tableName + " VALUES ('AA')"); + stmt.execute("UPSERT INTO " + tableName + " VALUES ('EB')"); + stmt.execute("UPSERT INTO " + tableName + " VALUES ('FA')"); + stmt.close(); + conn.commit(); + } } @After @@ -100,7 +97,8 @@ public class SpooledTmpFileDeleteIT extends ParallelStatsDisabledIT { file.delete(); } - String query = "select * from " + tableName + ""; + String query = "select * from " + tableName; + Connection conn = getConnection(); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery(query); assertTrue(rs.next()); @@ -122,7 +120,7 @@ public class SpooledTmpFileDeleteIT extends ParallelStatsDisabledIT { fileNames.add(file.getName()); } - Connection conn2 = DriverManager.getConnection(getUrl(), props); + Connection conn2 = getConnection(); String query2 = "select * from " + tableName + ""; Statement statement2 = conn2.createStatement(); ResultSet rs2 = statement2.executeQuery(query2);