HBASE-27822 TestFromClientSide5.testAppendWithoutWAL is flaky (#5211)

Signed-off-by: Liangjun He <heliangjun@apache.org>
This commit is contained in:
Duo Zhang 2023-05-04 20:58:38 +08:00 committed by GitHub
parent 4e69921a00
commit b59eb96407
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 18 deletions

View File

@ -98,8 +98,8 @@ class FromClientSideBase {
return confClass.getName().equals(registryImpl.getName()) && numHedgedReqs == hedgedReqConfig; return confClass.getName().equals(registryImpl.getName()) && numHedgedReqs == hedgedReqConfig;
} }
protected static final void initialize(Class<?> registryImpl, int numHedgedReqs, Class<?>... cps) protected static final void initialize(Class<? extends ConnectionRegistry> registryImpl,
throws Exception { int numHedgedReqs, Class<?>... cps) throws Exception {
// initialize() is called for every unit test, however we only want to reset the cluster state // initialize() is called for every unit test, however we only want to reset the cluster state
// at the end of every parameterized run. // at the end of every parameterized run.
if (isSameParameterizedCluster(registryImpl, numHedgedReqs)) { if (isSameParameterizedCluster(registryImpl, numHedgedReqs)) {

View File

@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -91,6 +90,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -115,6 +115,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
@ClassRule @ClassRule
public static final HBaseClassTestRule CLASS_RULE = public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestFromClientSide5.class); HBaseClassTestRule.forClass(TestFromClientSide5.class);
@Rule @Rule
public TableNameTestRule name = new TableNameTestRule(); public TableNameTestRule name = new TableNameTestRule();
@ -122,14 +123,15 @@ public class TestFromClientSide5 extends FromClientSideBase {
TestFromClientSide5() { TestFromClientSide5() {
} }
public TestFromClientSide5(Class registry, int numHedgedReqs) throws Exception { public TestFromClientSide5(Class<? extends ConnectionRegistry> registry, int numHedgedReqs)
throws Exception {
initialize(registry, numHedgedReqs, MultiRowMutationEndpoint.class); initialize(registry, numHedgedReqs, MultiRowMutationEndpoint.class);
} }
@Parameterized.Parameters @Parameters(name = "{index}: registry={0}, numHedgedReqs={1}")
public static Collection parameters() { public static List<Object[]> parameters() {
return Arrays.asList(new Object[][] { { MasterRegistry.class, 1 }, { MasterRegistry.class, 2 }, return Arrays.asList(new Object[] { MasterRegistry.class, 1 },
{ ZKConnectionRegistry.class, 1 } }); new Object[] { MasterRegistry.class, 2 }, new Object[] { ZKConnectionRegistry.class, 1 });
} }
@AfterClass @AfterClass
@ -771,10 +773,20 @@ public class TestFromClientSide5 extends FromClientSideBase {
t.put(put_1); t.put(put_1);
List<Result> results = new LinkedList<>(); List<Result> results = new LinkedList<>();
try (ResultScanner scanner = t.getScanner(s)) { 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_1);
t.append(append_2); t.append(append_2);
t.append(append_3); t.append(append_3);
for (Result r : scanner) { for (;;) {
r = scanner.next();
if (r == null) {
break;
}
results.add(r); results.add(r);
} }
} }
@ -788,11 +800,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
List<Result> resultsWithWal = doAppend(true); List<Result> resultsWithWal = doAppend(true);
List<Result> resultsWithoutWal = doAppend(false); List<Result> resultsWithoutWal = doAppend(false);
assertEquals(resultsWithWal.size(), resultsWithoutWal.size()); 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 resultWithWal = resultsWithWal.get(i);
Result resultWithoutWal = resultsWithoutWal.get(i); Result resultWithoutWal = resultsWithoutWal.get(i);
assertEquals(resultWithWal.rawCells().length, resultWithoutWal.rawCells().length); 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 cellWithWal = resultWithWal.rawCells()[j];
Cell cellWithoutWal = resultWithoutWal.rawCells()[j]; Cell cellWithoutWal = resultWithoutWal.rawCells()[j];
assertArrayEquals(CellUtil.cloneRow(cellWithWal), CellUtil.cloneRow(cellWithoutWal)); assertArrayEquals(CellUtil.cloneRow(cellWithWal), CellUtil.cloneRow(cellWithoutWal));

View File

@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.client; package org.apache.hadoop.hbase.client;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.List;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint; import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
import org.apache.hadoop.hbase.regionserver.NoOpScanPolicyObserver; 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.AfterClass;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.experimental.categories.Category; 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 * 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 // Override the parameters from the parent class. We just want to run it for the default
// param combination. // param combination.
@Parameterized.Parameters @Parameters(name = "{index}: registry={0}, numHedgedReqs={1}")
public static Collection parameters() { public static List<Object[]> parameters() {
return Arrays return Arrays.asList(new Object[] { MasterRegistry.class, 1 },
.asList(new Object[][] { { MasterRegistry.class, 1 }, { ZKConnectionRegistry.class, 1 } }); new Object[] { ZKConnectionRegistry.class, 1 });
} }
@AfterClass @AfterClass
@ -52,7 +52,8 @@ public class TestFromClientSideWithCoprocessor5 extends TestFromClientSide5 {
afterClass(); afterClass();
} }
public TestFromClientSideWithCoprocessor5(Class registry, int numHedgedReqs) throws Exception { public TestFromClientSideWithCoprocessor5(Class<? extends ConnectionRegistry> registry,
int numHedgedReqs) throws Exception {
initialize(registry, numHedgedReqs, NoOpScanPolicyObserver.class, initialize(registry, numHedgedReqs, NoOpScanPolicyObserver.class,
MultiRowMutationEndpoint.class); MultiRowMutationEndpoint.class);
} }