phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: Parameterize transactional tests for both Tephra and Omid
Date Thu, 14 Jun 2018 20:11:33 GMT
Repository: phoenix
Updated Branches:
  refs/heads/omid2 f92519156 -> a7cd47da6


Parameterize transactional tests for both Tephra and Omid


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

Branch: refs/heads/omid2
Commit: a7cd47da6a8fb849358f0fd5b7b0a324d66584d2
Parents: f925191
Author: James Taylor <jamestaylor@apache.org>
Authored: Thu Jun 14 22:09:30 2018 +0200
Committer: James Taylor <jamestaylor@apache.org>
Committed: Thu Jun 14 22:09:30 2018 +0200

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/IndexToolIT.java |  18 +-
 .../phoenix/end2end/TransactionalViewIT.java    |  23 ++-
 .../apache/phoenix/execute/PartialCommitIT.java | 186 +++++++++----------
 .../org/apache/phoenix/rpc/UpdateCacheIT.java   |  15 +-
 4 files changed, 121 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a7cd47da/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
index a120aaa..3cba9c4 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
@@ -71,15 +71,13 @@ public class IndexToolIT extends ParallelStatsEnabledIT {
     private final boolean transactional;
     private final boolean directApi;
     private final String tableDDLOptions;
-    private final boolean mutable;
     private final boolean useSnapshot;
 
-    public IndexToolIT(boolean transactional, boolean mutable, boolean localIndex,
+    public IndexToolIT(String transactionProvider, boolean mutable, boolean localIndex,
             boolean directApi, boolean useSnapshot) {
         this.localIndex = localIndex;
-        this.transactional = transactional;
+        this.transactional = transactionProvider != null;
         this.directApi = directApi;
-        this.mutable = mutable;
         this.useSnapshot = useSnapshot;
         StringBuilder optionBuilder = new StringBuilder();
         if (!mutable) {
@@ -89,7 +87,7 @@ public class IndexToolIT extends ParallelStatsEnabledIT {
             if (!(optionBuilder.length() == 0)) {
                 optionBuilder.append(",");
             }
-            optionBuilder.append(" TRANSACTIONAL=true ");
+            optionBuilder.append(" TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider
+ "'");
         }
         optionBuilder.append(" SPLIT ON(1,2)");
         this.tableDDLOptions = optionBuilder.toString();
@@ -108,16 +106,16 @@ public class IndexToolIT extends ParallelStatsEnabledIT {
     }
 
     @Parameters(
-            name = "transactional = {0} , mutable = {1} , localIndex = {2}, directApi = {3},
useSnapshot = {4}")
-    public static Collection<Boolean[]> data() {
-        List<Boolean[]> list = Lists.newArrayListWithExpectedSize(16);
+            name = "transactionProvider={0},mutable={1},localIndex={2},directApi={3},useSnapshot={4}")
+    public static Collection<Object[]> data() {
+        List<Object[]> list = Lists.newArrayListWithExpectedSize(48);
         boolean[] Booleans = new boolean[] { false, true };
-        for (boolean transactional : Booleans) {
+        for (Object transactionProvider : new String[] {"TEPHRA", "OMID", null}) {
             for (boolean mutable : Booleans) {
                 for (boolean localIndex : Booleans) {
                     for (boolean directApi : Booleans) {
                         for (boolean useSnapshot : Booleans) {
-                            list.add(new Boolean[] { transactional, mutable, localIndex,
directApi, useSnapshot });
+                            list.add(new Object[] { transactionProvider, mutable, localIndex,
directApi, useSnapshot });
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a7cd47da/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
index b8c028b..5a0c6e2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.phoenix.query.KeyRange;
@@ -31,12 +33,27 @@ import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(Parameterized.class)
 public class TransactionalViewIT extends ParallelStatsEnabledIT {
 
     private String fullTableName;
     private String fullViewName;
-
+    private final String transactionProvider;
+      
+    public TransactionalViewIT(String transactionProvider) {
+        this.transactionProvider = transactionProvider;
+    }
+    
+    @Parameters(name="TransactionalViewIT_transactionProvider={0}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] { 
+                 {"TEPHRA"},{"OMID"}});
+    }
+    
     @Before
     public void generateTableNames() {
         String schemaName = TestUtil.DEFAULT_SCHEMA_NAME;
@@ -51,7 +68,7 @@ public class TransactionalViewIT extends ParallelStatsEnabledIT {
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
             String ddl = "CREATE TABLE " + fullTableName
-                    + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
+                    + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true,TRANSACTION_PROVIDER='"
+ transactionProvider + "'";
             conn1.createStatement().execute(ddl);
             ddl = "CREATE VIEW " + fullViewName + " (v2 VARCHAR) AS SELECT * FROM " + fullTableName
+ " where k>5";
             conn1.createStatement().execute(ddl);
@@ -86,7 +103,7 @@ public class TransactionalViewIT extends ParallelStatsEnabledIT {
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
             String ddl = "CREATE TABLE " + fullTableName
-                    + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true";
+                    + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true,TRANSACTION_PROVIDER='"
+ transactionProvider + "'";
             conn1.createStatement().execute(ddl);
             ddl = "CREATE VIEW " + fullViewName + " (v2 VARCHAR) AS SELECT * FROM " + fullTableName
+ " where k>5";
             conn1.createStatement().execute(ddl);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a7cd47da/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
index b08924d..4da9de7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -18,7 +18,6 @@
 package org.apache.phoenix.execute;
 
 import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Sets.newHashSet;
 import static java.util.Collections.singletonList;
 import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_MUTATION_BATCH_FAILED_COUNT;
 import static org.apache.phoenix.monitoring.MetricType.MUTATION_BATCH_FAILED_SIZE;
@@ -28,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -36,11 +36,9 @@ import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseIOException;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Mutation;
@@ -50,7 +48,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
 import org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.end2end.BaseOwnClusterIT;
+import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT;
 import org.apache.phoenix.execute.MutationState.MultiRowMutationState;
 import org.apache.phoenix.hbase.index.Indexer;
 import org.apache.phoenix.jdbc.PhoenixConnection;
@@ -60,8 +58,6 @@ import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.TableRef;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
-import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -70,27 +66,23 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 @RunWith(Parameterized.class)
 // Needs to extend BaseOwnClusterIT due to installation of FailingRegionObserver coprocessor
-public class PartialCommitIT extends BaseOwnClusterIT {
+public class PartialCommitIT extends BaseUniqueNamesOwnClusterIT {
     
-	private final String A_SUCESS_TABLE;
-	private final String B_FAILURE_TABLE;
-	private final String C_SUCESS_TABLE;
-    private final String UPSERT_TO_FAIL;
-    private final String UPSERT_SELECT_TO_FAIL;
-    private final String DELETE_TO_FAIL;
+	private final String aSuccessTable;
+	private final String bFailureTable;
+	private final String cSuccessTable;
+    private final String upsertToFail;
+    private final String upsertSelectToFail;
+    private final String deleteToFail;
     private static final String TABLE_NAME_TO_FAIL = "B_FAILURE_TABLE";
     private static final byte[] ROW_TO_FAIL_UPSERT_BYTES = Bytes.toBytes("fail me upsert");
     private static final byte[] ROW_TO_FAIL_DELETE_BYTES = Bytes.toBytes("fail me delete");
-    private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
     
-    @Override
-    @After
-    public void cleanUpAfterTest() throws Exception {}
-
     @BeforeClass
     public static void doSetup() throws Exception {
         Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(3);
@@ -101,65 +93,55 @@ public class PartialCommitIT extends BaseOwnClusterIT {
         clientProps.put(QueryServices.TRANSACTIONS_ENABLED, "true");
         clientProps.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true));
         setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator()));
-        createTablesWithABitOfData();
-    }
-    
-    @Parameters(name="PartialCommitIT_transactional={0}") // name is used by failsafe as
file name in reports
-    public static Collection<Boolean> data() {
-        return Arrays.asList(false, true);
     }
     
     private final boolean transactional;
+    private final String transactionProvider;
     
-    public PartialCommitIT(boolean transactional) {
-        this.transactional = transactional;
-		if (transactional) {
-			A_SUCESS_TABLE = "A_SUCCESS_TABLE_TXN";
-			B_FAILURE_TABLE = TABLE_NAME_TO_FAIL+"_TXN";
-			C_SUCESS_TABLE = "C_SUCCESS_TABLE_TXN";
-		}
-		else {
-			A_SUCESS_TABLE = "A_SUCCESS_TABLE";
-			B_FAILURE_TABLE = TABLE_NAME_TO_FAIL;
-			C_SUCESS_TABLE = "C_SUCCESS_TABLE";
-		}
-	    UPSERT_TO_FAIL = "upsert into " + B_FAILURE_TABLE + " values ('" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES)
+ "', 'boom!')";
-	    UPSERT_SELECT_TO_FAIL = "upsert into " + B_FAILURE_TABLE + " select k, c from a_success_table";
-	    DELETE_TO_FAIL = "delete from " + B_FAILURE_TABLE + "  where k='" + Bytes.toString(ROW_TO_FAIL_DELETE_BYTES)
+ "'";
+    @Parameters(name="PartialCommitIT_transactionProvider={0}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] { 
+                 {"TEPHRA"},{"OMID"}});
+    }
+    
+    public PartialCommitIT(String transactionProvider) {
+        this.transactionProvider = transactionProvider;
+        this.transactional = transactionProvider != null;
+		aSuccessTable = generateUniqueName();
+		bFailureTable = TABLE_NAME_TO_FAIL + generateUniqueName();
+		cSuccessTable = generateUniqueName();
+	    upsertToFail = "upsert into " + bFailureTable + " values ('" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES)
+ "', 'boom!')";
+	    upsertSelectToFail = "upsert into " + bFailureTable + " select k, c from " + aSuccessTable;
+	    deleteToFail = "delete from " + bFailureTable + "  where k='" + Bytes.toString(ROW_TO_FAIL_DELETE_BYTES)
+ "'";
 	}
     
-    private static void createTablesWithABitOfData() throws Exception {
-        try (Connection con = driver.connect(url, new Properties())) {
+    private void createTables() throws Exception {
+        try (Connection con = DriverManager.getConnection(getUrl())) {
             Statement sta = con.createStatement();
-            sta.execute("create table a_success_table (k varchar primary key, c varchar)");
-            sta.execute("create table b_failure_table (k varchar primary key, c varchar)");
-            sta.execute("create table c_success_table (k varchar primary key, c varchar)");
-            sta.execute("create table a_success_table_txn (k varchar primary key, c varchar)
TRANSACTIONAL=true");
-            sta.execute("create table b_failure_table_txn (k varchar primary key, c varchar)
TRANSACTIONAL=true");
-            sta.execute("create table c_success_table_txn (k varchar primary key, c varchar)
TRANSACTIONAL=true");
-            con.commit();
+            sta.execute("create table " + aSuccessTable + " (k varchar primary key, c varchar)"
+ (transactional ? (" TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider + "'")
: ""));
+            sta.execute("create table " + bFailureTable + " (k varchar primary key, c varchar)"
+ (transactional ? (" TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider + "'")
: ""));
+            sta.execute("create table " + cSuccessTable + " (k varchar primary key, c varchar)"
+ (transactional ? (" TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider + "'")
: ""));
         }
-
-        try (Connection con = driver.connect(url, new Properties())) {
+    }
+    
+    private void populateTables() throws Exception {
+        try (Connection con = DriverManager.getConnection(getUrl())) {
             con.setAutoCommit(false);
             Statement sta = con.createStatement();
-            for (String table : newHashSet("a_success_table", "b_failure_table", "c_success_table",

-            		"a_success_table_txn", "b_failure_table_txn", "c_success_table_txn")) {
-                sta.execute("upsert into " + table + " values ('z', 'z')");
-                sta.execute("upsert into " + table + " values ('zz', 'zz')");
-                sta.execute("upsert into " + table + " values ('zzz', 'zzz')");
+            List<String> tableNames = Lists.newArrayList(aSuccessTable, bFailureTable,
cSuccessTable);
+            for (String tableName : tableNames) {
+                sta.execute("upsert into " + tableName + " values ('z', 'z')");
+                sta.execute("upsert into " + tableName + " values ('zz', 'zz')");
+                sta.execute("upsert into " + tableName + " values ('zzz', 'zzz')");
             }
             con.commit();
         }
     }
     
-    @AfterClass
-    public static void teardownCluster() throws Exception {
-      TEST_UTIL.shutdownMiniCluster();
-    }
-    
     @Before
-    public void resetGlobalMetrics() {
+    public void resetGlobalMetrics() throws Exception {
+        createTables();
+        populateTables();
         for (GlobalMetric m : PhoenixRuntime.getGlobalPhoenixClientMetrics()) {
             m.reset();
         }
@@ -167,44 +149,44 @@ public class PartialCommitIT extends BaseOwnClusterIT {
     
     @Test
     public void testNoFailure() throws SQLException {
-        testPartialCommit(singletonList("upsert into " + A_SUCESS_TABLE + " values ('testNoFailure',
'a')"), new int[0], false, singletonList("select count(*) from " + A_SUCESS_TABLE + " where
k='testNoFailure'"),
+        testPartialCommit(singletonList("upsert into " + aSuccessTable + " values ('testNoFailure',
'a')"), new int[0], false, singletonList("select count(*) from " + aSuccessTable + " where
k='testNoFailure'"),
                                         singletonList(new Integer(1)));
     }
     
     @Test
     public void testUpsertFailure() throws SQLException {
-        testPartialCommit(newArrayList("upsert into " + A_SUCESS_TABLE + " values ('testUpsertFailure1',
'a')", 
-                                       UPSERT_TO_FAIL, 
-                                       "upsert into " + A_SUCESS_TABLE + " values ('testUpsertFailure2',
'b')"), 
+        testPartialCommit(newArrayList("upsert into " + aSuccessTable + " values ('testUpsertFailure1',
'a')", 
+                                       upsertToFail, 
+                                       "upsert into " + aSuccessTable + " values ('testUpsertFailure2',
'b')"), 
                                        transactional ? new int[] {0,1,2} : new int[]{1},
true,
-                                       newArrayList("select count(*) from " + A_SUCESS_TABLE
+ " where k like 'testUpsertFailure_'",
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
+                                       newArrayList("select count(*) from " + aSuccessTable
+ " where k like 'testUpsertFailure_'",
+                                                    "select count(*) from " + bFailureTable
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
                                        transactional ? newArrayList(new Integer(0), new Integer(0))
: newArrayList(new Integer(2), new Integer(0)));
     }
     
     @Test
     public void testUpsertSelectFailure() throws SQLException {
-        try (Connection con = driver.connect(url, new Properties())) {
-            con.createStatement().execute("upsert into " + A_SUCESS_TABLE + " values ('"
+ Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "', 'boom!')");
+        try (Connection con = DriverManager.getConnection(getUrl())) {
+            con.createStatement().execute("upsert into " + aSuccessTable + " values ('" +
Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "', 'boom!')");
             con.commit();
         }
         
-        testPartialCommit(newArrayList("upsert into " + A_SUCESS_TABLE + " values ('testUpsertSelectFailure',
'a')", 
-                                       UPSERT_SELECT_TO_FAIL), 
+        testPartialCommit(newArrayList("upsert into " + aSuccessTable + " values ('testUpsertSelectFailure',
'a')", 
+                                       upsertSelectToFail), 
                                        transactional ? new int[] {0,1} : new int[]{1}, true,

-                                       newArrayList("select count(*) from " + A_SUCESS_TABLE
+ " where k in ('testUpsertSelectFailure', '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) +
"')",
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
+                                       newArrayList("select count(*) from " + aSuccessTable
+ " where k in ('testUpsertSelectFailure', '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) +
"')",
+                                                    "select count(*) from " + bFailureTable
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
                                        transactional ? newArrayList(new Integer(1) /* from
commit above */, new Integer(0)) : newArrayList(new Integer(2), new Integer(0)));
     }
     
     @Test
     public void testDeleteFailure() throws SQLException {
-        testPartialCommit(newArrayList("upsert into " + A_SUCESS_TABLE + " values ('testDeleteFailure1',
'a')", 
-                                       DELETE_TO_FAIL,
-                                       "upsert into " + A_SUCESS_TABLE + " values ('testDeleteFailure2',
'b')"), 
+        testPartialCommit(newArrayList("upsert into " + aSuccessTable + " values ('testDeleteFailure1',
'a')", 
+                                       deleteToFail,
+                                       "upsert into " + aSuccessTable + " values ('testDeleteFailure2',
'b')"), 
                                        transactional ? new int[] {0,1,2} : new int[]{1},
true, 
-                                       newArrayList("select count(*) from " + A_SUCESS_TABLE
+ " where k like 'testDeleteFailure_'",
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = 'z'"),
+                                       newArrayList("select count(*) from " + aSuccessTable
+ " where k like 'testDeleteFailure_'",
+                                                    "select count(*) from " + bFailureTable
+ " where k = 'z'"),
                                        transactional ? newArrayList(new Integer(0), new Integer(1)
/* original row */) : newArrayList(new Integer(2), new Integer(1)));
     }
     
@@ -214,27 +196,27 @@ public class PartialCommitIT extends BaseOwnClusterIT {
      */
     @Test
     public void testOrderOfMutationsIsPredicatable() throws SQLException {
-        testPartialCommit(newArrayList("upsert into " + C_SUCESS_TABLE + " values ('testOrderOfMutationsIsPredicatable',
'c')", // will fail because c_success_table is after b_failure_table by table sort order
-                                       UPSERT_TO_FAIL, 
-                                       "upsert into " + A_SUCESS_TABLE + " values ('testOrderOfMutationsIsPredicatable',
'a')"), // will succeed because a_success_table is before b_failure_table by table sort order
+        testPartialCommit(newArrayList("upsert into " + cSuccessTable + " values ('testOrderOfMutationsIsPredicatable',
'c')", // will fail because c_success_table is after b_failure_table by table sort order
+                                       upsertToFail, 
+                                       "upsert into " + aSuccessTable + " values ('testOrderOfMutationsIsPredicatable',
'a')"), // will succeed because a_success_table is before b_failure_table by table sort order
                                        transactional ? new int[] {0,1,2} : new int[]{0,1},
true, 
-                                       newArrayList("select count(*) from " + C_SUCESS_TABLE
+ " where k='testOrderOfMutationsIsPredicatable'",
-                                                    "select count(*) from " + A_SUCESS_TABLE
+ " where k='testOrderOfMutationsIsPredicatable'",
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
+                                       newArrayList("select count(*) from " + cSuccessTable
+ " where k='testOrderOfMutationsIsPredicatable'",
+                                                    "select count(*) from " + aSuccessTable
+ " where k='testOrderOfMutationsIsPredicatable'",
+                                                    "select count(*) from " + bFailureTable
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'"),
                                        transactional ? newArrayList(new Integer(0), new Integer(0),
new Integer(0)) : newArrayList(new Integer(0), new Integer(1), new Integer(0)));
     }
     
     @Test
     public void testStatementOrderMaintainedInConnection() throws SQLException {
-        testPartialCommit(newArrayList("upsert into " + A_SUCESS_TABLE + " values ('testStatementOrderMaintainedInConnection',
'a')", 
-                                       "upsert into " + A_SUCESS_TABLE + " select k, c from
" + C_SUCESS_TABLE,
-                                       DELETE_TO_FAIL,
-                                       "select * from " + A_SUCESS_TABLE + "", 
-                                       UPSERT_TO_FAIL), 
+        testPartialCommit(newArrayList("upsert into " + aSuccessTable + " values ('testStatementOrderMaintainedInConnection',
'a')", 
+                                       "upsert into " + aSuccessTable + " select k, c from
" + cSuccessTable,
+                                       deleteToFail,
+                                       "select * from " + aSuccessTable + "", 
+                                       upsertToFail), 
                                        transactional ? new int[] {0,1,2,4} : new int[]{2,4},
true, 
-                                       newArrayList("select count(*) from " + A_SUCESS_TABLE
+ " where k='testStatementOrderMaintainedInConnection' or k like 'z%'", // rows left: zz,
zzz, checkThatAllStatementTypesMaintainOrderInConnection
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'",
-                                                    "select count(*) from " + B_FAILURE_TABLE
+ " where k = 'z'"),
+                                       newArrayList("select count(*) from " + aSuccessTable
+ " where k='testStatementOrderMaintainedInConnection' or k like 'z%'", // rows left: zz,
zzz, checkThatAllStatementTypesMaintainOrderInConnection
+                                                    "select count(*) from " + bFailureTable
+ " where k = '" + Bytes.toString(ROW_TO_FAIL_UPSERT_BYTES) + "'",
+                                                    "select count(*) from " + bFailureTable
+ " where k = 'z'"),
                                        transactional ? newArrayList(new Integer(3) /* original
rows */, new Integer(0), new Integer(1) /* original row */) : newArrayList(new Integer(4),
new Integer(0), new Integer(1)));
     }
     
@@ -263,7 +245,7 @@ public class PartialCommitIT extends BaseOwnClusterIT {
                 int[] uncommittedStatementIndexes = ((CommitException)sqle).getUncommittedStatementIndexes();
                 assertArrayEquals(expectedUncommittedStatementIndexes, uncommittedStatementIndexes);
                 Map<String, Map<MetricType, Long>> mutationWriteMetrics = PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(con);
-                assertEquals(expectedUncommittedStatementIndexes.length, mutationWriteMetrics.get(B_FAILURE_TABLE).get(MUTATION_BATCH_FAILED_SIZE).intValue());
+                assertEquals(expectedUncommittedStatementIndexes.length, mutationWriteMetrics.get(bFailureTable).get(MUTATION_BATCH_FAILED_SIZE).intValue());
                 assertEquals(expectedUncommittedStatementIndexes.length, GLOBAL_MUTATION_BATCH_FAILED_COUNT.getMetric().getTotalSum());
             }
             
@@ -281,16 +263,16 @@ public class PartialCommitIT extends BaseOwnClusterIT {
     }
     
     private PhoenixConnection getConnectionWithTableOrderPreservingMutationState() throws
SQLException {
-        Connection con = driver.connect(url, new Properties());
-        PhoenixConnection phxCon = new PhoenixConnection(con.unwrap(PhoenixConnection.class));
-        final Map<TableRef, MultiRowMutationState> mutations = Maps.newTreeMap(new
TableRefComparator());
-        // passing a null mutation state forces the connection.newMutationState() to be used
to create the MutationState
-        return new PhoenixConnection(phxCon, null) {
-            @Override
-            protected MutationState newMutationState(int maxSize, int maxSizeBytes) {
-                return new MutationState(maxSize, maxSizeBytes, this, mutations, false, null);
+        try (PhoenixConnection con = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class))
{
+            final Map<TableRef, MultiRowMutationState> mutations = Maps.newTreeMap(new
TableRefComparator());
+            // passing a null mutation state forces the connection.newMutationState() to
be used to create the MutationState
+            return new PhoenixConnection(con, null) {
+                @Override
+                protected MutationState newMutationState(int maxSize, int maxSizeBytes) {
+                    return new MutationState(maxSize, maxSizeBytes, this, mutations, false,
null);
+                };
             };
-        };
+        }
     }
 
     public static class FailingRegionObserver extends SimpleRegionObserver {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a7cd47da/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
index e6a2f7d..c9b09e9 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java
@@ -19,7 +19,6 @@ package org.apache.phoenix.rpc;
 
 import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.apache.phoenix.util.TestUtil.TRANSACTIONAL_DATA_TABLE;
 import static org.junit.Assert.assertFalse;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Matchers.eq;
@@ -42,6 +41,7 @@ import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.schema.MetaDataClient;
 import org.apache.phoenix.schema.PName;
 import org.apache.phoenix.schema.types.PVarchar;
+import org.apache.phoenix.transaction.TransactionFactory;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
@@ -49,7 +49,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 /**
- * Verifies the number of rpcs calls from {@link MetaDataClient} updateCache() 
+ * Verifies the number of RPC calls from {@link MetaDataClient} updateCache() 
  * for transactional and non-transactional tables.
  */
 public class UpdateCacheIT extends ParallelStatsDisabledIT {
@@ -66,10 +66,13 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT {
     
     @Test
     public void testUpdateCacheForTxnTable() throws Exception {
-        String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + TRANSACTIONAL_DATA_TABLE;
-        Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
-        conn.createStatement().execute("create table " + fullTableName + TestUtil.TEST_TABLE_SCHEMA
+ "TRANSACTIONAL=true");
-        helpTestUpdateCache(fullTableName, new int[] {1, 1});
+        for (TransactionFactory.Provider provider : TransactionFactory.Provider.values())
{
+            String tableName = generateUniqueName();
+            String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + tableName;
+            Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
+            conn.createStatement().execute("create table " + fullTableName + TestUtil.TEST_TABLE_SCHEMA
+ "TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + provider + "'");
+            helpTestUpdateCache(fullTableName, new int[] {1, 1});
+        }
     }
     
     @Test


Mime
View raw message