Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend HBASE-26187 UTs, adding a check for Split procedure completion … #3598

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.regionserver;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.List;
Expand All @@ -30,6 +31,8 @@
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.master.assignment.SplitTableRegionProcedure;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -98,6 +101,7 @@ public void testMergeStoreFile() throws Exception {
TEST_UTIL.createTable(table, FAMILY_NAME);
//splitting the table first
TEST_UTIL.getAdmin().split(table, Bytes.toBytes("002"));
waitForSplitProcComplete(1000, 10);
//Add data and flush to create files in the two different regions
putThreeRowsAndFlush(table);
List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(table);
Expand Down Expand Up @@ -176,6 +180,7 @@ public void testCommitMergedRegion() throws Exception {
TEST_UTIL.createTable(table, FAMILY_NAME);
//splitting the table first
TEST_UTIL.getAdmin().split(table, Bytes.toBytes("002"));
waitForSplitProcComplete(1000, 10);
//Add data and flush to create files in the two different regions
putThreeRowsAndFlush(table);
List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(table);
Expand All @@ -202,6 +207,22 @@ public void testCommitMergedRegion() throws Exception {
mergeRegionFs.commitMergedRegion();
}

private void waitForSplitProcComplete(int attempts, int waitTime) throws Exception {
List<Procedure<?>> procedures = TEST_UTIL.getHBaseCluster().getMaster().getProcedures();
if(procedures.size()>0) {
Procedure splitProc = procedures.stream().
filter(p -> p instanceof SplitTableRegionProcedure).findFirst().get();
Comment on lines +211 to +214
Copy link
Contributor Author

@wchevreuil wchevreuil Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to modify this logic a bit. The branch-2 version is wrong, leading to NoSuchElement when the first proc is not a split one. I will cherry-pick this once it gets merged.

int count = 0;
while ((splitProc.isWaiting() || splitProc.isRunnable()) && count < attempts) {
synchronized (splitProc) {
splitProc.wait(waitTime);
}
count++;
}
assertTrue(splitProc.isSuccess());
}
}

private void mergeFileFromRegion(HRegionFileSystem regionFS, HRegion regionToMerge,
HStoreFile file) throws IOException {
Path mergedFile = regionFS.mergeStoreFile(regionToMerge.getRegionInfo(),
Expand Down