Repository: phoenix Updated Branches: refs/heads/master 26a7b9e8b -> 4c2674b1d
PHOENIX-4208 Modify tests 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/4c2674b1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4c2674b1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4c2674b1 Branch: refs/heads/master Commit: 4c2674b1ddc679d897933fd266273bf8c50db21c Parents: 26a7b9e Author: James Taylor <jtay...@salesforce.com> Authored: Wed Sep 13 17:48:21 2017 -0700 Committer: James Taylor <jtay...@salesforce.com> Committed: Wed Sep 13 17:48:21 2017 -0700 ---------------------------------------------------------------------- .../apache/phoenix/end2end/DropSchemaIT.java | 80 +++++++------------- .../org/apache/phoenix/end2end/GroupByIT.java | 26 ------- .../apache/phoenix/end2end/MutableQueryIT.java | 4 +- .../phoenix/end2end/ReadIsolationLevelIT.java | 46 ++++++----- .../end2end/RebuildIndexConnectionPropsIT.java | 2 - .../org/apache/phoenix/end2end/ScanQueryIT.java | 21 +++++ .../apache/phoenix/end2end/StoreNullsIT.java | 5 +- .../org/apache/phoenix/rpc/UpdateCacheIT.java | 30 +++----- .../phoenix/rpc/UpdateCacheWithScnIT.java | 49 ------------ 9 files changed, 88 insertions(+), 175 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java index 6a7bd52..5c5420c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java @@ -33,12 +33,11 @@ import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.SchemaNotFoundException; -import org.apache.phoenix.util.PhoenixRuntime; 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; @@ -48,10 +47,13 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.collect.Maps; @RunWith(Parameterized.class) -public class DropSchemaIT extends BaseClientManagedTimeIT { +public class DropSchemaIT extends BaseUniqueNamesOwnClusterIT { private String schema; - @Shadower(classBeingShadowed = BaseClientManagedTimeIT.class) + public DropSchemaIT(String schema) { + this.schema = schema; + } + @BeforeClass public static void doSetup() throws Exception { Map<String,String> props = Maps.newHashMapWithExpectedSize(1); @@ -60,61 +62,39 @@ public class DropSchemaIT extends BaseClientManagedTimeIT { // Must update config before starting server setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); } - - public DropSchemaIT(String schema) { - this.schema = schema; - } + @Parameters(name = "DropSchemaIT_schema={0}") // name is used by failsafe as file name in reports public static Collection<String> data() { - return Arrays.asList("TEST_SCHEMA", "\"test_schema\""); + return Arrays.asList(generateUniqueName().toUpperCase(), "\"" + generateUniqueName().toLowerCase() + "\""); } @Test public void testDropSchema() throws Exception { - long ts = nextTimestamp(); - - String tableName = "TEST"; + String tableName = generateUniqueName(); Properties props = new Properties(); + props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); String normalizeSchemaIdentifier = SchemaUtil.normalizeIdentifier(schema); String ddl = "DROP SCHEMA " + schema; - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); - props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + try (Connection conn = DriverManager.getConnection(getUrl(), props); + HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try { + conn.createStatement().execute(ddl); + fail(); + } catch (SchemaNotFoundException e) { + // expected + } conn.createStatement().execute("CREATE SCHEMA " + schema); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { conn.createStatement().execute("CREATE TABLE " + schema + "." + tableName + "(id INTEGER PRIMARY KEY)"); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 15)); - HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { - try { conn.createStatement().execute(ddl); fail(); } catch (SQLException e) { - e.printStackTrace(); assertEquals(e.getErrorCode(), SQLExceptionCode.CANNOT_MUTATE_SCHEMA.getErrorCode()); } assertNotNull(admin.getNamespaceDescriptor(normalizeSchemaIdentifier)); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts - 20)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { - conn.createStatement().execute(ddl); - fail(); - } catch (SchemaNotFoundException e) { - // expected - } - assertNotNull(admin.getNamespaceDescriptor(normalizeSchemaIdentifier)); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { conn.createStatement().execute("DROP TABLE " + schema + "." + tableName); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 50)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { conn.createStatement().execute(ddl); try { admin.getNamespaceDescriptor(normalizeSchemaIdentifier); @@ -122,28 +102,20 @@ public class DropSchemaIT extends BaseClientManagedTimeIT { } catch (NamespaceNotFoundException ne) { // expected } - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 60)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + conn.createStatement().execute("DROP SCHEMA IF EXISTS " + schema); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 70)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { + admin.createNamespace(NamespaceDescriptor.create(normalizeSchemaIdentifier).build()); conn.createStatement().execute("DROP SCHEMA IF EXISTS " + schema); assertNotNull(admin.getNamespaceDescriptor(normalizeSchemaIdentifier)); conn.createStatement().execute("CREATE SCHEMA " + schema); - } - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 80)); - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { - conn.createStatement().execute("DROP SCHEMA " + schema); - } - try (Connection conn = DriverManager.getConnection(getUrl(), props);) { conn.createStatement().execute("DROP SCHEMA " + schema); - fail(); - } catch (SQLException e) { - assertEquals(e.getErrorCode(), SQLExceptionCode.SCHEMA_NOT_FOUND.getErrorCode()); + try { + conn.createStatement().execute("DROP SCHEMA " + schema); + fail(); + } catch (SQLException e) { + assertEquals(e.getErrorCode(), SQLExceptionCode.SCHEMA_NOT_FOUND.getErrorCode()); + } } - admin.close(); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/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 27aa234..80175c4 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 @@ -58,32 +58,6 @@ public class GroupByIT extends BaseQueryIT { } @Test - public void testNoWhereScan() throws Exception { - String query = "SELECT y_integer FROM " + tableName; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - //props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 - Connection conn = DriverManager.getConnection(getUrl(), props); - try { - PreparedStatement statement = conn.prepareStatement(query); - ResultSet rs = statement.executeQuery(); - for (int i =0; i < 8; i++) { - assertTrue (rs.next()); - assertEquals(0, rs.getInt(1)); - assertTrue(rs.wasNull()); - } - assertTrue (rs.next()); - assertEquals(300, rs.getInt(1)); - assertFalse(rs.next()); - } finally { - conn.close(); - } - } - - // FIXME: this is flapping with an phoenix.memory.InsufficientMemoryException - // in the GroupedAggregateRegionObserver. We can work around it by increasing - // the amount of available memory in QueryServicesTestImpl, but we shouldn't - // have to. I think something may no be being closed to reclaim the memory. - @Test public void testGroupedAggregation() throws Exception { // Tests that you don't get an ambiguous column exception when using the same alias as the column name String query = "SELECT a_string as a_string, count(1), 'foo' FROM " + tableName + " WHERE organization_id=? GROUP BY a_string"; http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java index 746d274..6a8ce53 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutableQueryIT.java @@ -248,7 +248,7 @@ public class MutableQueryIT extends BaseQueryIT { "VALUES (?, ?, ?)"; // Override value that was set at creation time - String url = getUrl();// + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 1); // Run query at timestamp 5 + String url = getUrl(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); // Remove column value at ts + 1 (i.e. equivalent to setting the value to null) @@ -272,7 +272,7 @@ public class MutableQueryIT extends BaseQueryIT { // Delete row at timestamp 3. This should not be seen by the query executing // Remove column value at ts + 1 (i.e. equivalent to setting the value to null) - Connection futureConn = DriverManager.getConnection(getUrl());// + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 3), props); + Connection futureConn = DriverManager.getConnection(getUrl()); stmt = futureConn.prepareStatement("delete from " + tableName + " where organization_id=? and entity_id=?"); stmt.setString(1, tenantId); stmt.setString(2, ROW6); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java index 8b320fa..c5d8798 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java @@ -29,27 +29,28 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Properties; +import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; -public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { +public class ReadIsolationLevelIT extends ParallelStatsEnabledIT { private static final String ENTITY_ID1= "000000000000001"; private static final String ENTITY_ID2= "000000000000002"; private static final String VALUE1 = "a"; private static final String VALUE2= "b"; - - protected static void initTableValues(long ts, byte[][] splits) throws Exception { + + private static String initTableValues() throws Exception { String tenantId = getOrganizationId(); - ensureTableCreated(getUrl(),ATABLE_NAME, ATABLE_NAME, splits, ts-2, null); + String tableName = generateUniqueName(); + ensureTableCreated(getUrl(),tableName, ATABLE_NAME); Properties props = new Properties(); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); Connection upsertConn = DriverManager.getConnection(getUrl(), props); // Insert all rows at ts PreparedStatement stmt = upsertConn.prepareStatement( - "upsert into ATABLE VALUES (?, ?, ?)"); + "upsert into " + tableName + " VALUES (?, ?, ?)"); stmt.setString(1, tenantId); stmt.setString(2, ENTITY_ID1); stmt.setString(3, VALUE1); @@ -61,20 +62,19 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { upsertConn.commit(); upsertConn.close(); + return tableName; } @Test public void testStatementReadIsolationLevel() throws Exception { - long ts = nextTimestamp(); - initTableValues(ts, null); - String query = "SELECT A_STRING FROM ATABLE WHERE ORGANIZATION_ID=? AND ENTITY_ID=?"; + String tableName = initTableValues(); + String query = "SELECT A_STRING FROM " + tableName + " WHERE ORGANIZATION_ID=? AND ENTITY_ID=?"; Properties props = new Properties(); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1)); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+2)); Connection conn2 = DriverManager.getConnection(getUrl(), props); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts+1)); + long ts = EnvironmentEdgeManager.currentTimeMillis(); + props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); Connection conn3 = DriverManager.getConnection(getUrl(), props); try { String tenantId = getOrganizationId(); @@ -88,7 +88,7 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { // Locate existing row and reset one of it's KVs. // Insert all rows at ts - PreparedStatement stmt = conn.prepareStatement("upsert into ATABLE VALUES (?, ?, ?)"); + PreparedStatement stmt = conn.prepareStatement("upsert into " + tableName + " VALUES (?, ?, ?)"); stmt.setString(1, tenantId); stmt.setString(2, ENTITY_ID1); stmt.setString(3, VALUE2); @@ -114,17 +114,19 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { } finally { conn.close(); conn2.close(); + conn3.close(); } } @Test public void testConnectionReadIsolationLevel() throws Exception { - long ts = nextTimestamp(); - initTableValues(ts, null); - String query = "SELECT A_STRING FROM ATABLE WHERE ORGANIZATION_ID=? AND ENTITY_ID=?"; - String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts+1); - Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); + String tableName = initTableValues(); + String query = "SELECT A_STRING FROM " + tableName + " WHERE ORGANIZATION_ID=? AND ENTITY_ID=?"; + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); + long ts = EnvironmentEdgeManager.currentTimeMillis(); + String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts+1); + Connection conn2 = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { String tenantId = getOrganizationId(); PreparedStatement statement = conn.prepareStatement(query); @@ -137,7 +139,7 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { // Locate existing row and reset one of it's KVs. // Insert all rows at ts - PreparedStatement stmt = conn.prepareStatement("upsert into ATABLE VALUES (?, ?, ?)"); + PreparedStatement stmt = conn.prepareStatement("upsert into " + tableName + " VALUES (?, ?, ?)"); stmt.setString(1, tenantId); stmt.setString(2, ENTITY_ID1); stmt.setString(3, VALUE2); @@ -145,12 +147,16 @@ public class ReadIsolationLevelIT extends BaseClientManagedTimeIT { // Run another query through same connection and make sure // you can't find the new row - rs = statement.executeQuery(); + PreparedStatement statement2 = conn2.prepareStatement(query); + statement2.setString(1, tenantId); + statement2.setString(2, ENTITY_ID1); + rs = statement2.executeQuery(); assertTrue(rs.next()); assertEquals(VALUE1, rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); + conn2.close(); } } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java index 56ae0f7..33a891f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java @@ -90,8 +90,6 @@ public class RebuildIndexConnectionPropsIT extends BaseUniqueNamesOwnClusterIT { Configuration rebuildQueryServicesConfig = rebuildIndexConnection.getQueryServices().getConfiguration(); // assert that the properties are part of the query services config - assertEquals(Long.toString(Long.MAX_VALUE), - rebuildQueryServicesConfig.get(PhoenixRuntime.CURRENT_SCN_ATTRIB)); assertEquals( Long.toString(QueryServicesOptions.DEFAULT_INDEX_REBUILD_QUERY_TIMEOUT), rebuildQueryServicesConfig.get(QueryServices.THREAD_TIMEOUT_MS_ATTRIB)); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java index 2bde28c..c343e80 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanQueryIT.java @@ -84,6 +84,27 @@ public class ScanQueryIT extends BaseQueryIT { } @Test + public void testNoWhereScan() throws Exception { + String query = "SELECT y_integer FROM " + tableName; + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection conn = DriverManager.getConnection(getUrl(), props); + try { + PreparedStatement statement = conn.prepareStatement(query); + ResultSet rs = statement.executeQuery(); + for (int i =0; i < 8; i++) { + assertTrue (rs.next()); + assertEquals(0, rs.getInt(1)); + assertTrue(rs.wasNull()); + } + assertTrue (rs.next()); + assertEquals(300, rs.getInt(1)); + assertFalse(rs.next()); + } finally { + conn.close(); + } + } + + @Test public void testScanByByteValue() throws Exception { String query = "SELECT a_string, b_string, a_byte FROM " + tableName + " WHERE ?=organization_id and 1=a_byte"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java index abc8411..378a9ed 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java @@ -51,6 +51,7 @@ import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.tuple.ResultTuple; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.util.ByteUtil; +import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; @@ -177,7 +178,7 @@ public class StoreNullsIT extends ParallelStatsDisabledIT { stmt.execute(String.format(ddlFormat, dataTableName)); stmt.executeUpdate("UPSERT INTO " + dataTableName + " VALUES (1, 'v1')"); Thread.sleep(10L); - long afterFirstInsert = System.currentTimeMillis(); + long afterFirstInsert = EnvironmentEdgeManager.currentTimeMillis(); Thread.sleep(10L); stmt.executeUpdate("UPSERT INTO " + dataTableName + " VALUES (1, null)"); @@ -221,7 +222,7 @@ public class StoreNullsIT extends ParallelStatsDisabledIT { stmt.executeUpdate("UPSERT INTO " + dataTableName + " VALUES (1, 'v1')"); Thread.sleep(10L); - long afterFirstInsert = System.currentTimeMillis(); + long afterFirstInsert = EnvironmentEdgeManager.currentTimeMillis(); Thread.sleep(10L); stmt.executeUpdate("DELETE FROM " + dataTableName + " WHERE id = 1"); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/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 ff9036f..e6a2f7d 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 @@ -42,7 +42,6 @@ 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.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; @@ -70,7 +69,7 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { 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, null, new int[] {1, 1}); + helpTestUpdateCache(fullTableName, new int[] {1, 1}); } @Test @@ -79,14 +78,14 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { 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); - helpTestUpdateCache(fullTableName, null, new int[] {1, 3}); + helpTestUpdateCache(fullTableName, new int[] {1, 3}); } @Test public void testUpdateCacheForNonTxnSystemTable() throws Exception { String fullTableName = "\""+ QueryConstants.SYSTEM_SCHEMA_NAME + "\""+ QueryConstants.NAME_SEPARATOR + generateUniqueName(); setupSystemTable(fullTableName); - helpTestUpdateCache(fullTableName, null, new int[] {0, 0}); + helpTestUpdateCache(fullTableName, new int[] {0, 0}); } @Test @@ -99,7 +98,7 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { conn.createStatement().execute( "alter table " + fullTableName + " SET UPDATE_CACHE_FREQUENCY=NEVER"); } - helpTestUpdateCache(fullTableName, null, new int[] {0, 0}); + helpTestUpdateCache(fullTableName, new int[] {0, 0}); } @Test @@ -109,7 +108,7 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("CREATE TABLE " + fullTableName + TestUtil.TEST_TABLE_SCHEMA + " UPDATE_CACHE_FREQUENCY=always"); } - helpTestUpdateCache(fullTableName, null, new int[] {1, 3}); + helpTestUpdateCache(fullTableName, new int[] {1, 3}); } @Test @@ -119,9 +118,9 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("CREATE TABLE " + fullTableName + TestUtil.TEST_TABLE_SCHEMA + " UPDATE_CACHE_FREQUENCY=" + 10000); } - helpTestUpdateCache(fullTableName, null, new int[] {0, 0}); + helpTestUpdateCache(fullTableName, new int[] {0, 0}); Thread.sleep(10000); - helpTestUpdateCache(fullTableName, null, new int[] {1, 0}); + helpTestUpdateCache(fullTableName, new int[] {1, 0}); } @Test @@ -131,14 +130,14 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("CREATE TABLE " + fullTableName + TestUtil.TEST_TABLE_SCHEMA + " UPDATE_CACHE_FREQUENCY=never"); } - helpTestUpdateCache(fullTableName, null, new int[] {0, 0}); + helpTestUpdateCache(fullTableName, new int[] {0, 0}); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("ALTER TABLE " + fullTableName + " SET UPDATE_CACHE_FREQUENCY=ALWAYS"); } - helpTestUpdateCache(fullTableName, null, new int[] {1, 3}); + helpTestUpdateCache(fullTableName, new int[] {1, 3}); } - public static void helpTestUpdateCache(String fullTableName, Long scn, int[] expectedRPCs) throws Exception { + private static void helpTestUpdateCache(String fullTableName, int[] expectedRPCs) throws Exception { String tableName = SchemaUtil.getTableNameFromFullName(fullTableName); String schemaName = SchemaUtil.getSchemaNameFromFullName(fullTableName); String selectSql = "SELECT * FROM "+fullTableName; @@ -146,9 +145,6 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { ConnectionQueryServices connectionQueryServices = Mockito.spy(driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))); Properties props = new Properties(); props.putAll(PhoenixEmbeddedDriver.DEFFAULT_PROPS.asMap()); - if (scn!=null) { - props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(scn+10)); - } Connection conn = connectionQueryServices.connect(getUrl(), props); try { conn.setAutoCommit(false); @@ -167,12 +163,6 @@ public class UpdateCacheIT extends ParallelStatsDisabledIT { verify(connectionQueryServices, times(numUpsertRpcs)).getTable((PName)isNull(), eq(PVarchar.INSTANCE.toBytes(schemaName)), eq(PVarchar.INSTANCE.toBytes(tableName)), anyLong(), anyLong()); reset(connectionQueryServices); - if (scn!=null) { - // advance scn so that we can see the data we just upserted - props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(scn+20)); - conn = connectionQueryServices.connect(getUrl(), props); - } - ResultSet rs = conn.createStatement().executeQuery(selectSql); TestUtil.validateRowKeyColumns(rs, 1); TestUtil.validateRowKeyColumns(rs, 2); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4c2674b1/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java deleted file mode 100644 index b0d672d..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheWithScnIT.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.rpc; - -import static org.apache.phoenix.util.TestUtil.INDEX_DATA_SCHEMA; -import static org.apache.phoenix.util.TestUtil.MUTABLE_INDEX_DATA_TABLE; -import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.util.Properties; - -import org.apache.phoenix.end2end.BaseClientManagedTimeIT; -import org.apache.phoenix.query.QueryConstants; -import org.apache.phoenix.util.PhoenixRuntime; -import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.TestUtil; -import org.junit.Test; - -public class UpdateCacheWithScnIT extends BaseClientManagedTimeIT { - - @Test - public void testUpdateCacheWithScn() throws Exception { - long ts = nextTimestamp(); - String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + MUTABLE_INDEX_DATA_TABLE; - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); - Connection conn = DriverManager.getConnection(getUrl(), props); - conn.createStatement().execute("create table " + fullTableName + TestUtil.TEST_TABLE_SCHEMA); - // FIXME: given that the scn is advancing in the test, why aren't there more RPCs? - UpdateCacheIT.helpTestUpdateCache(fullTableName, ts+2, new int[] {1, 1}); - } - -}