[2/3] phoenix git commit: PHOENIX-3327 Use same driver for all tests within a group
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 { -Mapprops = 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
[2/3] phoenix git commit: PHOENIX-3327 Use same driver for all tests within a group
http://git-wip-us.apache.org/repos/asf/phoenix/blob/fedbca8b/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 { -Mapprops = 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