HBASE-20363 TestNamespaceAuditor.testRegionMerge is flaky
This commit is contained in:
parent
74ab10c353
commit
2487b4603c
|
@ -72,6 +72,7 @@ import org.apache.hadoop.hbase.master.TableNamespaceManager;
|
|||
import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
|
||||
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
|
||||
import org.apache.hadoop.hbase.quotas.QuotaUtil;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.Store;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreFile;
|
||||
import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker;
|
||||
|
@ -348,24 +349,30 @@ public class TestNamespaceAuditor {
|
|||
UTIL.loadNumericRows(table, Bytes.toBytes("info"), 1000, 1999);
|
||||
}
|
||||
ADMIN.flush(tableTwo);
|
||||
List<HRegionInfo> hris = ADMIN.getTableRegions(tableTwo);
|
||||
List<RegionInfo> hris = ADMIN.getRegions(tableTwo);
|
||||
assertEquals(initialRegions, hris.size());
|
||||
Collections.sort(hris);
|
||||
Collections.sort(hris, RegionInfo.COMPARATOR);
|
||||
Future<?> f = ADMIN.mergeRegionsAsync(
|
||||
hris.get(0).getEncodedNameAsBytes(),
|
||||
hris.get(1).getEncodedNameAsBytes(),
|
||||
false);
|
||||
f.get(10, TimeUnit.SECONDS);
|
||||
|
||||
hris = ADMIN.getTableRegions(tableTwo);
|
||||
hris = ADMIN.getRegions(tableTwo);
|
||||
assertEquals(initialRegions - 1, hris.size());
|
||||
Collections.sort(hris);
|
||||
ADMIN.split(tableTwo, Bytes.toBytes("3"));
|
||||
// Not much we can do here until we have split return a Future.
|
||||
Threads.sleep(5000);
|
||||
hris = ADMIN.getTableRegions(tableTwo);
|
||||
Collections.sort(hris, RegionInfo.COMPARATOR);
|
||||
byte[] splitKey = Bytes.toBytes("3");
|
||||
HRegion regionToSplit = UTIL.getMiniHBaseCluster().getRegions(tableTwo).stream()
|
||||
.filter(r -> r.getRegionInfo().containsRow(splitKey)).findFirst().get();
|
||||
regionToSplit.compact(true);
|
||||
// the above compact may quit immediately if there is a compaction ongoing, so here we need to
|
||||
// wait a while to let the ongoing compaction finish.
|
||||
UTIL.waitFor(10000, regionToSplit::isSplittable);
|
||||
ADMIN.splitRegionAsync(regionToSplit.getRegionInfo().getRegionName(), splitKey).get(10,
|
||||
TimeUnit.SECONDS);
|
||||
hris = ADMIN.getRegions(tableTwo);
|
||||
assertEquals(initialRegions, hris.size());
|
||||
Collections.sort(hris);
|
||||
Collections.sort(hris, RegionInfo.COMPARATOR);
|
||||
|
||||
// Fail region merge through Coprocessor hook
|
||||
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
|
||||
|
@ -384,11 +391,10 @@ public class TestNamespaceAuditor {
|
|||
} catch (ExecutionException ee) {
|
||||
// Expected.
|
||||
}
|
||||
hris = ADMIN.getTableRegions(tableTwo);
|
||||
hris = ADMIN.getRegions(tableTwo);
|
||||
assertEquals(initialRegions, hris.size());
|
||||
Collections.sort(hris);
|
||||
Collections.sort(hris, RegionInfo.COMPARATOR);
|
||||
// verify that we cannot split
|
||||
HRegionInfo hriToSplit2 = hris.get(1);
|
||||
try {
|
||||
ADMIN.split(tableTwo, Bytes.toBytes("6"));
|
||||
fail();
|
||||
|
@ -396,7 +402,7 @@ public class TestNamespaceAuditor {
|
|||
// Expected
|
||||
}
|
||||
Thread.sleep(2000);
|
||||
assertEquals(initialRegions, ADMIN.getTableRegions(tableTwo).size());
|
||||
assertEquals(initialRegions, ADMIN.getRegions(tableTwo).size());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue