http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java index 0b5a92d..2445948 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java @@ -34,7 +34,6 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Properties; import java.util.Random; @@ -50,18 +49,14 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; 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 StatsCollectorIT extends ParallelStatsEnabledIT { private final String tableDDLOptions; @@ -69,23 +64,18 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { private String schemaName; private String fullTableName; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsEnabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(10); - // Must update config before starting server - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); - props.put(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, Boolean.TRUE.toString()); - props.put(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, Boolean.TRUE.toString()); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - public StatsCollectorIT( boolean transactional) { this.tableDDLOptions= transactional ? " TRANSACTIONAL=true" : ""; } + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, Boolean.TRUE.toString()); + props.setProperty(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, Boolean.TRUE.toString()); + props.setProperty(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); + return DriverManager.getConnection(getUrl(), props); + } + @Before public void generateTableNames() { schemaName = TestUtil.DEFAULT_SCHEMA_NAME; @@ -100,9 +90,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { @Test public void testUpdateEmptyStats() throws Exception { - Connection conn; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(true); conn.createStatement().execute( "CREATE TABLE " + fullTableName +" ( k CHAR(1) PRIMARY KEY )" + tableDDLOptions); @@ -118,9 +106,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { @Test public void testSomeUpdateEmptyStats() throws Exception { - Connection conn; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(true); conn.createStatement().execute( "CREATE TABLE " + fullTableName +" ( k VARCHAR PRIMARY KEY, a.v1 VARCHAR, b.v2 VARCHAR ) " + tableDDLOptions + (tableDDLOptions.isEmpty() ? "" : ",") + "SALT_BUCKETS = 3"); @@ -158,7 +144,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { PreparedStatement stmt; ResultSet rs; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + conn = getConnection(); conn.createStatement().execute( "CREATE TABLE " + fullTableName +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n" + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))" @@ -178,9 +164,6 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { array = conn.createArrayOf("VARCHAR", s); stmt.setArray(3, array); stmt.execute(); - conn.close(); - conn = DriverManager.getConnection(getUrl(), props); - // This analyze would not work stmt = conn.prepareStatement("UPDATE STATISTICS " + tableName); stmt.execute(); rs = conn.createStatement().executeQuery("SELECT k FROM " + tableName); @@ -189,11 +172,9 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { } private void testNoDuplicatesAfterUpdateStats(String splitKey) throws Throwable { - Connection conn; + Connection conn = getConnection(); PreparedStatement stmt; ResultSet rs; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); conn.createStatement() .execute("CREATE TABLE " + fullTableName + " ( k VARCHAR, c1.a bigint,c2.b bigint CONSTRAINT pk PRIMARY KEY (k))"+ tableDDLOptions @@ -229,7 +210,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { PreparedStatement stmt; ResultSet rs; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + conn = getConnection(); conn.createStatement().execute( "CREATE TABLE " + fullTableName +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n" + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))" + tableDDLOptions ); @@ -264,7 +245,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { stmt.setArray(3, array); stmt.execute(); conn.close(); - conn = DriverManager.getConnection(getUrl(), props); + conn = getConnection(); // This analyze would not work stmt = conn.prepareStatement("UPDATE STATISTICS "+fullTableName2); stmt.execute(); @@ -277,7 +258,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { InterruptedException { Connection conn; PreparedStatement stmt; - conn = DriverManager.getConnection(getUrl(), props); + conn = getConnection(); stmt = upsertStmt(conn, tableName); stmt.setString(1, "a"); String[] s = new String[] { "abc", "def", "ghi", "jkll", null, null, "xxx" }; @@ -363,10 +344,8 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { private void testCompactUpdatesStats(Integer minStatsUpdateFreq, String tableName) throws Exception { int nRows = 10; - Connection conn; + Connection conn = getConnection(); PreparedStatement stmt; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("CREATE TABLE " + tableName + "(k CHAR(1) PRIMARY KEY, v INTEGER, w INTEGER) " + HColumnDescriptor.KEEP_DELETED_CELLS + "=" + Boolean.FALSE); stmt = conn.prepareStatement("UPSERT INTO " + tableName + " VALUES(?,?,?)"); @@ -424,10 +403,8 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { @Test public void testWithMultiCF() throws Exception { int nRows = 20; - Connection conn; + Connection conn = getConnection(); PreparedStatement stmt; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute( "CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, a.v INTEGER, b.v INTEGER, c.v INTEGER NULL, d.v INTEGER NULL) "); @@ -505,9 +482,7 @@ public class StatsCollectorIT extends ParallelStatsEnabledIT { @Test public void testRowCountAndByteCounts() throws SQLException { - Connection conn; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); String ddl = "CREATE TABLE " + fullTableName + " (t_id VARCHAR NOT NULL,\n" + "k1 INTEGER NOT NULL,\n" + "k2 INTEGER NOT NULL,\n" + "C3.k3 INTEGER,\n" + "C2.v1 VARCHAR,\n" + "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2)) split on ('e','j','o')";
http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java index c11d765..1afe6ef 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java @@ -21,36 +21,41 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.schema.types.PhoenixArray; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { - private static final String TABLE_NAME = generateUniqueName(); - - @BeforeClass - public static void initTables() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - String ddl = "CREATE TABLE " + TABLE_NAME - + " (region_name VARCHAR PRIMARY KEY, string1 VARCHAR, string2 CHAR(50), delimiter1 VARCHAR, delimiter2 CHAR(20), nullstring1 VARCHAR, nullstring2 CHAR(20))"; - conn.createStatement().execute(ddl); - String dml = "UPSERT INTO " + TABLE_NAME - + "(region_name, string1, string2, delimiter1, delimiter2, nullstring1, nullstring2) VALUES('SF Bay Area'," - + - "'a,b,c,d'," + - "'1.2.3.4'," + - "','," + - "'.'," + - "'c'," + - "'3'" + - ")"; - PreparedStatement stmt = conn.prepareStatement(dml); - stmt.execute(); - conn.commit(); + private String tableName; + + @Before + public void initTables() throws Exception { + tableName = generateUniqueName(); + try (Connection conn = DriverManager.getConnection(getUrl())) { + String ddl = "CREATE TABLE " + tableName + + " (region_name VARCHAR PRIMARY KEY, string1 VARCHAR, string2 CHAR(50), delimiter1 VARCHAR, delimiter2 CHAR(20), nullstring1 VARCHAR, nullstring2 CHAR(20))"; + conn.createStatement().execute(ddl); + String dml = "UPSERT INTO " + tableName + + "(region_name, string1, string2, delimiter1, delimiter2, nullstring1, nullstring2) VALUES('SF Bay Area'," + + + "'a,b,c,d'," + + "'1.2.3.4'," + + "','," + + "'.'," + + "'c'," + + "'3'" + + ")"; + PreparedStatement stmt = conn.prepareStatement(dml); + stmt.execute(); + conn.commit(); + } } @Test @@ -59,7 +64,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string1, delimiter1) FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string1, delimiter1) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -75,7 +80,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string1, delimiter1, nullstring1) FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string1, delimiter1, nullstring1) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -91,7 +96,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string1, delimiter1, 'a') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string1, delimiter1, 'a') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -107,7 +112,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string1, delimiter1, 'd') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string1, delimiter1, 'd') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -123,7 +128,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string2, delimiter2) FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string2, delimiter2) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -139,7 +144,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string2, delimiter2, nullstring2) FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string2, delimiter2, nullstring2) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -155,7 +160,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string2, delimiter2, '1') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string2, delimiter2, '1') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -171,7 +176,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(string2, delimiter2, '4') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(string2, delimiter2, '4') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -187,7 +192,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY(region_name, ' ', '4') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY(region_name, ' ', '4') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -203,7 +208,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY('hello,hello,hello', delimiter1) FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY('hello,hello,hello', delimiter1) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -219,7 +224,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY('a,hello,hello,hello,b', ',', 'hello') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY('a,hello,hello,hello,b', ',', 'hello') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -235,7 +240,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT STRING_TO_ARRAY('b.a.b', delimiter2, 'b') FROM " + TABLE_NAME + "SELECT STRING_TO_ARRAY('b.a.b', delimiter2, 'b') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -251,7 +256,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( - "SELECT ARRAY_LENGTH(STRING_TO_ARRAY('a, b, c', ', ')) FROM " + TABLE_NAME + "SELECT ARRAY_LENGTH(STRING_TO_ARRAY('a, b, c', ', ')) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); @@ -266,7 +271,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( "SELECT STRING_TO_ARRAY(ARRAY_TO_STRING(ARRAY['a', 'b', 'c'], delimiter2), delimiter2, 'b') FROM " - + TABLE_NAME + " WHERE region_name = 'SF Bay Area'"); + + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); PhoenixArray expected = new PhoenixArray(PVarchar.INSTANCE, new Object[]{"a", null, "c"}); @@ -282,7 +287,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { ResultSet rs; rs = conn.createStatement().executeQuery( "SELECT STRING_TO_ARRAY(ARRAY_TO_STRING(ARRAY['a', 'b', 'c'], delimiter2), ARRAY_ELEM(ARRAY[',', '.'], 2), 'b') FROM " - + TABLE_NAME + " WHERE region_name = 'SF Bay Area'"); + + tableName + " WHERE region_name = 'SF Bay Area'"); assertTrue(rs.next()); PhoenixArray expected = new PhoenixArray(PVarchar.INSTANCE, new Object[]{"a", null, "c"}); @@ -435,7 +440,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { Connection conn = DriverManager.getConnection(getUrl()); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + TABLE_NAME + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE ARRAY['a', 'b', 'c', 'd']=STRING_TO_ARRAY(string1, delimiter1)"); assertTrue(rs.next()); @@ -448,7 +453,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { Connection conn = DriverManager.getConnection(getUrl()); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + TABLE_NAME + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE 'a'=ANY(STRING_TO_ARRAY(string1, delimiter1))"); assertTrue(rs.next()); @@ -461,7 +466,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { Connection conn = DriverManager.getConnection(getUrl()); ResultSet rs; - rs = conn.createStatement().executeQuery("SELECT region_name FROM " + TABLE_NAME + rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName + " WHERE 'a'=ALL(STRING_TO_ARRAY('a,a,a,', delimiter1))"); assertTrue(rs.next()); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java index 18e6e5a..b8c028b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java @@ -25,33 +25,18 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.util.List; -import java.util.Map; import org.apache.phoenix.query.KeyRange; -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class TransactionalViewIT extends ParallelStatsEnabledIT { private String fullTableName; private String fullViewName; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsEnabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Integer.toString(20)); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - 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/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexDisabledIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexDisabledIT.java index 5f02790..06edbcf 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexDisabledIT.java @@ -25,28 +25,15 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; -import java.util.Map; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; -import org.apache.phoenix.util.ReadOnlyProps; -import org.junit.BeforeClass; import org.junit.Test; -import com.google.common.collect.Maps; - public class AsyncIndexDisabledIT extends ParallelStatsDisabledIT { - @BeforeClass - public static void doSetup() throws Exception { - Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(1); - clientProps.put(QueryServices.INDEX_ASYNC_BUILD_ENABLED, Boolean.toString(false)); - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps.entrySet().iterator())); - } - @Test public void testAsyncIndexRegularBuild() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl())) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropMetadataIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropMetadataIT.java index 8b3c111..4e7d06a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropMetadataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/DropMetadataIT.java @@ -18,7 +18,7 @@ package org.apache.phoenix.end2end.index; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; -import static org.apache.phoenix.util.TestUtil.*; +import static org.apache.phoenix.util.TestUtil.HBASE_NATIVE_SCHEMA_NAME; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -27,7 +27,6 @@ import static org.junit.Assert.fail; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; -import java.util.Map; import java.util.Properties; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -40,7 +39,6 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; @@ -52,31 +50,36 @@ import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.util.IndexUtil; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; -import org.junit.BeforeClass; +import org.apache.phoenix.util.StringUtil; +import org.apache.phoenix.util.TestUtil; import org.junit.Test; -import com.google.common.collect.Maps; - public class DropMetadataIT extends ParallelStatsDisabledIT { + private static final String PRINCIPAL = "dropMetaData"; private static final byte[] FAMILY_NAME = Bytes.toBytes(SchemaUtil.normalizeIdentifier("1")); public static final String SCHEMA_NAME = ""; - private final String TENANT_SPECIFIC_URL = getUrl() + ';' + TENANT_ID_ATTRIB + "=tenant1"; + private final String TENANT_ID = "tenant1"; + + private Connection getConnection() throws Exception { + return getConnection(PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES)); + } - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - @BeforeClass - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - // Drop the HBase table metadata for this test - props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private Connection getConnection(Properties props) throws Exception { + props.setProperty(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); + // Force real driver to be used as the test one doesn't handle creating + // more than one ConnectionQueryService + props.setProperty(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, StringUtil.EMPTY_STRING); + // Create new ConnectionQueryServices so that we can set DROP_METADATA_ATTRIB + String url = QueryUtil.getConnectionUrl(props, config, PRINCIPAL); + return DriverManager.getConnection(url, props); } @Test public void testDropViewKeepsHTable() throws Exception { - HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), TEST_PROPERTIES).getAdmin(); + Connection conn = getConnection(); + HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); String hbaseNativeViewName = generateUniqueName(); byte[] hbaseNativeBytes = SchemaUtil.getTableNameAsBytes(HBASE_NATIVE_SCHEMA_NAME, hbaseNativeViewName); @@ -91,8 +94,6 @@ public class DropMetadataIT extends ParallelStatsDisabledIT { admin.close(); } - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create view " + hbaseNativeViewName+ " (uint_key unsigned_int not null," + " ulong_key unsigned_long not null," + @@ -102,17 +103,16 @@ public class DropMetadataIT extends ParallelStatsDisabledIT { " CONSTRAINT pk PRIMARY KEY (uint_key, ulong_key, string_key))\n" + HColumnDescriptor.DATA_BLOCK_ENCODING + "='" + DataBlockEncoding.NONE + "'"); conn.createStatement().execute("drop view " + hbaseNativeViewName); - + conn.close(); } @Test public void testDroppingIndexedColDropsIndex() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String indexTableName = generateUniqueName(); String dataTableFullName = SchemaUtil.getTableName(SCHEMA_NAME, generateUniqueName()); String localIndexTableName1 = "LOCAL_" + indexTableName + "_1"; String localIndexTableName2 = "LOCAL_" + indexTableName + "_2"; - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); conn.createStatement().execute( "CREATE TABLE " + dataTableFullName @@ -200,8 +200,10 @@ public class DropMetadataIT extends ParallelStatsDisabledIT { } public void helpTestDroppingIndexedColDropsViewIndex(boolean isMultiTenant) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : conn ) { + Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + props.setProperty(TENANT_ID_ATTRIB, TENANT_ID); + try (Connection conn = getConnection(); + Connection viewConn = isMultiTenant ? getConnection(props) : conn ) { String tableWithView = generateUniqueName(); String viewOfTable = generateUniqueName(); String viewIndex1 = generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java index d3c3085..51e9de9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java @@ -25,30 +25,16 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.Map; import java.util.regex.Pattern; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.util.*; -import org.junit.BeforeClass; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.QueryUtil; +import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; -import com.google.common.collect.Maps; - public class GlobalIndexOptimizationIT extends ParallelStatsDisabledIT { - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(3); - // Drop the HBase table metadata for this test - props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - private void createBaseTable(String tableName, Integer saltBuckets, String splits, boolean multiTenant) throws SQLException { Connection conn = DriverManager.getConnection(getUrl()); String ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT NULL,\n" + http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexIT.java index e2bc873..9a2eec1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexIT.java @@ -38,7 +38,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.hadoop.hbase.Cell; @@ -55,7 +54,6 @@ import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory; import org.apache.phoenix.compile.ColumnResolver; import org.apache.phoenix.compile.FromCompiler; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixStatement; @@ -63,24 +61,19 @@ import org.apache.phoenix.parse.NamedTableNode; import org.apache.phoenix.parse.TableName; 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.util.DateUtil; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.apache.phoenix.util.TransactionUtil; -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 IndexIT extends ParallelStatsDisabledIT { @@ -105,14 +98,6 @@ public class IndexIT extends ParallelStatsDisabledIT { this.tableDDLOptions = optionBuilder.toString(); } - @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())); - } - @Parameters(name="IndexIT_localIndex={0},mutable={1},transactional={2}") // name is used by failsafe as file name in reports public static Collection<Boolean[]> data() { return Arrays.asList(new Boolean[][] { http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java index 214b7ba..9d3da8e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java @@ -194,7 +194,7 @@ public class LocalIndexIT extends ParallelStatsDisabledIT { private Connection getConnection() throws SQLException{ Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); - props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); + props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); return DriverManager.getConnection(getUrl(),props); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java index ff4e7e8..d770b22 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java @@ -96,7 +96,7 @@ public class MutableIndexFailureIT extends BaseOwnClusterIT { this.tableName = (localIndex ? "L_" : "") + TestUtil.DEFAULT_DATA_TABLE_NAME + (transactional ? "_TXN" : "") + (isNamespaceMapped ? "_NM" : ""); this.indexName = INDEX_NAME; - this.fullTableName = SchemaUtil.getTableName(schema, tableName); + fullTableName = SchemaUtil.getTableName(schema, tableName); this.fullIndexName = SchemaUtil.getTableName(schema, indexName); this.isNamespaceMapped = isNamespaceMapped; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java index 87b660a..0765843 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java @@ -33,7 +33,6 @@ import java.sql.Statement; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Properties; import jline.internal.Log; @@ -46,7 +45,6 @@ import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Threads; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTableKey; @@ -54,16 +52,13 @@ import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; -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; import com.google.common.primitives.Doubles; @RunWith(Parameterized.class) @@ -81,16 +76,17 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { this.tableDDLOptions = optionBuilder.toString(); } - @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)); - // Forces server cache to be used - props.put(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(1)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection(Properties props) throws SQLException { + props.setProperty(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(1)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } - + + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + return getConnection(props); + } + @Parameters(name="MutableIndexIT_localIndex={0},transactional={1}") // name is used by failsafe as file name in reports public static Collection<Boolean[]> data() { return Arrays.asList(new Boolean[][] { @@ -100,8 +96,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { @Test public void testCoveredColumnUpdates() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); @@ -200,12 +195,11 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { @Test public void testCoveredColumns() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); String query; @@ -310,12 +304,11 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { @Test public void testCompoundIndexKey() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); String query; ResultSet rs; @@ -429,12 +422,11 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { */ @Test public void testMultipleUpdatesToSingleRow() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); String query; ResultSet rs; @@ -513,12 +505,11 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { @Test public void testUpsertingNullForIndexedColumns() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); String testTableName = tableName + "_" + System.currentTimeMillis(); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); ResultSet rs; Statement stmt = conn.createStatement(); @@ -603,9 +594,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { String tableName = "TBL_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); - - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); conn.createStatement().execute( "CREATE TABLE " + fullTableName +" (k VARCHAR NOT NULL PRIMARY KEY, v VARCHAR) " + tableDDLOptions); @@ -635,10 +624,10 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { } private void testSplitDuringIndexScan(boolean isReverse) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.SCAN_CACHE_SIZE_ATTRIB, Integer.toString(2)); - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); - Connection conn1 = DriverManager.getConnection(getUrl()); + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); + Connection conn1 = getConnection(props); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); @@ -688,7 +677,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { @Test public void testIndexHalfStoreFileReader() throws Exception { - Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn1 = getConnection(); HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); @@ -859,7 +848,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); // create data table conn.createStatement().execute( @@ -876,7 +865,7 @@ public class MutableIndexIT extends ParallelStatsDisabledIT { String dml = "UPSERT INTO " + fullTableName + " (ENTITY_ID, TYPE) VALUES ( ?, ?)"; props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); // connection is tenant-specific - try (Connection tenantConn = DriverManager.getConnection(getUrl(), props)) { + try (Connection tenantConn = getConnection(props)) { // upsert one row upsertRow(dml, tenantConn, 0); tenantConn.commit(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java index 5bf0c58..06e7ede 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SaltedIndexIT.java @@ -26,39 +26,33 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.Map; +import java.sql.SQLException; import java.util.Properties; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTableKey; -import org.apache.phoenix.util.*; -import org.junit.BeforeClass; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.QueryUtil; +import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.TestUtil; import org.junit.Test; -import com.google.common.collect.Maps; - public class SaltedIndexIT extends ParallelStatsDisabledIT { private static final int TABLE_SPLITS = 3; private static final int INDEX_SPLITS = 4; - @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)); - // Drop the HBase table metadata for this test - props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); - // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.INDEX_MUTATE_BATCH_SIZE_THRESHOLD_ATTRIB, Integer.toString(1)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } private static void makeImmutableAndDeleteData(String tableName, String fullTableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn = getConnection(); try { conn.setAutoCommit(true); conn.createStatement().execute("DELETE FROM " + fullTableName); @@ -108,8 +102,7 @@ public class SaltedIndexIT extends ParallelStatsDisabledIT { String query; ResultSet rs; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); conn.createStatement().execute("CREATE TABLE IF NOT EXISTS " + dataTableFullName + " (k VARCHAR NOT NULL PRIMARY KEY, v VARCHAR) " + (tableSaltBuckets == null ? "" : " SALT_BUCKETS=" + tableSaltBuckets)); query = "SELECT * FROM " + dataTableFullName; http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java index 99a8b4d..1abbc87 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java @@ -82,7 +82,7 @@ public class ViewIndexIT extends ParallelStatsDisabledIT { private Connection getConnection() throws SQLException{ Properties props = new Properties(); - props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); + props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); return DriverManager.getConnection(getUrl(),props); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java index 3ffade0..cbfe9a5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java @@ -30,27 +30,21 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; -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 MutableRollbackIT extends ParallelStatsDisabledIT { @@ -60,23 +54,20 @@ public class MutableRollbackIT extends ParallelStatsDisabledIT { this.localIndex = localIndex; } - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(2); - props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } - @Parameters(name="MutableRollbackIT_localIndex={0}") // name is used by failsafe as file name in reports public static Collection<Boolean> data() { return Arrays.asList(new Boolean[] { false, true}); } - public void testRollbackOfUncommittedExistingKeyValueIndexUpdate() throws Exception { + private static Connection getConnection() throws SQLException { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; + } + + public void testRollbackOfUncommittedExistingKeyValueIndexUpdate() throws Exception { + Connection conn = getConnection(); String tableName1 = "TBL1_" + generateUniqueName(); String indexName1 = "IDX1_" + generateUniqueName(); String fullTableName1 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName1); @@ -215,8 +206,7 @@ public class MutableRollbackIT extends ParallelStatsDisabledIT { String tableName2 = "TBL2_" + generateUniqueName(); String indexName2 = "IDX2_" + generateUniqueName(); String fullTableName2 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName2); - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); @@ -350,12 +340,10 @@ public class MutableRollbackIT extends ParallelStatsDisabledIT { @Test public void testMultiRollbackOfUncommittedExistingRowKeyIndexUpdate() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); String tableName1 = "TBL1_" + generateUniqueName(); String indexName1 = "IDX1_" + generateUniqueName(); String fullTableName1 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName1); - String tableName2 = "TBL2_" + generateUniqueName(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); @@ -456,12 +444,10 @@ public class MutableRollbackIT extends ParallelStatsDisabledIT { @Test public void testCheckpointAndRollback() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); String tableName1 = "TBL1_" + generateUniqueName(); String indexName1 = "IDX1_" + generateUniqueName(); String fullTableName1 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName1); - String tableName2 = "TBL2_" + generateUniqueName(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java index 5153a68..8cafcfc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java @@ -25,27 +25,22 @@ import static org.junit.Assert.assertTrue; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; -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 RollbackIT extends ParallelStatsDisabledIT { @@ -57,15 +52,13 @@ public class RollbackIT extends ParallelStatsDisabledIT { this.mutable = mutable; } - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(2); + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } - + @Parameters(name="RollbackIT_localIndex={0},mutable={1}") // name is used by failsafe as file name in reports public static Collection<Boolean[]> data() { return Arrays.asList(new Boolean[][] { @@ -79,8 +72,7 @@ public class RollbackIT extends ParallelStatsDisabledIT { String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); @@ -121,8 +113,7 @@ public class RollbackIT extends ParallelStatsDisabledIT { @Test public void testRollbackOfUncommittedRowKeyIndexInsert() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/iterate/PhoenixQueryTimeoutIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/iterate/PhoenixQueryTimeoutIT.java b/phoenix-core/src/it/java/org/apache/phoenix/iterate/PhoenixQueryTimeoutIT.java index 8fcdebb..956deba 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/iterate/PhoenixQueryTimeoutIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/iterate/PhoenixQueryTimeoutIT.java @@ -17,7 +17,8 @@ */ package org.apache.phoenix.iterate; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import java.sql.Connection; import java.sql.DriverManager; @@ -28,7 +29,8 @@ import java.util.Properties; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; import org.apache.phoenix.jdbc.PhoenixStatement; -import org.junit.BeforeClass; +import org.apache.phoenix.query.QueryServices; +import org.junit.Before; import org.junit.Test; /** @@ -37,13 +39,33 @@ import org.junit.Test; */ public class PhoenixQueryTimeoutIT extends ParallelStatsDisabledIT { - private static final String QUERY_TIMEOUT_TEST = generateUniqueName(); + private String tableName; + + @Before + public void createTableAndInsertRows() throws Exception { + tableName = generateUniqueName(); + int numRows = 1000; + String ddl = + "CREATE TABLE " + tableName + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; + try (Connection conn = DriverManager.getConnection(getUrl())) { + conn.createStatement().execute(ddl); + String dml = "UPSERT INTO " + tableName + " VALUES (?, ?)"; + PreparedStatement stmt = conn.prepareStatement(dml); + for (int i = 1; i <= numRows; i++) { + String key = "key" + i; + stmt.setString(1, key); + stmt.setString(2, "value" + i); + stmt.executeUpdate(); + } + conn.commit(); + } + } - @Test /** * This test validates that we timeout as expected. It does do by * setting the timeout value to 1 ms. */ + @Test public void testCustomQueryTimeoutWithVeryLowTimeout() throws Exception { // Arrange PreparedStatement ps = loadDataAndPrepareQuery(1, 1); @@ -85,30 +107,12 @@ public class PhoenixQueryTimeoutIT extends ParallelStatsDisabledIT { private PreparedStatement loadDataAndPrepareQuery(int timeoutMs, int timeoutSecs) throws Exception, SQLException { Properties props = new Properties(); - props.setProperty("phoenix.query.timeoutMs", String.valueOf(timeoutMs)); + props.setProperty(QueryServices.THREAD_TIMEOUT_MS_ATTRIB, String.valueOf(timeoutMs)); Connection conn = DriverManager.getConnection(getUrl(), props); - PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + QUERY_TIMEOUT_TEST); + PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + tableName); PhoenixStatement phoenixStmt = ps.unwrap(PhoenixStatement.class); assertEquals(timeoutMs, phoenixStmt.getQueryTimeoutInMillis()); assertEquals(timeoutSecs, phoenixStmt.getQueryTimeout()); return ps; } - - @BeforeClass - public static void createTableAndInsertRows() throws Exception { - int numRows = 1000; - String ddl = - "CREATE TABLE " + QUERY_TIMEOUT_TEST + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; - Connection conn = DriverManager.getConnection(getUrl()); - conn.createStatement().execute(ddl); - String dml = "UPSERT INTO " + QUERY_TIMEOUT_TEST + " VALUES (?, ?)"; - PreparedStatement stmt = conn.prepareStatement(dml); - for (int i = 1; i <= numRows; i++) { - String key = "key" + i; - stmt.setString(1, key); - stmt.setString(2, "value" + i); - stmt.executeUpdate(); - } - conn.commit(); - } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java index 47261ac..c1f7c88 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -43,7 +42,6 @@ import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.compile.StatementContext; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.jdbc.PhoenixStatement; @@ -51,37 +49,31 @@ import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTable; 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; import com.google.common.collect.Sets; public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { private static final int NUM_SALT_BUCKETS = 4; - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(1); - props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, Integer.toString(32)); + private static Connection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); /* * Don't force row key order. This causes RoundRobinResultIterator to be used if there was no order by specified * on the query. */ - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); - props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1000)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } - + @Test public void testRoundRobinAfterTableSplit() throws Exception { String tableName = generateUniqueName(); byte[] tableNameBytes = Bytes.toBytes(tableName); int numRows = setupTableForSplit(tableName); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); int nRegions = services.getAllTableRegions(tableNameBytes).size(); int nRegionsBeforeSplit = nRegions; @@ -131,7 +123,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); int numRows = 9; Set<String> expectedKeys = Collections.unmodifiableSet(createTableAndInsertRows(tableName, numRows, salted, false)); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT K, V FROM " + tableName); tryWithFetchSize(new HashSet<>(expectedKeys), 1, stmt, 0); tryWithFetchSize(new HashSet<>(expectedKeys), 2, stmt, salted ? 2 : 5); @@ -155,7 +147,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { String tableName = generateUniqueName(); int numRows = 6; Set<String> insertedKeys = createTableAndInsertRows(tableName, numRows, salted, false); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT K, V FROM " + tableName + " WHERE K = ?"); stmt.setString(1, "key1"); // will return only 1 row int numRowsFiltered = 1; @@ -187,7 +179,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { private Set<String> createTableAndInsertRows(String tableName, int numRows, boolean salted, boolean addTableNameToKey) throws Exception { String ddl = "CREATE TABLE " + tableName + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)" + (salted ? "SALT_BUCKETS=" + NUM_SALT_BUCKETS : ""); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + tableName + " VALUES (?, ?)"; PreparedStatement stmt = conn.prepareStatement(dml); @@ -207,7 +199,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { public void testFetchSizesAndRVCExpression() throws Exception { String tableName = generateUniqueName(); Set<String> insertedKeys = Collections.unmodifiableSet(createTableAndInsertRows(tableName, 4, false, false)); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement("SELECT K FROM " + tableName + " WHERE (K, V) > (?, ?)"); stmt.setString(1, "key0"); stmt.setString(2, "value0"); @@ -244,7 +236,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { int MIN_CHAR = 'a'; int MAX_CHAR = 'z'; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + "a VARCHAR PRIMARY KEY, b VARCHAR) " + HTableDescriptor.MAX_FILESIZE + "=" + maxFileSize + "," @@ -288,7 +280,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { Set<String> keySetB = createTableAndInsertRows(tableB, insertedRowsB, true, true); Set<String> keySetC = createTableAndInsertRows(tableC, insertedRowsC, false, true); String query = "SELECT K FROM " + tableA + " UNION ALL SELECT K FROM " + tableB + " UNION ALL SELECT K FROM " + tableC; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement(query); stmt.setFetchSize(2); // force parallel fetch of scanner cache ResultSet rs = stmt.executeQuery(); @@ -317,7 +309,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { @Test public void testBug2074() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); try { conn.createStatement().execute("CREATE TABLE EVENTS" + " (id VARCHAR(10) PRIMARY KEY, " @@ -407,7 +399,7 @@ public class RoundRobinResultIteratorIT extends ParallelStatsDisabledIT { @Test public void testIteratorsPickedInRoundRobinFashionForSaltedTable() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = getConnection()) { String testTable = "testIteratorsPickedInRoundRobinFashionForSaltedTable".toUpperCase(); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + testTable + "(K VARCHAR PRIMARY KEY) SALT_BUCKETS = 8"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java index 29dcd17..ac935e7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java @@ -36,29 +36,22 @@ 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.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; -import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.MetaDataClient; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; -import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; -import com.google.common.collect.Maps; - /** * Verifies the number of rpcs calls from {@link MetaDataClient} updateCache() * for transactional and non-transactional tables. @@ -67,14 +60,6 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { public static final int NUM_MILLIS_IN_DAY = 86400000; - @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 static void setupSystemTable(String fullTableName) throws SQLException { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/tx/NotThreadSafeTransactionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/NotThreadSafeTransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/NotThreadSafeTransactionIT.java index 6fea975..b50f424 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/tx/NotThreadSafeTransactionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/NotThreadSafeTransactionIT.java @@ -27,32 +27,62 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.Map; import javax.annotation.concurrent.NotThreadSafe; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.query.QueryConstants; -import org.apache.phoenix.query.QueryServices; -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; - -@NotThreadSafe +/** + * + * Transaction related tests that flap when run in parallel. + * TODO: review with Tephra community + * + */ +@NotThreadSafe // Prevents test methods from running in parallel public class NotThreadSafeTransactionIT extends ParallelStatsDisabledIT { - - @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())); + @Test + public void testDelete() throws Exception { + String transTableName = generateUniqueName(); + String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName; + String selectSQL = "SELECT * FROM " + fullTableName; + try (Connection conn = DriverManager.getConnection(getUrl()); + Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn2 = DriverManager.getConnection(getUrl())) { + TestUtil.createTransactionalTable(conn, fullTableName); + conn1.setAutoCommit(false); + ResultSet rs = conn1.createStatement().executeQuery(selectSQL); + assertFalse(rs.next()); + + String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)"; + PreparedStatement stmt = conn1.prepareStatement(upsert); + // upsert two rows + TestUtil.setRowKeyColumns(stmt, 1); + stmt.execute(); + conn1.commit(); + + TestUtil.setRowKeyColumns(stmt, 2); + stmt.execute(); + + // verify rows can be read even though commit has not been called + int rowsDeleted = conn1.createStatement().executeUpdate("DELETE FROM " + fullTableName); + assertEquals(2, rowsDeleted); + + // Delete and second upsert not committed yet, so there should be one row. + rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName); + assertTrue(rs.next()); + assertEquals(1, rs.getInt(1)); + + conn1.commit(); + + // verify rows are deleted after commit + rs = conn1.createStatement().executeQuery(selectSQL); + assertFalse(rs.next()); + } } - + @Test public void testInflightUpdateNotSeen() throws Exception { String transTableName = generateUniqueName(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java index f825564..8c3ad7f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java @@ -33,7 +33,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.List; -import java.util.Map; import java.util.Properties; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -47,7 +46,6 @@ import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.coprocessor.PhoenixTransactionalProcessor; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; @@ -59,31 +57,19 @@ import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.types.PInteger; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.StringUtil; import org.apache.phoenix.util.TestUtil; import org.apache.tephra.TransactionContext; import org.apache.tephra.TransactionSystemClient; import org.apache.tephra.TxConstants; import org.apache.tephra.hbase.TransactionAwareHTable; -import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; public class TransactionIT extends ParallelStatsDisabledIT { - - @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())); - } - @Test public void testReadOwnWrites() throws Exception { String transTableName = generateUniqueName(); @@ -154,46 +140,6 @@ public class TransactionIT extends ParallelStatsDisabledIT { } @Test - public void testDelete() throws Exception { - String transTableName = generateUniqueName(); - String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName; - String selectSQL = "SELECT * FROM " + fullTableName; - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection conn1 = DriverManager.getConnection(getUrl()); - Connection conn2 = DriverManager.getConnection(getUrl())) { - TestUtil.createTransactionalTable(conn, fullTableName); - conn1.setAutoCommit(false); - ResultSet rs = conn1.createStatement().executeQuery(selectSQL); - assertFalse(rs.next()); - - String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)"; - PreparedStatement stmt = conn1.prepareStatement(upsert); - // upsert two rows - TestUtil.setRowKeyColumns(stmt, 1); - stmt.execute(); - conn1.commit(); - - TestUtil.setRowKeyColumns(stmt, 2); - stmt.execute(); - - // verify rows can be read even though commit has not been called - int rowsDeleted = conn1.createStatement().executeUpdate("DELETE FROM " + fullTableName); - assertEquals(2, rowsDeleted); - - // Delete and second upsert not committed yet, so there should be one row. - rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName); - assertTrue(rs.next()); - assertEquals(1, rs.getInt(1)); - - conn1.commit(); - - // verify rows are deleted after commit - rs = conn1.createStatement().executeQuery(selectSQL); - assertFalse(rs.next()); - } - } - - @Test public void testAutoCommitQuerySingleTable() throws Exception { String transTableName = generateUniqueName(); String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName; http://git-wip-us.apache.org/repos/asf/phoenix/blob/ba132fe4/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java index 21ea072..14bcd70 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TxCheckpointIT.java @@ -30,26 +30,20 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.Collection; -import java.util.Map; import java.util.Properties; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; -import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.execute.MutationState; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.tephra.Transaction.VisibilityLevel; -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 TxCheckpointIT extends ParallelStatsDisabledIT { @@ -62,13 +56,14 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { } - @BeforeClass - @Shadower(classBeingShadowed = ParallelStatsDisabledIT.class) - public static void doSetup() throws Exception { - Map<String,String> props = Maps.newHashMapWithExpectedSize(2); - props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); - props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + private static Connection getConnection() throws SQLException { + return getConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES)); + } + + private static Connection getConnection(Properties props) throws SQLException { + props.setProperty(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true)); + Connection conn = DriverManager.getConnection(getUrl(), props); + return conn; } @Parameters(name="TxCheckpointIT_localIndex={0},mutable={1}") // name is used by failsafe as file name in reports @@ -88,7 +83,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { props.setProperty(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3)); props.setProperty(QueryServices.SCAN_CACHE_SIZE_ATTRIB, Integer.toString(3)); props.setProperty(QueryServices.SCAN_RESULT_CHUNK_SIZE, Integer.toString(3)); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(props); conn.setAutoCommit(true); conn.createStatement().execute("CREATE SEQUENCE "+seqName); conn.createStatement().execute("CREATE TABLE " + fullTableName + "(pk INTEGER PRIMARY KEY, val INTEGER)"+(!mutable? " IMMUTABLE_ROWS=true" : "")); @@ -123,7 +118,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { private void testRollbackOfUncommittedDelete(String indexDDL, String fullTableName) throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = getConnection(); conn.setAutoCommit(false); try { Statement stmt = conn.createStatement(); @@ -212,7 +207,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { String indexName = "IDX_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(tableName, tableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); Statement stmt = conn.createStatement(); @@ -303,7 +298,7 @@ public class TxCheckpointIT extends ParallelStatsDisabledIT { String fullTableName = SchemaUtil.getTableName(tableName, tableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); ResultSet rs; - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + try (Connection conn = getConnection()) { conn.setAutoCommit(false); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName + "1(ID1 BIGINT NOT NULL PRIMARY KEY, FK1A INTEGER, FK1B INTEGER)"