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
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.apache.hadoop.hdds.scm.node.NodeManager;
import org.apache.hadoop.hdds.scm.node.NodeStatus;
import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.List;
Expand All @@ -42,7 +42,7 @@ public class TestSCMCommonPlacementPolicy {
private NodeManager nodeManager;
private OzoneConfiguration conf;

@Before
@BeforeEach
public void setup() {
nodeManager = new MockNodeManager(true, 10);
conf = SCMTestUtils.getConf();
Expand All @@ -56,7 +56,7 @@ public void testGetResultSet() throws SCMException {
nodeManager.getNodes(NodeStatus.inServiceHealthy());
List<DatanodeDetails> result = dummyPlacementPolicy.getResultSet(3, list);
Set<DatanodeDetails> resultSet = new HashSet<>(result);
Assert.assertNotEquals(1, resultSet.size());
Assertions.assertNotEquals(1, resultSet.size());
}

private static class DummyPlacementPolicy extends SCMCommonPlacementPolicy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.io.File;
Expand Down Expand Up @@ -93,7 +93,7 @@ public class TestDeletedBlockLog {
private Map<Long, Set<ContainerReplica>> replicas = new HashMap<>();
private ScmBlockDeletingServiceMetrics metrics;

@Before
@BeforeEach
public void setup() throws Exception {
testDir = GenericTestUtils.getTestDir(
TestDeletedBlockLog.class.getSimpleName());
Expand Down Expand Up @@ -148,7 +148,7 @@ private void setupContainerManager() throws IOException {
for (Map.Entry<ContainerID, Long> e : map.entrySet()) {
ContainerInfo info = containers.get(e.getKey().getId());
try {
Assert.assertTrue(e.getValue() > info.getDeleteTransactionId());
Assertions.assertTrue(e.getValue() > info.getDeleteTransactionId());
} catch (AssertionError err) {
throw new Exception("New TxnId " + e.getValue() + " < " + info
.getDeleteTransactionId());
Expand Down Expand Up @@ -181,7 +181,7 @@ private void updateContainerMetadata(long cid) throws IOException {
replicas.put(cid, replicaSet);
}

@After
@AfterEach
public void tearDown() throws Exception {
deletedBlockLog.close();
scm.stop();
Expand Down Expand Up @@ -278,24 +278,24 @@ private List<DeletedBlocksTransaction> getTransactions(
public void testContainerManagerTransactionId() throws Exception {
// Initially all containers should have deleteTransactionId as 0
for (ContainerInfo containerInfo : containerManager.getContainers()) {
Assert.assertEquals(0, containerInfo.getDeleteTransactionId());
Assertions.assertEquals(0, containerInfo.getDeleteTransactionId());
}

// Create 30 TXs
addTransactions(generateData(30), false);
// Since transactions are not yet flushed deleteTransactionId should be
// 0 for all containers
Assert.assertEquals(0, getTransactions(1000).size());
Assertions.assertEquals(0, getTransactions(1000).size());
for (ContainerInfo containerInfo : containerManager.getContainers()) {
Assert.assertEquals(0, containerInfo.getDeleteTransactionId());
Assertions.assertEquals(0, containerInfo.getDeleteTransactionId());
}

scmHADBTransactionBuffer.flush();
// After flush there should be 30 transactions in deleteTable
// All containers should have positive deleteTransactionId
Assert.assertEquals(30, getTransactions(1000).size());
Assertions.assertEquals(30, getTransactions(1000).size());
for (ContainerInfo containerInfo : containerManager.getContainers()) {
Assert.assertTrue(containerInfo.getDeleteTransactionId() > 0);
Assertions.assertTrue(containerInfo.getDeleteTransactionId() > 0);
}
}

Expand All @@ -321,12 +321,12 @@ public void testIncrementCount() throws Exception {
incrementCount(txIDs);
blocks = getTransactions(40 * BLOCKS_PER_TXN);
for (DeletedBlocksTransaction block : blocks) {
Assert.assertEquals(-1, block.getCount());
Assertions.assertEquals(-1, block.getCount());
}

// If all TXs are failed, getTransactions call will always return nothing.
blocks = getTransactions(40 * BLOCKS_PER_TXN);
Assert.assertEquals(blocks.size(), 0);
Assertions.assertEquals(blocks.size(), 0);
}

@Test
Expand All @@ -342,17 +342,17 @@ public void testCommitTransactions() throws Exception {
blocks.remove(blocks.size() - 1);

blocks = getTransactions(50 * BLOCKS_PER_TXN);
Assert.assertEquals(30, blocks.size());
Assertions.assertEquals(30, blocks.size());
commitTransactions(blocks, dnList.get(1), dnList.get(2),
DatanodeDetails.newBuilder().setUuid(UUID.randomUUID())
.build());

blocks = getTransactions(50 * BLOCKS_PER_TXN);
Assert.assertEquals(30, blocks.size());
Assertions.assertEquals(30, blocks.size());
commitTransactions(blocks, dnList.get(0));

blocks = getTransactions(50 * BLOCKS_PER_TXN);
Assert.assertEquals(0, blocks.size());
Assertions.assertEquals(0, blocks.size());
}

@Test
Expand Down Expand Up @@ -385,7 +385,7 @@ public void testRandomOperateTransactions() throws Exception {
scm.getScmMetadataStore().getDeletedBlocksTXTable().iterator()) {
AtomicInteger count = new AtomicInteger();
iter.forEachRemaining((keyValue) -> count.incrementAndGet());
Assert.assertEquals(added, count.get() + committed);
Assertions.assertEquals(added, count.get() + committed);
}
}
}
Expand All @@ -409,10 +409,10 @@ public void testPersistence() throws Exception {
metrics);
List<DeletedBlocksTransaction> blocks =
getTransactions(BLOCKS_PER_TXN * 10);
Assert.assertEquals(10, blocks.size());
Assertions.assertEquals(10, blocks.size());
commitTransactions(blocks);
blocks = getTransactions(BLOCKS_PER_TXN * 40);
Assert.assertEquals(40, blocks.size());
Assertions.assertEquals(40, blocks.size());
commitTransactions(blocks);

// close db and reopen it again to make sure
Expand All @@ -427,8 +427,8 @@ public void testPersistence() throws Exception {
scm.getSequenceIdGen(),
metrics);
blocks = getTransactions(BLOCKS_PER_TXN * 40);
Assert.assertEquals(0, blocks.size());
//Assert.assertEquals((long)deletedBlockLog.getCurrentTXID(), 50L);
Assertions.assertEquals(0, blocks.size());
//Assertions.assertEquals((long)deletedBlockLog.getCurrentTXID(), 50L);
}

@Test
Expand Down Expand Up @@ -459,7 +459,7 @@ public void testDeletedBlockTransactions() throws IOException {

blocks = getTransactions(txNum * BLOCKS_PER_TXN);
// There should be one txn remaining
Assert.assertEquals(1, blocks.size());
Assertions.assertEquals(1, blocks.size());

// add two transactions for same container
containerID = blocks.get(0).getContainerID();
Expand All @@ -474,7 +474,7 @@ public void testDeletedBlockTransactions() throws IOException {

// get should return two transactions for the same container
blocks = getTransactions(txNum);
Assert.assertEquals(2, blocks.size());
Assertions.assertEquals(2, blocks.size());
}

private void mockContainerInfo(long containerID, DatanodeDetails dd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
import org.apache.hadoop.hdds.server.events.Event;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.ozone.test.GenericTestUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

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

/**
* Unit test for command status report handler.
Expand All @@ -55,7 +55,7 @@ public class TestCommandStatusReportHandler implements EventPublisher {
.getLogger(TestCommandStatusReportHandler.class);
private CommandStatusReportHandler cmdStatusReportHandler;

@Before
@BeforeEach
public void setup() {
cmdStatusReportHandler = new CommandStatusReportHandler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
import static org.apache.hadoop.hdds.scm.events.SCMEvents.CLOSE_CONTAINER;
import static org.apache.hadoop.hdds.scm.events.SCMEvents.DATANODE_COMMAND;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/**
* Tests the closeContainerEventHandler class.
Expand All @@ -76,7 +76,7 @@ public class TestCloseContainerEventHandler {
private static SCMHAManager scmhaManager;
private static SequenceIdGenerator sequenceIdGen;

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
configuration = SCMTestUtils.getConf();
size = (long)configuration.getStorageSize(OZONE_SCM_CONTAINER_SIZE,
Expand Down Expand Up @@ -130,7 +130,7 @@ public static void setUp() throws Exception {
HddsTestUtils.openAllRatisPipelines(pipelineManager);
}

@AfterClass
@AfterAll
public static void tearDown() throws Exception {
if (containerManager != null) {
containerManager.close();
Expand All @@ -151,7 +151,7 @@ public void testIfCloseContainerEventHadnlerInvoked() {
eventQueue.fireEvent(CLOSE_CONTAINER,
ContainerID.valueOf(Math.abs(RandomUtils.nextInt())));
eventQueue.processAll(1000);
Assert.assertTrue(logCapturer.getOutput()
Assertions.assertTrue(logCapturer.getOutput()
.contains("Close container Event triggered for container"));
}

Expand All @@ -163,7 +163,7 @@ public void testCloseContainerEventWithInvalidContainer() {
eventQueue.fireEvent(CLOSE_CONTAINER,
ContainerID.valueOf(id));
eventQueue.processAll(1000);
Assert.assertTrue(logCapturer.getOutput()
Assertions.assertTrue(logCapturer.getOutput()
.contains("Failed to close the container"));
}

Expand All @@ -178,9 +178,9 @@ public void testCloseContainerEventWithValidContainers() throws IOException {
int closeCount = nodeManager.getCommandCount(datanode);
eventQueue.fireEvent(CLOSE_CONTAINER, id);
eventQueue.processAll(1000);
Assert.assertEquals(closeCount + 1,
Assertions.assertEquals(closeCount + 1,
nodeManager.getCommandCount(datanode));
Assert.assertEquals(HddsProtos.LifeCycleState.CLOSING,
Assertions.assertEquals(HddsProtos.LifeCycleState.CLOSING,
containerManager.getContainer(id).getState());
}

Expand All @@ -204,7 +204,8 @@ public void testCloseContainerEventWithRatis() throws IOException {
i = 0;
for (DatanodeDetails details : pipelineManager
.getPipeline(container.getPipelineID()).getNodes()) {
Assert.assertEquals(closeCount[i], nodeManager.getCommandCount(details));
Assertions.assertEquals(closeCount[i],
nodeManager.getCommandCount(details));
i++;
}
eventQueue.fireEvent(CLOSE_CONTAINER, id);
Expand All @@ -213,9 +214,9 @@ public void testCloseContainerEventWithRatis() throws IOException {
// Make sure close is queued for each datanode on the pipeline
for (DatanodeDetails details : pipelineManager
.getPipeline(container.getPipelineID()).getNodes()) {
Assert.assertEquals(closeCount[i] + 1,
Assertions.assertEquals(closeCount[i] + 1,
nodeManager.getCommandCount(details));
Assert.assertEquals(HddsProtos.LifeCycleState.CLOSING,
Assertions.assertEquals(HddsProtos.LifeCycleState.CLOSING,
containerManager.getContainer(id).getState());
i++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.hadoop.hdds.scm.events.SCMEvents;
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.ContainerActionsFromDatanode;
import org.apache.hadoop.hdds.server.events.EventQueue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.mockito.Mockito.times;
Expand Down
Loading