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 2008c806021..dd8bd3a03ea 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 @@ -97,8 +97,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 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 ceef1ef3247..e72bd8fee86 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; @@ -96,6 +95,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; @@ -113,6 +113,7 @@ public class TestFromClientSide5 extends FromClientSideBase { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestFromClientSide5.class); + @Rule public TableNameTestRule name = new TableNameTestRule(); @@ -120,14 +121,15 @@ public class TestFromClientSide5 extends FromClientSideBase { TestFromClientSide5() { } - public TestFromClientSide5(Class registry, int numHedgedReqs) throws Exception { + public TestFromClientSide5(Class 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 parameters() { + return Arrays.asList(new Object[] { MasterRegistry.class, 1 }, + new Object[] { MasterRegistry.class, 2 }, new Object[] { ZKConnectionRegistry.class, 1 }); } @AfterClass @@ -769,10 +771,20 @@ public class TestFromClientSide5 extends FromClientSideBase { t.put(put_1); List 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); } } @@ -786,11 +798,11 @@ public class TestFromClientSide5 extends FromClientSideBase { List resultsWithWal = doAppend(true); List 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 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 registry, + int numHedgedReqs) throws Exception { initialize(registry, numHedgedReqs, NoOpScanPolicyObserver.class, MultiRowMutationEndpoint.class); }