phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject [02/15] phoenix git commit: Modify phoenix IT tests to extend BaseHBaseManagedTimeTableReuseIT (Prakul Agarwal, Samarth Jain)
Date Fri, 26 Aug 2016 23:16:06 GMT
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/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 d3f54fe..0377a37 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
@@ -47,7 +47,7 @@ import org.apache.hadoop.hbase.client.Put;
 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.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.end2end.Shadower;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.jdbc.PhoenixConnection;
@@ -75,17 +75,11 @@ import org.apache.tephra.hbase.TransactionAwareHTable;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
-public class TransactionIT extends BaseHBaseManagedTimeIT {
-    
-    private static final String FULL_TABLE_NAME = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + TRANSACTIONAL_DATA_TABLE;
-    
-    @Before
-    public void setUp() throws SQLException {
-        ensureTableCreated(getUrl(), TRANSACTIONAL_DATA_TABLE);
-    }
+public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT {
     
+
     @BeforeClass
-    @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
+    @Shadower(classBeingShadowed = BaseHBaseManagedTimeTableReuseIT.class)
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(1);
         props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
@@ -94,13 +88,16 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
         
     @Test
     public void testReadOwnWrites() throws Exception {
-        String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
+        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())) {
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
             PreparedStatement stmt = conn.prepareStatement(upsert);
             // upsert two rows
             TestUtil.setRowKeyColumns(stmt, 1);
@@ -126,13 +123,16 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testTxnClosedCorrecty() throws Exception {
-        String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
+        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())) {
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
             PreparedStatement stmt = conn.prepareStatement(upsert);
             // upsert two rows
             TestUtil.setRowKeyColumns(stmt, 1);
@@ -155,14 +155,17 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testDelete() throws Exception {
-        String selectSQL = "SELECT * FROM " + FULL_TABLE_NAME;
+        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())) {
             conn1.setAutoCommit(false);
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            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);
@@ -173,11 +176,11 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             stmt.execute();
             
             // verify rows can be read even though commit has not been called
-            int rowsDeleted = conn1.createStatement().executeUpdate("DELETE FROM " + FULL_TABLE_NAME);
+            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 " + FULL_TABLE_NAME);
+            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName);
             assertTrue(rs.next());
             assertEquals(1, rs.getInt(1));
             
@@ -191,36 +194,45 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     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())) {
             conn.setAutoCommit(true);
             // verify no rows returned
-            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + FULL_TABLE_NAME);
+            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + fullTableName);
             assertFalse(rs.next());
         }
     }
     
     @Test
     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())) {
             conn.setAutoCommit(true);
             // verify no rows returned
-            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + FULL_TABLE_NAME + " a JOIN " + FULL_TABLE_NAME + " b ON (a.long_pk = b.int_pk)");
+            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + fullTableName + " a JOIN " + fullTableName + " b ON (a.long_pk = b.int_pk)");
             assertFalse(rs.next());
         } 
     }
     
     @Test
     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())) {
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(false);
-            String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
+            String selectSql = "SELECT * FROM "+fullTableName;
             conn1.setAutoCommit(false);
             ResultSet rs = conn1.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
             // upsert row using conn1
-            String upsertSql = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, a.int_col1) VALUES(?, ?, ?, ?, ?, ?, ?)";
+            String upsertSql = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, a.int_col1) VALUES(?, ?, ?, ?, ?, ?, ?)";
             PreparedStatement stmt = conn1.prepareStatement(upsertSql);
             TestUtil.setRowKeyColumns(stmt, 1);
             stmt.setInt(7, 10);
@@ -243,24 +255,24 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
         }
     }
     
-    private void testRowConflicts() throws Exception {
-        try (Connection conn1 = DriverManager.getConnection(getUrl()); 
+    private void testRowConflicts(String fullTableName) throws Exception {
+        try (Connection conn1 = DriverManager.getConnection(getUrl());
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(false);
-            String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
+            String selectSql = "SELECT * FROM "+fullTableName;
             conn1.setAutoCommit(false);
             ResultSet rs = conn1.createStatement().executeQuery(selectSql);
-            boolean immutableRows = conn1.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, FULL_TABLE_NAME)).isImmutableRows();
+            boolean immutableRows = conn1.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, fullTableName)).isImmutableRows();
             assertFalse(rs.next());
             // upsert row using conn1
-            String upsertSql = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, a.int_col1) VALUES(?, ?, ?, ?, ?, ?, ?)";
+            String upsertSql = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, a.int_col1) VALUES(?, ?, ?, ?, ?, ?, ?)";
             PreparedStatement stmt = conn1.prepareStatement(upsertSql);
             TestUtil.setRowKeyColumns(stmt, 1);
             stmt.setInt(7, 10);
             stmt.execute();
             // upsert row using conn2
-            upsertSql = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, b.int_col2) VALUES(?, ?, ?, ?, ?, ?, ?)";
+            upsertSql = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, b.int_col2) VALUES(?, ?, ?, ?, ?, ?, ?)";
             stmt = conn2.prepareStatement(upsertSql);
             TestUtil.setRowKeyColumns(stmt, 1);
             stmt.setInt(7, 11);
@@ -281,51 +293,59 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testRowConflictDetected() throws Exception {
-        testRowConflicts();
+        String transTableName = generateRandomString();
+        String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
+        ensureTableCreated(getUrl(), transTableName, TRANSACTIONAL_DATA_TABLE);
+        testRowConflicts(fullTableName);
     }
     
     @Test
     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());
-        conn.createStatement().execute("ALTER TABLE " + FULL_TABLE_NAME + " SET IMMUTABLE_ROWS=true");
-        testRowConflicts();
+        conn.createStatement().execute("ALTER TABLE " + fullTableName + " SET IMMUTABLE_ROWS=true");
+        testRowConflicts(fullTableName);
     }
     
     @Test
     public void testNonTxToTxTable() throws Exception {
+        String nonTxTableName = generateRandomString();
+
         Connection conn = DriverManager.getConnection(getUrl());
-        conn.createStatement().execute("CREATE TABLE NON_TX_TABLE(k INTEGER PRIMARY KEY, v VARCHAR)");
-        conn.createStatement().execute("UPSERT INTO NON_TX_TABLE VALUES (1)");
-        conn.createStatement().execute("UPSERT INTO NON_TX_TABLE VALUES (2, 'a')");
-        conn.createStatement().execute("UPSERT INTO NON_TX_TABLE VALUES (3, 'b')");
+        conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
+        conn.createStatement().execute("UPSERT INTO " + nonTxTableName + " VALUES (1)");
+        conn.createStatement().execute("UPSERT INTO " + nonTxTableName + " VALUES (2, 'a')");
+        conn.createStatement().execute("UPSERT INTO " + nonTxTableName + " VALUES (3, 'b')");
         conn.commit();
         
-        conn.createStatement().execute("CREATE INDEX IDX ON NON_TX_TABLE(v)");
+        conn.createStatement().execute("CREATE INDEX IDX ON " + nonTxTableName + "(v)");
         // Reset empty column value to an empty value like it is pre-transactions
-        HTableInterface htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("NON_TX_TABLE"));
+        HTableInterface htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes( nonTxTableName));
         List<Put>puts = Lists.newArrayList(new Put(PInteger.INSTANCE.toBytes(1)), new Put(PInteger.INSTANCE.toBytes(2)), new Put(PInteger.INSTANCE.toBytes(3)));
         for (Put put : puts) {
             put.add(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, QueryConstants.EMPTY_COLUMN_BYTES, ByteUtil.EMPTY_BYTE_ARRAY);
         }
         htable.put(puts);
         
-        conn.createStatement().execute("ALTER TABLE NON_TX_TABLE SET TRANSACTIONAL=true");
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + " SET TRANSACTIONAL=true");
         
-        htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("NON_TX_TABLE"));
+        htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes( nonTxTableName));
         assertTrue(htable.getTableDescriptor().getCoprocessors().contains(PhoenixTransactionalProcessor.class.getName()));
         htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("IDX"));
         assertTrue(htable.getTableDescriptor().getCoprocessors().contains(PhoenixTransactionalProcessor.class.getName()));
 
-        conn.createStatement().execute("UPSERT INTO NON_TX_TABLE VALUES (4, 'c')");
-        ResultSet rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ k FROM NON_TX_TABLE WHERE v IS NULL");
-        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "NON_TX_TABLE")).isTransactional());
+        conn.createStatement().execute("UPSERT INTO " + nonTxTableName + " VALUES (4, 'c')");
+        ResultSet rs = conn.createStatement().executeQuery("SELECT /*+ NO_INDEX */ k FROM " + nonTxTableName + " WHERE v IS NULL");
+        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,  nonTxTableName)).isTransactional());
         assertTrue(rs.next());
         assertEquals(1,rs.getInt(1));
         assertFalse(rs.next());
         conn.commit();
         
-        conn.createStatement().execute("UPSERT INTO NON_TX_TABLE VALUES (5, 'd')");
-        rs = conn.createStatement().executeQuery("SELECT k FROM NON_TX_TABLE");
+        conn.createStatement().execute("UPSERT INTO " + nonTxTableName + " VALUES (5, 'd')");
+        rs = conn.createStatement().executeQuery("SELECT k FROM " + nonTxTableName);
         assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "IDX")).isTransactional());
         assertTrue(rs.next());
         assertEquals(1,rs.getInt(1));
@@ -340,7 +360,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
         assertFalse(rs.next());
         conn.rollback();
         
-        rs = conn.createStatement().executeQuery("SELECT k FROM NON_TX_TABLE");
+        rs = conn.createStatement().executeQuery("SELECT k FROM " + nonTxTableName);
         assertTrue(rs.next());
         assertEquals(1,rs.getInt(1));
         assertTrue(rs.next());
@@ -355,13 +375,15 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     @Ignore
     @Test
     public void testNonTxToTxTableFailure() throws Exception {
+        String nonTxTableName = generateRandomString();
+
         Connection conn = DriverManager.getConnection(getUrl());
         // Put table in SYSTEM schema to prevent attempts to update the cache after we disable SYSTEM.CATALOG
-        conn.createStatement().execute("CREATE TABLE SYSTEM.NON_TX_TABLE(k INTEGER PRIMARY KEY, v VARCHAR)");
-        conn.createStatement().execute("UPSERT INTO SYSTEM.NON_TX_TABLE VALUES (1)");
+        conn.createStatement().execute("CREATE TABLE SYSTEM." + nonTxTableName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
+        conn.createStatement().execute("UPSERT INTO SYSTEM." + nonTxTableName + " VALUES (1)");
         conn.commit();
         // Reset empty column value to an empty value like it is pre-transactions
-        HTableInterface htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("SYSTEM.NON_TX_TABLE"));
+        HTableInterface htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("SYSTEM." + nonTxTableName));
         Put put = new Put(PInteger.INSTANCE.toBytes(1));
         put.add(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, QueryConstants.EMPTY_COLUMN_BYTES, ByteUtil.EMPTY_BYTE_ARRAY);
         htable.put(put);
@@ -372,7 +394,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             // This will succeed initially in updating the HBase metadata, but then will fail when
             // the SYSTEM.CATALOG table is attempted to be updated, exercising the code to restore
             // the coprocessors back to the non transactional ones.
-            conn.createStatement().execute("ALTER TABLE SYSTEM.NON_TX_TABLE SET TRANSACTIONAL=true");
+            conn.createStatement().execute("ALTER TABLE SYSTEM." + nonTxTableName + " SET TRANSACTIONAL=true");
             fail();
         } catch (SQLException e) {
             assertTrue(e.getMessage().contains(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME + " is disabled"));
@@ -381,28 +403,30 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             admin.close();
         }
         
-        ResultSet rs = conn.createStatement().executeQuery("SELECT k FROM SYSTEM.NON_TX_TABLE WHERE v IS NULL");
+        ResultSet rs = conn.createStatement().executeQuery("SELECT k FROM SYSTEM." + nonTxTableName + " WHERE v IS NULL");
         assertTrue(rs.next());
         assertEquals(1,rs.getInt(1));
         assertFalse(rs.next());
         
-        htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("SYSTEM.NON_TX_TABLE"));
+        htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("SYSTEM." + nonTxTableName));
         assertFalse(htable.getTableDescriptor().getCoprocessors().contains(PhoenixTransactionalProcessor.class.getName()));
         assertEquals(1,conn.unwrap(PhoenixConnection.class).getQueryServices().
-                getTableDescriptor(Bytes.toBytes("SYSTEM.NON_TX_TABLE")).
+                getTableDescriptor(Bytes.toBytes("SYSTEM." + nonTxTableName)).
                 getFamily(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES).getMaxVersions());
     }
     
     @Test
     public void testProperties() throws Exception {
+        String nonTxTableName = generateRandomString();
+
         Connection conn = DriverManager.getConnection(getUrl());
-        conn.createStatement().execute("CREATE TABLE NON_TX_TABLE1(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR) TTL=1000");
-        conn.createStatement().execute("CREATE INDEX idx1 ON NON_TX_TABLE1(a.v, b.v) TTL=1000");
-        conn.createStatement().execute("CREATE INDEX idx2 ON NON_TX_TABLE1(c.v) INCLUDE (a.v, b.v) TTL=1000");
+        conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "1(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR) TTL=1000");
+        conn.createStatement().execute("CREATE INDEX idx1 ON " + nonTxTableName + "1(a.v, b.v) TTL=1000");
+        conn.createStatement().execute("CREATE INDEX idx2 ON " + nonTxTableName + "1(c.v) INCLUDE (a.v, b.v) TTL=1000");
 
-        conn.createStatement().execute("ALTER TABLE NON_TX_TABLE1 SET TRANSACTIONAL=true");
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "1 SET TRANSACTIONAL=true");
 
-        HTableDescriptor desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("NON_TX_TABLE1"));
+        HTableDescriptor desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes(nonTxTableName + "1"));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, colDesc.getMaxVersions());
             assertEquals(1000, colDesc.getTimeToLive());
@@ -423,39 +447,39 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             assertEquals(1000, Integer.parseInt(colDesc.getValue(TxConstants.PROPERTY_TTL)));
         }
         
-        conn.createStatement().execute("CREATE TABLE NON_TX_TABLE2(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
-        conn.createStatement().execute("ALTER TABLE NON_TX_TABLE2 SET TRANSACTIONAL=true, VERSIONS=10");
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("NON_TX_TABLE2"));
+        conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "2(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "2 SET TRANSACTIONAL=true, VERSIONS=10");
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes( nonTxTableName + "2"));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(10, colDesc.getMaxVersions());
             assertEquals(HColumnDescriptor.DEFAULT_TTL, colDesc.getTimeToLive());
             assertEquals(null, colDesc.getValue(TxConstants.PROPERTY_TTL));
         }
-        conn.createStatement().execute("ALTER TABLE NON_TX_TABLE2 SET TTL=1000");
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("NON_TX_TABLE2"));
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "2 SET TTL=1000");
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes( nonTxTableName + "2"));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(10, colDesc.getMaxVersions());
             assertEquals(1000, colDesc.getTimeToLive());
             assertEquals(1000, Integer.parseInt(colDesc.getValue(TxConstants.PROPERTY_TTL)));
         }
 
-        conn.createStatement().execute("CREATE TABLE NON_TX_TABLE3(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
-        conn.createStatement().execute("ALTER TABLE NON_TX_TABLE3 SET TRANSACTIONAL=true, b.VERSIONS=10, c.VERSIONS=20");
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("NON_TX_TABLE3"));
+        conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "3(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "3 SET TRANSACTIONAL=true, b.VERSIONS=10, c.VERSIONS=20");
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes( nonTxTableName + "3"));
         assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, desc.getFamily(Bytes.toBytes("A")).getMaxVersions());
         assertEquals(10, desc.getFamily(Bytes.toBytes("B")).getMaxVersions());
         assertEquals(20, desc.getFamily(Bytes.toBytes("C")).getMaxVersions());
 
-        conn.createStatement().execute("CREATE TABLE NON_TX_TABLE4(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
+        conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "4(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
         try {
-            conn.createStatement().execute("ALTER TABLE NON_TX_TABLE4 SET TRANSACTIONAL=true, VERSIONS=1");
+            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, VERSIONS=1");
             fail();
         } catch (SQLException e) {
             assertEquals(SQLExceptionCode.TX_MAX_VERSIONS_MUST_BE_GREATER_THAN_ONE.getErrorCode(), e.getErrorCode());
         }
 
         try {
-            conn.createStatement().execute("ALTER TABLE NON_TX_TABLE4 SET TRANSACTIONAL=true, b.VERSIONS=1");
+            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, b.VERSIONS=1");
             fail();
         } catch (SQLException e) {
             assertEquals(SQLExceptionCode.TX_MAX_VERSIONS_MUST_BE_GREATER_THAN_ONE.getErrorCode(), e.getErrorCode());
@@ -472,6 +496,10 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @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";
@@ -515,13 +543,15 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     }
 
     public void testCurrentDate() throws Exception {
-        String selectSql = "SELECT current_date() FROM "+FULL_TABLE_NAME;
+        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())) {
             conn.setAutoCommit(false);
             ResultSet rs = conn.createStatement().executeQuery(selectSql);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
             PreparedStatement stmt = conn.prepareStatement(upsert);
             // upsert two rows
             TestUtil.setRowKeyColumns(stmt, 1);
@@ -545,34 +575,36 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testReCreateTxnTableAfterDroppingExistingNonTxnTable() throws SQLException {
+        String tableName = generateRandomString();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         Statement stmt = conn.createStatement();
-        stmt.execute("CREATE TABLE DEMO(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
-        stmt.execute("DROP TABLE DEMO");
-        stmt.execute("CREATE TABLE DEMO(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true");
-        stmt.execute("CREATE INDEX DEMO_IDX ON DEMO (v1) INCLUDE(v2)");
-        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "DEMO")).isTransactional());
-        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, "DEMO_IDX")).isTransactional());
+        stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+        stmt.execute("DROP TABLE " + tableName);
+        stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true");
+        stmt.execute("CREATE INDEX " + tableName + "_IDX ON " + tableName + " (v1) INCLUDE(v2)");
+        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)).isTransactional());
+        assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,  tableName + "_IDX")).isTransactional());
     }
     
     @Test
     public void testRowTimestampDisabled() throws SQLException {
+        String tableName = generateRandomString();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
             conn.setAutoCommit(false);
             Statement stmt = conn.createStatement();
             try {
-                stmt.execute("CREATE TABLE DEMO(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP)) TRANSACTIONAL=true");
+                stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP)) TRANSACTIONAL=true");
                 fail();
             }
             catch(SQLException e) {
                 assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_WITH_ROW_TIMESTAMP.getErrorCode(), e.getErrorCode());
             }
-            stmt.execute("CREATE TABLE DEMO(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP))");
+            stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP))");
             try {
-                stmt.execute("ALTER TABLE DEMO SET TRANSACTIONAL=true");
+                stmt.execute("ALTER TABLE " + tableName + " SET TRANSACTIONAL=true");
                 fail();
             }
             catch(SQLException e) {
@@ -587,11 +619,11 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
+        String fullTableName = generateRandomString();
         PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
         
         TransactionSystemClient txServiceClient = pconn.getQueryServices().getTransactionSystemClient();
 
-        String fullTableName = "T";
         Statement stmt = conn.createStatement();
         stmt.execute("CREATE TABLE " + fullTableName + "(K VARCHAR PRIMARY KEY, V1 VARCHAR, V2 VARCHAR) TRANSACTIONAL=true");
         HTableInterface htable = pconn.getQueryServices().getTable(Bytes.toBytes(fullTableName));
@@ -706,9 +738,9 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     public void testCheckpointAndRollback() throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
+        String fullTableName = generateRandomString();
         conn.setAutoCommit(false);
         try {
-            String fullTableName = "T";
             Statement stmt = conn.createStatement();
             stmt.execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true");
             stmt.executeUpdate("upsert into " + fullTableName + " values('x', 'a', 'a')");
@@ -748,7 +780,10 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testInflightUpdateNotSeen() throws Exception {
-        String selectSQL = "SELECT * FROM " + FULL_TABLE_NAME;
+        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())) {
             conn1.setAutoCommit(false);
@@ -756,7 +791,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            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);
@@ -766,32 +801,32 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             TestUtil.setRowKeyColumns(stmt, 2);
             stmt.execute();
             
-            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME + " WHERE int_col1 IS NULL");
+            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName + " WHERE int_col1 IS NULL");
             assertTrue(rs.next());
             assertEquals(2, rs.getInt(1));
             
-            upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, int_col1) VALUES(?, ?, ?, ?, ?, ?, 1)";
+            upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk, int_col1) VALUES(?, ?, ?, ?, ?, ?, 1)";
             stmt = conn1.prepareStatement(upsert);
             TestUtil.setRowKeyColumns(stmt, 1);
             stmt.execute();
             
-            rs = conn1.createStatement().executeQuery("SELECT int_col1 FROM " + FULL_TABLE_NAME + " WHERE int_col1 = 1");
+            rs = conn1.createStatement().executeQuery("SELECT int_col1 FROM " + fullTableName + " WHERE int_col1 = 1");
             assertTrue(rs.next());
             assertEquals(1, rs.getInt(1));
             assertFalse(rs.next());
             
-            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME + " WHERE int_col1 = 1");
+            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName + " WHERE int_col1 = 1");
             assertTrue(rs.next());
             assertEquals(0, rs.getInt(1));
-            rs = conn2.createStatement().executeQuery("SELECT * FROM " + FULL_TABLE_NAME + " WHERE int_col1 = 1");
+            rs = conn2.createStatement().executeQuery("SELECT * FROM " + fullTableName + " WHERE int_col1 = 1");
             assertFalse(rs.next());
             
             conn1.commit();
             
-            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME + " WHERE int_col1 = 1");
+            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName + " WHERE int_col1 = 1");
             assertTrue(rs.next());
             assertEquals(1, rs.getInt(1));
-            rs = conn2.createStatement().executeQuery("SELECT * FROM " + FULL_TABLE_NAME + " WHERE int_col1 = 1");
+            rs = conn2.createStatement().executeQuery("SELECT * FROM " + fullTableName + " WHERE int_col1 = 1");
             assertTrue(rs.next());
             assertFalse(rs.next());
         }
@@ -799,7 +834,10 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testInflightDeleteNotSeen() throws Exception {
-        String selectSQL = "SELECT * FROM " + FULL_TABLE_NAME;
+        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())) {
             conn1.setAutoCommit(false);
@@ -807,7 +845,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
             
-            String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)";
+            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);
@@ -817,28 +855,28 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
             
             conn1.commit();
             
-            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME);
+            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName);
             assertTrue(rs.next());
             assertEquals(2, rs.getInt(1));
             
-            String delete = "DELETE FROM " + FULL_TABLE_NAME + " WHERE varchar_pk = 'varchar1'";
+            String delete = "DELETE FROM " + fullTableName + " WHERE varchar_pk = 'varchar1'";
             stmt = conn1.prepareStatement(delete);
             int count = stmt.executeUpdate();
             assertEquals(1,count);
             
-            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME);
+            rs = conn1.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName);
             assertTrue(rs.next());
             assertEquals(1, rs.getInt(1));
             assertFalse(rs.next());
             
-            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME);
+            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName);
             assertTrue(rs.next());
             assertEquals(2, rs.getInt(1));
             assertFalse(rs.next());
             
             conn1.commit();
             
-            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + FULL_TABLE_NAME);
+            rs = conn2.createStatement().executeQuery("SELECT count(*) FROM " + fullTableName);
             assertTrue(rs.next());
             assertEquals(1, rs.getInt(1));
             assertFalse(rs.next());
@@ -899,23 +937,23 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
     public void testInflightPartialEval() throws SQLException {
 
         try (Connection conn = DriverManager.getConnection(getUrl())) {
-            String transactTableName = "TR";
+            String transactTableName = "TR" + generateRandomString();
             Statement stmt = conn.createStatement();
             stmt.execute("CREATE TABLE " + transactTableName + " (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) " +
                 "TRANSACTIONAL=true");
             
             try (Connection conn1 = DriverManager.getConnection(getUrl()); Connection conn2 = DriverManager.getConnection(getUrl())) {
-                conn1.createStatement().execute("UPSERT INTO tr VALUES ('a','b','x')");
+                conn1.createStatement().execute("UPSERT INTO " + transactTableName + " VALUES ('a','b','x')");
                 // Select to force uncommitted data to be written
-                ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM tr");
+                ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM " + transactTableName);
                 assertTrue(rs.next());
                 assertEquals("a", rs.getString(1));
                 assertEquals("b", rs.getString(2));
                 assertFalse(rs.next());
                 
-                conn2.createStatement().execute("UPSERT INTO tr VALUES ('a','c','x')");
+                conn2.createStatement().execute("UPSERT INTO " + transactTableName + " VALUES ('a','c','x')");
                 // Select to force uncommitted data to be written
-                rs = conn2.createStatement().executeQuery("SELECT * FROM tr");
+                rs = conn2.createStatement().executeQuery("SELECT * FROM " + transactTableName );
                 assertTrue(rs.next());
                 assertEquals("a", rs.getString(1));
                 assertEquals("c", rs.getString(2));
@@ -924,14 +962,14 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
                 // If the AndExpression were to see the uncommitted row from conn2, the filter would
                 // filter the row out early and no longer continue to evaluate other cells due to
                 // the way partial evaluation holds state.
-                rs = conn1.createStatement().executeQuery("SELECT * FROM tr WHERE v1 != 'c' AND v2 = 'x'");
+                rs = conn1.createStatement().executeQuery("SELECT * FROM " +  transactTableName + " WHERE v1 != 'c' AND v2 = 'x'");
                 assertTrue(rs.next());
                 assertEquals("a", rs.getString(1));
                 assertEquals("b", rs.getString(2));
                 assertFalse(rs.next());
                 
                 // Same as above for conn1 data
-                rs = conn2.createStatement().executeQuery("SELECT * FROM tr WHERE v1 != 'b' AND v2 = 'x'");
+                rs = conn2.createStatement().executeQuery("SELECT * FROM " + transactTableName + " WHERE v1 != 'b' AND v2 = 'x'");
                 assertTrue(rs.next());
                 assertEquals("a", rs.getString(1));
                 assertEquals("c", rs.getString(2));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/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 df9a195..9f47a1e 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
@@ -33,7 +33,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.end2end.Shadower;
 import org.apache.phoenix.execute.MutationState;
 import org.apache.phoenix.jdbc.PhoenixConnection;
@@ -41,7 +41,6 @@ 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;
@@ -53,26 +52,19 @@ import org.apache.tephra.Transaction.VisibilityLevel;
 import com.google.common.collect.Maps;
 
 @RunWith(Parameterized.class)
-public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
+public class TxCheckpointIT extends BaseHBaseManagedTimeTableReuseIT {
 	
 	private final boolean localIndex;
 	private final boolean mutable;
-	private String tableName;
-    private String indexName;
-    private String seqName;
-    private String fullTableName;
 
 	public TxCheckpointIT(boolean localIndex, boolean mutable) {
 		this.localIndex = localIndex;
 		this.mutable = mutable;
-		this.tableName = TestUtil.DEFAULT_DATA_TABLE_NAME;
-        this.indexName = "IDX_" + System.currentTimeMillis();
-        this.seqName = "SEQ_" + System.currentTimeMillis();
-        this.fullTableName = SchemaUtil.getTableName(tableName, tableName);
+
 	}
 	
 	@BeforeClass
-    @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
+    @Shadower(classBeingShadowed = BaseHBaseManagedTimeTableReuseIT.class)
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(2);
         props.put(QueryServices.DEFAULT_TABLE_ISTRANSACTIONAL_ATTRIB, Boolean.toString(true));
@@ -89,6 +81,10 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testUpsertSelectDoesntSeeUpsertedData() throws Exception {
+        String tableName = "TBL_" + generateRandomString();
+        String indexName = "IDX_" + generateRandomString();
+        String seqName = "SEQ_" + generateRandomString();
+        String fullTableName = SchemaUtil.getTableName(tableName, tableName);
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         props.setProperty(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3));
         props.setProperty(QueryServices.SCAN_CACHE_SIZE_ATTRIB, Integer.toString(3));
@@ -110,17 +106,23 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testRollbackOfUncommittedDeleteSingleCol() throws Exception {
+        String tableName = "TBL_" + generateRandomString();
+        String indexName = "IDX_" + generateRandomString();
+        String fullTableName = SchemaUtil.getTableName(tableName, tableName);
         String indexDDL = "CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + indexName + " ON " + fullTableName + " (v1) INCLUDE(v2)";
-        testRollbackOfUncommittedDelete(indexDDL);
+        testRollbackOfUncommittedDelete(indexDDL, fullTableName);
     }
 
     @Test
     public void testRollbackOfUncommittedDeleteMultiCol() throws Exception {
+        String tableName = "TBL_" + generateRandomString();
+        String indexName = "IDX_" + generateRandomString();
+        String fullTableName = SchemaUtil.getTableName(tableName, tableName);
         String indexDDL = "CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + indexName + " ON " + fullTableName + " (v1, v2)";
-        testRollbackOfUncommittedDelete(indexDDL);
+        testRollbackOfUncommittedDelete(indexDDL, fullTableName);
     }
     
-    private void testRollbackOfUncommittedDelete(String indexDDL) throws Exception {
+    private void testRollbackOfUncommittedDelete(String indexDDL, String fullTableName) throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
@@ -207,6 +209,9 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
     
 	@Test
 	public void testCheckpointForUpsertSelect() throws Exception {
+        String tableName = "TBL_" + generateRandomString();
+        String indexName = "IDX_" + generateRandomString();
+        String fullTableName = SchemaUtil.getTableName(tableName, tableName);
 		Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
 		try (Connection conn = DriverManager.getConnection(getUrl(), props);) {
 			conn.setAutoCommit(false);
@@ -222,17 +227,17 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
             stmt.executeUpdate("upsert into " + fullTableName + " values(3, 'a3', 'b3')");
 			conn.commit();
 
-			upsertRows(conn);
+			upsertRows(conn, fullTableName);
 			conn.rollback();
-			verifyRows(conn, 3);
+			verifyRows(conn, fullTableName, 3);
 
-			upsertRows(conn);
+			upsertRows(conn, fullTableName);
 			conn.commit();
-			verifyRows(conn, 6);
+			verifyRows(conn, fullTableName, 6);
 		}
 	}
 
-	private void verifyRows(Connection conn, int expectedMaxId) throws SQLException {
+	private void verifyRows(Connection conn, String fullTableName, int expectedMaxId) throws SQLException {
 		ResultSet rs;
 		//query the data table
 		rs = conn.createStatement().executeQuery("select /*+ NO_INDEX */ max(id) from " + fullTableName + "");
@@ -247,7 +252,7 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
 		assertFalse(rs.next());
 	}
 
-	private void upsertRows(Connection conn) throws SQLException {
+	private void upsertRows(Connection conn, String fullTableName) throws SQLException {
 		ResultSet rs;
 		MutationState state = conn.unwrap(PhoenixConnection.class)
 				.getMutationState();
@@ -294,6 +299,9 @@ public class TxCheckpointIT extends BaseHBaseManagedTimeIT {
 	
 	@Test
     public void testCheckpointForDeleteAndUpsert() throws Exception {
+        String tableName = "TBL_" + generateRandomString();
+        String indexName = "IDX_" + generateRandomString();
+        String fullTableName = SchemaUtil.getTableName(tableName, tableName);
 		Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
 		ResultSet rs;
 		try (Connection conn = DriverManager.getConnection(getUrl(), props);) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index d7c7c62..dbd0a99 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -105,7 +105,7 @@ public interface QueryServices extends SQLCloseable {
 
     public static final String MASTER_INFO_PORT_ATTRIB = "hbase.master.info.port";
     public static final String REGIONSERVER_INFO_PORT_ATTRIB = "hbase.regionserver.info.port";
-    public static final String REGIONSERVER_LEASE_PERIOD_ATTRIB = "hbase.regionserver.lease.period";
+    public static final String HBASE_CLIENT_SCANNER_TIMEOUT_ATTRIB = "hbase.client.scanner.timeout.period";
     public static final String RPC_TIMEOUT_ATTRIB = "hbase.rpc.timeout";
     public static final String DYNAMIC_JARS_DIR_KEY = "hbase.dynamic.jars.dir";
     public static final String ZOOKEEPER_QUORUM_ATTRIB = "hbase.zookeeper.quorum";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index d874860..475c141 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -58,7 +58,7 @@ import static org.apache.phoenix.query.QueryServices.MUTATE_BATCH_SIZE_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.NUM_RETRIES_FOR_SCHEMA_UPDATE_CHECK;
 import static org.apache.phoenix.query.QueryServices.QUEUE_SIZE_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.REGIONSERVER_INFO_PORT_ATTRIB;
-import static org.apache.phoenix.query.QueryServices.REGIONSERVER_LEASE_PERIOD_ATTRIB;
+import static org.apache.phoenix.query.QueryServices.HBASE_CLIENT_SCANNER_TIMEOUT_ATTRIB;
 import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_ENABLED;
 import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_THREAD_POOL_SIZE;
 import static org.apache.phoenix.query.QueryServices.RENEW_LEASE_THRESHOLD_MILLISECONDS;
@@ -555,7 +555,7 @@ public class QueryServicesOptions {
     }
 
     public QueryServicesOptions setRegionServerLeasePeriodMs(int period) {
-        return set(REGIONSERVER_LEASE_PERIOD_ATTRIB, period);
+        return set(HBASE_CLIENT_SCANNER_TIMEOUT_ATTRIB, period);
     }
 
     public QueryServicesOptions setRpcTimeoutMs(int timeout) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
index 33c03ab..a116a2c 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
@@ -122,7 +122,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
 
     @Test
     public void testGetByteBitExpression() throws SQLException {
-        ensureTableCreated(getUrl(), TestUtil.BINARY_NAME);
+        ensureTableCreated(getUrl(), TestUtil.BINARY_NAME, TestUtil.BINARY_NAME);
         int result = 1;
         String query = "select * from " + BINARY_NAME + " where GET_BYTE(a_binary, 0)=" + result;
         Scan scan = compileStatement(query).getScan();
@@ -1044,7 +1044,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
      */
     @Test
     public void testValueComparisonInt() throws SQLException {
-        ensureTableCreated(getUrl(),"PKIntValueTest");
+        ensureTableCreated(getUrl(),"PKIntValueTest", "PKIntValueTest");
         String query;
         // int <-> long
         // Case 1: int = long, comparison always false, key is degenerated.
@@ -1070,7 +1070,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
 
     @Test
     public void testValueComparisonUnsignedInt() throws SQLException {
-        ensureTableCreated(getUrl(), "PKUnsignedIntValueTest");
+        ensureTableCreated(getUrl(), "PKUnsignedIntValueTest", "PKUnsignedIntValueTest");
         String query;
         // unsigned_int <-> negative int/long
         // Case 1: unsigned_int = negative int, always false;
@@ -1102,7 +1102,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
 
     @Test
     public void testValueComparisonUnsignedLong() throws SQLException {
-        ensureTableCreated(getUrl(), "PKUnsignedLongValueTest");
+        ensureTableCreated(getUrl(), "PKUnsignedLongValueTest", "PKUnsignedLongValueTest");
         String query;
         // unsigned_long <-> positive int/long
         // Case 1: unsigned_long = negative int/long, always false;
@@ -1256,7 +1256,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest {
     
     @Test
     public void testForceRangeScanKeepsFilters() throws SQLException {
-        ensureTableCreated(getUrl(), TestUtil.ENTITY_HISTORY_TABLE_NAME);
+        ensureTableCreated(getUrl(), TestUtil.ENTITY_HISTORY_TABLE_NAME, TestUtil.ENTITY_HISTORY_TABLE_NAME);
         String tenantId = "000000000000001";
         String keyPrefix = "002";
         String query = "select /*+ RANGE_SCAN */ ORGANIZATION_ID, PARENT_ID, CREATED_DATE, ENTITY_HISTORY_ID from " + TestUtil.ENTITY_HISTORY_TABLE_NAME + 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/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 fdb4002..daef367 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
@@ -83,9 +83,11 @@ 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.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
@@ -193,6 +195,7 @@ import org.apache.tephra.persist.InMemoryTransactionStateStorage;
  * make sure to shutdown the mini cluster in a method annotated by @AfterClass.  
  *
  */
+
 public abstract class BaseTest {
     protected static final String TEST_TABLE_SCHEMA = "(" +
             "   varchar_pk VARCHAR NOT NULL, " +
@@ -227,7 +230,7 @@ public abstract class BaseTest {
             .setNameFormat("DROP-TABLE-BASETEST" + "-thread-%s").build();
     private static final ExecutorService dropHTableService = Executors
             .newSingleThreadExecutor(factory);
-    
+
     static {
         ImmutableMap.Builder<String,String> builder = ImmutableMap.builder();
         builder.put(ENTITY_HISTORY_TABLE_NAME,"create table " + ENTITY_HISTORY_TABLE_NAME +
@@ -442,7 +445,7 @@ public abstract class BaseTest {
         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("SumDoubleTest","create table SumDoubleTest" +
+        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 +
                 "   (\"order_id\" varchar(15) not null primary key, " +
@@ -803,24 +806,31 @@ public abstract class BaseTest {
     }
 
     protected static void ensureTableCreated(String url, String tableName) throws SQLException {
-        ensureTableCreated(url, tableName, null, null);
+        ensureTableCreated(url, tableName, tableName, null, null);
+    }
+
+    protected static void ensureTableCreated(String url, String tableName, String tableDDLType) throws SQLException {
+        ensureTableCreated(url, tableName, tableDDLType, null, null);
     }
 
-    public static void ensureTableCreated(String url, String tableName, byte[][] splits) throws SQLException {
-        ensureTableCreated(url, tableName, splits, null);
+    public static void ensureTableCreated(String url, String tableName, String tableDDLType, byte[][] splits) throws SQLException {
+        ensureTableCreated(url, tableName, tableDDLType, splits, null);
     }
 
-    protected static void ensureTableCreated(String url, String tableName, Long ts) throws SQLException {
-        ensureTableCreated(url, tableName, null, ts);
+    protected static void ensureTableCreated(String url, String tableName, String tableDDLType, Long ts) throws SQLException {
+        ensureTableCreated(url, tableName, tableDDLType, null, ts);
     }
 
-    protected static void ensureTableCreated(String url, String tableName, byte[][] splits, Long ts) throws SQLException {
-        String ddl = tableDDLMap.get(tableName);
+    protected static void ensureTableCreated(String url, String tableName, String tableDDLType, byte[][] splits, Long ts) throws SQLException {
+        String ddl = tableDDLMap.get(tableDDLType);
+        if(!tableDDLType.equals(tableName)) {
+           ddl =  ddl.replace(tableDDLType, tableName);
+        }
         createSchema(url,tableName, ts);
         createTestTable(url, ddl, splits, ts);
     }
 
-    protected static String generateRandomString() {
+    public static String generateRandomString() {
       return RandomStringUtils.randomAlphabetic(20).toUpperCase();
     }
 
@@ -1052,16 +1062,20 @@ public abstract class BaseTest {
         }
         rs.close();
     }
-    
+
     protected static void initSumDoubleValues(byte[][] splits, String url) throws Exception {
-        ensureTableCreated(url, "SumDoubleTest", splits);
+        initSumDoubleValues(SUM_DOUBLE_NAME, splits, url);
+    }
+
+    protected static void initSumDoubleValues(String tableName, byte[][] splits, String url) throws Exception {
+        ensureTableCreated(url, tableName, SUM_DOUBLE_NAME, splits);
         Properties props = new Properties();
         Connection conn = DriverManager.getConnection(url, props);
         try {
             // Insert all rows at ts
             PreparedStatement stmt = conn.prepareStatement(
-                    "upsert into " +
-                    "SumDoubleTest(" +
+                    "upsert into " + tableName +
+                    "(" +
                     "    id, " +
                     "    d, " +
                     "    f, " +
@@ -1108,22 +1122,32 @@ public abstract class BaseTest {
             conn.close();
         }
     }
-    
-    protected static void initATableValues(String tenantId, byte[][] splits, String url) throws Exception {
-        initATableValues(tenantId, splits, null, url);
+
+    protected static String initATableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception {
+        return initATableValues(tenantId, splits, date, ts, getUrl());
     }
     
-    protected static void initATableValues(String tenantId, byte[][] splits, Date date, String url) throws Exception {
-        initATableValues(tenantId, splits, date, null, url);
+    protected static String initATableValues(String tenantId, byte[][] splits, String url) throws Exception {
+        return initATableValues(tenantId, splits, null, url);
     }
     
+    protected static String initATableValues(String tenantId, byte[][] splits, Date date, String url) throws Exception {
+        return initATableValues(tenantId, splits, date, null, url);
+    }
+
+    protected static String initATableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception {
+        return initATableValues(null, tenantId, splits, date, ts, url);
+    }
     
-    
-    protected static void initATableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception {
+    protected static String initATableValues(String tableName, String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception {
+        if(tableName == null) {
+            tableName = generateRandomString();
+        }
+        String tableDDLType = ATABLE_NAME;
         if (ts == null) {
-            ensureTableCreated(url, ATABLE_NAME, splits);
+            ensureTableCreated(url, tableName, tableDDLType, splits);
         } else {
-            ensureTableCreated(url, ATABLE_NAME, splits, ts-5);
+            ensureTableCreated(url, tableName, tableDDLType, splits, ts-5);
         }
         
         Properties props = new Properties();
@@ -1134,8 +1158,8 @@ public abstract class BaseTest {
         try {
             // Insert all rows at ts
             PreparedStatement stmt = conn.prepareStatement(
-                    "upsert into " +
-                    "ATABLE(" +
+                    "upsert into " + tableName +
+                    "(" +
                     "    ORGANIZATION_ID, " +
                     "    ENTITY_ID, " +
                     "    A_STRING, " +
@@ -1322,12 +1346,10 @@ public abstract class BaseTest {
             conn.commit();
         } finally {
             conn.close();
+            return tableName;
         }
     }
-    
-    protected static void initATableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception {
-        initATableValues(tenantId, splits, date, ts, getUrl());
-    }
+
     
     protected static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts) throws Exception {
         initEntityHistoryTableValues(tenantId, splits, date, ts, getUrl());
@@ -1347,9 +1369,9 @@ public abstract class BaseTest {
     
     private static void initEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception {
         if (ts == null) {
-            ensureTableCreated(url, ENTITY_HISTORY_TABLE_NAME, splits);
+            ensureTableCreated(url, ENTITY_HISTORY_TABLE_NAME, ENTITY_HISTORY_TABLE_NAME, splits);
         } else {
-            ensureTableCreated(url, ENTITY_HISTORY_TABLE_NAME, splits, ts-2);
+            ensureTableCreated(url, ENTITY_HISTORY_TABLE_NAME, ENTITY_HISTORY_TABLE_NAME, splits, ts-2);
         }
         
         Properties props = new Properties();
@@ -1451,9 +1473,9 @@ public abstract class BaseTest {
     
     protected static void initSaltedEntityHistoryTableValues(String tenantId, byte[][] splits, Date date, Long ts, String url) throws Exception {
         if (ts == null) {
-            ensureTableCreated(url, ENTITY_HISTORY_SALTED_TABLE_NAME, splits);
+            ensureTableCreated(url, ENTITY_HISTORY_SALTED_TABLE_NAME, ENTITY_HISTORY_SALTED_TABLE_NAME, splits);
         } else {
-            ensureTableCreated(url, ENTITY_HISTORY_SALTED_TABLE_NAME, splits, ts-2);
+            ensureTableCreated(url, ENTITY_HISTORY_SALTED_TABLE_NAME, ENTITY_HISTORY_SALTED_TABLE_NAME, splits, ts-2);
         }
         
         Properties props = new Properties();
@@ -1555,15 +1577,15 @@ public abstract class BaseTest {
     
     protected static void initJoinTableValues(String url, byte[][] splits, Long ts) throws Exception {
         if (ts == null) {
-            ensureTableCreated(url, JOIN_CUSTOMER_TABLE_FULL_NAME, splits);
-            ensureTableCreated(url, JOIN_ITEM_TABLE_FULL_NAME, splits);
-            ensureTableCreated(url, JOIN_SUPPLIER_TABLE_FULL_NAME, splits);
-            ensureTableCreated(url, JOIN_ORDER_TABLE_FULL_NAME, splits);
+            ensureTableCreated(url, JOIN_CUSTOMER_TABLE_FULL_NAME, JOIN_CUSTOMER_TABLE_FULL_NAME, splits);
+            ensureTableCreated(url, JOIN_ITEM_TABLE_FULL_NAME, JOIN_ITEM_TABLE_FULL_NAME, splits);
+            ensureTableCreated(url, JOIN_SUPPLIER_TABLE_FULL_NAME, JOIN_SUPPLIER_TABLE_FULL_NAME, splits);
+            ensureTableCreated(url, JOIN_ORDER_TABLE_FULL_NAME, JOIN_ORDER_TABLE_FULL_NAME, splits);
         } else {
-            ensureTableCreated(url, JOIN_CUSTOMER_TABLE_FULL_NAME, splits, ts - 2);
-            ensureTableCreated(url, JOIN_ITEM_TABLE_FULL_NAME, splits, ts - 2);
-            ensureTableCreated(url, JOIN_SUPPLIER_TABLE_FULL_NAME, splits, ts - 2);
-            ensureTableCreated(url, JOIN_ORDER_TABLE_FULL_NAME, splits, ts - 2);
+            ensureTableCreated(url, JOIN_CUSTOMER_TABLE_FULL_NAME, JOIN_CUSTOMER_TABLE_FULL_NAME, splits, ts - 2);
+            ensureTableCreated(url, JOIN_ITEM_TABLE_FULL_NAME, JOIN_ITEM_TABLE_FULL_NAME, splits, ts - 2);
+            ensureTableCreated(url, JOIN_SUPPLIER_TABLE_FULL_NAME, JOIN_SUPPLIER_TABLE_FULL_NAME, splits, ts - 2);
+            ensureTableCreated(url, JOIN_ORDER_TABLE_FULL_NAME, JOIN_ORDER_TABLE_FULL_NAME, splits, ts - 2);
         }
         
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -2063,5 +2085,29 @@ public abstract class BaseTest {
         } finally {
             conn.close();
         }
-    }  
+    }
+
+    protected static void verifySequence(String tenantID, String sequenceName, String sequenceSchemaName, boolean exists) throws SQLException {
+
+        PhoenixConnection phxConn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class);
+        String ddl = "SELECT "
+                + PhoenixDatabaseMetaData.TENANT_ID + ","
+                + PhoenixDatabaseMetaData.SEQUENCE_SCHEMA + ","
+                + PhoenixDatabaseMetaData.SEQUENCE_NAME
+                + " FROM " + PhoenixDatabaseMetaData.SYSTEM_SEQUENCE
+                + " WHERE ";
+
+        ddl += " TENANT_ID  " + ((tenantID == null ) ? "IS NULL " : " = '" + tenantID + "'");
+        ddl += " AND SEQUENCE_NAME " + ((sequenceName == null) ? "IS NULL " : " = '" +  sequenceName + "'");
+        ddl += " AND SEQUENCE_SCHEMA " + ((sequenceSchemaName == null) ? "IS NULL " : " = '" + sequenceSchemaName + "'" );
+
+        ResultSet rs = phxConn.createStatement().executeQuery(ddl);
+
+        if(exists) {
+            assertTrue(rs.next());
+        } else {
+            assertFalse(rs.next());
+        }
+        phxConn.close();
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/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 0a11977..68e7b9b 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
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.util;
 
+import static org.apache.phoenix.query.BaseTest.generateRandomString;
 import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY;
 import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_FAMILY_NAME;
 import static org.apache.phoenix.query.QueryConstants.SINGLE_COLUMN_NAME;
@@ -449,8 +450,8 @@ public class TestUtil {
      * @param input
      *            input to be inserted
      */
-    public static void upsertRow(Connection conn, String sortOrder, int id, Object input) throws SQLException {
-        String dml = String.format("UPSERT INTO TEST_TABLE_%s VALUES(?,?)", sortOrder);
+    public static void upsertRow(Connection conn, String tableName, String sortOrder, int id, Object input) throws SQLException {
+        String dml = String.format("UPSERT INTO " + tableName + "_%s VALUES(?,?)", sortOrder);
         PreparedStatement stmt = conn.prepareStatement(dml);
         stmt.setInt(1, id);
         if (input instanceof String)
@@ -471,11 +472,11 @@ public class TestUtil {
         conn.commit();
     }
 
-    private static void createTable(Connection conn, String inputSqlType, String sortOrder) throws SQLException {
+    private static void createTable(Connection conn, String inputSqlType, String tableName, String sortOrder) throws SQLException {
         String dmlFormat =
-            "CREATE TABLE TEST_TABLE_%s" + "(id INTEGER NOT NULL, pk %s NOT NULL, " + "kv %s "
+            "CREATE TABLE " + tableName + "_%s (id INTEGER NOT NULL, pk %s NOT NULL, " + "kv %s "
                 + "CONSTRAINT PK_CONSTRAINT PRIMARY KEY (id, pk %s))";
-        String ddl = String.format(dmlFormat, sortOrder, inputSqlType, inputSqlType, sortOrder);
+        String ddl = String.format(dmlFormat,sortOrder, inputSqlType, inputSqlType, sortOrder);
         conn.createStatement().execute(ddl);
         conn.commit();
     }
@@ -491,13 +492,15 @@ public class TestUtil {
      * @param inputList
      *            list of values to be inserted into the pk column
      */
-    public static void initTables(Connection conn, String inputSqlType, List<Object> inputList) throws Exception {
-        createTable(conn, inputSqlType, "ASC");
-        createTable(conn, inputSqlType, "DESC");
+    public static String initTables(Connection conn, String inputSqlType, List<Object> inputList) throws Exception {
+        String tableName = generateRandomString();
+        createTable(conn, inputSqlType, tableName, "ASC");
+        createTable(conn, inputSqlType, tableName, "DESC");
         for (int i = 0; i < inputList.size(); ++i) {
-            upsertRow(conn, "ASC", i, inputList.get(i));
-            upsertRow(conn, "DESC", i, inputList.get(i));
+            upsertRow(conn, tableName, "ASC", i, inputList.get(i));
+            upsertRow(conn, tableName, "DESC", i, inputList.get(i));
         }
+        return tableName;
     }
     
     public static List<KeyRange> getAllSplits(Connection conn, String tableName) throws SQLException {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-flume/src/it/java/org/apache/phoenix/flume/PhoenixSinkIT.java
----------------------------------------------------------------------
diff --git a/phoenix-flume/src/it/java/org/apache/phoenix/flume/PhoenixSinkIT.java b/phoenix-flume/src/it/java/org/apache/phoenix/flume/PhoenixSinkIT.java
index a59a356..22dfa36 100644
--- a/phoenix-flume/src/it/java/org/apache/phoenix/flume/PhoenixSinkIT.java
+++ b/phoenix-flume/src/it/java/org/apache/phoenix/flume/PhoenixSinkIT.java
@@ -29,7 +29,7 @@ import org.apache.flume.lifecycle.LifecycleState;
 import org.apache.flume.sink.DefaultSinkFactory;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.flume.serializer.EventSerializers;
 import org.apache.phoenix.flume.serializer.CustomSerializer;
 import org.apache.phoenix.flume.sink.NullPhoenixSink;
@@ -48,7 +48,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
 
-public class PhoenixSinkIT extends BaseHBaseManagedTimeIT {
+public class PhoenixSinkIT extends BaseHBaseManagedTimeTableReuseIT {
 
     private Context sinkContext;
     private PhoenixSink sink;
@@ -128,13 +128,14 @@ public class PhoenixSinkIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testSinkLifecycle () {
-        
-        String ddl = "CREATE TABLE flume_test " +
+        String tableName = generateRandomString();
+
+        String ddl = "CREATE TABLE " + tableName +
                 "  (flume_time timestamp not null, col1 varchar , col2 varchar" +
                 "  CONSTRAINT pk PRIMARY KEY (flume_time))\n";
         
         sinkContext = new Context ();
-        sinkContext.put(FlumeConstants.CONFIG_TABLE, "flume_test");
+        sinkContext.put(FlumeConstants.CONFIG_TABLE,  tableName);
         sinkContext.put(FlumeConstants.CONFIG_JDBC_URL, getUrl());
         sinkContext.put(FlumeConstants.CONFIG_SERIALIZER,EventSerializers.REGEX.name());
         sinkContext.put(FlumeConstants.CONFIG_TABLE_DDL, ddl);
@@ -158,12 +159,12 @@ public class PhoenixSinkIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testCreateTable () throws Exception {
-        
-        String ddl = "CREATE TABLE flume_test " +
+        String tableName = generateRandomString();
+        String ddl = "CREATE TABLE " + tableName + " " +
                 "  (flume_time timestamp not null, col1 varchar , col2 varchar" +
                 "  CONSTRAINT pk PRIMARY KEY (flume_time))\n";
 
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName =  tableName;
         sinkContext = new Context ();
         sinkContext.put(FlumeConstants.CONFIG_TABLE, fullTableName);
         sinkContext.put(FlumeConstants.CONFIG_JDBC_URL, getUrl());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java
----------------------------------------------------------------------
diff --git a/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java b/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java
index 1c0a836..6863401 100644
--- a/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java
+++ b/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java
@@ -40,7 +40,7 @@ import org.apache.flume.conf.Configurables;
 import org.apache.flume.event.EventBuilder;
 import org.apache.flume.lifecycle.LifecycleState;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.flume.serializer.EventSerializers;
 import org.apache.phoenix.flume.sink.PhoenixSink;
 import org.apache.phoenix.util.PropertiesUtil;
@@ -51,7 +51,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 
-public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
+public class RegexEventSerializerIT extends BaseHBaseManagedTimeTableReuseIT {
 
     private Context sinkContext;
     private PhoenixSink sink;
@@ -59,7 +59,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     @Test
     public void testKeyGenerator() throws EventDeliveryException, SQLException {
         
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName = generateRandomString();
         initSinkContextWithDefaults(fullTableName);
         
         sink = new PhoenixSink();
@@ -94,7 +94,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     @Test
     public void testMismatchKeyGenerator() throws EventDeliveryException, SQLException {
         
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName = generateRandomString();
         initSinkContextWithDefaults(fullTableName);
         setConfig(FlumeConstants.CONFIG_SERIALIZER_PREFIX + FlumeConstants.CONFIG_ROWKEY_TYPE_GENERATOR,DefaultKeyGenerator.UUID.name());
      
@@ -127,7 +127,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     @Test
     public void testMissingColumnsInEvent() throws EventDeliveryException, SQLException {
         
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName = generateRandomString();
         initSinkContextWithDefaults(fullTableName);
       
         sink = new PhoenixSink();
@@ -160,7 +160,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     @Test
     public void testBatchEvents() throws EventDeliveryException, SQLException {
         
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName = generateRandomString();
         initSinkContextWithDefaults(fullTableName);
       
         sink = new PhoenixSink();
@@ -205,7 +205,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     public void testApacheLogRegex() throws Exception {
         
         sinkContext = new Context ();
-        final String fullTableName = "s1.apachelogs";
+        final String fullTableName = generateRandomString();
         final String logRegex = "([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\]) \"([^ ]+) ([^ ]+)" +
                                 " ([^\"]+)\" (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\"[^\"]*\")" +
                                 " ([^ \"]*|\"[^\"]*\"))?";
@@ -280,7 +280,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT {
     public void testEventsWithHeaders() throws Exception {
         
         sinkContext = new Context ();
-        final String fullTableName = "FLUME_TEST";
+        final String fullTableName = generateRandomString();
         final String ddl = "CREATE TABLE " + fullTableName +
                 "  (rowkey VARCHAR not null, col1 varchar , cf1.col2 varchar , host varchar , source varchar \n" +
                 "  CONSTRAINT pk PRIMARY KEY (rowkey))\n";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
index 16d2d20..07618a7 100644
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/ResultBaseTestIT.java
@@ -18,7 +18,7 @@
 
 package org.apache.phoenix.pherf;
 
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.pherf.configuration.XMLConfigParser;
 import org.apache.phoenix.pherf.result.ResultUtil;
 import org.apache.phoenix.pherf.schema.SchemaReader;
@@ -30,7 +30,7 @@ import java.nio.file.Path;
 import java.util.List;
 import java.util.Properties;
 
-public class ResultBaseTestIT extends BaseHBaseManagedTimeIT {
+public class ResultBaseTestIT extends BaseHBaseManagedTimeTableReuseIT {
     protected static final String matcherScenario = ".*scenario/.*test.*xml";
     protected static final String matcherSchema = ".*datamodel/.*test.*sql";
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/SchemaReaderIT.java
----------------------------------------------------------------------
diff --git a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/SchemaReaderIT.java b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/SchemaReaderIT.java
index 4ff1fb5..4f6d3c1 100644
--- a/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/SchemaReaderIT.java
+++ b/phoenix-pherf/src/it/java/org/apache/phoenix/pherf/SchemaReaderIT.java
@@ -30,7 +30,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.pherf.configuration.Column;
 import org.apache.phoenix.pherf.configuration.DataModel;
 import org.apache.phoenix.pherf.configuration.Scenario;
@@ -39,7 +39,8 @@ import org.apache.phoenix.pherf.schema.SchemaReader;
 import org.apache.phoenix.pherf.util.PhoenixUtil;
 import org.junit.Test;
 
-public class SchemaReaderIT extends BaseHBaseManagedTimeIT {
+
+public class SchemaReaderIT extends BaseHBaseManagedTimeTableReuseIT {
     protected static PhoenixUtil util = PhoenixUtil.create(true);
 
     @Test 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-pig/src/it/java/org/apache/phoenix/pig/BasePigIT.java
----------------------------------------------------------------------
diff --git a/phoenix-pig/src/it/java/org/apache/phoenix/pig/BasePigIT.java b/phoenix-pig/src/it/java/org/apache/phoenix/pig/BasePigIT.java
index 94ccc25..4ff818f 100644
--- a/phoenix-pig/src/it/java/org/apache/phoenix/pig/BasePigIT.java
+++ b/phoenix-pig/src/it/java/org/apache/phoenix/pig/BasePigIT.java
@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
+import org.apache.phoenix.end2end.BaseHBaseManagedTimeTableReuseIT;
 import org.apache.phoenix.end2end.Shadower;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -42,7 +42,7 @@ import org.junit.BeforeClass;
 
 import com.google.common.collect.Maps;
 
-public class BasePigIT extends BaseHBaseManagedTimeIT {
+public class BasePigIT extends BaseHBaseManagedTimeTableReuseIT {
     protected TupleFactory tupleFactory;
     protected String zkQuorum;
     protected Connection conn;
@@ -50,7 +50,7 @@ public class BasePigIT extends BaseHBaseManagedTimeIT {
     protected PigServer pigServer;
 
     @BeforeClass
-    @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
+    @Shadower(classBeingShadowed = BaseHBaseManagedTimeTableReuseIT.class)
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(3);
         props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/14dab2f4/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java b/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java
index ba49bab..b7db592 100644
--- a/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java
+++ b/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/QueryServerBasicsIT.java
@@ -50,7 +50,7 @@ import org.junit.Test;
 /**
  * Smoke test for query server.
  */
-public class QueryServerBasicsIT extends BaseHBaseManagedTimeIT {
+public class QueryServerBasicsIT extends BaseHBaseManagedTimeTableReuseIT {
 
   private static final Log LOG = LogFactory.getLog(QueryServerBasicsIT.class);
 


Mime
View raw message