Revert "PHOENIX-2543 Modify StatsCollectorIT to test transactional test cases"

This reverts commit 51870229ea9566c6095695038eebc54953744de7.
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
index 35889cd..954ad99 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
@@ -30,8 +30,6 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -46,23 +44,14 @@
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
-import org.apache.phoenix.util.SchemaUtil;
-import org.apache.phoenix.util.TestUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
 
 import com.google.common.collect.Maps;
 
-@RunWith(Parameterized.class)
+
 public class StatsCollectorIT extends StatsCollectorAbstractIT {
     private static final String STATS_TEST_TABLE_NAME = "S";
-    
-    private final String tableDDLOptions;
-    private final String tableName;
-    private final String fullTableName;
         
     @BeforeClass
     public static void doSetup() throws Exception {
@@ -74,31 +63,30 @@
         props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
-    
-    public StatsCollectorIT( boolean transactional) {
-        this.tableDDLOptions= transactional ? " TRANSACTIONAL=true" : "";
-        this.tableName = TestUtil.DEFAULT_DATA_TABLE_NAME + ( transactional ?  "_TXN" : "");
-        this.fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName);
-    }
-    
-    @Parameters(name="transactional = {0}")
-    public static Collection<Boolean> data() {
-        return Arrays.asList(false,true);
-    }
 
     @Test
-    public void testUpdateStats() throws SQLException, IOException,
+    public void testUpdateStatsForNonTxnTable() throws Throwable {
+        helpTestUpdateStats(false);
+    }
+    
+    @Test
+    public void testUpdateStatsForTxnTable() throws Throwable {
+        helpTestUpdateStats(true);
+    }
+
+	private void helpTestUpdateStats(boolean transactional) throws SQLException, IOException,
 			InterruptedException {
 		Connection conn;
         PreparedStatement stmt;
         ResultSet rs;
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String tableName = "T" + (transactional ? "_TXN" : "");
         // props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
         conn = DriverManager.getConnection(getUrl(), props);
         conn.createStatement().execute(
-                "CREATE TABLE " + fullTableName +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
-                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))"
-                		+ tableDDLOptions );
+                "CREATE TABLE " + tableName +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
+                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))" 
+                		+ (transactional ? " TRANSACTIONAL=true" : ""));
         String[] s;
         Array array;
         conn = upsertValues(props, tableName);
@@ -132,14 +120,14 @@
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         conn = DriverManager.getConnection(getUrl(), props);
         conn.createStatement()
-                .execute("CREATE TABLE " + fullTableName +" ( k VARCHAR, c1.a bigint,c2.b bigint CONSTRAINT pk PRIMARY KEY (k))" + tableDDLOptions );
-        conn.createStatement().execute("upsert into " + fullTableName +" values ('abc',1,3)");
-        conn.createStatement().execute("upsert into " + fullTableName +" values ('def',2,4)");
+                .execute("CREATE TABLE x ( k VARCHAR, c1.a bigint,c2.b bigint CONSTRAINT pk PRIMARY KEY (k)) \n");
+        conn.createStatement().execute("upsert into x values ('abc',1,3)");
+        conn.createStatement().execute("upsert into x values ('def',2,4)");
         conn.commit();
         // CAll the update statistics query here
-        stmt = conn.prepareStatement("UPDATE STATISTICS " + fullTableName);
+        stmt = conn.prepareStatement("UPDATE STATISTICS X");
         stmt.execute();
-        rs = conn.createStatement().executeQuery("SELECT k FROM " + fullTableName);
+        rs = conn.createStatement().executeQuery("SELECT k FROM x");
         assertTrue(rs.next());
         assertEquals("abc", rs.getString(1));
         assertTrue(rs.next());
@@ -150,7 +138,6 @@
 
     @Test
     public void testUpdateStatsWithMultipleTables() throws Throwable {
-        String fullTableName2 = fullTableName+"_2";
         Connection conn;
         PreparedStatement stmt;
         ResultSet rs;
@@ -158,21 +145,21 @@
         // props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
         conn = DriverManager.getConnection(getUrl(), props);
         conn.createStatement().execute(
-                "CREATE TABLE " + fullTableName +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
-                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))" + tableDDLOptions );
+                "CREATE TABLE x ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
+                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC)) \n");
         conn.createStatement().execute(
-                "CREATE TABLE " + fullTableName2 +" ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
-                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC))" + tableDDLOptions );
+                "CREATE TABLE z ( k VARCHAR, a_string_array VARCHAR(100) ARRAY[4], b_string_array VARCHAR(100) ARRAY[4] \n"
+                        + " CONSTRAINT pk PRIMARY KEY (k, b_string_array DESC)) \n");
         String[] s;
         Array array;
-        conn = upsertValues(props, fullTableName);
-        conn = upsertValues(props, fullTableName2);
+        conn = upsertValues(props, "x");
+        conn = upsertValues(props, "z");
         // CAll the update statistics query here
-        stmt = conn.prepareStatement("UPDATE STATISTICS "+fullTableName);
+        stmt = conn.prepareStatement("UPDATE STATISTICS X");
         stmt.execute();
-        stmt = conn.prepareStatement("UPDATE STATISTICS "+fullTableName2);
+        stmt = conn.prepareStatement("UPDATE STATISTICS Z");
         stmt.execute();
-        stmt = upsertStmt(conn, fullTableName);
+        stmt = upsertStmt(conn, "x");
         stmt.setString(1, "z");
         s = new String[] { "xyz", "def", "ghi", "jkll", null, null, "xxx" };
         array = conn.createArrayOf("VARCHAR", s);
@@ -181,7 +168,7 @@
         array = conn.createArrayOf("VARCHAR", s);
         stmt.setArray(3, array);
         stmt.execute();
-        stmt = upsertStmt(conn, fullTableName2);
+        stmt = upsertStmt(conn, "z");
         stmt.setString(1, "z");
         s = new String[] { "xyz", "def", "ghi", "jkll", null, null, "xxx" };
         array = conn.createArrayOf("VARCHAR", s);
@@ -193,9 +180,9 @@
         conn.close();
         conn = DriverManager.getConnection(getUrl(), props);
         // This analyze would not work
-        stmt = conn.prepareStatement("UPDATE STATISTICS "+fullTableName2);
+        stmt = conn.prepareStatement("UPDATE STATISTICS Z");
         stmt.execute();
-        rs = conn.createStatement().executeQuery("SELECT k FROM "+fullTableName2);
+        rs = conn.createStatement().executeQuery("SELECT k FROM Z");
         assertTrue(rs.next());
         conn.close();
     }
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 af0e037..fe1f16c 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
@@ -20,8 +20,6 @@
 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.apache.phoenix.util.TestUtil.analyzeTable;
-import static org.apache.phoenix.util.TestUtil.getAllSplits;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -38,6 +36,12 @@
 import java.util.Map;
 import java.util.Properties;
 
+import co.cask.tephra.TransactionContext;
+import co.cask.tephra.TransactionSystemClient;
+import co.cask.tephra.TxConstants;
+import co.cask.tephra.hbase10.TransactionAwareHTable;
+import co.cask.tephra.hbase10.coprocessor.TransactionProcessor;
+
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
@@ -52,7 +56,6 @@
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
-import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -68,12 +71,6 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import co.cask.tephra.TransactionContext;
-import co.cask.tephra.TransactionSystemClient;
-import co.cask.tephra.TxConstants;
-import co.cask.tephra.hbase10.TransactionAwareHTable;
-import co.cask.tephra.hbase10.coprocessor.TransactionProcessor;
-
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
@@ -89,9 +86,8 @@
     @BeforeClass
     @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
     public static void doSetup() throws Exception {
-        Map<String,String> props = Maps.newHashMapWithExpectedSize(2);
+        Map<String,String> props = Maps.newHashMapWithExpectedSize(1);
         props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
-        props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Integer.toString(20));
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
         
@@ -585,107 +581,30 @@
     }
     
     @Test
-    public void testReadOnlyViewWithStats() throws Exception {
-        try (Connection conn = DriverManager.getConnection(getUrl())) {
-            String ddl = "CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
-            conn.createStatement().execute(ddl);
-            ddl = "CREATE VIEW v (v2 VARCHAR) AS SELECT * FROM t where k>5";
-            conn.createStatement().execute(ddl);
-            for (int i = 0; i < 10; i++) {
-                conn.createStatement().execute("UPSERT INTO t VALUES(" + i + ")");
-            }
-            conn.commit();
-            
-            // verify rows are visible for stats
-            analyzeTable(conn, "v", true);
-            List<KeyRange> splits = getAllSplits(conn, "v");
-            assertEquals(4, splits.size());
-            
-            int count = 0;
-            ResultSet rs = conn.createStatement().executeQuery("SELECT k FROM t");
-            while (rs.next()) {
-                assertEquals(count++, rs.getInt(1));
-            }
-            assertEquals(10, count);
-            
-            count = 0;
-            rs = conn.createStatement().executeQuery("SELECT k FROM v");
-            while (rs.next()) {
-                assertEquals(6+count++, rs.getInt(1));
-            }
-            assertEquals(4, count);
+    public void testReadOnlyView() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        String ddl = "CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
+        conn.createStatement().execute(ddl);
+        ddl = "CREATE VIEW v (v2 VARCHAR) AS SELECT * FROM t where k>4";
+        conn.createStatement().execute(ddl);
+        for (int i = 0; i < 10; i++) {
+            conn.createStatement().execute("UPSERT INTO t VALUES(" + i + ")");
         }
-    }
-    
-    @Test
-    public void testReadOwnWritesWithStats() throws Exception {
-        try (Connection conn1 = DriverManager.getConnection(getUrl()); 
-                Connection conn2 = DriverManager.getConnection(getUrl())) {
-            String ddl = "CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
-            conn1.createStatement().execute(ddl);
-            ddl = "CREATE VIEW v (v2 VARCHAR) AS SELECT * FROM t where k>5";
-            conn1.createStatement().execute(ddl);
-            for (int i = 0; i < 10; i++) {
-                conn1.createStatement().execute("UPSERT INTO t VALUES(" + i + ")");
-            }
-    
-            // verify you can read your own writes
-            int count = 0;
-            ResultSet rs = conn1.createStatement().executeQuery("SELECT k FROM t");
-            while (rs.next()) {
-                assertEquals(count++, rs.getInt(1));
-            }
-            assertEquals(10, count);
-            
-            count = 0;
-            rs = conn1.createStatement().executeQuery("SELECT k FROM v");
-            while (rs.next()) {
-                assertEquals(6+count++, rs.getInt(1));
-            }
-            assertEquals(4, count);
-            
-            // verify stats can see the read own writes rows
-            analyzeTable(conn2, "v", true);
-            List<KeyRange> splits = getAllSplits(conn2, "v");
-            assertEquals(4, splits.size());
+        conn.commit();
+        
+        int count = 0;
+        ResultSet rs = conn.createStatement().executeQuery("SELECT k FROM t");
+        while (rs.next()) {
+            assertEquals(count++, rs.getInt(1));
         }
-    }
-    
-    @Test
-    public void testInvalidRowsWithStats() throws Exception {
-        try (Connection conn1 = DriverManager.getConnection(getUrl()); 
-                Connection conn2 = DriverManager.getConnection(getUrl())) {
-            String ddl = "CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
-            conn1.createStatement().execute(ddl);
-            ddl = "CREATE VIEW v (v2 VARCHAR) AS SELECT * FROM t where k>5";
-            conn1.createStatement().execute(ddl);
-            for (int i = 0; i < 10; i++) {
-                conn1.createStatement().execute("UPSERT INTO t VALUES(" + i + ")");
-            }
-    
-            // verify you can read your own writes
-            int count = 0;
-            ResultSet rs = conn1.createStatement().executeQuery("SELECT k FROM t");
-            while (rs.next()) {
-                assertEquals(count++, rs.getInt(1));
-            }
-            assertEquals(10, count);
-            
-            count = 0;
-            rs = conn1.createStatement().executeQuery("SELECT k FROM v");
-            while (rs.next()) {
-                assertEquals(6+count++, rs.getInt(1));
-            }
-            assertEquals(4, count);
-            
-            Thread.sleep(DEFAULT_TXN_TIMEOUT_SECONDS*1000+20000);
-            assertEquals("There should be one invalid transaction", 1, txManager.getInvalidSize());
-            
-            // verify stats can see the rows from the invalid transaction
-            analyzeTable(conn2, "v", true);
-            List<KeyRange> splits = getAllSplits(conn2, "v");
-            assertEquals(4, splits.size());
+        assertEquals(10, count);
+        
+        count = 0;
+        rs = conn.createStatement().executeQuery("SELECT k FROM v");
+        while (rs.next()) {
+            assertEquals(5+count++, rs.getInt(1));
         }
+        assertEquals(5, count);
     }
     
     @Test