phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-4199 Modify SequenceIT.java to not use CurrentSCN
Date Mon, 18 Sep 2017 18:28:28 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 6bcb1802a -> c42fa1542


PHOENIX-4199 Modify SequenceIT.java to not use CurrentSCN


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

Branch: refs/heads/4.x-HBase-1.1
Commit: c42fa15423b47df2769f871f30a0bd16dd730740
Parents: 6bcb180
Author: James Taylor <jtaylor@salesforce.com>
Authored: Mon Sep 18 11:25:09 2017 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Mon Sep 18 11:27:37 2017 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/SequenceIT.java  | 47 +++++++-------------
 1 file changed, 17 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c42fa154/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
index 7a06bcd..e226491 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java
@@ -41,6 +41,7 @@ import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.SchemaNotFoundException;
 import org.apache.phoenix.schema.SequenceAlreadyExistsException;
 import org.apache.phoenix.schema.SequenceNotFoundException;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.QueryUtil;
@@ -1403,47 +1404,39 @@ public class SequenceIT extends ParallelStatsDisabledIT {
 
     @Test
     public void testPointInTimeSequence() throws Exception {
-        String sequenceName = generateNameWithSchema();    	
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn;
+        String seqName = generateNameWithSchema();    	
+        Properties scnProps = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        scnProps.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(EnvironmentEdgeManager.currentTimeMillis()));
+        Connection beforeSeqConn = DriverManager.getConnection(getUrl(), scnProps);
+
         ResultSet rs;
-        String seqName = sequenceName;
-        long ts = nextTimestamp();
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
-        conn = DriverManager.getConnection(getUrl(), props);
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.createStatement().execute("CREATE SEQUENCE " + seqName + "");
 
         try {
-            conn.createStatement().executeQuery("SELECT next value for " + seqName);
+            beforeSeqConn.createStatement().executeQuery("SELECT next value for " + seqName);
             fail();
         } catch (SequenceNotFoundException e) {
-            conn.close();
+            beforeSeqConn.close();
         }
 
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
-        conn = DriverManager.getConnection(getUrl(), props);
+        scnProps.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(EnvironmentEdgeManager.currentTimeMillis()));
+        Connection afterSeqConn = DriverManager.getConnection(getUrl(), scnProps);
+
         rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
         assertTrue(rs.next());
         assertEquals(1, rs.getInt(1));
-        conn.close();
-
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 7));
-        conn = DriverManager.getConnection(getUrl(), props);
         rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
         assertTrue(rs.next());
         assertEquals(2, rs.getInt(1));
-        conn.close();
 
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 15));
-        conn = DriverManager.getConnection(getUrl(), props);
         conn.createStatement().execute("DROP SEQUENCE " + seqName + "");
-        rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+        
+        rs = afterSeqConn.createStatement().executeQuery("SELECT next value for " + seqName);
         assertTrue(rs.next());
         assertEquals(3, rs.getInt(1));
-        conn.close();
 
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 20));
-        conn = DriverManager.getConnection(getUrl(), props);
         try {
             rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
             fail();
@@ -1451,20 +1444,14 @@ public class SequenceIT extends ParallelStatsDisabledIT {
         }
 
         conn.createStatement().execute("CREATE SEQUENCE " + seqName);
-        conn.close();
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 25));
-        conn = DriverManager.getConnection(getUrl(), props);
         rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
         assertTrue(rs.next());
         assertEquals(1, rs.getInt(1));
-        conn.close();
 
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 6));
-        conn = DriverManager.getConnection(getUrl(), props);
-        rs = conn.createStatement().executeQuery("SELECT next value for " + seqName);
+        rs = afterSeqConn.createStatement().executeQuery("SELECT next value for " + seqName);
         assertTrue(rs.next());
         assertEquals(4, rs.getInt(1));
-        conn.close();
+        afterSeqConn.close();
     }
 
 }
\ No newline at end of file


Mime
View raw message