HBASE-12181 Some tests create a table and try to use it before regions get assigned (Dima Spivak)
This commit is contained in:
parent
ad2064d8a5
commit
0bec57e7c1
|
@ -1032,19 +1032,28 @@ public class TestSplitTransactionOnCluster {
|
||||||
public void testSplitHooksBeforeAndAfterPONR() throws Exception {
|
public void testSplitHooksBeforeAndAfterPONR() throws Exception {
|
||||||
TableName firstTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_1");
|
TableName firstTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_1");
|
||||||
TableName secondTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_2");
|
TableName secondTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_2");
|
||||||
|
HColumnDescriptor hcd = new HColumnDescriptor("cf");
|
||||||
|
|
||||||
HTableDescriptor desc = new HTableDescriptor(firstTable);
|
HTableDescriptor desc = new HTableDescriptor(firstTable);
|
||||||
desc.addCoprocessor(MockedRegionObserver.class.getName());
|
desc.addCoprocessor(MockedRegionObserver.class.getName());
|
||||||
HColumnDescriptor hcd = new HColumnDescriptor("cf");
|
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
admin.createTable(desc);
|
admin.createTable(desc);
|
||||||
|
TESTING_UTIL.waitUntilAllRegionsAssigned(firstTable);
|
||||||
|
|
||||||
desc = new HTableDescriptor(secondTable);
|
desc = new HTableDescriptor(secondTable);
|
||||||
hcd = new HColumnDescriptor("cf");
|
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
admin.createTable(desc);
|
admin.createTable(desc);
|
||||||
List<HRegion> firstTableregions = cluster.getRegions(firstTable);
|
TESTING_UTIL.waitUntilAllRegionsAssigned(secondTable);
|
||||||
|
|
||||||
|
List<HRegion> firstTableRegions = cluster.getRegions(firstTable);
|
||||||
List<HRegion> secondTableRegions = cluster.getRegions(secondTable);
|
List<HRegion> secondTableRegions = cluster.getRegions(secondTable);
|
||||||
|
|
||||||
|
// Check that both tables actually have regions.
|
||||||
|
if (firstTableRegions.size() == 0 || secondTableRegions.size() == 0) {
|
||||||
|
fail("Each table should have at least one region.");
|
||||||
|
}
|
||||||
ServerName serverName =
|
ServerName serverName =
|
||||||
cluster.getServerHoldingRegion(firstTableregions.get(0).getRegionName());
|
cluster.getServerHoldingRegion(firstTableRegions.get(0).getRegionName());
|
||||||
admin.move(secondTableRegions.get(0).getRegionInfo().getEncodedNameAsBytes(),
|
admin.move(secondTableRegions.get(0).getRegionInfo().getEncodedNameAsBytes(),
|
||||||
Bytes.toBytes(serverName.getServerName()));
|
Bytes.toBytes(serverName.getServerName()));
|
||||||
Table table1 = null;
|
Table table1 = null;
|
||||||
|
@ -1055,12 +1064,12 @@ public class TestSplitTransactionOnCluster {
|
||||||
insertData(firstTable, admin, table1);
|
insertData(firstTable, admin, table1);
|
||||||
insertData(secondTable, admin, table2);
|
insertData(secondTable, admin, table2);
|
||||||
admin.split(firstTable, "row2".getBytes());
|
admin.split(firstTable, "row2".getBytes());
|
||||||
firstTableregions = cluster.getRegions(firstTable);
|
firstTableRegions = cluster.getRegions(firstTable);
|
||||||
while (firstTableregions.size() != 2) {
|
while (firstTableRegions.size() != 2) {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
firstTableregions = cluster.getRegions(firstTable);
|
firstTableRegions = cluster.getRegions(firstTable);
|
||||||
}
|
}
|
||||||
assertEquals("Number of regions after split should be 2.", 2, firstTableregions.size());
|
assertEquals("Number of regions after split should be 2.", 2, firstTableRegions.size());
|
||||||
secondTableRegions = cluster.getRegions(secondTable);
|
secondTableRegions = cluster.getRegions(secondTable);
|
||||||
assertEquals("Number of regions after split should be 2.", 2, secondTableRegions.size());
|
assertEquals("Number of regions after split should be 2.", 2, secondTableRegions.size());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue