hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
Repository: hbase Updated Branches: refs/heads/master 23d54f858 -> 6b18e39f3 HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. Signed-off-by: Duo Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6b18e39f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6b18e39f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6b18e39f Branch: refs/heads/master Commit: 6b18e39f30b30ad2aa027eefbf520f2c5b1de490 Parents: 23d54f8 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Tue Aug 21 09:17:51 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 51 ++-- 1 file changed, 15 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/6b18e39f/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 5fa3072..8bd13a0 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -31,10 +31,8 @@ import javax.xml.bind.JAXBException; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; @@ -43,7 +41,6 @@ import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Table; -import org.apache.hadoop.hbase.regionserver.TestEndToEndSplitTransaction; import org.apache.hadoop.hbase.rest.client.Client; import org.apache.hadoop.hbase.rest.client.Cluster; import org.apache.hadoop.hbase.rest.client.Response; @@ -72,9 +69,10 @@ public class TestTableResource { private static final Logger LOG = LoggerFactory.getLogger(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -94,13 +92,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -117,37 +109,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) RegionLocator regionLocator = connection.getRegionLocator(TABLE); List m = regionLocator.getAllRegionLocations(); -assertEquals(1, m.size()); -// tell the master to split the table -admin.split(TABLE); -// give some time for the split to happen - - TestEndToEndSplitTransaction.blockUntilRegionSplit(TEST_UTIL.getConfiguration(), 6, - m.get(0).getRegionInfo().getRegionName(), true); -long timeout = System.currentTimeMillis() + (15 * 1000); -while (System.currentTimeMillis() < timeout && m.size()!=2){ - try { -Thread.sleep(250); - } catch (InterruptedException e) { -LOG.warn(StringUtils.stringifyException(e)); - } - // check again - m = regionLocator.getA
[1/3] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
Repository: hbase Updated Branches: refs/heads/branch-2 16af11bb1 -> cf4d23f8d refs/heads/branch-2.0 343a0f675 -> 89ec91608 refs/heads/branch-2.1 1120f33c3 -> 9a3093a88 HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/cf4d23f8 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cf4d23f8 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cf4d23f8 Branch: refs/heads/branch-2 Commit: cf4d23f8d4afa2a568866c7ea3ea5197f0d00f16 Parents: 16af11b Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:17:05 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 53 ++-- 1 file changed, 15 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/cf4d23f8/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 5fa3072..7cbc631 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -31,19 +31,15 @@ import javax.xml.bind.JAXBException; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Table; -import org.apache.hadoop.hbase.regionserver.TestEndToEndSplitTransaction; import org.apache.hadoop.hbase.rest.client.Client; import org.apache.hadoop.hbase.rest.client.Cluster; import org.apache.hadoop.hbase.rest.client.Response; @@ -54,7 +50,6 @@ import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RestTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.util.StringUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -72,9 +67,10 @@ public class TestTableResource { private static final Logger LOG = LoggerFactory.getLogger(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -94,13 +90,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -117,37 +107,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) RegionLocator re
[2/3] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/89ec9160 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/89ec9160 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/89ec9160 Branch: refs/heads/branch-2.0 Commit: 89ec91608fac7cb833b29a2a72c1e401550924f4 Parents: 343a0f6 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:26:31 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 53 ++-- 1 file changed, 15 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/89ec9160/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 5fa3072..7cbc631 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -31,19 +31,15 @@ import javax.xml.bind.JAXBException; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Table; -import org.apache.hadoop.hbase.regionserver.TestEndToEndSplitTransaction; import org.apache.hadoop.hbase.rest.client.Client; import org.apache.hadoop.hbase.rest.client.Cluster; import org.apache.hadoop.hbase.rest.client.Response; @@ -54,7 +50,6 @@ import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RestTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.util.StringUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -72,9 +67,10 @@ public class TestTableResource { private static final Logger LOG = LoggerFactory.getLogger(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -94,13 +90,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -117,37 +107,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) RegionLocator regionLocator = connection.getRegionLocator(TABLE); List m = regionLocator.getAllRegionLocations(); -assertEquals(1, m.size()); -// tell the master to split the tab
[3/3] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9a3093a8 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9a3093a8 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9a3093a8 Branch: refs/heads/branch-2.1 Commit: 9a3093a886d455e460c87fbe3ab65f6f55dcca23 Parents: 1120f33 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:37:28 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 53 ++-- 1 file changed, 15 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/9a3093a8/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 5fa3072..7cbc631 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -31,19 +31,15 @@ import javax.xml.bind.JAXBException; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Table; -import org.apache.hadoop.hbase.regionserver.TestEndToEndSplitTransaction; import org.apache.hadoop.hbase.rest.client.Client; import org.apache.hadoop.hbase.rest.client.Cluster; import org.apache.hadoop.hbase.rest.client.Response; @@ -54,7 +50,6 @@ import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RestTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.util.StringUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -72,9 +67,10 @@ public class TestTableResource { private static final Logger LOG = LoggerFactory.getLogger(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -94,13 +90,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = CellUtil.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -117,37 +107,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) RegionLocator regionLocator = connection.getRegionLocator(TABLE); List m = regionLocator.getAllRegionLocations(); -assertEquals(1, m.size()); -// tell the master to split the tab
[4/4] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Conflicts: hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/524f7fbe Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/524f7fbe Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/524f7fbe Branch: refs/heads/branch-1.2 Commit: 524f7fbe572897f2a318eaad4865d83a49932f1a Parents: 69f5005 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 20:40:02 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 52 ++-- 1 file changed, 16 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/524f7fbe/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index a7de2f1..77ebcdc 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -35,14 +35,11 @@ import javax.xml.bind.JAXBException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; @@ -57,7 +54,6 @@ import org.apache.hadoop.hbase.rest.model.TableModel; import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.util.StringUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -67,9 +63,10 @@ import org.junit.experimental.categories.Category; public class TestTableResource { private static final Log LOG = LogFactory.getLog(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -89,13 +86,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getHBaseAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -112,35 +103,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) - + RegionLocator regionLocator = connection.getRegionLocator(TABLE); List m = regionLocator.getAllRegionLocations(); -assertEquals(m.size(), 1); -// tell the master to split the table -admin.split(TABLE); -// give some time for the split to happen - -long timeout = System.currentTimeMillis() + (15 * 1000); -while (System
[3/4] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Conflicts: hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/05460c93 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/05460c93 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/05460c93 Branch: refs/heads/branch-1.3 Commit: 05460c9370c175729c10b1f0ad6d91b15e5660ac Parents: 89cfe88 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:56:52 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 55 ++-- 1 file changed, 17 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/05460c93/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 3abcb4a..77ebcdc 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -35,15 +35,11 @@ import javax.xml.bind.JAXBException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.Waiter; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; @@ -58,7 +54,6 @@ import org.apache.hadoop.hbase.rest.model.TableModel; import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -68,9 +63,10 @@ import org.junit.experimental.categories.Category; public class TestTableResource { private static final Log LOG = LogFactory.getLog(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -90,13 +86,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getHBaseAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -113,35 +103,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) - -final RegionLocator regionLocator = connection.getRegionLocator(TABLE); -List m = regionLocator.getAllRegionLocations(); -assertEquals(m.size(), 1); -// tell the master to split the table -admin.split(TABLE); -// give some time for the split to happen -long timeout =
[2/4] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Conflicts: hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9354d6b4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9354d6b4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9354d6b4 Branch: refs/heads/branch-1.4 Commit: 9354d6b457be45abd1b832b8c783ae7c87511e24 Parents: f936514 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:51:35 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 55 ++-- 1 file changed, 17 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/9354d6b4/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 25508b0..2551ee8 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -35,15 +35,11 @@ import javax.xml.bind.JAXBException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.Waiter; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; @@ -58,7 +54,6 @@ import org.apache.hadoop.hbase.rest.model.TableModel; import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -68,9 +63,10 @@ import org.junit.experimental.categories.Category; public class TestTableResource { private static final Log LOG = LogFactory.getLog(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -90,13 +86,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getHBaseAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -113,35 +103,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) - -final RegionLocator regionLocator = connection.getRegionLocator(TABLE); -List m = regionLocator.getAllRegionLocations(); -assertEquals(m.size(), 1); -// tell the master to split the table -admin.split(TABLE); -// give some time for the split to happen -TEST_UTIL.wait
[1/4] hbase git commit: HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation.
Repository: hbase Updated Branches: refs/heads/branch-1 0ac599920 -> 062d1dcf2 refs/heads/branch-1.2 69f500570 -> 524f7fbe5 refs/heads/branch-1.3 89cfe88a7 -> 05460c937 refs/heads/branch-1.4 f936514b2 -> 9354d6b45 HBASE-21076 refactor TestTableResource to ask for a multi-region table instead of relying on a split operation. Also correct how the test does string conversion for region names that include non-printable characters. includes addendum. Signed-off-by: Duo Zhang Signed-off-by: Ted Yu Signed-off-by: Andrew Purtell (cherry picked from commit 6b18e39f30b30ad2aa027eefbf520f2c5b1de490) (cherry picked from commit 63f2d3cbdc8151f5f61f33e0a078c51b9ac076a5) Conflicts: hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/062d1dcf Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/062d1dcf Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/062d1dcf Branch: refs/heads/branch-1 Commit: 062d1dcf2bbb4a89f4232d40527e3624a8f714f8 Parents: 0ac5999 Author: Sean Busbey Authored: Mon Aug 20 13:43:25 2018 -0500 Committer: Sean Busbey Committed: Wed Aug 22 19:46:01 2018 -0500 -- .../hadoop/hbase/rest/TestTableResource.java| 55 ++-- 1 file changed, 17 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/062d1dcf/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java -- diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java index 25508b0..2551ee8 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java @@ -35,15 +35,11 @@ import javax.xml.bind.JAXBException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; -import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.Waiter; -import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; @@ -58,7 +54,6 @@ import org.apache.hadoop.hbase.rest.model.TableModel; import org.apache.hadoop.hbase.rest.model.TableRegionModel; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -68,9 +63,10 @@ import org.junit.experimental.categories.Category; public class TestTableResource { private static final Log LOG = LogFactory.getLog(TestTableResource.class); - private static TableName TABLE = TableName.valueOf("TestTableResource"); - private static String COLUMN_FAMILY = "test"; - private static String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final TableName TABLE = TableName.valueOf("TestTableResource"); + private static final String COLUMN_FAMILY = "test"; + private static final String COLUMN = COLUMN_FAMILY + ":qualifier"; + private static final int NUM_REGIONS = 4; private static List regionMap; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -90,13 +86,7 @@ public class TestTableResource { TableInfoModel.class, TableListModel.class, TableRegionModel.class); -Admin admin = TEST_UTIL.getHBaseAdmin(); -if (admin.tableExists(TABLE)) { - return; -} -HTableDescriptor htd = new HTableDescriptor(TABLE); -htd.addFamily(new HColumnDescriptor(COLUMN_FAMILY)); -admin.createTable(htd); +TEST_UTIL.createMultiRegionTable(TABLE, Bytes.toBytes(COLUMN_FAMILY), NUM_REGIONS); byte[] k = new byte[3]; byte [][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(COLUMN)); List puts = new ArrayList<>(); @@ -113,35 +103,20 @@ public class TestTableResource { } } } + Connection connection = TEST_UTIL.getConnection(); Table table = connection.getTable(TABLE); table.put(puts); table.close(); -// get the initial layout (should just be one region) - -final RegionLocator regionLocator = connection.getRegionLocator(TABLE);