Skip to content

Commit

Permalink
HBASE-27822 TestFromClientSide5.testAppendWithoutWAL is flaky (apache…
Browse files Browse the repository at this point in the history
…#5211)

Signed-off-by: Liangjun He <heliangjun@apache.org>
(cherry picked from commit b59eb96)
(cherry picked from commit af78169)
Change-Id: Ia08fc63548ddccbfd8f32fb5c4ac6bc37b9e5080
  • Loading branch information
Apache9 authored and Jenkins User committed May 8, 2023
1 parent 9855f26 commit 2fcb7f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ protected static boolean isSameParameterizedCluster(Class<?> registryImpl, int n
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;
Expand Down Expand Up @@ -96,6 +95,7 @@
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;

Expand All @@ -113,21 +113,23 @@ public class TestFromClientSide5 extends FromClientSideBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestFromClientSide5.class);

@Rule
public TableNameTestRule name = new TableNameTestRule();

// To keep the child classes happy.
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
Expand Down Expand Up @@ -769,10 +771,20 @@ private List<Result> doAppend(final boolean walUsed) throws IOException {
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);
}
}
Expand All @@ -786,11 +798,11 @@ public void testAppendWithoutWAL() throws Exception {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +27,7 @@
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
Expand All @@ -41,18 +41,19 @@ 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
public static void tearDownAfterClass() throws Exception {
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);
}
Expand Down

0 comments on commit 2fcb7f5

Please sign in to comment.