You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2022/06/23 14:29:07 UTC
[hbase] branch master updated: HBASE-26790 Addendum ensure test is not flaky due to async caching
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 59e5c610e32 HBASE-26790 Addendum ensure test is not flaky due to async caching
59e5c610e32 is described below
commit 59e5c610e32bb3d9b9bd085b449b52287a48830a
Author: Bryan Beaudreault <bb...@hubspot.com>
AuthorDate: Thu Jun 23 10:22:55 2022 -0400
HBASE-26790 Addendum ensure test is not flaky due to async caching
---
.../hbase/client/TestAsyncNonMetaRegionLocator.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
index 6655bba3d4f..f3b231d5bde 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
@@ -494,8 +494,9 @@ public class TestAsyncNonMetaRegionLocator {
regionLocator.clearRegionLocationCache();
regionLocator.getAllRegionLocations().get();
+ int tries = 3;
// expect all to be non-null at first
- checkRegions(conn, regions, null);
+ checkRegionsWithRetries(conn, regions, null, tries);
// clear servername from region info
Put put = MetaTableAccessor.makePutFromRegionInfo(chosen, EnvironmentEdgeManager.currentTime());
@@ -511,7 +512,23 @@ public class TestAsyncNonMetaRegionLocator {
}
// expect all but chosen to be non-null. chosen should be null because serverName was null
- checkRegions(conn, regions, chosen);
+ checkRegionsWithRetries(conn, regions, chosen, tries);
+ }
+
+ // caching of getAllRegionLocations is async. so we give it a couple tries
+ private void checkRegionsWithRetries(AsyncConnectionImpl conn, List<RegionInfo> regions,
+ RegionInfo chosen, int retries) throws InterruptedException {
+ while (true) {
+ try {
+ checkRegions(conn, regions, chosen);
+ break;
+ } catch (AssertionError e) {
+ if (retries-- <= 0) {
+ throw e;
+ }
+ Thread.sleep(500);
+ }
+ }
}
private void checkRegions(AsyncConnectionImpl conn, List<RegionInfo> regions, RegionInfo chosen) {