phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-3278 Remove usage of BaseTest.ensureTableCreated()
Date Wed, 14 Sep 2016 16:43:26 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master e4fd03952 -> 7af708873


PHOENIX-3278 Remove usage of BaseTest.ensureTableCreated()


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7af70887
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7af70887
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7af70887

Branch: refs/heads/master
Commit: 7af708873c0b4457eb6598fb41fd279672fe0029
Parents: e4fd039
Author: James Taylor <jamestaylor@apache.org>
Authored: Wed Sep 14 09:31:00 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Wed Sep 14 09:45:30 2016 -0700

----------------------------------------------------------------------
 .../BaseHBaseManagedTimeTableReuseIT.java       |  3 --
 .../ConnectionQueryServicesTestImpl.java        | 30 +++--------
 .../apache/phoenix/end2end/DynamicUpsertIT.java | 31 ++++++------
 .../apache/phoenix/end2end/GroupByCaseIT.java   | 27 +++++-----
 .../apache/phoenix/end2end/HashJoinMoreIT.java  | 14 ------
 .../apache/phoenix/end2end/PercentileIT.java    | 29 +++++------
 .../end2end/QueryDatabaseMetaDataIT.java        |  9 ++--
 .../org/apache/phoenix/end2end/QueryMoreIT.java |  6 +--
 .../end2end/RegexpReplaceFunctionIT.java        |  4 +-
 .../phoenix/end2end/RegexpSubstrFunctionIT.java |  4 +-
 .../apache/phoenix/end2end/SkipScanQueryIT.java |  2 +-
 .../org/apache/phoenix/end2end/SortOrderIT.java |  9 +++-
 .../phoenix/end2end/SpillableGroupByIT.java     | 21 +++++---
 .../end2end/index/IndexExpressionIT.java        | 47 ++++++++++-------
 .../apache/phoenix/end2end/index/IndexIT.java   |  4 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  | 26 ++++++----
 .../phoenix/end2end/index/MutableIndexIT.java   |  2 +-
 .../org/apache/phoenix/rpc/UpdateCacheIT.java   |  9 ++--
 .../phoenix/rpc/UpdateCacheWithScnIT.java       | 12 ++++-
 .../org/apache/phoenix/tx/TransactionIT.java    | 53 +++++++++++---------
 .../apache/phoenix/jdbc/PhoenixTestDriver.java  |  2 +-
 .../java/org/apache/phoenix/query/BaseTest.java | 52 +++----------------
 .../java/org/apache/phoenix/util/TestUtil.java  | 29 +++++++++++
 23 files changed, 208 insertions(+), 217 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTableReuseIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTableReuseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTableReuseIT.java
index c40ec59..b09984b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTableReuseIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseHBaseManagedTimeTableReuseIT.java
@@ -18,8 +18,6 @@
 
 package org.apache.phoenix.end2end;
 
-import javax.annotation.concurrent.NotThreadSafe;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.phoenix.query.BaseTest;
 import org.apache.phoenix.util.ReadOnlyProps;
@@ -45,7 +43,6 @@ import org.junit.experimental.categories.Category;
  *
  * @since 0.1
  */
-@NotThreadSafe
 @Category(HBaseManagedTimeTableReuseTest.class)
 public class BaseHBaseManagedTimeTableReuseIT extends BaseTest {
     protected static Configuration getTestClusterConfig() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
index 2d0ed60..48f392b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
@@ -49,39 +49,23 @@ public class ConnectionQueryServicesTestImpl extends ConnectionQueryServicesImpl
     }
     
     @Override
-    public void addConnection(PhoenixConnection connection) throws SQLException {
+    public synchronized void addConnection(PhoenixConnection connection) throws SQLException {
         connections.add(connection);
     }
     
     @Override
-    public void removeConnection(PhoenixConnection connection) throws SQLException {
+    public synchronized void removeConnection(PhoenixConnection connection) throws SQLException {
         connections.remove(connection);
     }
 
     @Override
-    public void init(String url, Properties props) throws SQLException {
-        try {
-            super.init(url, props);
-            /**
-             * Clear the server-side meta data cache on initialization. Otherwise, if we
-             * query for meta data tables, we'll get nothing (since the server just came
-             * up). However, our server-side cache (which is a singleton) will claim
-             * that we do have tables and our create table calls will return the cached
-             * meta data instead of creating new metadata.
-             */
-            clearCache();
-        } catch (SQLException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new SQLException(e);
-        }
-    }
-
-    @Override
     public void close() throws SQLException {
         try {
-            Set<PhoenixConnection> connections = this.connections;
-            this.connections = Sets.newHashSet();
+            Set<PhoenixConnection> connections;
+            synchronized(this) {
+                connections = this.connections;
+                this.connections = Sets.newHashSet();
+            }
             SQLCloseables.closeAll(connections);
             long unfreedBytes = clearCache();
             assertEquals("Found unfreed bytes in server-side cache", 0, unfreedBytes);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java
index 0852859..c0fd38a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java
@@ -36,7 +36,6 @@ import org.apache.phoenix.schema.ColumnAlreadyExistsException;
 import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
@@ -48,14 +47,14 @@ import org.junit.Test;
 
 
 public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
-    private static String TABLE;
+    private String tableName;
 
-    @BeforeClass
-    public static void doBeforeTestSetup() throws Exception {
-    	TABLE = BaseTest.generateRandomString();
+    @Before
+    public void doBeforeTestSetup() throws Exception {
+    	tableName = BaseTest.generateRandomString();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
-        String ddl = "create table if not exists  " + TABLE + "   (entry varchar not null primary key,"
+        String ddl = "create table " + tableName + "   (entry varchar not null primary key,"
                 + "    a.dummy varchar," + "    b.dummy varchar)";
         conn.createStatement().execute(ddl);
         conn.close();
@@ -66,9 +65,9 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test
     public void testUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE
+        String upsertquery = "UPSERT INTO " + tableName
                 + " (entry, a.DynCol VARCHAR,a.dummy) VALUES ('dynEntry','DynValue','DynColValue')";
-        String selectquery = "SELECT DynCol FROM " + TABLE + " (a.DynCol VARCHAR) where entry='dynEntry'";
+        String selectquery = "SELECT DynCol FROM " + tableName + " (a.DynCol VARCHAR) where entry='dynEntry'";
         // String selectquery = "SELECT * FROM "+TABLE;
 
         String url = getUrl() + ";";
@@ -96,9 +95,9 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test
     public void testMultiUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE
+        String upsertquery = "UPSERT INTO " + tableName
                 + " (entry, a.DynColA VARCHAR,b.DynColB varchar) VALUES('dynEntry','DynColValuea','DynColValueb')";
-        String selectquery = "SELECT DynColA,entry,DynColB FROM " + TABLE
+        String selectquery = "SELECT DynColA,entry,DynColB FROM " + tableName
                 + " (a.DynColA VARCHAR,b.DynColB VARCHAR) where entry='dynEntry'";
 
         String url = getUrl() + ";";
@@ -129,9 +128,9 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
     @Test
     public void testFullUpsert() throws Exception {
         String upsertquery = "UPSERT INTO "
-                + TABLE
+                + tableName
                 + " (a.DynColA VARCHAR,b.DynColB varchar) VALUES('dynEntry','aValue','bValue','DynColValuea','DynColValueb')";
-        String selectquery = "SELECT entry,DynColA,a.dummy,DynColB,b.dummy FROM " + TABLE
+        String selectquery = "SELECT entry,DynColA,a.dummy,DynColB,b.dummy FROM " + tableName
                 + " (a.DynColA VARCHAR,b.DynColB VARCHAR) where entry='dynEntry'";
 
         String url = getUrl() + ";";
@@ -163,7 +162,7 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test
     public void testFullUnbalancedUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE
+        String upsertquery = "UPSERT INTO " + tableName
                 + " (a.DynCol VARCHAR,b.DynCol varchar) VALUES('dynEntry','aValue','bValue','dyncola')";
 
         String url = getUrl() + ";";
@@ -185,7 +184,7 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test(expected = ColumnAlreadyExistsException.class)
     public void testAmbiguousStaticUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE + " (a.dummy INTEGER,b.dummy INTEGER) VALUES(1,2)";
+        String upsertquery = "UPSERT INTO " + tableName + " (a.dummy INTEGER,b.dummy INTEGER) VALUES(1,2)";
         String url = getUrl() + ";";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(url, props);
@@ -202,7 +201,7 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test(expected = ColumnAlreadyExistsException.class)
     public void testAmbiguousDynamicUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE + " (a.DynCol VARCHAR,a.DynCol INTEGER) VALUES('dynCol',1)";
+        String upsertquery = "UPSERT INTO " + tableName + " (a.DynCol VARCHAR,a.DynCol INTEGER) VALUES('dynCol',1)";
         String url = getUrl() + ";";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(url, props);
@@ -219,7 +218,7 @@ public class DynamicUpsertIT extends BaseHBaseManagedTimeTableReuseIT {
      */
     @Test(expected = ColumnFamilyNotFoundException.class)
     public void testFakeCFDynamicUpsert() throws Exception {
-        String upsertquery = "UPSERT INTO " + TABLE + " (fakecf.DynCol VARCHAR) VALUES('dynCol')";
+        String upsertquery = "UPSERT INTO " + tableName + " (fakecf.DynCol VARCHAR) VALUES('dynCol')";
         String url = getUrl() + ";";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(url, props);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java
index 86a1f64..7cbbcbe 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByCaseIT.java
@@ -17,9 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.TestUtil.GROUPBYTEST_NAME;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.apache.phoenix.util.TestUtil.getTableName;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -42,29 +40,28 @@ import org.junit.Test;
 
 
 public class GroupByCaseIT extends BaseHBaseManagedTimeTableReuseIT {
-    private static int id;
-
     private static void initData(Connection conn, String tableName) throws SQLException {
-        ensureTableCreated(getUrl(), tableName, GROUPBYTEST_NAME);
-        insertRow(conn, tableName, "Report1", 10);
-        insertRow(conn, tableName, "Report2", 10);
-        insertRow(conn, tableName, "Report3", 30);
-        insertRow(conn, tableName, "Report4", 30);
-        insertRow(conn, tableName, "SOQL1", 10);
-        insertRow(conn, tableName, "SOQL2", 10);
-        insertRow(conn, tableName, "SOQL3", 30);
-        insertRow(conn, tableName, "SOQL4", 30);
+        conn.createStatement().execute("create table " + tableName +
+                "   (id varchar not null primary key,\n" +
+                "    uri varchar, appcpu integer)");
+        insertRow(conn, tableName, "Report1", 10, 1);
+        insertRow(conn, tableName, "Report2", 10, 2);
+        insertRow(conn, tableName, "Report3", 30, 3);
+        insertRow(conn, tableName, "Report4", 30, 4);
+        insertRow(conn, tableName, "SOQL1", 10, 5);
+        insertRow(conn, tableName, "SOQL2", 10, 6);
+        insertRow(conn, tableName, "SOQL3", 30, 7);
+        insertRow(conn, tableName, "SOQL4", 30, 8);
         conn.commit();
         conn.close();
     }
 
-    private static void insertRow(Connection conn, String tableName, String uri, int appcpu) throws SQLException {
+    private static void insertRow(Connection conn, String tableName, String uri, int appcpu, int id) throws SQLException {
         PreparedStatement statement = conn.prepareStatement("UPSERT INTO " + tableName + "(id, uri, appcpu) values (?,?,?)");
         statement.setString(1, "id" + id);
         statement.setString(2, uri);
         statement.setInt(3, appcpu);
         statement.executeUpdate();
-        id++;
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/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 943a376..715132f 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
@@ -27,17 +27,14 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.phoenix.jdbc.PhoenixConnection;
 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.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -104,17 +101,6 @@ public class HashJoinMoreIT extends BaseHBaseManagedTimeTableReuseIT {
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
     
-    @After
-    public void assertNoUnfreedMemory() throws SQLException {
-        Connection conn = DriverManager.getConnection(getUrl());
-        try {
-            long unfreedBytes = conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache();
-            assertEquals(0,unfreedBytes);
-        } finally {
-            conn.close();
-        }
-    }
-    
     @Test
     public void testJoinOverSaltedTables() throws Exception {
         String tempTableNoSalting = generateRandomString();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
index f0b4b24..598785c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java
@@ -23,7 +23,6 @@ import static org.apache.phoenix.util.TestUtil.A_VALUE;
 import static org.apache.phoenix.util.TestUtil.B_VALUE;
 import static org.apache.phoenix.util.TestUtil.C_VALUE;
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
-import static org.apache.phoenix.util.TestUtil.INDEX_DATA_TABLE;
 import static org.apache.phoenix.util.TestUtil.ROW1;
 import static org.apache.phoenix.util.TestUtil.ROW2;
 import static org.apache.phoenix.util.TestUtil.ROW3;
@@ -408,14 +407,13 @@ public class PercentileIT extends BaseHBaseManagedTimeTableReuseIT {
     @Test
     public void testPercentileContOnDescPKColumn() throws Exception {
         String indexDataTableName = generateRandomString();
-        ensureTableCreated(getUrl(), indexDataTableName, INDEX_DATA_TABLE);
-        populateINDEX_DATA_TABLETable(indexDataTableName);
-
-        String query = "SELECT PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + INDEX_DATA_SCHEMA
-                + QueryConstants.NAME_SEPARATOR + indexDataTableName;
+        String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName;
+        String query = "SELECT PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + fullTableName;
 
         Connection conn = DriverManager.getConnection(getUrl());
         try {
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            populateINDEX_DATA_TABLETable(indexDataTableName);
             PreparedStatement statement = conn.prepareStatement(query);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());
@@ -431,14 +429,12 @@ public class PercentileIT extends BaseHBaseManagedTimeTableReuseIT {
     @Test
     public void testPercentRankOnDescPKColumn() throws Exception {
         String indexDataTableName = generateRandomString();
-        ensureTableCreated(getUrl(), indexDataTableName, INDEX_DATA_TABLE);
-        populateINDEX_DATA_TABLETable(indexDataTableName);
-
-        String query = "SELECT PERCENT_RANK(2) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + INDEX_DATA_SCHEMA
-                + QueryConstants.NAME_SEPARATOR + indexDataTableName;
-
         Connection conn = DriverManager.getConnection(getUrl());
         try {
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName;
+            String query = "SELECT PERCENT_RANK(2) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + fullTableName;
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            populateINDEX_DATA_TABLETable(indexDataTableName);
             PreparedStatement statement = conn.prepareStatement(query);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());
@@ -454,14 +450,13 @@ public class PercentileIT extends BaseHBaseManagedTimeTableReuseIT {
     @Test
     public void testPercentileDiscOnDescPKColumn() throws Exception {
         String indexDataTableName = generateRandomString();
-        ensureTableCreated(getUrl(), indexDataTableName, INDEX_DATA_TABLE);
-        populateINDEX_DATA_TABLETable(indexDataTableName);
-
-        String query = "SELECT PERCENTILE_DISC(0.4) WITHIN GROUP (ORDER BY long_pk DESC) FROM " + INDEX_DATA_SCHEMA
-                + QueryConstants.NAME_SEPARATOR + indexDataTableName;
 
         Connection conn = DriverManager.getConnection(getUrl());
         try {
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName;
+            String query = "SELECT PERCENTILE_DISC(0.4) WITHIN GROUP (ORDER BY long_pk DESC) FROM " + fullTableName;
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            populateINDEX_DATA_TABLETable(indexDataTableName);
             PreparedStatement statement = conn.prepareStatement(query);
             ResultSet rs = statement.executeQuery();
             assertTrue(rs.next());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
index fbcc120..805691d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
@@ -34,6 +34,7 @@ import static org.apache.phoenix.util.TestUtil.PTSDB_NAME;
 import static org.apache.phoenix.util.TestUtil.STABLE_NAME;
 import static org.apache.phoenix.util.TestUtil.TABLE_WITH_SALTING;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.apache.phoenix.util.TestUtil.createGroupByTestTable;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
@@ -591,13 +592,15 @@ public class QueryDatabaseMetaDataIT extends BaseClientManagedTimeIT {
     @Test
     public void testMultiTableColumnsMetadataScan() throws SQLException {
         long ts = nextTimestamp();
+        Properties props = new Properties();
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        createGroupByTestTable(conn, GROUPBYTEST_NAME);
         ensureTableCreated(getUrl(), MDTEST_NAME, MDTEST_NAME, ts);
-        ensureTableCreated(getUrl(), GROUPBYTEST_NAME, GROUPBYTEST_NAME, ts);
         ensureTableCreated(getUrl(), PTSDB_NAME, PTSDB_NAME, ts);
         ensureTableCreated(getUrl(), CUSTOM_ENTITY_DATA_FULL_NAME, CUSTOM_ENTITY_DATA_FULL_NAME, ts);
-        Properties props = new Properties();
         props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
-        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn = DriverManager.getConnection(getUrl(), props);
         DatabaseMetaData dbmd = conn.getMetaData();
         ResultSet rs = dbmd.getColumns(null, "", "%TEST%", null);
         assertTrue(rs.next());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index c4e4665..6da9144 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -72,21 +72,21 @@ public class QueryMoreIT extends BaseHBaseManagedTimeTableReuseIT {
     }
     
     private void testQueryMore(boolean queryAgainstTenantSpecificView, boolean dataTableSalted) throws Exception {
-        String[] tenantIds = new String[] {"00Dxxxxxtenant1", "00Dxxxxxtenant2", "00Dxxxxxtenant3"};
+        String[] tenantIds = new String[] {"T1_" + generateRandomString(), "T2_" + generateRandomString(), "T3_" + generateRandomString()};
         int numRowsPerTenant = 10;
         String cursorTableName = generateRandomString();
         String base_history_table = generateRandomString();
         this.dataTableName = base_history_table + (dataTableSalted ? "_SALTED" : "");
         String cursorTableDDL = "CREATE TABLE IF NOT EXISTS " + 
                 cursorTableName +  " (\n" +  
-                "TENANT_ID VARCHAR(15) NOT NULL\n," +  
+                "TENANT_ID VARCHAR NOT NULL\n," +  
                 "QUERY_ID VARCHAR(15) NOT NULL,\n" +
                 "CURSOR_ORDER BIGINT NOT NULL \n" + 
                 "CONSTRAINT CURSOR_TABLE_PK PRIMARY KEY (TENANT_ID, QUERY_ID, CURSOR_ORDER)) "+
                 "SALT_BUCKETS = 4, TTL=86400";
         String baseDataTableDDL = "CREATE TABLE IF NOT EXISTS " +
                 dataTableName + " (\n" + 
-                "TENANT_ID CHAR(15) NOT NULL,\n" +
+                "TENANT_ID VARCHAR NOT NULL,\n" +
                 "PARENT_ID CHAR(15) NOT NULL,\n" + 
                 "CREATED_DATE DATE NOT NULL,\n" + 
                 "ENTITY_HISTORY_ID CHAR(15) NOT NULL,\n" + 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java
index 7670481..5ce04eb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java
@@ -17,7 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.TestUtil.GROUPBYTEST_NAME;
+import static org.apache.phoenix.util.TestUtil.createGroupByTestTable;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -41,8 +41,8 @@ public class RegexpReplaceFunctionIT extends BaseHBaseManagedTimeTableReuseIT {
     @Before
     public void doBeforeTestSetup() throws Exception {
         this.tableName = generateRandomString();
-        ensureTableCreated(getUrl(), this.tableName, GROUPBYTEST_NAME);
         Connection conn = DriverManager.getConnection(getUrl());
+        createGroupByTestTable(conn, tableName);
         insertRow(conn, "Report11", 10);
         insertRow(conn, "Report11", 10);
         insertRow(conn, "Report22", 30);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java
index 6669017..777ccd1 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java
@@ -17,7 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.TestUtil.GROUPBYTEST_NAME;
+import static org.apache.phoenix.util.TestUtil.createGroupByTestTable;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -41,8 +41,8 @@ public class RegexpSubstrFunctionIT extends BaseHBaseManagedTimeTableReuseIT {
     @Before
     public void doBeforeTestSetup() throws Exception {
         tableName = generateRandomString();
-        ensureTableCreated(getUrl(), tableName, GROUPBYTEST_NAME);
         Connection conn = DriverManager.getConnection(getUrl());
+        createGroupByTestTable(conn, tableName);
         insertRow(conn, "Report1?1", 10);
         insertRow(conn, "Report1?2", 10);
         insertRow(conn, "Report2?1", 30);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
index 1021bdd..944acf7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
@@ -353,7 +353,7 @@ public class SkipScanQueryIT extends BaseHBaseManagedTimeTableReuseIT {
         String tableName = generateRandomString();
         String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
         try {
-            createMultiCFTestTable(fullTableName , null);
+            TestUtil.createMultiCFTestTable(conn , fullTableName, null);
             populateMultiCFTestTable(fullTableName);
             String upsert = "UPSERT INTO " + fullTableName
                     + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
index 4357272..87814fc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
@@ -45,6 +45,7 @@ import org.apache.phoenix.schema.types.PDouble;
 import org.apache.phoenix.schema.types.PFloat;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -55,6 +56,12 @@ import com.google.common.collect.Lists;
 
 
 public class SortOrderIT extends BaseHBaseManagedTimeTableReuseIT {
+    private String baseTableName;
+    
+    @Before
+    public void generateTableName() {
+        baseTableName = generateRandomString();
+    }
     
     @Test
     public void noOrder() throws Exception {
@@ -530,7 +537,7 @@ public class SortOrderIT extends BaseHBaseManagedTimeTableReuseIT {
     }
 
     private void testCompareCompositeKey(Integer saltBuckets, PDataType dataType, SortOrder sortOrder, String whereClause, List<Integer> expectedResults, String orderBy) throws SQLException {
-        String tableName = "t_" + saltBuckets + "_" + dataType + "_" + sortOrder;
+        String tableName = "t_" + saltBuckets + "_" + dataType + "_" + sortOrder + "_" + baseTableName;
         String ddl = "create table if not exists " + tableName + " (k1 bigint not null, k2 " + dataType.getSqlTypeName() + (dataType.isFixedWidth() ? " not null" : "") + ", constraint pk primary key (k1,k2 " + sortOrder + "))" + (saltBuckets == null ? "" : (" SALT_BUCKETS= " + saltBuckets));
         Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
         conn.createStatement().execute(ddl);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java
index 51dcd21..22bf8ce 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java
@@ -19,6 +19,7 @@ package org.apache.phoenix.end2end;
 
 import static org.apache.phoenix.util.TestUtil.GROUPBYTEST_NAME;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.apache.phoenix.util.TestUtil.createGroupByTestTable;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -47,7 +48,7 @@ import com.google.common.collect.Maps;
  * cluster.
  */
 
-public class SpillableGroupByIT extends BaseOwnClusterHBaseManagedTimeIT {
+public class SpillableGroupByIT extends BaseOwnClusterClientManagedTimeIT {
 
     private static final int NUM_ROWS_INSERTED = 1000;
     
@@ -72,10 +73,8 @@ public class SpillableGroupByIT extends BaseOwnClusterHBaseManagedTimeIT {
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
 
-    private long createTable() throws Exception {
-        long ts = nextTimestamp();
-        ensureTableCreated(getUrl(), GROUPBYTEST_NAME, GROUPBYTEST_NAME, null, ts - 2);
-        return ts;
+    private void createTable(Connection conn, String tableName) throws Exception {
+        createGroupByTestTable(conn, tableName);
     }
 
     private void loadData(long ts) throws SQLException {
@@ -108,13 +107,19 @@ public class SpillableGroupByIT extends BaseOwnClusterHBaseManagedTimeIT {
     
     @Test
     public void testScanUri() throws Exception {
+        long ts = nextTimestamp();
         SpillableGroupByIT spGpByT = new SpillableGroupByIT();
-        long ts = spGpByT.createTable();
-        spGpByT.loadData(ts);
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
-                Long.toString(ts + 10));
+                Long.toString(ts));
         Connection conn = DriverManager.getConnection(getUrl(), props);
+        createTable(conn, GROUPBYTEST_NAME);
+        ts += 2;
+        spGpByT.loadData(ts);
+        props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
+                Long.toString(ts + 10));
+        conn = DriverManager.getConnection(getUrl(), props);
         try {
             Statement stmt = conn.createStatement();
             ResultSet rs = stmt.executeQuery(GROUPBY1);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
index 65f9bac..0dc2036 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
@@ -11,8 +11,6 @@ package org.apache.phoenix.end2end.index;
 
 import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY;
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
-import static org.apache.phoenix.util.TestUtil.INDEX_DATA_TABLE;
-import static org.apache.phoenix.util.TestUtil.MUTABLE_INDEX_DATA_TABLE;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -111,6 +109,11 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         assertEquals(i, rs.getLong(12));
     }
 
+    private void createDataTable(Connection conn, String dataTableName, String tableProps) throws SQLException {
+        String tableDDL = "create table " + dataTableName + TEST_TABLE_SCHEMA + tableProps;
+        conn.createStatement().execute(tableDDL);
+    }
+    
     protected void helpTestCreateAndUpdate(boolean mutable, boolean localIndex) throws Exception {
         String dataTableName = generateRandomString();
         String fullDataTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + dataTableName;
@@ -119,7 +122,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
 
             // create an expression index
             String ddl = "CREATE "
@@ -207,7 +211,7 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         String dataTableName = generateRandomString();
         String fullDataTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + dataTableName;
         String indexName = generateRandomString();
-    	helpTestUpdate(dataTableName, fullDataTableName, indexName, false);
+    	helpTestUpdate(fullDataTableName, indexName, false);
     }
 
     @Test
@@ -215,15 +219,16 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         String dataTableName = generateRandomString();
         String fullDataTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + dataTableName;
         String indexName = generateRandomString();
-        helpTestUpdate(dataTableName, fullDataTableName, indexName, true);
+        helpTestUpdate(fullDataTableName, indexName, true);
     }
     
-    protected void helpTestUpdate(String dataTableName, String fullDataTableName, String indexName, boolean localIndex) throws Exception {
+    protected void helpTestUpdate(String fullDataTableName, String indexName, boolean localIndex) throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, MUTABLE_INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, "");
+            populateDataTable(conn, fullDataTableName);
 
             // create an expression index
             String ddl = "CREATE "
@@ -280,9 +285,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         }
     }
 
-    private void populateDataTable(Connection conn, String dataTable, String tableType) throws SQLException {
-        ensureTableCreated(getUrl(), dataTable, tableType);
-        String upsert = "UPSERT INTO " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + dataTable
+    private void populateDataTable(Connection conn, String dataTable) throws SQLException {
+        String upsert = "UPSERT INTO " + dataTable
                 + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
         PreparedStatement stmt1 = conn.prepareStatement(upsert);
         // insert two rows
@@ -320,8 +324,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            ensureTableCreated(getUrl(), dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (2*long_col2)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -394,8 +398,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            ensureTableCreated(getUrl(), dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (long_pk, varchar_pk, 1+long_pk, UPPER(varchar_pk) )" + " INCLUDE (long_col1, long_col2)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -475,7 +479,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (int_col1+int_col2)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -530,7 +535,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (int_col1+1)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -584,7 +590,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (int_col1+1)";
 
@@ -634,7 +641,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (int_col1+1)";
 
@@ -798,7 +806,8 @@ public class IndexExpressionIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         try {
             conn.setAutoCommit(false);
-            populateDataTable(conn, dataTableName, mutable ? MUTABLE_INDEX_DATA_TABLE : INDEX_DATA_TABLE);
+            createDataTable(conn, fullDataTableName, mutable ? "" : "IMMUTABLE_ROWS=true");
+            populateDataTable(conn, fullDataTableName);
             String ddl = "CREATE " + (localIndex ? "LOCAL" : "") + " INDEX " + indexName + " ON " + fullDataTableName
                     + " (int_col1+1)";
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/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 8283b28..072e216 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
@@ -517,7 +517,7 @@ public class IndexIT extends BaseOwnClusterIT {
 	        conn.setAutoCommit(false);
             Date date = new Date(System.currentTimeMillis());
             
-            createMultiCFTestTable(fullTableName, tableDDLOptions);
+            TestUtil.createMultiCFTestTable(conn, fullTableName, tableDDLOptions);
             populateMultiCFTestTable(fullTableName, date);
             String ddl = "CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName + " (date_col)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -1011,7 +1011,7 @@ public class IndexIT extends BaseOwnClusterIT {
 	        ResultSet rs;
             Date date = new Date(System.currentTimeMillis());
             
-            createMultiCFTestTable(fullTableName, tableDDLOptions);
+            TestUtil.createMultiCFTestTable(conn, fullTableName, tableDDLOptions);
             populateMultiCFTestTable(fullTableName, date);
             String ddl = null;
             ddl = "CREATE " + (localIndex ? "LOCAL " : "") + "INDEX " + indexName + " ON " + fullTableName + " (decimal_pk) INCLUDE (decimal_col1, decimal_col2)";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 8cce14a..2e1fe1d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -17,7 +17,8 @@
  */
 package org.apache.phoenix.end2end.index;
 
-import static org.apache.phoenix.util.TestUtil.*;
+import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -33,7 +34,6 @@ import java.sql.SQLException;
 import java.sql.Types;
 import java.util.Properties;
 
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.exception.SQLExceptionCode;
@@ -50,7 +50,6 @@ import org.apache.phoenix.schema.types.PDate;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.StringUtil;
-import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 
@@ -121,10 +120,12 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeTableReuseIT {
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         String indexDataTable = generateRandomString();
+        String fullIndexDataTable = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable;
         String indexName = generateRandomString();
         try {
-            ensureTableCreated(getUrl(), indexDataTable, MUTABLE_INDEX_DATA_TABLE);
-            String ddl = "CREATE INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable
+            String tableDDL = "create table " + fullIndexDataTable + TEST_TABLE_SCHEMA;
+            conn.createStatement().execute(tableDDL);
+            String ddl = "CREATE INDEX " + indexName + " ON " + fullIndexDataTable
                     + " (varchar_col1 ASC, varchar_col2 ASC, int_pk DESC)"
                     + " INCLUDE (int_col1, int_col2)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -299,8 +300,9 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeTableReuseIT {
         String indexName = generateRandomString();
         conn.setAutoCommit(false);
         try {
-            ensureTableCreated(getUrl(), indexDataTable, INDEX_DATA_TABLE);
-            String ddl = "CREATE INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable;
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            String ddl = "CREATE INDEX " + indexName + " ON " + fullTableName
                     + " (char_col1 ASC, int_col2 ASC, long_col2 DESC)"
                     + " INCLUDE (int_col1)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -359,8 +361,9 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeTableReuseIT {
         String indexName = "\"lowerCaseIndex\"";
         String indexDataTable = generateRandomString();
         try {
-            ensureTableCreated(getUrl(), indexDataTable, INDEX_DATA_TABLE);
-            String ddl = "CREATE INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable;
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            String ddl = "CREATE INDEX " + indexName + " ON " + fullTableName
                     + " (char_col1 ASC, int_col2 ASC, long_col2 DESC)"
                     + " INCLUDE (int_col1)";
             PreparedStatement stmt = conn.prepareStatement(ddl);
@@ -394,8 +397,9 @@ public class IndexMetadataIT extends BaseHBaseManagedTimeTableReuseIT {
         String indexDataTable = generateRandomString();
         String indexName = generateRandomString();
         try {
-            ensureTableCreated(getUrl(), indexDataTable, TestUtil.INDEX_DATA_TABLE);
-            String ddl = "CREATE INDEX " + indexName + " ON " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTable;
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
+            String ddl = "CREATE INDEX " + indexName + " ON " + fullTableName
             		+ " (a.int_col1, a.long_col1, b.int_col2, b.long_col2)"
             		+ " INCLUDE(int_col1, int_col2)";
             PreparedStatement stmt = conn.prepareStatement(ddl);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/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 0fde1c6..1646538 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
@@ -109,7 +109,7 @@ public class MutableIndexIT extends BaseHBaseManagedTimeTableReuseIT {
 			String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
 			String fullIndexName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName);
 
-			createMultiCFTestTable(fullTableName, tableDDLOptions);
+			TestUtil.createMultiCFTestTable(conn, fullTableName, tableDDLOptions);
             populateMultiCFTestTable(fullTableName);
             PreparedStatement stmt = conn.prepareStatement("CREATE " + (localIndex ? " LOCAL " : "") + " INDEX " + indexName + " ON " + fullTableName 
             		+ " (char_col1 ASC, int_col1 ASC) INCLUDE (long_col1, long_col2)");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/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 00de6b0..f1eafc2 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
@@ -18,7 +18,6 @@
 package org.apache.phoenix.rpc;
 
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
-import static org.apache.phoenix.util.TestUtil.MUTABLE_INDEX_DATA_TABLE;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.apache.phoenix.util.TestUtil.TRANSACTIONAL_DATA_TABLE;
 import static org.junit.Assert.assertFalse;
@@ -84,7 +83,8 @@ public class UpdateCacheIT extends BaseHBaseManagedTimeTableReuseIT {
     @Test
     public void testUpdateCacheForTxnTable() throws Exception {
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + TRANSACTIONAL_DATA_TABLE;
-        ensureTableCreated(getUrl(), TRANSACTIONAL_DATA_TABLE, TRANSACTIONAL_DATA_TABLE);
+        Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
+        conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA + "TRANSACTIONAL=true");
         helpTestUpdateCache(fullTableName, null, new int[] {1, 1});
     }
     
@@ -92,7 +92,8 @@ public class UpdateCacheIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testUpdateCacheForNonTxnTable() throws Exception {
         String tableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + tableName;
-        ensureTableCreated(getUrl(), tableName, MUTABLE_INDEX_DATA_TABLE);
+        Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
+        conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA);
         helpTestUpdateCache(fullTableName, null, new int[] {1, 3});
     }
 	
@@ -107,9 +108,9 @@ public class UpdateCacheIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testUpdateCacheForNeverUpdatedTable() throws Exception {
         String tableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + tableName;
-        ensureTableCreated(getUrl(), tableName, MUTABLE_INDEX_DATA_TABLE);
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+            conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA);
             conn.createStatement().execute(
             "alter table " + fullTableName + " SET UPDATE_CACHE_FREQUENCY=NEVER");
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java
index 44e3115..75f67b3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java
@@ -19,9 +19,16 @@ package org.apache.phoenix.rpc;
 
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
 import static org.apache.phoenix.util.TestUtil.MUTABLE_INDEX_DATA_TABLE;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Properties;
 
 import org.apache.phoenix.end2end.BaseClientManagedTimeIT;
 import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Test;
 
 public class UpdateCacheWithScnIT extends BaseClientManagedTimeIT {
@@ -30,7 +37,10 @@ public class UpdateCacheWithScnIT extends BaseClientManagedTimeIT {
 	public void testUpdateCacheWithScn() throws Exception {
         long ts = nextTimestamp();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + MUTABLE_INDEX_DATA_TABLE;
-        ensureTableCreated(getUrl(), MUTABLE_INDEX_DATA_TABLE, MUTABLE_INDEX_DATA_TABLE, ts);
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.createStatement().execute("create table " + fullTableName + TEST_TABLE_SCHEMA);
         // FIXME: given that the scn is advancing in the test, why aren't there more RPCs?
 		UpdateCacheIT.helpTestUpdateCache(fullTableName, ts+2, new int[] {1, 1});
 	}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/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 0377a37..e55a63e 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
@@ -19,7 +19,6 @@ package org.apache.phoenix.tx;
 
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.apache.phoenix.util.TestUtil.TRANSACTIONAL_DATA_TABLE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -52,6 +51,7 @@ import org.apache.phoenix.end2end.Shadower;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.jdbc.PhoenixResultSet;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -62,15 +62,13 @@ import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.phoenix.util.TestUtil;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
 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;
@@ -85,14 +83,18 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
         props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
-        
+
+    private static void createTable(Connection conn, String tableName) throws SQLException {
+        conn.createStatement().execute("create table " + tableName + TEST_TABLE_SCHEMA + "TRANSACTIONAL=true");
+    }
+    
     @Test
     public void testReadOwnWrites() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         String selectSql = "SELECT * FROM "+ fullTableName;
         try (Connection conn = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
@@ -125,9 +127,9 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testTxnClosedCorrecty() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         String selectSql = "SELECT * FROM "+fullTableName;
         try (Connection conn = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
@@ -144,12 +146,13 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
             rs = conn.createStatement().executeQuery(selectSql);
             TestUtil.validateRowKeyColumns(rs, 1);
             TestUtil.validateRowKeyColumns(rs, 2);
+            Long currentTx = rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp();
             assertFalse(rs.next());
             
             conn.close();
-            // wait for any open txns to time out
-            Thread.sleep(DEFAULT_TXN_TIMEOUT_SECONDS*1000+10000);
-            assertTrue("There should be no invalid transactions", txManager.getInvalidSize()==0);
+            // start new connection
+            conn.createStatement().executeQuery(selectSql);
+            assertFalse("This transaction should not be on the invalid transactions", txManager.getCurrentState().getInvalid().contains(currentTx));
         }
     }
     
@@ -157,10 +160,11 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testDelete() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         String selectSQL = "SELECT * FROM " + fullTableName;
-        try (Connection conn1 = DriverManager.getConnection(getUrl()); 
+        try (Connection conn = DriverManager.getConnection(getUrl());
+                Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn1.setAutoCommit(false);
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
@@ -196,8 +200,8 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testAutoCommitQuerySingleTable() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         try (Connection conn = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn.setAutoCommit(true);
             // verify no rows returned
             ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + fullTableName);
@@ -209,8 +213,8 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testAutoCommitQueryMultiTables() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         try (Connection conn = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn.setAutoCommit(true);
             // verify no rows returned
             ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + fullTableName + " a JOIN " + fullTableName + " b ON (a.long_pk = b.int_pk)");
@@ -222,9 +226,9 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testColConflicts() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
+            createTable(conn1, fullTableName);
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(false);
             String selectSql = "SELECT * FROM "+fullTableName;
@@ -295,7 +299,8 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testRowConflictDetected() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
+        Connection conn = DriverManager.getConnection(getUrl());
+        createTable(conn, fullTableName);
         testRowConflicts(fullTableName);
     }
     
@@ -303,8 +308,8 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testNoConflictDetectionForImmutableRows() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         Connection conn = DriverManager.getConnection(getUrl());
+        createTable(conn, fullTableName);
         conn.createStatement().execute("ALTER TABLE " + fullTableName + " SET IMMUTABLE_ROWS=true");
         testRowConflicts(fullTableName);
     }
@@ -496,10 +501,6 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     
     @Test
     public void testCreateTableToBeTransactional() throws Exception {
-
-        String transTableName = generateRandomString();
-        String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         String ddl = "CREATE TABLE TEST_TRANSACTIONAL_TABLE (k varchar primary key) transactional=true";
@@ -542,11 +543,13 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
         assertTrue(htable.getTableDescriptor().getCoprocessors().contains(PhoenixTransactionalProcessor.class.getName()));
     }
 
+    @Test
     public void testCurrentDate() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
         String selectSql = "SELECT current_date() FROM "+fullTableName;
         try (Connection conn = DriverManager.getConnection(getUrl())) {
+            createTable(conn, fullTableName);
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
@@ -782,10 +785,10 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testInflightUpdateNotSeen() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         String selectSQL = "SELECT * FROM " + fullTableName;
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
+            createTable(conn1, fullTableName);
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(true);
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
@@ -836,10 +839,10 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     public void testInflightDeleteNotSeen() throws Exception {
         String transTableName = generateRandomString();
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
-        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
         String selectSQL = "SELECT * FROM " + fullTableName;
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
+            createTable(conn1, fullTableName);
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(true);
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
index c8928cc..f9fa9f8 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
@@ -116,7 +116,7 @@ public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
             try {
                 queryServices.close();
             } finally {
-                if (executor != null) executor.shutdown();
+                if (executor != null) executor.shutdownNow();
                 connectionQueryServices = null;
             }
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index daef367..a28ef3b 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -42,11 +42,8 @@ import static org.apache.phoenix.util.TestUtil.ENTITY_HISTORY_SALTED_TABLE_NAME;
 import static org.apache.phoenix.util.TestUtil.ENTITY_HISTORY_TABLE_NAME;
 import static org.apache.phoenix.util.TestUtil.E_VALUE;
 import static org.apache.phoenix.util.TestUtil.FUNKY_NAME;
-import static org.apache.phoenix.util.TestUtil.GROUPBYTEST_NAME;
 import static org.apache.phoenix.util.TestUtil.HBASE_DYNAMIC_COLUMNS;
 import static org.apache.phoenix.util.TestUtil.HBASE_NATIVE;
-import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
-import static org.apache.phoenix.util.TestUtil.INDEX_DATA_TABLE;
 import static org.apache.phoenix.util.TestUtil.JOIN_COITEM_TABLE_FULL_NAME;
 import static org.apache.phoenix.util.TestUtil.JOIN_CUSTOMER_TABLE_FULL_NAME;
 import static org.apache.phoenix.util.TestUtil.JOIN_ITEM_TABLE_FULL_NAME;
@@ -55,7 +52,6 @@ import static org.apache.phoenix.util.TestUtil.JOIN_SUPPLIER_TABLE_FULL_NAME;
 import static org.apache.phoenix.util.TestUtil.KEYONLY_NAME;
 import static org.apache.phoenix.util.TestUtil.MDTEST_NAME;
 import static org.apache.phoenix.util.TestUtil.MULTI_CF_NAME;
-import static org.apache.phoenix.util.TestUtil.MUTABLE_INDEX_DATA_TABLE;
 import static org.apache.phoenix.util.TestUtil.PARENTID1;
 import static org.apache.phoenix.util.TestUtil.PARENTID2;
 import static org.apache.phoenix.util.TestUtil.PARENTID3;
@@ -79,15 +75,14 @@ import static org.apache.phoenix.util.TestUtil.ROW7;
 import static org.apache.phoenix.util.TestUtil.ROW8;
 import static org.apache.phoenix.util.TestUtil.ROW9;
 import static org.apache.phoenix.util.TestUtil.STABLE_NAME;
+import static org.apache.phoenix.util.TestUtil.SUM_DOUBLE_NAME;
 import static org.apache.phoenix.util.TestUtil.TABLE_WITH_ARRAY;
 import static org.apache.phoenix.util.TestUtil.TABLE_WITH_SALTING;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.apache.phoenix.util.TestUtil.TRANSACTIONAL_DATA_TABLE;
-import static org.apache.phoenix.util.TestUtil.SUM_DOUBLE_NAME;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
@@ -157,6 +152,11 @@ 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.tephra.TransactionManager;
+import org.apache.tephra.TxConstants;
+import org.apache.tephra.distributed.TransactionService;
+import org.apache.tephra.metrics.TxMetricsCollector;
+import org.apache.tephra.persist.InMemoryTransactionStateStorage;
 import org.apache.twill.discovery.DiscoveryService;
 import org.apache.twill.discovery.ZKDiscoveryService;
 import org.apache.twill.internal.utils.Networks;
@@ -175,12 +175,6 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.google.inject.util.Providers;
 
-import org.apache.tephra.TransactionManager;
-import org.apache.tephra.TxConstants;
-import org.apache.tephra.distributed.TransactionService;
-import org.apache.tephra.metrics.TxMetricsCollector;
-import org.apache.tephra.persist.InMemoryTransactionStateStorage;
-
 /**
  * 
  * Base class that contains all the methods needed by
@@ -364,9 +358,6 @@ public abstract class BaseTest {
                 "    e.cpu_utilization decimal(31,10),\n" +
                 "    f.response_time bigint,\n" +
                 "    g.response_time bigint)");
-        builder.put(GROUPBYTEST_NAME,"create table " + GROUPBYTEST_NAME +
-                "   (id varchar not null primary key,\n" +
-                "    uri varchar, appcpu integer)");
         builder.put(HBASE_NATIVE,"create table " + HBASE_NATIVE +
                 "   (uint_key unsigned_int not null," +
                 "    ulong_key unsigned_long not null," +
@@ -442,9 +433,6 @@ public abstract class BaseTest {
         builder.put("KVBigIntValueTest", "create table KVBigIntValueTest" +
                 "   (pk integer not null primary key,\n" +
                 "    kv bigint)\n");
-        builder.put(INDEX_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + INDEX_DATA_TABLE + TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true");
-        builder.put(MUTABLE_INDEX_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + MUTABLE_INDEX_DATA_TABLE + TEST_TABLE_SCHEMA);
-        builder.put(TRANSACTIONAL_DATA_TABLE, "create table " + INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + TRANSACTIONAL_DATA_TABLE + TEST_TABLE_SCHEMA + "TRANSACTIONAL=true");
         builder.put(SUM_DOUBLE_NAME,"create table SumDoubleTest" +
                 "   (id varchar not null primary key, d DOUBLE, f FLOAT, ud UNSIGNED_DOUBLE, uf UNSIGNED_FLOAT, i integer, de decimal)");
         builder.put(JOIN_ORDER_TABLE_FULL_NAME, "create table " + JOIN_ORDER_TABLE_FULL_NAME +
@@ -1988,32 +1976,6 @@ public abstract class BaseTest {
         }
     }
 
-    protected static void createMultiCFTestTable(String tableName, String options) throws SQLException {
-        String ddl = "create table if not exists " + tableName + "(" +
-                "   varchar_pk VARCHAR NOT NULL, " +
-                "   char_pk CHAR(5) NOT NULL, " +
-                "   int_pk INTEGER NOT NULL, "+ 
-                "   long_pk BIGINT NOT NULL, " +
-                "   decimal_pk DECIMAL(31, 10) NOT NULL, " +
-                "   a.varchar_col1 VARCHAR, " +
-                "   a.char_col1 CHAR(5), " +
-                "   a.int_col1 INTEGER, " +
-                "   a.long_col1 BIGINT, " +
-                "   a.decimal_col1 DECIMAL(31, 10), " +
-                "   b.varchar_col2 VARCHAR, " +
-                "   b.char_col2 CHAR(5), " +
-                "   b.int_col2 INTEGER, " +
-                "   b.long_col2 BIGINT, " +
-                "   b.decimal_col2 DECIMAL, " +
-                "   b.date_col DATE " + 
-                "   CONSTRAINT pk PRIMARY KEY (varchar_pk, char_pk, int_pk, long_pk DESC, decimal_pk)) "
-                + (options!=null? options : "");
-            Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-            Connection conn = DriverManager.getConnection(getUrl(), props);
-            conn.createStatement().execute(ddl);
-            conn.close();
-    }
-        
     // Populate the test table with data.
     protected static void populateMultiCFTestTable(String tableName) throws SQLException {
         populateMultiCFTestTable(tableName, null);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7af70887/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index 68e7b9b..cddd762 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@ -472,6 +472,12 @@ public class TestUtil {
         conn.commit();
     }
 
+    public static void createGroupByTestTable(Connection conn, String tableName) throws SQLException {
+        conn.createStatement().execute("create table " + tableName +
+                "   (id varchar not null primary key,\n" +
+                "    uri varchar, appcpu integer)");
+    }
+    
     private static void createTable(Connection conn, String inputSqlType, String tableName, String sortOrder) throws SQLException {
         String dmlFormat =
             "CREATE TABLE " + tableName + "_%s (id INTEGER NOT NULL, pk %s NOT NULL, " + "kv %s "
@@ -697,5 +703,28 @@ public class TestUtil {
             return aggregators;
         }
     }
+
+    public static void createMultiCFTestTable(Connection conn, String tableName, String options) throws SQLException {
+        String ddl = "create table if not exists " + tableName + "(" +
+                "   varchar_pk VARCHAR NOT NULL, " +
+                "   char_pk CHAR(5) NOT NULL, " +
+                "   int_pk INTEGER NOT NULL, "+ 
+                "   long_pk BIGINT NOT NULL, " +
+                "   decimal_pk DECIMAL(31, 10) NOT NULL, " +
+                "   a.varchar_col1 VARCHAR, " +
+                "   a.char_col1 CHAR(5), " +
+                "   a.int_col1 INTEGER, " +
+                "   a.long_col1 BIGINT, " +
+                "   a.decimal_col1 DECIMAL(31, 10), " +
+                "   b.varchar_col2 VARCHAR, " +
+                "   b.char_col2 CHAR(5), " +
+                "   b.int_col2 INTEGER, " +
+                "   b.long_col2 BIGINT, " +
+                "   b.decimal_col2 DECIMAL, " +
+                "   b.date_col DATE " + 
+                "   CONSTRAINT pk PRIMARY KEY (varchar_pk, char_pk, int_pk, long_pk DESC, decimal_pk)) "
+                + (options!=null? options : "");
+            conn.createStatement().execute(ddl);
+    }
 }
 


Mime
View raw message