Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions hbase-procedure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-metrics-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
*/
package org.apache.hadoop.hbase.procedure2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -264,8 +267,8 @@ public static <TEnv> void setKillAndToggleBeforeStoreUpdateInRollback(
if (
procExecutor.testing.killBeforeStoreUpdate || procExecutor.testing.toggleKillBeforeStoreUpdate
) {
assertEquals("expected only one executor running during test with kill/restart", 1,
procExecutor.getCorePoolSize());
assertEquals(1, procExecutor.getCorePoolSize(),
"expected only one executor running during test with kill/restart");
}
}

Expand Down Expand Up @@ -342,48 +345,48 @@ public static <TEnv> void waitNoProcedureRunning(ProcedureExecutor<TEnv> procExe

public static <TEnv> void assertProcNotYetCompleted(ProcedureExecutor<TEnv> procExecutor,
long procId) {
assertFalse("expected a running proc", procExecutor.isFinished(procId));
assertEquals(null, procExecutor.getResult(procId));
assertFalse(procExecutor.isFinished(procId), "expected a running proc");
assertNull(procExecutor.getResult(procId));
}

public static <TEnv> void assertProcNotFailed(ProcedureExecutor<TEnv> procExecutor, long procId) {
Procedure<?> result = procExecutor.getResult(procId);
assertTrue("expected procedure result", result != null);
assertNotNull(result, "expected procedure result");
assertProcNotFailed(result);
}

public static void assertProcNotFailed(final Procedure<?> result) {
assertFalse("found exception: " + result.getException(), result.isFailed());
assertFalse(result.isFailed(), "found exception: " + result.getException());
}

public static <TEnv> Throwable assertProcFailed(final ProcedureExecutor<TEnv> procExecutor,
final long procId) {
Procedure<?> result = procExecutor.getResult(procId);
assertTrue("expected procedure result", result != null);
assertNotNull(result, "expected procedure result");
return assertProcFailed(result);
}

public static Throwable assertProcFailed(final Procedure<?> result) {
assertEquals(true, result.isFailed());
assertTrue(result.isFailed());
LOG.info("procId=" + result.getProcId() + " exception: " + result.getException().getMessage());
return getExceptionCause(result);
}

public static void assertIsAbortException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected abort exception, got " + cause,
cause instanceof ProcedureAbortedException);
assertInstanceOf(ProcedureAbortedException.class, cause,
"expected abort exception, got " + cause);
}

public static void assertIsTimeoutException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected TimeoutIOException, got " + cause, cause instanceof TimeoutIOException);
assertInstanceOf(TimeoutIOException.class, cause, "expected TimeoutIOException, got " + cause);
}

public static void assertIsIllegalArgumentException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected IllegalArgumentIOException, got " + cause,
cause instanceof IllegalArgumentIOException);
assertInstanceOf(IllegalArgumentIOException.class, cause,
"expected IllegalArgumentIOException, got " + cause);
}

public static Throwable getExceptionCause(final Procedure<?> procInfo) {
Expand Down Expand Up @@ -669,7 +672,7 @@ public void load(ProcedureIterator procIter) throws IOException {
runnable.add(proc);
}
if (procIds != null) {
assertTrue("procId=" + procId + " unexpected", procIds.contains(procId));
assertTrue(procIds.contains(procId), "procId=" + procId + " unexpected");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,27 @@
*/
package org.apache.hadoop.hbase.procedure2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Category({ MasterTests.class, SmallTests.class })
@Tag(MasterTests.TAG)
@Tag(SmallTests.TAG)
public class TestChildProcedures {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestChildProcedures.class);

private static final Logger LOG = LoggerFactory.getLogger(TestChildProcedures.class);

private static final int PROCEDURE_EXECUTOR_SLOTS = 1;
Expand All @@ -56,7 +51,7 @@ public class TestChildProcedures {
private Path testDir;
private Path logDir;

@Before
@BeforeEach
public void setUp() throws IOException {
htu = new HBaseCommonTestingUtility();
testDir = htu.getDataTestDir();
Expand All @@ -72,7 +67,7 @@ public void setUp() throws IOException {
ProcedureTestingUtility.initAndStartWorkers(procExecutor, PROCEDURE_EXECUTOR_SLOTS, true);
}

@After
@AfterEach
public void tearDown() throws IOException {
procExecutor.stop();
procStore.stop(false);
Expand All @@ -88,7 +83,7 @@ public void testChildLoad() throws Exception {
ProcedureTestingUtility.restart(procExecutor);
ProcedureTestingUtility.waitProcedure(procExecutor, proc);

assertTrue("expected completed proc", procExecutor.isFinished(procId));
assertTrue(procExecutor.isFinished(procId), "expected completed proc");
ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);
}

Expand All @@ -105,7 +100,7 @@ public void testChildLoadWithSteppedRestart() throws Exception {
restartCount++;
}
assertEquals(3, restartCount);
assertTrue("expected completed proc", procExecutor.isFinished(procId));
assertTrue(procExecutor.isFinished(procId), "expected completed proc");
ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);
}

Expand All @@ -126,7 +121,7 @@ public void testChildLoadWithRestartAfterChildSuccess() throws Exception {
restartCount++;
}
assertEquals(4, restartCount);
assertTrue("expected completed proc", procExecutor.isFinished(procId));
assertTrue(procExecutor.isFinished(procId), "expected completed proc");
ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);
}

Expand Down Expand Up @@ -161,9 +156,9 @@ public void testChildRollbackLoadWithSteppedRestart() throws Exception {
}

private void assertProcFailed(long procId) {
assertTrue("expected completed proc", procExecutor.isFinished(procId));
assertTrue(procExecutor.isFinished(procId), "expected completed proc");
Procedure<?> result = procExecutor.getResult(procId);
assertEquals(true, result.isFailed());
assertTrue(result.isFailed());
LOG.info(result.getException().getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,55 @@
*/
package org.apache.hadoop.hbase.procedure2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Exchanger;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.NoopProcedure;
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;

@Category({ MasterTests.class, SmallTests.class })
@Tag(MasterTests.TAG)
@Tag(SmallTests.TAG)
public class TestForceUpdateProcedure {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestForceUpdateProcedure.class);

private static HBaseCommonTestingUtility UTIL = new HBaseCommonTestingUtility();

private static WALProcedureStore STORE;

private static ProcedureExecutor<Void> EXEC;

private static Exchanger<Boolean> EXCHANGER = new Exchanger<>();
private static final Exchanger<Boolean> EXCHANGER = new Exchanger<>();

private static int WAL_COUNT = 5;
private static final int WAL_COUNT = 5;

@Rule
public final TestName name = new TestName();
private String methodName;

private void createStoreAndExecutor() throws IOException {
UTIL.getConfiguration().setInt(CompletedProcedureCleaner.CLEANER_INTERVAL_CONF_KEY, 1000);
Path logDir = UTIL.getDataTestDir(name.getMethodName());
Path logDir = UTIL.getDataTestDir(methodName);
STORE = ProcedureTestingUtility.createWalStore(UTIL.getConfiguration(), logDir);
STORE.start(1);
EXEC = new ProcedureExecutor<Void>(UTIL.getConfiguration(), null, STORE);
EXEC = new ProcedureExecutor<>(UTIL.getConfiguration(), null, STORE);
ProcedureTestingUtility.initAndStartWorkers(EXEC, 1, true);
}

@BeforeClass
@BeforeAll
public static void setUpBeforeClass() throws IOException {
UTIL.getConfiguration().setInt(WALProcedureStore.WAL_COUNT_WARN_THRESHOLD_CONF_KEY, WAL_COUNT);
}
Expand All @@ -84,17 +77,18 @@ private void stopStoreAndExecutor() {
STORE = null;
}

@AfterClass
@AfterAll
public static void tearDownAfterClass() throws IOException {
UTIL.cleanupTestDir();
}

@Before
public void setUp() throws IOException {
@BeforeEach
public void setUp(TestInfo testInfo) throws IOException {
methodName = testInfo.getTestMethod().get().getName();
createStoreAndExecutor();
}

@After
@AfterEach
public void tearDown() {
stopStoreAndExecutor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,21 @@
*/
package org.apache.hadoop.hbase.procedure2;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashMap;
import java.util.Map;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.NoopProcedure;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category({ MasterTests.class, SmallTests.class })
@Tag(MasterTests.TAG)
@Tag(SmallTests.TAG)
public class TestLockAndQueue {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestLockAndQueue.class);

@Test
public void testHasLockAccess() {
Map<Long, NoopProcedure<Void>> procMap = new HashMap<>();
Expand Down
Loading