You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2020/11/11 23:59:58 UTC
[phoenix] branch 4.x updated: PHOENIX-6212: Improve
SystemCatalogIT.testSystemTableSplit() to ensure no splitting occurs when
splitting is disabled
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push:
new 565b0ea PHOENIX-6212: Improve SystemCatalogIT.testSystemTableSplit() to ensure no splitting occurs when splitting is disabled
565b0ea is described below
commit 565b0eaa17de82e4bf6ea9634a5a30473e4167bf
Author: Chinmay Kulkarni <ch...@gmail.com>
AuthorDate: Tue Nov 10 17:57:59 2020 -0800
PHOENIX-6212: Improve SystemCatalogIT.testSystemTableSplit() to ensure no splitting occurs when splitting is disabled
---
.../phoenix/end2end/SplitSystemCatalogIT.java | 14 +++++----
.../end2end/SystemCatalogRollbackEnabledIT.java | 36 ++++++++++------------
.../java/org/apache/phoenix/query/BaseTest.java | 3 +-
3 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java
index dce530f..b2075a7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java
@@ -19,7 +19,6 @@ package org.apache.phoenix.end2end;
import java.sql.Connection;
import java.sql.DriverManager;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -54,7 +53,8 @@ public class SplitSystemCatalogIT extends BaseTest {
doSetup(null);
}
- public static synchronized void doSetup(Map<String, String> props) throws Exception {
+ public static synchronized void doSetup(Map<String, String> props)
+ throws Exception {
NUM_SLAVES_BASE = 6;
if (props == null) {
props = Collections.emptyMap();
@@ -69,18 +69,20 @@ public class SplitSystemCatalogIT extends BaseTest {
}
}
- protected static void splitSystemCatalog() throws SQLException, Exception {
- try (Connection conn = DriverManager.getConnection(getUrl())) {
+ protected static void splitSystemCatalog() throws Exception {
+ try (Connection ignored = DriverManager.getConnection(getUrl())) {
}
String tableName = "TABLE";
String fullTableName1 = SchemaUtil.getTableName(SCHEMA1, tableName);
String fullTableName2 = SchemaUtil.getTableName(SCHEMA2, tableName);
String fullTableName3 = SchemaUtil.getTableName(SCHEMA3, tableName);
String fullTableName4 = SchemaUtil.getTableName(SCHEMA4, tableName);
- ArrayList<String> tableList = Lists.newArrayList(fullTableName1, fullTableName2, fullTableName3);
+ ArrayList<String> tableList = Lists.newArrayList(fullTableName1,
+ fullTableName2, fullTableName3);
Map<String, List<String>> tenantToTableMap = Maps.newHashMap();
tenantToTableMap.put(null, tableList);
- tenantToTableMap.put(TENANT1, Lists.newArrayList(fullTableName2, fullTableName3));
+ tenantToTableMap.put(TENANT1, Lists.newArrayList(fullTableName2,
+ fullTableName3));
tenantToTableMap.put(TENANT2, Lists.newArrayList(fullTableName4));
splitSystemCatalog(tenantToTableMap);
}
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java
index 2b69596..0241eab 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
@@ -31,7 +32,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionLocator;
@@ -51,8 +51,7 @@ import org.junit.experimental.categories.Category;
* Tests various scenarios when
* {@link QueryServices#ALLOW_SPLITTABLE_SYSTEM_CATALOG_ROLLBACK}
* is set to true and SYSTEM.CATALOG should not be allowed to split.
- * Note that this config must
- * be set on both the client and server
+ * Note that this config must be set on both the client and server
*/
@Category(NeedsOwnMiniClusterTest.class)
public class SystemCatalogRollbackEnabledIT extends BaseTest {
@@ -100,37 +99,34 @@ public class SystemCatalogRollbackEnabledIT extends BaseTest {
return DriverManager.getConnection(getUrl(), tenantProps);
}
+ private void assertNumRegions(HBaseTestingUtility testUtil,
+ TableName tableName, int expectedNumRegions) throws IOException {
+ RegionLocator rl = testUtil.getConnection().getRegionLocator(tableName);
+ assertEquals(expectedNumRegions, rl.getAllRegionLocations().size());
+ }
/**
* Make sure that SYSTEM.CATALOG cannot be split if
* {@link QueryServices#SYSTEM_CATALOG_SPLITTABLE} is false
*/
@Test
- public void testSystemTableDoesNotSplit() throws Exception {
+ public void testSystemCatalogDoesNotSplit() throws Exception {
HBaseTestingUtility testUtil = getUtility();
for (int i=0; i<10; i++) {
createTableAndTenantViews("schema"+i+".table_"+i);
}
TableName systemCatalog = TableName.valueOf(
PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME);
- RegionLocator rl = testUtil.getConnection()
- .getRegionLocator(systemCatalog);
- assertEquals(1, rl.getAllRegionLocations().size());
- try {
- // now attempt to split SYSTEM.CATALOG
- testUtil.getHBaseAdmin().split(systemCatalog);
- // make sure the split finishes (there's no synchronous splitting
- // before HBase 2.x)
- testUtil.getHBaseAdmin().disableTable(systemCatalog);
- testUtil.getHBaseAdmin().enableTable(systemCatalog);
- } catch (DoNotRetryIOException e) {
- // table is not splittable
- assertTrue(e.getMessage().contains("NOT splittable"));
- }
+ assertNumRegions(testUtil, systemCatalog, 1);
+
+ // now attempt to split SYSTEM.CATALOG
+ // The expectation is for the split to be a no-op. It should not fail/
+ // throw any exception in HBase 1.x. Also, this split is synchronous
+ // since there's no asynchronous splitting before HBase 2.x
+ testUtil.getHBaseAdmin().split(systemCatalog);
// test again... Must still be exactly one region.
- rl = testUtil.getConnection().getRegionLocator(systemCatalog);
- assertEquals(1, rl.getAllRegionLocations().size());
+ assertNumRegions(testUtil, systemCatalog, 1);
}
/**
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index fc9df19..c6aa33e 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -1874,7 +1874,8 @@ public abstract class BaseTest {
availableRegionServers.remove(serverName);
}
}
- assertTrue("No region servers available to move regions on to ", !availableRegionServers.isEmpty());
+ assertFalse("No region servers available to move regions on to ",
+ availableRegionServers.isEmpty());
for (Entry<ServerName, List<HRegionInfo>> entry : serverToRegionsList.entrySet()) {
List<HRegionInfo> regions = entry.getValue();
if (regions.size()>1) {