phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/2] phoenix git commit: PHOENIX-4257 Breakup GroupByIT into several integration tests so as not to create too many tables in one test
Date Fri, 29 Sep 2017 18:32:17 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 70a985bea -> 7a332cede


PHOENIX-4257 Breakup GroupByIT into several integration tests so as not to create too many
tables in one test


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

Branch: refs/heads/4.x-HBase-0.98
Commit: c14e15d91092cda01486e2306261ab4e0da232f6
Parents: 70a985b
Author: James Taylor <jtaylor@salesforce.com>
Authored: Fri Sep 29 10:34:07 2017 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Fri Sep 29 11:30:46 2017 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/GroupByIT.java   | 151 --------------
 .../org/apache/phoenix/end2end/UngroupedIT.java | 204 +++++++++++++++++++
 2 files changed, 204 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c14e15d9/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
index 80175c4..f4e10e3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java
@@ -22,8 +22,6 @@ import static org.apache.phoenix.util.TestUtil.B_VALUE;
 import static org.apache.phoenix.util.TestUtil.C_VALUE;
 import static org.apache.phoenix.util.TestUtil.E_VALUE;
 import static org.apache.phoenix.util.TestUtil.ROW5;
-import static org.apache.phoenix.util.TestUtil.ROW6;
-import static org.apache.phoenix.util.TestUtil.ROW7;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -203,54 +201,6 @@ public class GroupByIT extends BaseQueryIT {
     }
 
     @Test
-    public void testUngroupedAggregation() throws Exception {
-        String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and
a_string = ?";
-        String url = getUrl();
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
-        try {
-            PreparedStatement statement = conn.prepareStatement(query);
-            statement.setString(1, tenantId);
-            statement.setString(2, B_VALUE);
-            ResultSet rs = statement.executeQuery();
-            assertTrue(rs.next());
-            assertEquals(4, rs.getLong(1));
-            assertFalse(rs.next());
-        } finally {
-            conn.close();
-        }
-        conn = DriverManager.getConnection(url, props);
-        try {
-            PreparedStatement statement = conn.prepareStatement(query);
-            statement.setString(1, tenantId);
-            statement.setString(2, B_VALUE);
-            ResultSet rs = statement.executeQuery();
-            assertTrue(rs.next());
-            assertEquals(4, rs.getLong(1));
-            assertFalse(rs.next());
-        } finally {
-            conn.close();
-        }
-    }
-
-    @Test
-    public void testUngroupedAggregationNoWhere() throws Exception {
-        String query = "SELECT count(*) FROM " + tableName;
-        String url = getUrl();
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(url, props);
-        try {
-            PreparedStatement statement = conn.prepareStatement(query);
-            ResultSet rs = statement.executeQuery();
-            assertTrue(rs.next());
-            assertEquals(9, rs.getLong(1));
-            assertFalse(rs.next());
-        } finally {
-            conn.close();
-        }
-    }
-
-    @Test
     public void testGroupByWithIntegerDivision1() throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
@@ -365,105 +315,4 @@ public class GroupByIT extends BaseQueryIT {
         conn.close();
     }
 
-    @Test
-    public void testPointInTimeUngroupedAggregation() throws Exception {
-        // Override value that was set at creation time
-        String url = getUrl();
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection upsertConn = DriverManager.getConnection(url, props);
-        String updateStmt =
-                "upsert into " + tableName + " (" + "    ORGANIZATION_ID, " + "    ENTITY_ID,
"
-                        + "    A_STRING) " + "VALUES (?, ?, ?)";
-        // Insert all rows at ts
-        PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
-        stmt.setString(1, tenantId);
-        stmt.setString(2, ROW5);
-        stmt.setString(3, null);
-        stmt.execute();
-        stmt.setString(3, C_VALUE);
-        stmt.execute();
-        stmt.setString(2, ROW7);
-        stmt.setString(3, E_VALUE);
-        stmt.execute();
-        upsertConn.commit();
-        upsertConn.close();
-        long upsert1Time = System.currentTimeMillis();
-        long timeDelta = 100;
-        Thread.sleep(timeDelta);
-
-        upsertConn = DriverManager.getConnection(url, props);
-        upsertConn.setAutoCommit(true); // Test auto commit
-        stmt = upsertConn.prepareStatement(updateStmt);
-        stmt.setString(1, tenantId);
-        stmt.setString(2, ROW6);
-        stmt.setString(3, E_VALUE);
-        stmt.execute();
-        upsertConn.close();
-        
-        long queryTime = upsert1Time + timeDelta / 2;
-        String query =
-                "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string
= ?";
-        // Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
-        Connection conn = DriverManager.getConnection(url, props);
-        PreparedStatement statement = conn.prepareStatement(query);
-        statement.setString(1, tenantId);
-        statement.setString(2, B_VALUE);
-        ResultSet rs = statement.executeQuery();
-        assertTrue(rs.next());
-        assertEquals(2, rs.getLong(1));
-        assertFalse(rs.next());
-        conn.close();
-    }
-
-    @Test
-    public void testPointInTimeUngroupedLimitedAggregation() throws Exception {
-        String updateStmt =
-                "upsert into " + tableName + " (" + "    ORGANIZATION_ID, " + "    ENTITY_ID,
"
-                        + "    A_STRING) " + "VALUES (?, ?, ?)";
-        String url = getUrl();
-        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
-        Connection upsertConn = DriverManager.getConnection(url, props);
-        upsertConn.setAutoCommit(true); // Test auto commit
-        PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
-        stmt.setString(1, tenantId);
-        stmt.setString(2, ROW6);
-        stmt.setString(3, C_VALUE);
-        stmt.execute();
-        stmt.setString(3, E_VALUE);
-        stmt.execute();
-        stmt.setString(3, B_VALUE);
-        stmt.execute();
-        stmt.setString(3, B_VALUE);
-        stmt.execute();
-        upsertConn.close();
-        long upsert1Time = System.currentTimeMillis();
-        long timeDelta = 100;
-        Thread.sleep(timeDelta);
-        
-        upsertConn = DriverManager.getConnection(url, props);
-        upsertConn.setAutoCommit(true); // Test auto commit
-        stmt = upsertConn.prepareStatement(updateStmt);
-        stmt.setString(1, tenantId);
-        stmt.setString(2, ROW6);
-        stmt.setString(3, E_VALUE);
-        stmt.execute();
-        upsertConn.close();
-
-        long queryTime = upsert1Time + timeDelta / 2;
-        String query =
-                "SELECT count(1) FROM " + tableName
-                        + " WHERE organization_id=? and a_string = ? LIMIT 3";
-        // Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
-        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
-        Connection conn = DriverManager.getConnection(url, props);
-        PreparedStatement statement = conn.prepareStatement(query);
-        statement.setString(1, tenantId);
-        statement.setString(2, B_VALUE);
-        ResultSet rs = statement.executeQuery();
-        assertTrue(rs.next());
-        assertEquals(4, rs.getLong(1)); // LIMIT applied at end, so all rows would be counted
-        assertFalse(rs.next());
-        conn.close();
-    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c14e15d9/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java
new file mode 100644
index 0000000..c1c6d31
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.apache.phoenix.util.TestUtil.B_VALUE;
+import static org.apache.phoenix.util.TestUtil.C_VALUE;
+import static org.apache.phoenix.util.TestUtil.E_VALUE;
+import static org.apache.phoenix.util.TestUtil.ROW5;
+import static org.apache.phoenix.util.TestUtil.ROW6;
+import static org.apache.phoenix.util.TestUtil.ROW7;
+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;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+public class UngroupedIT extends BaseQueryIT {
+
+    public UngroupedIT(String idxDdl, boolean mutable, boolean columnEncoded, boolean keepDeletedCells)
+            throws Exception {
+        super(idxDdl, mutable, columnEncoded, keepDeletedCells);
+    }
+
+    @Parameters(name="UngroupedIT_{index}") // name is used by failsafe as file name in reports
+    public static Collection<Object> data() {
+        return QueryIT.data();
+    }
+    
+    @Test
+    public void testUngroupedAggregation() throws Exception {
+        String query = "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and
a_string = ?";
+        String url = getUrl();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(url, props);
+        try {
+            PreparedStatement statement = conn.prepareStatement(query);
+            statement.setString(1, tenantId);
+            statement.setString(2, B_VALUE);
+            ResultSet rs = statement.executeQuery();
+            assertTrue(rs.next());
+            assertEquals(4, rs.getLong(1));
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
+        conn = DriverManager.getConnection(url, props);
+        try {
+            PreparedStatement statement = conn.prepareStatement(query);
+            statement.setString(1, tenantId);
+            statement.setString(2, B_VALUE);
+            ResultSet rs = statement.executeQuery();
+            assertTrue(rs.next());
+            assertEquals(4, rs.getLong(1));
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
+    }
+
+    @Test
+    public void testUngroupedAggregationNoWhere() throws Exception {
+        String query = "SELECT count(*) FROM " + tableName;
+        String url = getUrl();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(url, props);
+        try {
+            PreparedStatement statement = conn.prepareStatement(query);
+            ResultSet rs = statement.executeQuery();
+            assertTrue(rs.next());
+            assertEquals(9, rs.getLong(1));
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
+    }
+
+    @Test
+    public void testPointInTimeUngroupedAggregation() throws Exception {
+        // Override value that was set at creation time
+        String url = getUrl();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection upsertConn = DriverManager.getConnection(url, props);
+        String updateStmt =
+                "upsert into " + tableName + " (" + "    ORGANIZATION_ID, " + "    ENTITY_ID,
"
+                        + "    A_STRING) " + "VALUES (?, ?, ?)";
+        // Insert all rows at ts
+        PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
+        stmt.setString(1, tenantId);
+        stmt.setString(2, ROW5);
+        stmt.setString(3, null);
+        stmt.execute();
+        stmt.setString(3, C_VALUE);
+        stmt.execute();
+        stmt.setString(2, ROW7);
+        stmt.setString(3, E_VALUE);
+        stmt.execute();
+        upsertConn.commit();
+        upsertConn.close();
+        long upsert1Time = System.currentTimeMillis();
+        long timeDelta = 100;
+        Thread.sleep(timeDelta);
+
+        upsertConn = DriverManager.getConnection(url, props);
+        upsertConn.setAutoCommit(true); // Test auto commit
+        stmt = upsertConn.prepareStatement(updateStmt);
+        stmt.setString(1, tenantId);
+        stmt.setString(2, ROW6);
+        stmt.setString(3, E_VALUE);
+        stmt.execute();
+        upsertConn.close();
+        
+        long queryTime = upsert1Time + timeDelta / 2;
+        String query =
+                "SELECT count(1) FROM " + tableName + " WHERE organization_id=? and a_string
= ?";
+        // Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
+        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
+        Connection conn = DriverManager.getConnection(url, props);
+        PreparedStatement statement = conn.prepareStatement(query);
+        statement.setString(1, tenantId);
+        statement.setString(2, B_VALUE);
+        ResultSet rs = statement.executeQuery();
+        assertTrue(rs.next());
+        assertEquals(2, rs.getLong(1));
+        assertFalse(rs.next());
+        conn.close();
+    }
+
+    @Test
+    public void testPointInTimeUngroupedLimitedAggregation() throws Exception {
+        String updateStmt =
+                "upsert into " + tableName + " (" + "    ORGANIZATION_ID, " + "    ENTITY_ID,
"
+                        + "    A_STRING) " + "VALUES (?, ?, ?)";
+        String url = getUrl();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection upsertConn = DriverManager.getConnection(url, props);
+        upsertConn.setAutoCommit(true); // Test auto commit
+        PreparedStatement stmt = upsertConn.prepareStatement(updateStmt);
+        stmt.setString(1, tenantId);
+        stmt.setString(2, ROW6);
+        stmt.setString(3, C_VALUE);
+        stmt.execute();
+        stmt.setString(3, E_VALUE);
+        stmt.execute();
+        stmt.setString(3, B_VALUE);
+        stmt.execute();
+        stmt.setString(3, B_VALUE);
+        stmt.execute();
+        upsertConn.close();
+        long upsert1Time = System.currentTimeMillis();
+        long timeDelta = 100;
+        Thread.sleep(timeDelta);
+        
+        upsertConn = DriverManager.getConnection(url, props);
+        upsertConn.setAutoCommit(true); // Test auto commit
+        stmt = upsertConn.prepareStatement(updateStmt);
+        stmt.setString(1, tenantId);
+        stmt.setString(2, ROW6);
+        stmt.setString(3, E_VALUE);
+        stmt.execute();
+        upsertConn.close();
+
+        long queryTime = upsert1Time + timeDelta / 2;
+        String query =
+                "SELECT count(1) FROM " + tableName
+                        + " WHERE organization_id=? and a_string = ? LIMIT 3";
+        // Specify CurrentSCN on URL with extra stuff afterwards (which should be ignored)
+        props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(queryTime));
+        Connection conn = DriverManager.getConnection(url, props);
+        PreparedStatement statement = conn.prepareStatement(query);
+        statement.setString(1, tenantId);
+        statement.setString(2, B_VALUE);
+        ResultSet rs = statement.executeQuery();
+        assertTrue(rs.next());
+        assertEquals(4, rs.getLong(1)); // LIMIT applied at end, so all rows would be counted
+        assertFalse(rs.next());
+        conn.close();
+    }
+}


Mime
View raw message