Repository: phoenix
Updated Branches:
  refs/heads/master 9e5cd3ffe -> 1d4025a57


PHOENIX-4196 Remove SCN usage from ToNumberFunctionIT, TruncateFunctionIT and 
UpdateCacheAcrossDifferentClientsIT


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

Branch: refs/heads/master
Commit: 1d4025a57daedeebb64ef735b1055ebc9c6b2131
Parents: 9e5cd3f
Author: Samarth Jain <[email protected]>
Authored: Mon Sep 11 16:53:16 2017 -0700
Committer: Samarth Jain <[email protected]>
Committed: Mon Sep 11 16:53:16 2017 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/ToNumberFunctionIT.java     | 273 +++++++++----------
 .../phoenix/end2end/TruncateFunctionIT.java     |  26 +-
 .../UpdateCacheAcrossDifferentClientsIT.java    |  69 -----
 3 files changed, 144 insertions(+), 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d4025a5/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java
index 90b860b..3d025b6 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java
@@ -17,7 +17,6 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -31,14 +30,10 @@ import java.sql.ResultSet;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Locale;
-import java.util.Properties;
 
 import org.apache.phoenix.expression.function.ToNumberFunction;
 import org.apache.phoenix.schema.types.PDecimal;
-import org.apache.phoenix.util.PhoenixRuntime;
-import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.AfterClass;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -50,36 +45,34 @@ import org.junit.Test;
  * @since 0.1
  */
 
-public class ToNumberFunctionIT extends BaseClientManagedTimeIT {
+public class ToNumberFunctionIT extends ParallelStatsDisabledIT {
 
     // This test changes to locale to en_US, and saves the previous locale here
     private static Locale saveLocale;
 
-    public static final String TO_NUMBER_TABLE_NAME = "TO_NUMBER_TABLE";
-    
-    public static final String TO_NUMBER_TABLE_DDL = "create table " + 
TO_NUMBER_TABLE_NAME +
-        "(a_id integer not null, \n" + 
-        "a_string char(4) not null, \n" +
-        "b_string char(4), \n" + 
-        "a_date date, \n" + 
-        "a_time date, \n" + 
-        "a_timestamp timestamp \n" + 
-        "CONSTRAINT my_pk PRIMARY KEY (a_id, a_string))";
-    
-    private Date row1Date;
-    private Date row2Date;
-    private Date row3Date;
-    private Time row1Time;
-    private Time row2Time;
-    private Time row3Time;
-    private Timestamp row1Timestamp;
-    private Timestamp row2Timestamp;
-    private Timestamp row3Timestamp;
+    public static final String TO_NUMBER_TABLE_NAME = generateUniqueName();
+
+    public static final String TO_NUMBER_TABLE_DDL =
+            "create table " + TO_NUMBER_TABLE_NAME + "(a_id integer not null, 
\n"
+                    + "a_string char(4) not null, \n" + "b_string char(4), \n" 
+ "a_date date, \n"
+                    + "a_time date, \n" + "a_timestamp timestamp \n"
+                    + "CONSTRAINT my_pk PRIMARY KEY (a_id, a_string))";
+
+    private static Date row1Date;
+    private static Date row2Date;
+    private static Date row3Date;
+    private static Time row1Time;
+    private static Time row2Time;
+    private static Time row3Time;
+    private static Timestamp row1Timestamp;
+    private static Timestamp row2Timestamp;
+    private static Timestamp row3Timestamp;
 
     @BeforeClass
-    public static void setUpBeforeClass() {
+    public static void setUpBeforeClass() throws Exception {
         saveLocale = Locale.getDefault();
         Locale.setDefault(Locale.US);
+        initTable();
     }
 
     @AfterClass
@@ -87,218 +80,224 @@ public class ToNumberFunctionIT extends 
BaseClientManagedTimeIT {
         Locale.setDefault(saveLocale);
     }
 
-    @Before
-    public void initTable() throws Exception {
-        long ts = nextTimestamp();
-        createTestTable(getUrl(), TO_NUMBER_TABLE_DDL, null, ts-2);
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" 
+ ts;
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
-        conn.setAutoCommit(false);
-        
-        PreparedStatement stmt = conn.prepareStatement(
-                "upsert into " + TO_NUMBER_TABLE_NAME +
-                "    (a_id, " +
-                "    a_string," +
-                "    b_string," +
-                "    a_date," +
-                "    a_time," +
-                "    a_timestamp)" +
-                "VALUES (?, ?, ?, ?, ?, ?)");
-        
-        stmt.setInt(1, 1);
-        stmt.setString(2, "   1");
-        stmt.setString(3, "   1");
-        row1Date = new Date(System.currentTimeMillis() - 1000);
-        row1Time = new Time(System.currentTimeMillis() - 1000);
-        row1Timestamp = new Timestamp(System.currentTimeMillis() + 10000);
-        stmt.setDate(4, row1Date);
-        stmt.setTime(5, row1Time);
-        stmt.setTimestamp(6, row1Timestamp);
-        stmt.execute();
-        
-        stmt.setInt(1, 2);
-        stmt.setString(2, " 2.2");
-        stmt.setString(3, " 2.2");
-        row2Date = new Date(System.currentTimeMillis() - 10000);
-        row2Time = new Time(System.currentTimeMillis() - 1234);
-        row2Timestamp = new Timestamp(System.currentTimeMillis() + 1234567);
-        stmt.setDate(4, row2Date);
-        stmt.setTime(5, row2Time);
-        stmt.setTimestamp(6, row2Timestamp);
-        stmt.execute();
-        
-        stmt.setInt(1, 3);
-        stmt.setString(2, "$3.3");
-        stmt.setString(3, "$3.3");
-        row3Date = new Date(System.currentTimeMillis() - 100);
-        row3Time = new Time(System.currentTimeMillis() - 789);
-        row3Timestamp = new Timestamp(System.currentTimeMillis() + 78901);
-        stmt.setDate(4, row3Date);
-        stmt.setTime(5, row3Time);
-        stmt.setTimestamp(6, row3Timestamp);
-        stmt.execute();
-        
-        conn.commit();
-        conn.close();
+    public static void initTable() throws Exception {
+        createTestTable(getUrl(), TO_NUMBER_TABLE_DDL, null, null);
+        try (Connection conn = DriverManager.getConnection(url)) {
+            conn.setAutoCommit(false);
+
+            PreparedStatement stmt =
+                    conn.prepareStatement("upsert into " + 
TO_NUMBER_TABLE_NAME + "    (a_id, "
+                            + "    a_string," + "    b_string," + "    
a_date," + "    a_time,"
+                            + "    a_timestamp)" + "VALUES (?, ?, ?, ?, ?, 
?)");
+
+            stmt.setInt(1, 1);
+            stmt.setString(2, "   1");
+            stmt.setString(3, "   1");
+            row1Date = new Date(System.currentTimeMillis() - 1000);
+            row1Time = new Time(System.currentTimeMillis() - 1000);
+            row1Timestamp = new Timestamp(System.currentTimeMillis() + 10000);
+            stmt.setDate(4, row1Date);
+            stmt.setTime(5, row1Time);
+            stmt.setTimestamp(6, row1Timestamp);
+            stmt.execute();
+
+            stmt.setInt(1, 2);
+            stmt.setString(2, " 2.2");
+            stmt.setString(3, " 2.2");
+            row2Date = new Date(System.currentTimeMillis() - 10000);
+            row2Time = new Time(System.currentTimeMillis() - 1234);
+            row2Timestamp = new Timestamp(System.currentTimeMillis() + 
1234567);
+            stmt.setDate(4, row2Date);
+            stmt.setTime(5, row2Time);
+            stmt.setTimestamp(6, row2Timestamp);
+            stmt.execute();
+
+            stmt.setInt(1, 3);
+            stmt.setString(2, "$3.3");
+            stmt.setString(3, "$3.3");
+            row3Date = new Date(System.currentTimeMillis() - 100);
+            row3Time = new Time(System.currentTimeMillis() - 789);
+            row3Timestamp = new Timestamp(System.currentTimeMillis() + 78901);
+            stmt.setDate(4, row3Date);
+            stmt.setTime(5, row3Time);
+            stmt.setTimestamp(6, row3Timestamp);
+            stmt.execute();
+            conn.commit();
+        }
     }
 
     @Test
     public void testKeyFilterWithIntegerValue() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_string) = 1";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_string) = 1";
         int expectedId = 1;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testKeyFilterWithDoubleValue() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_string) = 2.2";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_string) = 2.2";
         int expectedId = 2;
         runOneRowQueryTest(query, expectedId);
     }
 
     @Test
     public void testNonKeyFilterWithIntegerValue() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(b_string) = 1";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(b_string) = 1";
         int expectedId = 1;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testNonKeyFilterWithDoubleValue() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(b_string) = 2.2";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(b_string) = 2.2";
         int expectedId = 2;
         runOneRowQueryTest(query, expectedId);
     }
 
     @Test
     public void testKeyProjectionWithIntegerValue() throws Exception {
-        String query = "select to_number(a_string) from " + 
TO_NUMBER_TABLE_NAME + " where a_id = 1";
+        String query =
+                "select to_number(a_string) from " + TO_NUMBER_TABLE_NAME + " 
where a_id = 1";
         int expectedIntValue = 1;
         runOneRowQueryTest(query, expectedIntValue);
     }
-    
+
     @Test
     public void testKeyProjectionWithDecimalValue() throws Exception {
-        String query = "select to_number(a_string) from " + 
TO_NUMBER_TABLE_NAME + " where a_id = 2";
+        String query =
+                "select to_number(a_string) from " + TO_NUMBER_TABLE_NAME + " 
where a_id = 2";
         BigDecimal expectedDecimalValue = (BigDecimal) 
PDecimal.INSTANCE.toObject("2.2");
         runOneRowQueryTest(query, expectedDecimalValue);
     }
-    
+
     @Test
     public void testNonKeyProjectionWithIntegerValue() throws Exception {
-        String query = "select to_number(b_string) from " + 
TO_NUMBER_TABLE_NAME + " where a_id = 1";
+        String query =
+                "select to_number(b_string) from " + TO_NUMBER_TABLE_NAME + " 
where a_id = 1";
         int expectedIntValue = 1;
         runOneRowQueryTest(query, expectedIntValue);
     }
-    
+
     @Test
     public void testNonKeyProjectionWithDecimalValue() throws Exception {
-        String query = "select to_number(b_string) from " + 
TO_NUMBER_TABLE_NAME + " where a_id = 2";
+        String query =
+                "select to_number(b_string) from " + TO_NUMBER_TABLE_NAME + " 
where a_id = 2";
         BigDecimal expectedDecimalValue = (BigDecimal) 
PDecimal.INSTANCE.toObject("2.2");
         runOneRowQueryTest(query, expectedDecimalValue);
     }
-    
+
     @Test
     public void testKeyFilterWithPatternParam() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_string, '\u00A4###.####') = 3.3";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME
+                        + " WHERE to_number(a_string, '\u00A4###.####') = 3.3";
         int expectedId = 3;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testNonKeyFilterWithPatternParam() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(b_string, '\u00A4#.#') = 3.3";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME
+                        + " WHERE to_number(b_string, '\u00A4#.#') = 3.3";
         int expectedId = 3;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testDateFilter() throws Exception {
-       String pattern = "yyyyMMddHHmmssZ";
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_date, '" + pattern + "') = " + row1Date.getTime() ;
+        String pattern = "yyyyMMddHHmmssZ";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_date, '" + pattern
+                        + "') = " + row1Date.getTime();
         int expectedId = 1;
         runOneRowQueryTest(query, expectedId);
     }
-    
-    
+
     @Test
     public void testTimeFilter() throws Exception {
-       String pattern = "HH:mm:ss z";
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_time, '" + pattern + "') = " + row1Time.getTime() ;
+        String pattern = "HH:mm:ss z";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_time, '" + pattern
+                        + "') = " + row1Time.getTime();
         int expectedId = 1;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testDateFilterWithoutPattern() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_date) = " + row2Date.getTime() ;
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_date) = "
+                        + row2Date.getTime();
         int expectedId = 2;
         runOneRowQueryTest(query, expectedId);
     }
-    
-    
+
     @Test
     public void testTimeFilterWithoutPattern() throws Exception {
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_time) = " + row2Time.getTime() ;
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_time) = "
+                        + row2Time.getTime();
         int expectedId = 2;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testTimeStampFilter() throws Exception {
-       String pattern = "yyMMddHHmmssZ";
-        String query = "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_timestamp, '" + pattern + "') = " + row1Timestamp.getTime() ;
+        String pattern = "yyMMddHHmmssZ";
+        String query =
+                "SELECT a_id FROM " + TO_NUMBER_TABLE_NAME + " WHERE 
to_number(a_timestamp, '"
+                        + pattern + "') = " + row1Timestamp.getTime();
         int expectedId = 1;
         runOneRowQueryTest(query, expectedId);
     }
-    
+
     @Test
     public void testDateProjection() throws Exception {
         String query = "select to_number(a_date) from " + TO_NUMBER_TABLE_NAME 
+ " where a_id = 1";
         BigDecimal expectedDecimalValue = new BigDecimal(row1Date.getTime());
         runOneRowQueryTest(query, expectedDecimalValue);
     }
-    
+
     @Test
     public void testTimeProjection() throws Exception {
         String query = "select to_number(a_time) from " + TO_NUMBER_TABLE_NAME 
+ " where a_id = 2";
         BigDecimal expectedDecimalValue = new BigDecimal(row2Time.getTime());
         runOneRowQueryTest(query, expectedDecimalValue);
     }
-    
+
     @Test
     public void testTimeStampProjection() throws Exception {
-        String query = "select to_number(a_timestamp) from " + 
TO_NUMBER_TABLE_NAME + " where a_id = 3";
+        String query =
+                "select to_number(a_timestamp) from " + TO_NUMBER_TABLE_NAME + 
" where a_id = 3";
         BigDecimal expectedDecimalValue = new 
BigDecimal(row3Timestamp.getTime());
         runOneRowQueryTest(query, expectedDecimalValue);
     }
-    
-    private void runOneRowQueryTest(String oneRowQuery, BigDecimal 
expectedDecimalValue) throws Exception {
-       runOneRowQueryTest(oneRowQuery, false, null, expectedDecimalValue);
+
+    private void runOneRowQueryTest(String oneRowQuery, BigDecimal 
expectedDecimalValue)
+            throws Exception {
+        runOneRowQueryTest(oneRowQuery, false, null, expectedDecimalValue);
     }
-    
+
     private void runOneRowQueryTest(String oneRowQuery, int expectedIntValue) 
throws Exception {
-       runOneRowQueryTest(oneRowQuery, true, expectedIntValue, null);
+        runOneRowQueryTest(oneRowQuery, true, expectedIntValue, null);
     }
-    
-    private void runOneRowQueryTest(String oneRowQuery, boolean 
isIntegerColumn, Integer expectedIntValue, BigDecimal expectedDecimalValue) 
throws Exception {
-        long ts = nextTimestamp();
-        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" 
+ ts;
-        Connection conn = DriverManager.getConnection(url);
-        try {
+
+    private void runOneRowQueryTest(String oneRowQuery, boolean 
isIntegerColumn,
+            Integer expectedIntValue, BigDecimal expectedDecimalValue) throws 
Exception {
+        try (Connection conn = DriverManager.getConnection(url)) {
             PreparedStatement statement = conn.prepareStatement(oneRowQuery);
             ResultSet rs = statement.executeQuery();
-            
-            assertTrue (rs.next());
-            if (isIntegerColumn)
-               assertEquals(expectedIntValue.intValue(), rs.getInt(1));
-            else
-               assertTrue(expectedDecimalValue == rs.getBigDecimal(1) || 
(expectedDecimalValue != null && 
expectedDecimalValue.compareTo(rs.getBigDecimal(1)) == 0));
+            assertTrue(rs.next());
+            if (isIntegerColumn) assertEquals(expectedIntValue.intValue(), 
rs.getInt(1));
+            else assertTrue(
+                expectedDecimalValue == rs.getBigDecimal(1) || 
(expectedDecimalValue != null
+                        && expectedDecimalValue.compareTo(rs.getBigDecimal(1)) 
== 0));
             assertFalse(rs.next());
         }
-        finally {
-               conn.close();
-        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d4025a5/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java
index 983d086..ba8b7ab 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java
@@ -17,8 +17,6 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.phoenix.util.PhoenixRuntime.CURRENT_SCN_ATTRIB;
-import static org.apache.phoenix.util.TestUtil.ATABLE_NAME;
 import static org.apache.phoenix.util.TestUtil.ROW1;
 import static org.apache.phoenix.util.TestUtil.ROW2;
 import static org.apache.phoenix.util.TestUtil.ROW3;
@@ -33,14 +31,14 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Timestamp;
 import java.text.ParseException;
-import java.util.Properties;
 
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.util.DateUtil;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 
-public class TruncateFunctionIT extends BaseClientManagedTimeIT {
+public class TruncateFunctionIT extends ParallelStatsDisabledIT {
     private static final String DS1 = "1970-01-10 00:58:01.587";
     private static final String DS2 = "1970-01-20 01:02:45.906";
     private static final String DS3 = "1970-01-30 01:30:24.353";
@@ -55,16 +53,13 @@ public class TruncateFunctionIT extends 
BaseClientManagedTimeIT {
     
     @Test
     public void testTruncate() throws Exception {
-        long ts = nextTimestamp();
         String tenantId = getOrganizationId();
-        ensureTableCreated(getUrl(), ATABLE_NAME,ATABLE_NAME, ts-5);
-        Properties props = new Properties();
-        props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts-3));
-        Connection conn = DriverManager.getConnection(getUrl(), props);
-        try {
+        String tableName = generateUniqueName();
+        ensureTableCreated(url, tableName, TestUtil.ATABLE_NAME, null, null, 
null);
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
             PreparedStatement stmt = conn.prepareStatement(
-                    "upsert into " +
-                    "ATABLE(" +
+                    "upsert into " + tableName + 
+                    "(" +
                     "    ORGANIZATION_ID, " +
                     "    ENTITY_ID, " +
                     "    A_DATE, " +
@@ -86,11 +81,8 @@ public class TruncateFunctionIT extends 
BaseClientManagedTimeIT {
             stmt.setTimestamp(4, toTimestamp(DS3));
             stmt.execute();
             conn.commit();
-            conn.close();
             
-            props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts+1));
-            conn = DriverManager.getConnection(getUrl(), props);
-            String query = "SELECT entity_id, trunc(a_date, 'day', 7), 
trunc(a_timestamp, 'second', 10) FROM ATABLE WHERE organization_id = ?";
+            String query = "SELECT entity_id, trunc(a_date, 'day', 7), 
trunc(a_timestamp, 'second', 10) FROM " + tableName + " WHERE organization_id = 
?";
             PreparedStatement statement = conn.prepareStatement(query);
             statement.setString(1, tenantId);
             ResultSet rs = statement.executeQuery();
@@ -111,8 +103,6 @@ public class TruncateFunctionIT extends 
BaseClientManagedTimeIT {
             assertEquals(toTimestamp("1970-01-30 01:30:20.000"), 
rs.getTimestamp(3));
             
             assertFalse(rs.next());
-        } finally {
-            conn.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1d4025a5/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
index ddeebc0..25e2367 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
@@ -334,73 +334,4 @@ public class UpdateCacheAcrossDifferentClientsIT extends 
BaseUniqueNamesOwnClust
             conn2.close();
         }
     }
-
-    @Test
-    public void testUpsertSelectOnSameTableWithFutureData() throws Exception {
-        String tableName = generateUniqueName();
-        Properties longRunningProps = new Properties();
-        longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
-            QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
-        longRunningProps.put(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, 
Integer.toString(3000));
-        Connection conn = DriverManager.getConnection(getUrl(), 
longRunningProps);
-        conn.setAutoCommit(false);
-        longRunningProps = new Properties();
-        longRunningProps.put(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, 
Integer.toString(3000));
-        conn.createStatement().execute("CREATE TABLE " + tableName + "("
-                + "a VARCHAR PRIMARY KEY, b VARCHAR) 
UPDATE_CACHE_FREQUENCY=1000000000");
-        String payload;
-        StringBuilder buf = new StringBuilder();
-        for (int i = 0; i < 1; i++) {
-            buf.append('a');
-        }
-        payload = buf.toString();
-        int MIN_CHAR = 'a';
-        int MAX_CHAR = 'c';
-        PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + 
tableName + " VALUES(?,?)");
-        int rowCount = 0;
-        for (int c1 = MIN_CHAR; c1 <= MAX_CHAR; c1++) {
-            for (int c2 = MIN_CHAR; c2 <= MAX_CHAR; c2++) {
-                String pk = Character.toString((char)c1) + 
Character.toString((char)c2);
-                stmt.setString(1, pk);
-                stmt.setString(2, payload);
-                stmt.execute();
-                rowCount++;
-            }
-        }
-        conn.commit();
-        int count = conn.createStatement().executeUpdate("UPSERT INTO  " + 
tableName + "  SELECT a, b FROM  " + tableName);
-        assertEquals(rowCount, count);
-
-        //Upsert some data with future timestamp
-        longRunningProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, 
Long.toString(System.currentTimeMillis()+(24*60*60*1000)));
-        Connection conn2 = DriverManager.getConnection(getUrl(), 
longRunningProps);
-        conn2.setAutoCommit(false);
-        stmt = conn2.prepareStatement("UPSERT INTO " + tableName + " 
VALUES(?,?)");
-        MAX_CHAR = 'f';
-        int rowCount2=0;
-        for (int c1 = MIN_CHAR; c1 <= MAX_CHAR; c1++) {
-            for (int c2 = MIN_CHAR; c2 <= MAX_CHAR; c2++) {
-                String pk = "2--"+Character.toString((char)c1) + 
Character.toString((char)c2);
-                stmt.setString(1, pk);
-                stmt.setString(2, payload);
-                stmt.execute();
-                rowCount2++;
-            }
-        }
-        conn2.commit();
-
-        //Open new connection with future timestamp to see all data
-        longRunningProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, 
Long.toString(System.currentTimeMillis()+(25*60*60*1000)));
-        conn2 = DriverManager.getConnection(getUrl(), longRunningProps);
-        conn2.setAutoCommit(false);
-        count = conn2.createStatement().executeUpdate("UPSERT INTO  " + 
tableName + "  SELECT * FROM  " + tableName);
-        assertEquals(rowCount+rowCount2, count);
-        conn.close();
-        longRunningProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, 
Long.toString(System.currentTimeMillis()));
-        conn = DriverManager.getConnection(getUrl(), longRunningProps);
-        //This connection should see data only upto current time
-        count = conn.createStatement().executeUpdate("UPSERT INTO  " + 
tableName + "  SELECT * FROM  " + tableName);
-        assertEquals(rowCount, count);
-        conn2.close();
-    }
 }

Reply via email to