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/12 00:11:20 UTC
[phoenix] branch master 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 master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 2ad33a1 PHOENIX-6212: Improve SystemCatalogIT.testSystemTableSplit() to ensure no splitting occurs when splitting is disabled
2ad33a1 is described below
commit 2ad33a19b8d380bb1be411422de8e005047f76a1
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 | 28 +++++++++++++---------
.../java/org/apache/phoenix/query/BaseTest.java | 3 ++-
3 files changed, 27 insertions(+), 18 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 414f10c..9560a57 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 5a34a4f..fb2e379 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;
@@ -51,8 +52,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 {
@@ -99,37 +99,43 @@ 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());
+ assertNumRegions(testUtil, systemCatalog, 1);
+
try {
// now attempt to split SYSTEM.CATALOG
testUtil.getAdmin().split(systemCatalog);
- // make sure the split finishes (there's no synchronous splitting
- // before HBase 2.x)
+ // make sure the split finishes (in hbase 2.x the Admin.split() API
+ // is asynchronous)
testUtil.getAdmin().disableTable(systemCatalog);
testUtil.getAdmin().enableTable(systemCatalog);
+ fail(String.format("Splitting %s should have failed",
+ systemCatalog.getNameAsString()));
} catch (DoNotRetryIOException e) {
- // table is not splittable
+ // In hbase 2.x, if splitting is disabled for a table,
+ // the split request will throw an exception.
assertTrue(e.getMessage().contains("NOT splittable"));
}
// 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 6b6518f..b2a346f 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
@@ -1872,7 +1872,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) {