Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that TestOzoneFileInterfaces is being migrated to JUnit5 in #5838. The same changes are done in that PR, too. Please remove TestOzoneFileInterfaces from the patch to avoid conflicts.


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 @@ -201,7 +201,7 @@ public void testDeleteVolumeAndBucket() throws IOException {
assertTrue(getFs().delete(bucketPath2, true));
assertTrue(getFs().delete(volumePath1, false));
long deletes = getOMMetrics().getNumKeyDeletes();
assertTrue(deletes == prevDeletes + 1);
assertEquals(prevDeletes + 1, deletes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ private void checkLeaderBalance(int dnNum, int leaderNumOfEachDn)
leaderCount.put(leader, leaderCount.get(leader) + 1);
}

assertTrue(leaderCount.size() == dnNum);
assertEquals(leaderCount.size(), dnNum);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also flip the arguments to match expected, actual order:

Suggested change
assertEquals(leaderCount.size(), dnNum);
assertEquals(dnNum, leaderCount.size());

for (Map.Entry<UUID, Integer> entry: leaderCount.entrySet()) {
assertTrue(leaderCount.get(entry.getKey()) == leaderNumOfEachDn);
assertEquals(leaderCount.get(entry.getKey()), leaderNumOfEachDn);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals(leaderCount.get(entry.getKey()), leaderNumOfEachDn);
assertEquals(leaderNumOfEachDn, leaderCount.get(entry.getKey()));

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
* Tests for Pipeline Closing.
Expand Down Expand Up @@ -229,7 +230,7 @@ public void testPipelineCloseWithLogFailure()
try {
pipelineManager.getPipeline(openPipeline.getId());
} catch (PipelineNotFoundException e) {
assertTrue(false, "pipeline should exist");
fail("pipeline should exist");
}

DatanodeDetails datanodeDetails = openPipeline.getNodes().get(0);
Expand Down Expand Up @@ -275,6 +276,6 @@ private boolean verifyCloseForPipeline(Pipeline pipeline,
}

assertTrue(found, "SCM did not receive a Close action for the Pipeline");
return found;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ public void testCreateBucketWithVersioning()
volume.createBucket(bucketName, builder.build());
OzoneBucket bucket = volume.getBucket(bucketName);
assertEquals(bucketName, bucket.getName());
assertEquals(true, bucket.getVersioning());
assertTrue(bucket.getVersioning());
}

@Test
Expand Down Expand Up @@ -708,7 +708,7 @@ public void testCreateBucketWithAllArgument()
volume.createBucket(bucketName, builder.build());
OzoneBucket bucket = volume.getBucket(bucketName);
assertEquals(bucketName, bucket.getName());
assertEquals(true, bucket.getVersioning());
assertTrue(bucket.getVersioning());
assertEquals(StorageType.SSD, bucket.getStorageType());
assertTrue(bucket.getAcls().contains(userAcl));
assertEquals(repConfig, bucket.getReplicationConfig());
Expand Down Expand Up @@ -812,7 +812,7 @@ public void testSetBucketVersioning()
bucket.setVersioning(true);
OzoneBucket newBucket = volume.getBucket(bucketName);
assertEquals(bucketName, newBucket.getName());
assertEquals(true, newBucket.getVersioning());
assertTrue(newBucket.getVersioning());
}

@Test
Expand All @@ -830,7 +830,7 @@ public void testAclsAfterCallingSetBucketProperty() throws Exception {

OzoneBucket newBucket = volume.getBucket(bucketName);
assertEquals(bucketName, newBucket.getName());
assertEquals(true, newBucket.getVersioning());
assertTrue(newBucket.getVersioning());

List<OzoneAcl> aclsAfterSet = newBucket.getAcls();
assertEquals(currentAcls, aclsAfterSet);
Expand Down Expand Up @@ -3796,7 +3796,7 @@ private void doMultipartUpload(OzoneBucket bucket, String keyName, byte val,
assertTrue(latestVersionLocations.isMultipartKey());
latestVersionLocations.getBlocksLatestVersionOnly()
.forEach(omKeyLocationInfo ->
assertTrue(omKeyLocationInfo.getPartNumber() != -1));
assertNotEquals(omKeyLocationInfo.getPartNumber(), -1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertNotEquals(omKeyLocationInfo.getPartNumber(), -1));
assertNotEquals(-1, omKeyLocationInfo.getPartNumber()));

}

private String initiateMultipartUpload(OzoneBucket bucket, String keyName,
Expand Down Expand Up @@ -3996,7 +3996,7 @@ public void testDeletedKeyForGDPR() throws Exception {
assertEquals("true", key.getMetadata().get(OzoneConsts.GDPR_FLAG));
assertEquals("AES",
key.getMetadata().get(OzoneConsts.GDPR_ALGORITHM));
assertTrue(key.getMetadata().get(OzoneConsts.GDPR_SECRET) != null);
assertNotNull(key.getMetadata().get(OzoneConsts.GDPR_SECRET));

try (OzoneInputStream is = bucket.readKey(keyName)) {
assertInputStreamContent(text, is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS_WILDCARD;
import static org.apache.hadoop.ozone.security.acl.OzoneObj.ResourceType.VOLUME;
import static org.apache.hadoop.ozone.security.acl.OzoneObj.StoreType.OZONE;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
Expand Down Expand Up @@ -287,7 +288,7 @@ private void verifyLog(String... expected) throws Exception {
try {
// When log entry is expected, the log file will contain one line and
// that must be equal to the expected string
assertTrue(lines.size() != 0);
assertNotEquals(0, lines.size());
for (String exp: expected) {
assertTrue(lines.get(0).contains(exp));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -144,7 +143,7 @@ public void testAllocateCommit() throws Exception {
List<OmKeyLocationInfo> locationInfoList =
openKey.getKeyInfo().getLatestVersionLocations()
.getBlocksLatestVersionOnly();
assertTrue(locationInfoList.size() == 1);
assertEquals(locationInfoList.size(), 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals(locationInfoList.size(), 1);
assertEquals(1, locationInfoList.size());

locationInfoList.add(locationInfo);
keyArgs.setLocationInfoList(locationInfoList);
writeClient.commitKey(keyArgs, openKey.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private static void doAs(UserGroupInformation ugi,
Callable<Boolean> callable) {
// Some thread (eg: HeartbeatEndpointTask) will use the login ugi,
// so we could not use loginUserFromKeytabAndReturnUGI to switch user.
assertEquals(true, ugi.doAs((PrivilegedAction<Boolean>) () -> {
assertTrue(ugi.doAs((PrivilegedAction<Boolean>) () -> {
try {
return callable.call();
} catch (Throwable ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void testSCMSafeMode() throws Exception {
scm = cluster.getStorageContainerManager();
assertTrue(scm.isInSafeMode());
assertFalse(logCapturer.getOutput().contains("SCM exiting safe mode."));
assertTrue(scm.getCurrentContainerThreshold() == 0);
assertEquals(0, scm.getCurrentContainerThreshold());
for (HddsDatanodeService dn : cluster.getHddsDatanodes()) {
dn.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public void testSnapshotWithFSO() throws Exception {
RepeatedOmKeyInfo activeDBDeleted = next.getValue();
OMMetadataManager metadataManager =
cluster.getOzoneManager().getMetadataManager();
assertEquals(activeDBDeleted.getOmKeyInfoList().size(), 1);
assertEquals(1, activeDBDeleted.getOmKeyInfoList().size());
OmKeyInfo activeDbDeletedKeyInfo =
activeDBDeleted.getOmKeyInfoList().get(0);
long volumeId = metadataManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ public void testContainerReportKeyWrite() throws Exception {
Set<ContainerReplica> replicas =
scm.getContainerManager().getContainerReplicas(
ContainerID.valueOf(keyInfo.getContainerID()));
Assert.assertTrue(replicas.size() == 1);
replicas.stream().forEach(rp ->
Assert.assertTrue(rp.getDatanodeDetails().getParent() != null));
Assert.assertEquals(1, replicas.size());
replicas.stream().forEach(rp -> Assert.assertNotNull(rp.getDatanodeDetails().getParent()));

LOG.info("SCM Container Info keyCount: {} usedBytes: {}",
cinfo.getNumberOfKeys(), cinfo.getUsedBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testFailover() throws Exception {
scmClientConfig.setRetryCount(1);
scmClientConfig.setRetryInterval(100);
scmClientConfig.setMaxRetryTimeout(1500);
assertEquals(scmClientConfig.getRetryCount(), 15);
assertEquals(15, scmClientConfig.getRetryCount());
conf.setFromObject(scmClientConfig);
StorageContainerManager scm = getLeader(cluster);
assertNotNull(scm);
Expand Down Expand Up @@ -161,7 +161,7 @@ public void testMoveFailover() throws Exception {
scmClientConfig.setRetryCount(1);
scmClientConfig.setRetryInterval(100);
scmClientConfig.setMaxRetryTimeout(1500);
assertEquals(scmClientConfig.getRetryCount(), 15);
assertEquals(15, scmClientConfig.getRetryCount());
conf.setFromObject(scmClientConfig);
StorageContainerManager scm = getLeader(cluster);
assertNotNull(scm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public void testSCMContainerStateCount() throws Exception {

containerStateCount.forEach((k, v) -> {
if (k.equals(HddsProtos.LifeCycleState.CLOSING.toString())) {
assertEquals((int)v, 5);
assertEquals(5, (int)v);
} else if (k.equals(HddsProtos.LifeCycleState.CLOSED.toString())) {
assertEquals((int)v, 5);
assertEquals(5, (int)v);
} else {
// Remaining all container state count should be zero.
assertEquals((int)v, 0);
assertEquals(0, (int)v);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ public void testIncrementalContainerReportQueue() throws Exception {
eventQueue.fireEvent(SCMEvents.INCREMENTAL_CONTAINER_REPORT, dndata);
eventQueue.fireEvent(SCMEvents.INCREMENTAL_CONTAINER_REPORT, dndata);
eventQueue.fireEvent(SCMEvents.INCREMENTAL_CONTAINER_REPORT, dndata);
Assert.assertTrue(containerReportExecutors.droppedEvents() == 0);
Assert.assertEquals(0, containerReportExecutors.droppedEvents());
Thread.currentThread().sleep(3000);
Assert.assertEquals(containerReportExecutors.scheduledEvents(),
containerReportExecutors.queuedEvents());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void testCaching(boolean securityEnabled) throws IOException {
clientManager.releaseClient(client1, true);
clientManager.releaseClient(client2, true);
clientManager.releaseClient(client3, true);
Assertions.assertTrue(clientManager.getClientCache().size() == 0);
Assertions.assertEquals(0, clientManager.getClientCache().size());
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public void testFreeByReference() throws IOException {
XceiverClientSpi nonExistent1 = cache.getIfPresent(
container1.getContainerInfo().getPipelineID().getId().toString()
+ container1.getContainerInfo().getReplicationType());
Assertions.assertEquals(null, nonExistent1);
Assertions.assertNull(nonExistent1);
// However container call should succeed because of refcount on the client
ContainerProtocolCalls.createContainer(client1,
container1.getContainerInfo().getContainerID(), null);
Expand Down Expand Up @@ -218,7 +218,7 @@ public void testFreeByEviction() throws IOException {
XceiverClientSpi nonExistent = cache.getIfPresent(
container1.getContainerInfo().getPipelineID().getId().toString()
+ container1.getContainerInfo().getReplicationType());
Assertions.assertEquals(null, nonExistent);
Assertions.assertNull(nonExistent);

// Any container operation should now fail
Throwable t = Assertions.assertThrows(IOException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void testNumBlocksAllocated() throws IOException, TimeoutException {
Pipeline pipeline = block.getPipeline();
long numBlocksAllocated = getLongCounter(
SCMPipelineMetrics.getBlockAllocationMetricName(pipeline), metrics);
Assertions.assertEquals(numBlocksAllocated, 1);
Assertions.assertEquals(1, numBlocksAllocated);

// destroy the pipeline
Assertions.assertDoesNotThrow(() ->
Expand Down