HBASE-12181 Some tests create a table and try to use it before regions get assigned (Dima Spivak)
This commit is contained in:
parent
1636afb0aa
commit
652b81ab1e
|
@ -883,19 +883,28 @@ public class TestSplitTransactionOnCluster {
|
|||
public void testSplitHooksBeforeAndAfterPONR() throws Exception {
|
||||
TableName firstTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_1");
|
||||
TableName secondTable = TableName.valueOf("testSplitHooksBeforeAndAfterPONR_2");
|
||||
HColumnDescriptor hcd = new HColumnDescriptor("cf");
|
||||
|
||||
HTableDescriptor desc = new HTableDescriptor(firstTable);
|
||||
desc.addCoprocessor(MockedRegionObserver.class.getName());
|
||||
HColumnDescriptor hcd = new HColumnDescriptor("cf");
|
||||
desc.addFamily(hcd);
|
||||
admin.createTable(desc);
|
||||
TESTING_UTIL.waitUntilAllRegionsAssigned(firstTable);
|
||||
|
||||
desc = new HTableDescriptor(secondTable);
|
||||
hcd = new HColumnDescriptor("cf");
|
||||
desc.addFamily(hcd);
|
||||
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);
|
||||
|
||||
// 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 =
|
||||
cluster.getServerHoldingRegion(firstTableregions.get(0).getRegionName());
|
||||
cluster.getServerHoldingRegion(firstTableRegions.get(0).getRegionName());
|
||||
admin.move(secondTableRegions.get(0).getRegionInfo().getEncodedNameAsBytes(),
|
||||
Bytes.toBytes(serverName.getServerName()));
|
||||
Table table1 = null;
|
||||
|
@ -906,12 +915,12 @@ public class TestSplitTransactionOnCluster {
|
|||
insertData(firstTable, admin, table1);
|
||||
insertData(secondTable, admin, table2);
|
||||
admin.split(firstTable, "row2".getBytes());
|
||||
firstTableregions = cluster.getRegions(firstTable);
|
||||
while (firstTableregions.size() != 2) {
|
||||
firstTableRegions = cluster.getRegions(firstTable);
|
||||
while (firstTableRegions.size() != 2) {
|
||||
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);
|
||||
assertEquals("Number of regions after split should be 2.", 2, secondTableRegions.size());
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue