Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -72,6 +72,8 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -259,12 +261,9 @@ public void testOzFsReadWrite() throws IOException {
o3fs.pathToKey(path));

// verify prefix directories and the file, do not already exist
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(lev1key) == null);
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(lev2key) == null);
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(fileKey) == null);
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev1key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev2key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(fileKey));

try (FSDataOutputStream stream = fs.create(path)) {
stream.writeBytes(data);
Expand Down Expand Up @@ -376,19 +375,16 @@ public void testDirectory() throws IOException {
o3fs.pathToKey(leaf));

// verify prefix directories and the leaf, do not already exist
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(lev1key) == null);
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(lev2key) == null);
assertTrue(
metadataManager.getKeyTable(getBucketLayout()).get(leafKey) == null);
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev1key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev2key));
assertNull(metadataManager.getKeyTable(getBucketLayout()).get(leafKey));

assertTrue("Makedirs returned with false for the path " + leaf,
fs.mkdirs(leaf));

// verify the leaf directory got created.
leafstatus = getDirectoryStat(leaf);
assertTrue(leafstatus != null);
assertNotNull(leafstatus);

FileStatus lev1status;
FileStatus lev2status;
Expand All @@ -409,7 +405,7 @@ public void testDirectory() throws IOException {

// check the root directory
rootstatus = getDirectoryStat(createPath("/"));
assertTrue(rootstatus != null);
assertNotNull(rootstatus);

// root directory listing should contain the lev1 prefix directory
FileStatus[] statusList = fs.listStatus(createPath("/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static org.apache.hadoop.ozone.OzoneConsts.SCM_DUMMY_SERVICE_ID;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_SERVER_REQUEST_TIMEOUT_DEFAULT;
import static org.apache.hadoop.ozone.om.TestOzoneManagerHA.createKey;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -131,10 +132,10 @@ private void assertNewOMExistsInPeerList(String nodeId) throws Exception {
+ " not present in Peer list of OM " + om.getOMNodeId());
assertTrue(om.getOmRatisServer().doesPeerExist(nodeId), "New OM node " + nodeId
+ " not present in Peer list of OM " + om.getOMNodeId() + " RatisServer");
assertTrue(
om.getOmRatisServer().getCurrentPeersFromRaftConf().contains(nodeId),
"New OM node " + nodeId + " not present in " + "OM "
+ om.getOMNodeId() + "RatisServer's RaftConf");
assertThat(
om.getOmRatisServer().getCurrentPeersFromRaftConf())
.withFailMessage("New OM node " + nodeId + " not present in " + "OM "
+ om.getOMNodeId() + "RatisServer's RaftConf").contains(nodeId);
}

OzoneManager newOM = cluster.getOzoneManager(nodeId);
Expand All @@ -144,7 +145,8 @@ private void assertNewOMExistsInPeerList(String nodeId) throws Exception {

// Check Ratis Dir for log files
File[] logFiles = getRatisLogFiles(newOM);
assertTrue(logFiles.length > 0, "There are no ratis logs in new OM ");
assertThat(logFiles.length).withFailMessage("There are no ratis logs in new OM ")
.isGreaterThan(0);
}

private File[] getRatisLogFiles(OzoneManager om) {
Expand Down Expand Up @@ -197,9 +199,8 @@ public void testBootstrap() throws Exception {
GenericTestUtils.waitFor(() -> cluster.getOMLeader() != null, 500, 30000);
OzoneManager omLeader = cluster.getOMLeader();

assertTrue(newOMNodeIds.contains(omLeader.getOMNodeId()),
"New Bootstrapped OM not elected Leader even though" +
" other OMs are down");
assertThat(newOMNodeIds).withFailMessage("New Bootstrapped OM not elected Leader even though" +
" other OMs are down").contains(omLeader.getOMNodeId());

// Perform some read and write operations with new OM leader
IOUtils.closeQuietly(client);
Expand Down Expand Up @@ -247,10 +248,10 @@ public void testBootstrapWithoutConfigUpdate() throws Exception {
Lists.newArrayList(existingOM.getNodeDetails())) + " do not have or" +
" have incorrect information of the bootstrapping OM. Update their " +
"ozone-site.xml before proceeding.", e.getMessage());
assertTrue(omLog.getOutput().contains("Remote OM config check " +
"failed on OM " + existingOMNodeId));
assertTrue(miniOzoneClusterLog.getOutput().contains(newNodeId +
" - System Exit"));
assertThat(omLog.getOutput()).contains("Remote OM config check " +
"failed on OM " + existingOMNodeId);
assertThat(miniOzoneClusterLog.getOutput()).contains(newNodeId +
" - System Exit");
}

/***************************************************************************
Expand All @@ -268,11 +269,11 @@ public void testBootstrapWithoutConfigUpdate() throws Exception {
try {
cluster.bootstrapOzoneManager(newNodeId, false, true);
} catch (IOException e) {
assertTrue(omLog.getOutput().contains("Couldn't add OM " +
newNodeId + " to peer list."));
assertTrue(miniOzoneClusterLog.getOutput().contains(
assertThat(omLog.getOutput()).contains("Couldn't add OM " +
newNodeId + " to peer list.");
assertThat(miniOzoneClusterLog.getOutput()).contains(
existingOMNodeId + " - System Exit: There is no OM configuration " +
"for node ID " + newNodeId + " in ozone-site.xml."));
"for node ID " + newNodeId + " in ozone-site.xml.");

// Verify that the existing OM has stopped.
assertFalse(cluster.getOzoneManager(existingOMNodeId).isRunning());
Expand Down Expand Up @@ -321,12 +322,12 @@ public void testForceBootstrap() throws Exception {
Lists.newArrayList(downOM.getNodeDetails())) + " do not have or " +
"have incorrect information of the bootstrapping OM. Update their " +
"ozone-site.xml before proceeding.", e.getMessage());
assertTrue(omLog.getOutput().contains("Remote OM " + downOMNodeId +
" configuration returned null"));
assertTrue(omLog.getOutput().contains("Remote OM config check " +
"failed on OM " + downOMNodeId));
assertTrue(miniOzoneClusterLog.getOutput().contains(newNodeId +
" - System Exit"));
assertThat(omLog.getOutput()).contains("Remote OM " + downOMNodeId +
" configuration returned null");
assertThat(omLog.getOutput()).contains("Remote OM config check " +
"failed on OM " + downOMNodeId);
assertThat(miniOzoneClusterLog.getOutput()).contains(newNodeId +
" - System Exit");
}

/***************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@

import org.mockito.Mockito;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -317,8 +318,8 @@ public void allocateBlockFailureInSafeMode() throws Exception {
OMException omException = assertThrows(OMException.class,
() ->
writeClient.allocateBlock(keyArgs, 1L, new ExcludeList()));
assertTrue(omException.getMessage()
.contains("SafeModePrecheck failed for allocateBlock"));
assertThat(omException.getMessage())
.contains("SafeModePrecheck failed for allocateBlock");
}

@Test
Expand All @@ -334,8 +335,8 @@ public void openKeyFailureInSafeMode() throws Exception {
.build();
OMException omException = assertThrows(OMException.class,
() -> writeClient.openKey(keyArgs));
assertTrue(omException.getMessage()
.contains("SafeModePrecheck failed for allocateBlock"));
assertThat(omException.getMessage())
.contains("SafeModePrecheck failed for allocateBlock");
}

@Test
Expand Down Expand Up @@ -847,9 +848,8 @@ public void testLookupKeyWithLocation() throws IOException {
// lookup key, random node as client
OmKeyInfo key4 = keyManager.lookupKey(keyArgs, resolvedBucket(),
"/d=default-drack/127.0.0.1");
assertTrue(
keyPipeline.getNodes().containsAll(key4.getLatestVersionLocations()
.getLocationList().get(0).getPipeline().getNodesInOrder()));
assertThat(keyPipeline.getNodes()).containsAll(key4.getLatestVersionLocations()
.getLocationList().get(0).getPipeline().getNodesInOrder());
}

@NotNull
Expand Down Expand Up @@ -1592,11 +1592,11 @@ private void verifyFileStatus(String directory,
}
// verify filestatus is present in directory or file set accordingly
if (fileStatus.isDirectory()) {
assertTrue(directorySet.contains(normalizedKeyName),
directorySet + " doesn't contain " + normalizedKeyName);
assertThat(directorySet).withFailMessage(directorySet +
" doesn't contain " + normalizedKeyName).contains(normalizedKeyName);
} else {
assertTrue(fileSet.contains(normalizedKeyName),
fileSet + " doesn't contain " + normalizedKeyName);
assertThat(fileSet).withFailMessage(fileSet + " doesn't contain " + normalizedKeyName)
.contains(normalizedKeyName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_CONTAINER_REPORT_INTERVAL;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testKeysPurgingByKeyDeletingService() throws Exception {
() -> keyDeletingService.getDeletedKeyCount().get() >= NUM_KEYS,
1000, 10000);

assertTrue(keyDeletingService.getRunCount().get() > 1);
assertThat(keyDeletingService.getRunCount().get()).isGreaterThan(1);

GenericTestUtils.waitFor(
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import java.io.IOException;
import java.util.UUID;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.apache.hadoop.ozone.OzoneConfigKeys.
OZONE_FS_ITERATE_BATCH_SIZE;

Expand Down Expand Up @@ -198,7 +198,7 @@ private void checkKeyList(String keyPrefix, String startKey,
OzoneFileStatus stNext = statuses.get(i + 1);

System.out.println("status:" + stCurr);
assertTrue(stCurr.getPath().compareTo(stNext.getPath()) < 0);
assertThat(stCurr.getPath().compareTo(stNext.getPath())).isLessThan(0);
}

if (!statuses.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import static org.apache.hadoop.ozone.om.snapshot.OmSnapshotUtils.truncateFileName;
import static org.apache.hadoop.ozone.om.OmSnapshotManager.getSnapshotPath;
import static org.apache.ozone.rocksdiff.RocksDBCheckpointDiffer.COMPACTION_LOG_FILE_NAME_SUFFIX;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
Expand Down Expand Up @@ -275,15 +276,13 @@ public void testEndpoint(String httpMethod) throws Exception {

doEndpoint();

Assertions.assertTrue(tempFile.length() > 0);
Assertions.assertTrue(
omMetrics.getDBCheckpointMetrics().
getLastCheckpointCreationTimeTaken() > 0);
Assertions.assertTrue(
omMetrics.getDBCheckpointMetrics().
getLastCheckpointStreamingTimeTaken() > 0);
Assertions.assertTrue(omMetrics.getDBCheckpointMetrics().
getNumCheckpoints() > initialCheckpointCount);
assertThat(tempFile.length()).isGreaterThan(0);
assertThat(omMetrics.getDBCheckpointMetrics().getLastCheckpointCreationTimeTaken())
.isGreaterThan(0);
assertThat(omMetrics.getDBCheckpointMetrics().getLastCheckpointStreamingTimeTaken())
.isGreaterThan(0);
assertThat(omMetrics.getDBCheckpointMetrics().getNumCheckpoints())
.isGreaterThan(initialCheckpointCount);

Mockito.verify(omDbCheckpointServletMock).writeDbDataToStream(any(),
any(), any(), eq(toExcludeList), any(), any());
Expand Down Expand Up @@ -383,7 +382,7 @@ public void testSpnegoEnabled(String httpMethod) throws Exception {

// Recon user should be able to access the servlet and download the
// snapshot
Assertions.assertTrue(tempFile.length() > 0);
assertThat(tempFile.length()).isGreaterThan(0);
}

@Test
Expand Down Expand Up @@ -483,8 +482,8 @@ public void testWriteDbDataToStream() throws Exception {
Set<String> finalCheckpointSet = getFiles(finalCheckpointLocation,
newDbDirLength);

Assertions.assertTrue(finalCheckpointSet.contains(OM_HARDLINK_FILE),
"hardlink file exists in checkpoint dir");
assertThat(finalCheckpointSet).withFailMessage("hardlink file exists in checkpoint dir")
.contains(OM_HARDLINK_FILE);
finalCheckpointSet.remove(OM_HARDLINK_FILE);
Assertions.assertEquals(initialCheckpointSet, finalCheckpointSet);

Expand Down Expand Up @@ -522,10 +521,10 @@ public void testWriteDbDataToStream() throws Exception {

Set<String> initialFullSet =
getFiles(Paths.get(metaDir.toString(), OM_SNAPSHOT_DIR), metaDirLength);
Assertions.assertTrue(finalFullSet.contains(expectedLogStr));
Assertions.assertTrue(finalFullSet.contains(expectedSstStr));
Assertions.assertTrue(initialFullSet.contains(unExpectedLogStr));
Assertions.assertTrue(initialFullSet.contains(unExpectedSstStr));
assertThat(finalFullSet).contains(expectedLogStr);
assertThat(finalFullSet).contains(expectedSstStr);
assertThat(initialFullSet).contains(unExpectedLogStr);
assertThat(initialFullSet).contains(unExpectedSstStr);

// Remove the dummy files that should not have been copied over
// from the expected data.
Expand Down Expand Up @@ -628,7 +627,7 @@ public void testWriteDbDataWithToExcludeFileList()
testDirLength);

initialCheckpointSet.removeAll(finalCheckpointSet);
Assertions.assertTrue(initialCheckpointSet.contains(dummyFile.getName()));
assertThat(initialCheckpointSet).contains(dummyFile.getName());
}

/**
Expand Down
Loading