You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/05/04 12:58:45 UTC
[hbase] branch master updated: HBASE-27822 TestFromClientSide5.testAppendWithoutWAL is flaky (#5211)
This is an automated email from the ASF dual-hosted git repository.
zhangduo 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 b59eb964074 HBASE-27822 TestFromClientSide5.testAppendWithoutWAL is flaky (#5211)
b59eb964074 is described below
commit b59eb9640749bfb1bc22bbcb4a36921b79ad176f
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu May 4 20:58:38 2023 +0800
HBASE-27822 TestFromClientSide5.testAppendWithoutWAL is flaky (#5211)
Signed-off-by: Liangjun He <he...@apache.org>
---
.../hadoop/hbase/client/FromClientSideBase.java | 4 +--
.../hadoop/hbase/client/TestFromClientSide5.java | 30 +++++++++++++++-------
.../client/TestFromClientSideWithCoprocessor5.java | 15 ++++++-----
3 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/FromClientSideBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/FromClientSideBase.java
index 75e6738c126..fbd6e25c076 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/FromClientSideBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/FromClientSideBase.java
@@ -98,8 +98,8 @@ class FromClientSideBase {
return confClass.getName().equals(registryImpl.getName()) && numHedgedReqs == hedgedReqConfig;
}
- protected static final void initialize(Class<?> registryImpl, int numHedgedReqs, Class<?>... cps)
- throws Exception {
+ protected static final void initialize(Class<? extends ConnectionRegistry> registryImpl,
+ int numHedgedReqs, Class<?>... cps) throws Exception {
// initialize() is called for every unit test, however we only want to reset the cluster state
// at the end of every parameterized run.
if (isSameParameterizedCluster(registryImpl, numHedgedReqs)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
index 5a04697630d..8f820158e46 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -91,6 +90,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,6 +115,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestFromClientSide5.class);
+
@Rule
public TableNameTestRule name = new TableNameTestRule();
@@ -122,14 +123,15 @@ public class TestFromClientSide5 extends FromClientSideBase {
TestFromClientSide5() {
}
- public TestFromClientSide5(Class registry, int numHedgedReqs) throws Exception {
+ public TestFromClientSide5(Class<? extends ConnectionRegistry> registry, int numHedgedReqs)
+ throws Exception {
initialize(registry, numHedgedReqs, MultiRowMutationEndpoint.class);
}
- @Parameterized.Parameters
- public static Collection parameters() {
- return Arrays.asList(new Object[][] { { MasterRegistry.class, 1 }, { MasterRegistry.class, 2 },
- { ZKConnectionRegistry.class, 1 } });
+ @Parameters(name = "{index}: registry={0}, numHedgedReqs={1}")
+ public static List<Object[]> parameters() {
+ return Arrays.asList(new Object[] { MasterRegistry.class, 1 },
+ new Object[] { MasterRegistry.class, 2 }, new Object[] { ZKConnectionRegistry.class, 1 });
}
@AfterClass
@@ -771,10 +773,20 @@ public class TestFromClientSide5 extends FromClientSideBase {
t.put(put_1);
List<Result> results = new LinkedList<>();
try (ResultScanner scanner = t.getScanner(s)) {
+ // get one row(should be row3) from the scanner to make sure that we have send a request to
+ // region server, which means we have already set the read point, so later we should not see
+ // the new appended values.
+ Result r = scanner.next();
+ assertNotNull(r);
+ results.add(r);
t.append(append_1);
t.append(append_2);
t.append(append_3);
- for (Result r : scanner) {
+ for (;;) {
+ r = scanner.next();
+ if (r == null) {
+ break;
+ }
results.add(r);
}
}
@@ -788,11 +800,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
List<Result> resultsWithWal = doAppend(true);
List<Result> resultsWithoutWal = doAppend(false);
assertEquals(resultsWithWal.size(), resultsWithoutWal.size());
- for (int i = 0; i != resultsWithWal.size(); ++i) {
+ for (int i = 0; i < resultsWithWal.size(); ++i) {
Result resultWithWal = resultsWithWal.get(i);
Result resultWithoutWal = resultsWithoutWal.get(i);
assertEquals(resultWithWal.rawCells().length, resultWithoutWal.rawCells().length);
- for (int j = 0; j != resultWithWal.rawCells().length; ++j) {
+ for (int j = 0; j < resultWithWal.rawCells().length; ++j) {
Cell cellWithWal = resultWithWal.rawCells()[j];
Cell cellWithoutWal = resultWithoutWal.rawCells()[j];
assertArrayEquals(CellUtil.cloneRow(cellWithWal), CellUtil.cloneRow(cellWithoutWal));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSideWithCoprocessor5.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSideWithCoprocessor5.java
index e1677dfeb6c..759360f4b5e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSideWithCoprocessor5.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSideWithCoprocessor5.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.client;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.List;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
import org.apache.hadoop.hbase.regionserver.NoOpScanPolicyObserver;
@@ -27,7 +27,7 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
-import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
/**
* Test all client operations with a coprocessor that just implements the default flush/compact/scan
@@ -41,10 +41,10 @@ public class TestFromClientSideWithCoprocessor5 extends TestFromClientSide5 {
// Override the parameters from the parent class. We just want to run it for the default
// param combination.
- @Parameterized.Parameters
- public static Collection parameters() {
- return Arrays
- .asList(new Object[][] { { MasterRegistry.class, 1 }, { ZKConnectionRegistry.class, 1 } });
+ @Parameters(name = "{index}: registry={0}, numHedgedReqs={1}")
+ public static List<Object[]> parameters() {
+ return Arrays.asList(new Object[] { MasterRegistry.class, 1 },
+ new Object[] { ZKConnectionRegistry.class, 1 });
}
@AfterClass
@@ -52,7 +52,8 @@ public class TestFromClientSideWithCoprocessor5 extends TestFromClientSide5 {
afterClass();
}
- public TestFromClientSideWithCoprocessor5(Class registry, int numHedgedReqs) throws Exception {
+ public TestFromClientSideWithCoprocessor5(Class<? extends ConnectionRegistry> registry,
+ int numHedgedReqs) throws Exception {
initialize(registry, numHedgedReqs, NoOpScanPolicyObserver.class,
MultiRowMutationEndpoint.class);
}