This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 21068a3871 HDDS-10213. Improve assertTrue assertions in remaining
integration-test (#6101)
21068a3871 is described below
commit 21068a3871f4ddebc1bf2780813e5e72eaea2ab7
Author: Zhaohui Wang <[email protected]>
AuthorDate: Sat Jan 27 01:45:22 2024 +0800
HDDS-10213. Improve assertTrue assertions in remaining integration-test
(#6101)
---
.../fs/ozone/AbstractOzoneFileSystemTest.java | 45 ++++++------
.../ozone/AbstractOzoneFileSystemTestWithFSO.java | 24 ++++---
.../ozone/AbstractRootedOzoneFileSystemTest.java | 41 +++++------
.../ozone/TestDirectoryDeletingServiceWithFSO.java | 14 ++--
.../fs/ozone/TestOzoneFSWithObjectStoreCreate.java | 15 ++--
.../fs/ozone/TestOzoneFileSystemMetrics.java | 6 +-
.../fs/ozone/TestOzoneFileSystemMissingParent.java | 10 +--
.../apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java | 7 +-
.../hadoop/fs/ozone/TestRootedDDSWithFSO.java | 3 +-
.../hadoop/hdds/upgrade/TestHddsUpgradeUtils.java | 11 +--
.../hadoop/hdds/upgrade/TestScmHAFinalization.java | 5 +-
.../hadoop/ozone/TestContainerOperations.java | 11 ++-
.../org/apache/hadoop/ozone/TestCpuMetrics.java | 17 ++---
.../apache/hadoop/ozone/TestDelegationToken.java | 29 ++++----
.../ozone/container/TestContainerReplication.java | 4 +-
.../apache/hadoop/ozone/container/TestHelper.java | 12 ++--
.../commandhandler/TestBlockDeletion.java | 21 +++---
.../TestCloseContainerByPipeline.java | 4 +-
.../commandhandler/TestDeleteContainerHandler.java | 12 ++--
.../transport/server/ratis/TestCSMMetrics.java | 6 +-
.../ozoneimpl/TestOzoneContainerWithTLS.java | 19 ++---
.../server/TestSecureContainerServer.java | 6 +-
.../org/apache/hadoop/ozone/debug/TestLDBCli.java | 4 +-
.../freon/TestFreonWithDatanodeFastRestart.java | 6 +-
.../ozone/freon/TestHadoopDirTreeGenerator.java | 9 +--
.../ozone/freon/TestOmBucketReadWriteKeyOps.java | 10 +--
.../hadoop/ozone/shell/TestNSSummaryAdmin.java | 22 +++---
.../hadoop/ozone/shell/TestOzoneDatanodeShell.java | 6 +-
.../hadoop/ozone/shell/TestOzoneShellHA.java | 83 +++++++++++-----------
.../hadoop/ozone/shell/TestOzoneTenantShell.java | 10 ++-
.../hadoop/ozone/shell/TestReconfigShell.java | 7 +-
31 files changed, 242 insertions(+), 237 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
index d3eeffc9b0..b1af31e53f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
@@ -117,6 +117,7 @@ import static
org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
import static
org.apache.hadoop.ozone.om.helpers.BucketLayout.FILE_SYSTEM_OPTIMIZED;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -392,7 +393,7 @@ abstract class AbstractOzoneFileSystemTest {
InvalidPathException pathException = assertThrows(
InvalidPathException.class, () -> fs.create(path, false)
);
- assertTrue(pathException.getMessage().contains("Invalid path Name"));
+ assertThat(pathException.getMessage()).contains("Invalid path Name");
}
@Test
@@ -466,7 +467,7 @@ abstract class AbstractOzoneFileSystemTest {
// delete a dir with sub-file
try {
FileStatus[] parents = fs.listStatus(grandparent);
- assertTrue(parents.length > 0);
+ assertThat(parents.length).isGreaterThan(0);
fs.delete(parents[0].getPath(), false);
fail("Must throw exception as dir is not empty!");
} catch (PathIsNotEmptyDirectoryException pde) {
@@ -537,8 +538,8 @@ abstract class AbstractOzoneFileSystemTest {
fs.getFileStatus(path);
fail("testRecursiveDelete failed");
} catch (IOException ex) {
- assertTrue(ex instanceof FileNotFoundException);
- assertTrue(ex.getMessage().contains("No such file or directory"));
+ assertInstanceOf(FileNotFoundException.class, ex);
+ assertThat(ex.getMessage()).contains("No such file or directory");
}
}
@@ -748,7 +749,7 @@ abstract class AbstractOzoneFileSystemTest {
assertEquals(numDirs, fileStatuses.length, "Total directories listed do
not match the existing directories");
for (int i = 0; i < numDirs; i++) {
- assertTrue(paths.contains(fileStatuses[i].getPath().getName()));
+ assertThat(paths).contains(fileStatuses[i].getPath().getName());
}
}
@@ -1003,7 +1004,7 @@ abstract class AbstractOzoneFileSystemTest {
fs.open(fileNotExists);
fail("Should throw FileNotFoundException as file doesn't exist!");
} catch (FileNotFoundException fnfe) {
- assertTrue(fnfe.getMessage().contains("KEY_NOT_FOUND"), "Expected
KEY_NOT_FOUND error");
+ assertThat(fnfe.getMessage()).contains("KEY_NOT_FOUND");
}
}
@@ -1026,12 +1027,16 @@ abstract class AbstractOzoneFileSystemTest {
FileStatus fileStatus = fs.getFileStatus(file);
long blkSize = fileStatus.getBlockSize();
long fileLength = fileStatus.getLen();
- assertTrue(fileLength > blkSize, "Block allocation should happen");
+ assertThat(fileLength)
+ .withFailMessage("Block allocation should happen")
+ .isGreaterThan(blkSize);
long newNumBlockAllocations =
cluster.getOzoneManager().getMetrics().getNumBlockAllocates();
- assertTrue((newNumBlockAllocations > numBlockAllocationsOrg), "Block
allocation should happen");
+ assertThat(newNumBlockAllocations)
+ .withFailMessage("Block allocation should happen")
+ .isGreaterThan(numBlockAllocationsOrg);
stream.seek(fileLength);
assertEquals(-1, stream.read());
@@ -1366,7 +1371,7 @@ abstract class AbstractOzoneFileSystemTest {
IllegalArgumentException exception = assertThrows(
IllegalArgumentException.class,
() -> fs.rename(new Path(fs.getUri().toString() + "fake" + dir),
dest));
- assertTrue(exception.getMessage().contains("Wrong FS"));
+ assertThat(exception.getMessage()).contains("Wrong FS");
}
private OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
@@ -1419,7 +1424,7 @@ abstract class AbstractOzoneFileSystemTest {
for (int i = 0; i < 5; i++) {
Thread.sleep(10);
fileStatuses = o3fs.listStatus(mdir1);
- assertTrue(modificationTime <= fileStatuses[0].getModificationTime());
+
assertThat(modificationTime).isLessThanOrEqualTo(fileStatuses[0].getModificationTime());
}
}
@@ -1817,7 +1822,7 @@ abstract class AbstractOzoneFileSystemTest {
// The timestamp of the newly created file should always be greater than
// the time when the test was started
- assertTrue(status.getModificationTime() > currentTime);
+ assertThat(status.getModificationTime()).isGreaterThan(currentTime);
assertFalse(status.isDirectory());
assertEquals(FsPermission.getFileDefault(), status.getPermission());
@@ -1968,7 +1973,7 @@ abstract class AbstractOzoneFileSystemTest {
assertChange(initialStats, statistics, Statistic.OBJECTS_LIST.getSymbol(),
2);
assertEquals(initialListStatusCount + 2, omMetrics.getNumListStatus());
for (Path p : paths) {
- assertTrue(Arrays.asList(statusList).contains(fs.getFileStatus(p)));
+ assertThat(Arrays.asList(statusList)).contains(fs.getFileStatus(p));
}
}
@@ -2006,7 +2011,7 @@ abstract class AbstractOzoneFileSystemTest {
// doesn't actually exist on server; if it exists, it will be a fixed
value.
// In this case, the dir key exists.
assertEquals(0, omStatus.getKeyInfo().getDataSize());
- assertTrue(omStatus.getKeyInfo().getModificationTime() <= currentTime);
+
assertThat(omStatus.getKeyInfo().getModificationTime()).isLessThanOrEqualTo(currentTime);
assertEquals(new Path(omStatus.getPath()).getName(),
o3fs.pathToKey(path));
}
@@ -2020,13 +2025,12 @@ abstract class AbstractOzoneFileSystemTest {
stream.writeBytes(data);
}
FileStatus status = fs.getFileStatus(path);
- assertTrue(status instanceof LocatedFileStatus);
- LocatedFileStatus locatedFileStatus = (LocatedFileStatus) status;
- assertTrue(locatedFileStatus.getBlockLocations().length >= 1);
+ LocatedFileStatus locatedFileStatus =
assertInstanceOf(LocatedFileStatus.class, status);
+
assertThat(locatedFileStatus.getBlockLocations().length).isGreaterThanOrEqualTo(1);
for (BlockLocation blockLocation : locatedFileStatus.getBlockLocations()) {
- assertTrue(blockLocation.getNames().length >= 1);
- assertTrue(blockLocation.getHosts().length >= 1);
+ assertThat(blockLocation.getNames().length).isGreaterThanOrEqualTo(1);
+ assertThat(blockLocation.getHosts().length).isGreaterThanOrEqualTo(1);
}
}
@@ -2046,8 +2050,7 @@ abstract class AbstractOzoneFileSystemTest {
stream.writeBytes(data);
}
FileStatus status = fs.getFileStatus(path);
- assertTrue(status instanceof LocatedFileStatus);
- LocatedFileStatus locatedFileStatus = (LocatedFileStatus) status;
+ LocatedFileStatus locatedFileStatus =
assertInstanceOf(LocatedFileStatus.class, status);
BlockLocation[] blockLocations = locatedFileStatus.getBlockLocations();
assertEquals(0, blockLocations[0].getOffset());
@@ -2099,7 +2102,7 @@ abstract class AbstractOzoneFileSystemTest {
config.set(FS_DEFAULT_NAME_KEY, obsRootPath);
IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, () -> FileSystem.get(config));
- assertTrue(e.getMessage().contains("OBJECT_STORE, which does not support
file system semantics"));
+ assertThat(e.getMessage()).contains("OBJECT_STORE, which does not
support file system semantics");
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
index 2d4c310c88..f0ff1ab43b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
@@ -45,8 +45,10 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -305,8 +307,8 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
.getModificationTime();
// rename should change the parent directory of source and object files
// modification time but not change modification time of the renamed file
- assertTrue(dir1BeforeMTime < dir1AfterMTime);
- assertTrue(dir2BeforeMTime < dir2AfterMTime);
+ assertThat(dir1BeforeMTime).isLessThan(dir1AfterMTime);
+ assertThat(dir2BeforeMTime).isLessThan(dir2AfterMTime);
assertEquals(file1BeforeMTime, file1AfterMTime);
// mv "/dir1/subdir1/" to "/dir2/subdir1/"
@@ -323,8 +325,8 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
dir2AfterMTime = getFs().getFileStatus(dir2).getModificationTime();
long subdir1AfterMTime = getFs().getFileStatus(renamedSubdir1)
.getModificationTime();
- assertTrue(dir1BeforeMTime < dir1AfterMTime);
- assertTrue(dir2BeforeMTime < dir2AfterMTime);
+ assertThat(dir1BeforeMTime).isLessThan(dir1AfterMTime);
+ assertThat(dir2BeforeMTime).isLessThan(dir2AfterMTime);
assertEquals(subdir1BeforeMTime, subdir1AfterMTime);
}
@@ -379,7 +381,7 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
long bucketAfterMTime = omBucketInfo.getModificationTime();
long fileAfterMTime = getFs().getFileStatus(to).getModificationTime();
if (exceptChangeMtime) {
- assertTrue(bucketBeforeMTime < bucketAfterMTime);
+ assertThat(bucketBeforeMTime).isLessThan(bucketAfterMTime);
} else {
assertEquals(bucketBeforeMTime, bucketAfterMTime);
}
@@ -434,7 +436,7 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
long d6ObjectID =
verifyDirKey(volumeId, bucketId, d4ObjectID,
"d6", "/d1/d2/d3/d4/d6", dirKeys, omMgr);
- assertTrue(d5ObjectID != d6ObjectID, "Wrong objectIds for sub-dirs[" +
d5ObjectID + "/d5, " + d6ObjectID
+ assertNotEquals(d5ObjectID, d6ObjectID, "Wrong objectIds for sub-dirs[" +
d5ObjectID + "/d5, " + d6ObjectID
+ "/d6] of same parent!");
assertEquals(6, getCluster().getOzoneManager().getMetrics().getNumKeys(),
"Wrong OM numKeys metrics");
@@ -520,10 +522,10 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
GenericTestUtils.LogCapturer logCapture = GenericTestUtils.LogCapturer
.captureLogs(BasicOzoneClientAdapterImpl.LOG);
getFs().delete(new Path("/d1/d3/noexist/"), true);
- assertTrue(logCapture.getOutput().contains(
- "delete key failed Unable to get file status"));
- assertTrue(logCapture.getOutput().contains(
- "WARN ozone.BasicOzoneClientAdapterImpl"));
+ assertThat(logCapture.getOutput()).contains(
+ "delete key failed Unable to get file status");
+ assertThat(logCapture.getOutput()).contains(
+ "WARN ozone.BasicOzoneClientAdapterImpl");
}
private void verifyOMFileInfoFormat(OmKeyInfo omKeyInfo, String fileName,
@@ -546,7 +548,7 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
" using dbKey: " + dbKey);
assertEquals(parentId, dirInfo.getParentObjectID(), "Parent Id
mismatches");
assertEquals(dirKey, dirInfo.getName(), "Mismatches directory name");
- assertTrue(dirInfo.getCreationTime() > 0, "Mismatches directory creation
time param");
+ assertThat(dirInfo.getCreationTime()).isGreaterThan(0);
assertEquals(dirInfo.getCreationTime(), dirInfo.getModificationTime());
return dirInfo.getObjectID();
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
index 1675807d23..cb33970d87 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
@@ -124,6 +124,7 @@ import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.REA
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.DELETE;
import static
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.LIST;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -774,7 +775,7 @@ abstract class AbstractRootedOzoneFileSystemTest {
assertEquals(numDirs, fileStatuses.length, "Total directories listed do
not match the existing directories");
for (int i = 0; i < numDirs; i++) {
- assertTrue(paths.contains(fileStatuses[i].getPath().getName()));
+ assertThat(paths).contains(fileStatuses[i].getPath().getName());
}
} finally {
// Cleanup
@@ -1107,7 +1108,7 @@ abstract class AbstractRootedOzoneFileSystemTest {
*/
private FileStatus[] customListStatus(Path f, boolean recursive,
String startPath, int numEntries) throws IOException {
- assertTrue(numEntries > 0);
+ assertThat(numEntries).isGreaterThan(0);
LinkedList<FileStatus> statuses = new LinkedList<>();
List<FileStatus> tmpStatusList;
do {
@@ -1484,9 +1485,9 @@ abstract class AbstractRootedOzoneFileSystemTest {
new GenericTestUtils.SystemOutCapturer()) {
String linkPathStr = rootPath + destVolume;
ToolRunner.run(shell, new String[]{"-ls", linkPathStr});
- assertTrue(capture.getOutput().contains("drwxrwxrwx"));
- assertTrue(capture.getOutput().contains(linkPathStr +
- OZONE_URI_DELIMITER + srcBucket));
+ assertThat(capture.getOutput()).contains("drwxrwxrwx");
+ assertThat(capture.getOutput()).contains(linkPathStr +
+ OZONE_URI_DELIMITER + srcBucket);
} finally {
shell.close();
}
@@ -1507,12 +1508,12 @@ abstract class AbstractRootedOzoneFileSystemTest {
String linkPathStr = rootPath + destVolume;
ToolRunner.run(shell, new String[]{"-ls", "-R",
linkPathStr + OZONE_URI_DELIMITER + srcBucket});
- assertTrue(capture.getOutput().contains("drwxrwxrwx"));
- assertTrue(capture.getOutput().contains(linkPathStr +
- OZONE_URI_DELIMITER + srcBucket));
- assertTrue(capture.getOutput().contains("-rw-rw-rw-"));
- assertTrue(capture.getOutput().contains(linkPathStr +
- OZONE_URI_DELIMITER + srcBucket + OZONE_URI_DELIMITER + key));
+ assertThat(capture.getOutput()).contains("drwxrwxrwx");
+ assertThat(capture.getOutput()).contains(linkPathStr +
+ OZONE_URI_DELIMITER + srcBucket);
+ assertThat(capture.getOutput()).contains("-rw-rw-rw-");
+ assertThat(capture.getOutput()).contains(linkPathStr +
+ OZONE_URI_DELIMITER + srcBucket + OZONE_URI_DELIMITER + key);
} finally {
shell.close();
}
@@ -1676,7 +1677,7 @@ abstract class AbstractRootedOzoneFileSystemTest {
// confirm link is gone
FileNotFoundException exception = assertThrows(FileNotFoundException.class,
() -> fs.getFileStatus(dirPathLink));
- assertTrue(exception.getMessage().contains("File not found."));
+ assertThat(exception.getMessage()).contains("File not found.");
// Cleanup
fs.delete(bucketPath1, true);
@@ -1926,15 +1927,15 @@ abstract class AbstractRootedOzoneFileSystemTest {
}, 1000, 180000);
if (isBucketFSOptimized) {
- assertTrue(getOMMetrics()
- .getNumTrashAtomicDirRenames() > prevNumTrashAtomicDirRenames);
+ assertThat(getOMMetrics().getNumTrashAtomicDirRenames())
+ .isGreaterThan(prevNumTrashAtomicDirRenames);
} else {
// This condition should pass after the checkpoint
- assertTrue(getOMMetrics()
- .getNumTrashRenames() > prevNumTrashRenames);
+ assertThat(getOMMetrics().getNumTrashRenames())
+ .isGreaterThan(prevNumTrashRenames);
// With new layout version, file renames wouldn't be counted
- assertTrue(getOMMetrics()
- .getNumTrashFilesRenames() > prevNumTrashFileRenames);
+ assertThat(getOMMetrics().getNumTrashFilesRenames())
+ .isGreaterThan(prevNumTrashFileRenames);
}
// wait for deletion of checkpoint dir
@@ -1993,7 +1994,7 @@ abstract class AbstractRootedOzoneFileSystemTest {
private void checkInvalidPath(Path path) {
InvalidPathException exception = assertThrows(InvalidPathException.class,
() -> fs.create(path, false));
- assertTrue(exception.getMessage().contains("Invalid path Name"));
+ assertThat(exception.getMessage()).contains("Invalid path Name");
}
@@ -2445,7 +2446,7 @@ abstract class AbstractRootedOzoneFileSystemTest {
IllegalArgumentException.class,
() -> ofs.getSnapshotDiffReport(volumePath1, finalFromSnap,
finalToSnap));
- assertTrue(exception.getMessage().contains(errorMsg));
+ assertThat(exception.getMessage()).contains(errorMsg);
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestDirectoryDeletingServiceWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestDirectoryDeletingServiceWithFSO.java
index d5c042bb03..c41d4fa9aa 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestDirectoryDeletingServiceWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestDirectoryDeletingServiceWithFSO.java
@@ -57,7 +57,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.LongSupplier;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ACL_ENABLED;
@@ -177,7 +179,7 @@ public class TestDirectoryDeletingServiceWithFSO {
assertEquals(root.getName(), iterator.next().getValue().getName());
}
- assertTrue(dirDeletingService.getRunCount().get() > 1);
+ assertThat(dirDeletingService.getRunCount().get()).isGreaterThan(1);
}
/**
@@ -244,9 +246,9 @@ public class TestDirectoryDeletingServiceWithFSO {
assertSubPathsCount(dirDeletingService::getDeletedDirsCount, 19);
long elapsedRunCount = dirDeletingService.getRunCount().get() -
preRunCount;
- assertTrue(dirDeletingService.getRunCount().get() > 1);
+ assertThat(dirDeletingService.getRunCount().get()).isGreaterThan(1);
// Ensure dir deleting speed, here provide a backup value for safe CI
- assertTrue(elapsedRunCount >= 7);
+ assertThat(elapsedRunCount).isGreaterThanOrEqualTo(7);
}
@Test
@@ -295,7 +297,7 @@ public class TestDirectoryDeletingServiceWithFSO {
assertSubPathsCount(dirDeletingService::getMovedDirsCount, 2);
assertSubPathsCount(dirDeletingService::getDeletedDirsCount, 5);
- assertTrue(dirDeletingService.getRunCount().get() > 1);
+ assertThat(dirDeletingService.getRunCount().get()).isGreaterThan(1);
}
@Test
@@ -549,8 +551,8 @@ public class TestDirectoryDeletingServiceWithFSO {
fs.getFileStatus(path);
fail("testRecursiveDelete failed");
} catch (IOException ex) {
- assertTrue(ex instanceof FileNotFoundException);
- assertTrue(ex.getMessage().contains("No such file or directory"));
+ assertInstanceOf(FileNotFoundException.class, ex);
+ assertThat(ex.getMessage()).contains("No such file or directory");
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSWithObjectStoreCreate.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSWithObjectStoreCreate.java
index 71d1e4bddd..cf84a8ad30 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSWithObjectStoreCreate.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFSWithObjectStoreCreate.java
@@ -60,7 +60,9 @@ import java.util.Map;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NOT_A_FILE;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -269,9 +271,8 @@ public class TestOzoneFSWithObjectStoreCreate {
ozoneOutputStream.close();
fail("testKeyCreationFailDuetoDirectoryCreationBeforeCommit");
} catch (IOException ex) {
- assertTrue(ex instanceof OMException);
- assertEquals(NOT_A_FILE,
- ((OMException) ex).getResult());
+ OMException e = assertInstanceOf(OMException.class, ex);
+ assertEquals(NOT_A_FILE, e.getResult());
}
}
@@ -313,7 +314,7 @@ public class TestOzoneFSWithObjectStoreCreate {
omMultipartInfo.getUploadID(), partsMap);
fail("testMPUFailDuetoDirectoryCreationBeforeComplete failed");
} catch (OMException ex) {
- assertTrue(ex instanceof OMException);
+ assertInstanceOf(OMException.class, ex);
assertEquals(NOT_A_FILE, ex.getResult());
}
@@ -343,7 +344,7 @@ public class TestOzoneFSWithObjectStoreCreate {
o3fs.create(new Path("/t1/t2"));
fail("testCreateDirectoryFirstThenFileWithSameName failed");
} catch (FileAlreadyExistsException ex) {
- assertTrue(ex.getMessage().contains(NOT_A_FILE.name()));
+ assertThat(ex.getMessage()).contains(NOT_A_FILE.name());
}
OzoneVolume ozoneVolume =
@@ -354,7 +355,7 @@ public class TestOzoneFSWithObjectStoreCreate {
ozoneBucket.createKey("t1/t2", 0);
fail("testCreateDirectoryFirstThenFileWithSameName failed");
} catch (OMException ex) {
- assertTrue(ex instanceof OMException);
+ assertInstanceOf(OMException.class, ex);
assertEquals(NOT_A_FILE, ex.getResult());
}
}
@@ -463,7 +464,7 @@ public class TestOzoneFSWithObjectStoreCreate {
FileNotFoundException ex = assertThrows(FileNotFoundException.class, () ->
o3fs.getFileStatus(path),
"testObjectStoreCreateWithO3fs failed for Path" + path);
- assertTrue(ex.getMessage().contains("No such file or directory"));
+ assertThat(ex.getMessage()).contains("No such file or directory");
}
private void checkAncestors(Path p) throws Exception {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMetrics.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMetrics.java
index 6c0ecff0db..d11ea5376d 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMetrics.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMetrics.java
@@ -40,9 +40,9 @@ import org.junit.jupiter.api.Timeout;
import java.io.IOException;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.apache.hadoop.hdds.StringUtils.string2Bytes;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test OM Metrics for OzoneFileSystem operations.
@@ -149,13 +149,13 @@ public class TestOzoneFileSystemMetrics {
long numKeysAfterCommit = cluster
.getOzoneManager().getMetrics().getNumKeys();
- assertTrue(numKeysAfterCommit > 0);
+ assertThat(numKeysAfterCommit).isGreaterThan(0);
assertEquals(numKeysBeforeCreate + 2, numKeysAfterCommit);
fs.delete(parentDir, true);
long numKeysAfterDelete = cluster
.getOzoneManager().getMetrics().getNumKeys();
- assertTrue(numKeysAfterDelete >= 0);
+ assertThat(numKeysAfterDelete).isGreaterThanOrEqualTo(0);
assertEquals(numKeysBeforeCreate, numKeysAfterDelete);
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMissingParent.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMissingParent.java
index d03cd4c81c..228a820ed6 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMissingParent.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemMissingParent.java
@@ -38,8 +38,8 @@ import org.junit.jupiter.api.Test;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests OFS behavior when filesystem paths are enabled and parent directory is
@@ -111,8 +111,8 @@ public class TestOzoneFileSystemMissingParent {
// Close should throw exception, Since parent doesn't exist.
OMException omException = assertThrows(OMException.class, stream::close);
- assertTrue(omException.getMessage().contains("Cannot create file : " +
- "parent/file as parent directory doesn't exist"));
+ assertThat(omException.getMessage())
+ .contains("Cannot create file : " + "parent/file as parent directory
doesn't exist");
}
/**
@@ -132,8 +132,8 @@ public class TestOzoneFileSystemMissingParent {
// Close should throw exception, Since parent has been moved.
OMException omException = assertThrows(OMException.class, stream::close);
- assertTrue(omException.getMessage().contains("Cannot create file : " +
- "parent/file as parent directory doesn't exist"));
+ assertThat(omException.getMessage())
+ .contains("Cannot create file : " + "parent/file as parent directory
doesn't exist");
fs.delete(renamedPath, true);
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
index d639f2734f..e86e44f55b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsHAURLs.java
@@ -58,7 +58,6 @@ import static org.apache.hadoop.hdds.HddsUtils.getHostPort;
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.assertTrue;
/**
* Test client-side URI handling with Ozone Manager HA.
@@ -385,8 +384,7 @@ public class TestOzoneFsHAURLs {
res = ToolRunner.run(shell,
new String[] {"-ls", ofsPathWithIncorrectSvcId });
assertEquals(1, res);
- assertTrue(
- capture.getOutput().contains("Cannot resolve OM host"));
+ assertThat(capture.getOutput()).contains("Cannot resolve OM host");
}
try (GenericTestUtils.SystemErrCapturer capture = new
@@ -394,8 +392,7 @@ public class TestOzoneFsHAURLs {
res = ToolRunner.run(shell,
new String[] {"-ls", o3fsPathWithInCorrectSvcId });
assertEquals(1, res);
- assertTrue(
- capture.getOutput().contains("Cannot resolve OM host"));
+ assertThat(capture.getOutput()).contains("Cannot resolve OM host");
}
} finally {
shell.close();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedDDSWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedDDSWithFSO.java
index cd12e0d52a..074a8e7df4 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedDDSWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedDDSWithFSO.java
@@ -57,6 +57,7 @@ import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVI
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
+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.junit.jupiter.api.Assertions.assertThrows;
@@ -215,7 +216,7 @@ public class TestRootedDDSWithFSO {
private void checkPath(Path path) {
FileNotFoundException ex = assertThrows(FileNotFoundException.class, () ->
fs.getFileStatus(path), "testRecursiveDelete failed");
- assertTrue(ex.getMessage().contains("File not found"));
+ assertThat(ex.getMessage()).contains("File not found");
}
private void assertTableRowCount(Table<String, ?> table, int count)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestHddsUpgradeUtils.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestHddsUpgradeUtils.java
index 6fc964fd0a..cd0fd9d4bb 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestHddsUpgradeUtils.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestHddsUpgradeUtils.java
@@ -49,6 +49,7 @@ import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState.HEALTHY
import static org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.OPEN;
import static
org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.ALREADY_FINALIZED;
import static
org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_DONE;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -117,7 +118,7 @@ public final class TestHddsUpgradeUtils {
HDDSLayoutVersionManager scmVersionManager = scm.getLayoutVersionManager();
assertEquals(scmVersionManager.getSoftwareLayoutVersion(),
scmVersionManager.getMetadataLayoutVersion());
- assertTrue(scmVersionManager.getMetadataLayoutVersion() >= 1);
+
assertThat(scmVersionManager.getMetadataLayoutVersion()).isGreaterThanOrEqualTo(1);
// SCM should not return from finalization until there is at least one
// pipeline to use.
@@ -147,7 +148,7 @@ public final class TestHddsUpgradeUtils {
(ciState == HddsProtos.LifeCycleState.QUASI_CLOSED));
countContainers++;
}
- assertTrue(countContainers >= numContainers);
+ assertThat(countContainers).isGreaterThanOrEqualTo(numContainers);
}
/*
@@ -173,7 +174,7 @@ public final class TestHddsUpgradeUtils {
countContainers++;
}
}
- assertTrue(countContainers >= 1);
+ assertThat(countContainers).isGreaterThanOrEqualTo(1);
}
/*
@@ -217,7 +218,7 @@ public final class TestHddsUpgradeUtils {
dsm.getLayoutVersionManager();
assertEquals(dnVersionManager.getSoftwareLayoutVersion(),
dnVersionManager.getMetadataLayoutVersion());
- assertTrue(dnVersionManager.getMetadataLayoutVersion() >= 1);
+
assertThat(dnVersionManager.getMetadataLayoutVersion()).isGreaterThanOrEqualTo(1);
// Also verify that all the existing containers are closed.
for (Container<?> container :
@@ -228,7 +229,7 @@ public final class TestHddsUpgradeUtils {
countContainers++;
}
}
- assertTrue(countContainers >= numContainers);
+ assertThat(countContainers).isGreaterThanOrEqualTo(numContainers);
}
public static void testDataNodesStateOnSCM(List<StorageContainerManager>
scms,
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestScmHAFinalization.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestScmHAFinalization.java
index 87ccb466ee..d2ae30efce 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestScmHAFinalization.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestScmHAFinalization.java
@@ -55,6 +55,7 @@ import java.util.concurrent.Future;
import java.util.stream.Stream;
import static
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State.CLOSED;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -292,8 +293,8 @@ public class TestScmHAFinalization {
inactiveScm, 0, NUM_DATANODES);
// Use log to verify a snapshot was installed.
- assertTrue(logCapture.getOutput().contains("New SCM snapshot " +
- "received with metadata layout version"));
+ assertThat(logCapture.getOutput()).contains("New SCM snapshot " +
+ "received with metadata layout version");
}
private void waitForScmsToFinalize(Collection<StorageContainerManager> scms)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
index d50c75b0da..de57152a21 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
@@ -41,8 +41,9 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
+import static org.assertj.core.api.Assertions.assertThat;
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.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -97,11 +98,10 @@ public class TestContainerOperations {
storageClient.getPipeline(PipelineID.randomId().getProtobuf());
fail("Get Pipeline should fail");
} catch (Exception e) {
- assertTrue(
- SCMHAUtils.unwrapException(e) instanceof PipelineNotFoundException);
+ assertInstanceOf(PipelineNotFoundException.class,
SCMHAUtils.unwrapException(e));
}
- assertFalse(storageClient.listPipelines().isEmpty());
+ assertThat(storageClient.listPipelines()).isNotEmpty();
}
@Test
@@ -156,8 +156,7 @@ public class TestContainerOperations {
dn.getIpAddress(), dn.getUuidString());
assertEquals(1, usageInfoList.size());
- assertTrue(usageInfoList.get(0).getContainerCount() >= 0 &&
- usageInfoList.get(0).getContainerCount() <= 1);
+
assertThat(usageInfoList.get(0).getContainerCount()).isGreaterThanOrEqualTo(0).isLessThanOrEqualTo(1);
totalContainerCount[(int)usageInfoList.get(0).getContainerCount()]++;
}
assertEquals(2, totalContainerCount[0]);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestCpuMetrics.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestCpuMetrics.java
index c70d4da4ba..e49a378a15 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestCpuMetrics.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestCpuMetrics.java
@@ -19,7 +19,7 @@
package org.apache.hadoop.ozone;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_HTTP_ADDRESS_KEY;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
@@ -67,15 +67,12 @@ public class TestCpuMetrics {
String metricsResponseBodyContent = metricsResponse.body().string();
// then
- assertTrue(metricsResponseBodyContent
- .contains("jvm_metrics_cpu_available_processors"),
- metricsResponseBodyContent);
- assertTrue(metricsResponseBodyContent
- .contains("jvm_metrics_cpu_system_load"),
- metricsResponseBodyContent);
- assertTrue(metricsResponseBodyContent
- .contains("jvm_metrics_cpu_jvm_load"),
- metricsResponseBodyContent);
+ assertThat(metricsResponseBodyContent)
+ .contains("jvm_metrics_cpu_available_processors");
+ assertThat(metricsResponseBodyContent)
+ .contains("jvm_metrics_cpu_system_load");
+ assertThat(metricsResponseBodyContent)
+ .contains("jvm_metrics_cpu_jvm_load");
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDelegationToken.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDelegationToken.java
index da806ac2a3..a82a1a8be7 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDelegationToken.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestDelegationToken.java
@@ -86,11 +86,11 @@ import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVA
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.TOKEN_ERROR_OTHER;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND;
import static
org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
+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;
+
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.slf4j.event.Level.INFO;
import org.junit.jupiter.api.AfterEach;
@@ -323,8 +323,8 @@ public final class TestDelegationToken {
RandomStringUtils.randomAscii(5));
// Assert if auth was successful via Kerberos
- assertFalse(logs.getOutput().contains(
- "Auth successful for " + username + " (auth:KERBEROS)"));
+ assertThat(logs.getOutput()).doesNotContain(
+ "Auth successful for " + username + " (auth:KERBEROS)");
// Case 1: Test successful delegation token.
Token<OzoneTokenIdentifier> token = omClient
@@ -332,7 +332,7 @@ public final class TestDelegationToken {
// Case 2: Test successful token renewal.
long renewalTime = omClient.renewDelegationToken(token);
- assertTrue(renewalTime > 0);
+ assertThat(renewalTime).isGreaterThan(0);
// Check if token is of right kind and renewer is running om instance
assertNotNull(token);
@@ -358,13 +358,12 @@ public final class TestDelegationToken {
});
// Case 3: Test Client can authenticate using token.
- assertFalse(logs.getOutput().contains(
- "Auth successful for " + username + " (auth:TOKEN)"));
+ assertThat(logs.getOutput()).doesNotContain(
+ "Auth successful for " + username + " (auth:TOKEN)");
OzoneTestUtils.expectOmException(VOLUME_NOT_FOUND,
() -> omClient.deleteVolume("vol1"));
- assertTrue(logs.getOutput().contains("Auth successful for "
- + username + " (auth:TOKEN)"),
- "Log file doesn't contain successful auth for user " + username);
+ assertThat(logs.getOutput())
+ .contains("Auth successful for " + username + " (auth:TOKEN)");
// Case 4: Test failure of token renewal.
// Call to renewDelegationToken will fail but it will confirm that
@@ -374,8 +373,8 @@ public final class TestDelegationToken {
OMException ex = assertThrows(OMException.class,
() -> omClient.renewDelegationToken(token));
assertEquals(INVALID_AUTH_METHOD, ex.getResult());
- assertTrue(logs.getOutput().contains(
- "Auth successful for " + username + " (auth:TOKEN)"));
+ assertThat(logs.getOutput()).contains(
+ "Auth successful for " + username + " (auth:TOKEN)");
omLogs.clearOutput();
//testUser.setAuthenticationMethod(AuthMethod.KERBEROS);
omClient.close();
@@ -391,7 +390,7 @@ public final class TestDelegationToken {
// Wait for client to timeout
Thread.sleep(CLIENT_TIMEOUT);
- assertFalse(logs.getOutput().contains("Auth failed for"));
+ assertThat(logs.getOutput()).doesNotContain("Auth failed for");
// Case 6: Test failure of token cancellation.
// Get Om client, this time authentication using Token will fail as
@@ -402,8 +401,8 @@ public final class TestDelegationToken {
ex = assertThrows(OMException.class,
() -> omClient.cancelDelegationToken(token));
assertEquals(TOKEN_ERROR_OTHER, ex.getResult());
- assertTrue(ex.getMessage().contains("Cancel delegation token failed"));
- assertTrue(logs.getOutput().contains("Auth failed for"));
+ assertThat(ex.getMessage()).contains("Cancel delegation token failed");
+ assertThat(logs.getOutput()).contains("Auth failed for");
} finally {
om.stop();
om.join();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestContainerReplication.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestContainerReplication.java
index 28d19d0be8..810a572549 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestContainerReplication.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestContainerReplication.java
@@ -28,7 +28,7 @@ import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTER
import static
org.apache.hadoop.ozone.container.TestHelper.waitForContainerClose;
import static org.apache.hadoop.ozone.container.TestHelper.waitForReplicaCount;
import static org.apache.ozone.test.GenericTestUtils.setLogLevel;
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
@@ -108,7 +108,7 @@ class TestContainerReplication {
createTestData(client);
List<OmKeyLocationInfo> keyLocations = lookupKey(cluster);
- assertFalse(keyLocations.isEmpty());
+ assertThat(keyLocations).isNotEmpty();
OmKeyLocationInfo keyLocation = keyLocations.get(0);
long containerID = keyLocation.getContainerID();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestHelper.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestHelper.java
index 665e07630d..d6bb591979 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestHelper.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/TestHelper.java
@@ -65,7 +65,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.stream.Collectors.toList;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -205,7 +207,7 @@ public final class TestHelper {
containerIdList.add(id);
}
}
- assertFalse(containerIdList.isEmpty());
+ assertThat(containerIdList).isNotEmpty();
waitForContainerClose(cluster, containerIdList.toArray(new Long[0]));
}
@@ -223,7 +225,7 @@ public final class TestHelper {
containerIdList.add(id);
}
}
- assertFalse(containerIdList.isEmpty());
+ assertThat(containerIdList).isNotEmpty();
waitForContainerClose(cluster, containerIdList.toArray(new Long[0]));
}
@@ -241,7 +243,7 @@ public final class TestHelper {
containerIdList.add(id);
}
}
- assertFalse(containerIdList.isEmpty());
+ assertThat(containerIdList).isNotEmpty();
waitForPipelineClose(cluster, waitForContainerCreation,
containerIdList.toArray(new Long[0]));
}
@@ -296,7 +298,7 @@ public final class TestHelper {
XceiverServerSpi server =
cluster.getHddsDatanodes().get(cluster.getHddsDatanodeIndex(dn))
.getDatanodeStateMachine().getContainer().getWriteChannel();
- assertTrue(server instanceof XceiverServerRatis);
+ assertInstanceOf(XceiverServerRatis.class, server);
GenericTestUtils.waitFor(() -> !server.isExist(pipelineId),
100, 30_000);
}
@@ -313,7 +315,7 @@ public final class TestHelper {
cluster.getHddsDatanodes().get(cluster.getHddsDatanodeIndex(dn))
.getDatanodeStateMachine().getContainer()
.getWriteChannel();
- assertTrue(server instanceof XceiverServerRatis);
+ assertInstanceOf(XceiverServerRatis.class, server);
try {
server.addGroup(pipeline.getId().getProtobuf(), Collections.
unmodifiableList(pipeline.getNodes()));
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
index e5c0d5d253..d5564ac231 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
@@ -100,6 +100,7 @@ import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_EXPIRED_CONTAIN
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -250,7 +251,7 @@ public class TestBlockDeletion {
}
}, 1000, 10000);
// No containers with deleted blocks
- assertTrue(containerIdsWithDeletedBlocks.isEmpty());
+ assertThat(containerIdsWithDeletedBlocks).isEmpty();
// Delete transactionIds for the containers should be 0.
// NOTE: this test assumes that all the container is KetValueContainer. If
// other container types is going to be added, this test should be checked.
@@ -295,7 +296,7 @@ public class TestBlockDeletion {
}, 2000, 30000);
// Few containers with deleted blocks
- assertFalse(containerIdsWithDeletedBlocks.isEmpty());
+ assertThat(containerIdsWithDeletedBlocks).isNotEmpty();
// Containers in the DN and SCM should have same delete transactionIds
matchContainerTransactionIds();
@@ -318,11 +319,11 @@ public class TestBlockDeletion {
assertEquals(metrics.getNumBlockDeletionTransactionCreated(),
metrics.getNumBlockDeletionTransactionCompleted());
- assertTrue(metrics.getNumBlockDeletionCommandSent() >=
- metrics.getNumBlockDeletionCommandSuccess() +
+ assertThat(metrics.getNumBlockDeletionCommandSent())
+ .isGreaterThanOrEqualTo(metrics.getNumBlockDeletionCommandSuccess() +
metrics.getBNumBlockDeletionCommandFailure());
- assertTrue(metrics.getNumBlockDeletionTransactionSent() >=
- metrics.getNumBlockDeletionTransactionFailure() +
+ assertThat(metrics.getNumBlockDeletionTransactionSent())
+
.isGreaterThanOrEqualTo(metrics.getNumBlockDeletionTransactionFailure() +
metrics.getNumBlockDeletionTransactionSuccess());
LOG.info(metrics.toString());
@@ -330,8 +331,8 @@ public class TestBlockDeletion {
for (int i = 5; i >= 0; i--) {
if (logCapturer.getOutput().contains("1(" + i + ")")) {
for (int j = 0; j <= i; j++) {
- assertTrue(logCapturer.getOutput()
- .contains("1(" + i + ")"));
+ assertThat(logCapturer.getOutput())
+ .contains("1(" + i + ")");
}
break;
}
@@ -720,8 +721,8 @@ public class TestBlockDeletion {
for (ContainerData containerData : containerDataList) {
long containerId = containerData.getContainerID();
if (containerIdsWithDeletedBlocks.contains(containerId)) {
- assertTrue(
- scm.getContainerInfo(containerId).getDeleteTransactionId() > 0);
+
assertThat(scm.getContainerInfo(containerId).getDeleteTransactionId())
+ .isGreaterThan(0);
maxTransactionId = max(maxTransactionId,
scm.getContainerInfo(containerId).getDeleteTransactionId());
} else {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
index c62f943ee8..cd25ee25c8 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
@@ -58,6 +58,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_DATANODE_PIPELINE_LIMIT;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -159,8 +160,7 @@ public class TestCloseContainerByPipeline {
.waitFor(() -> isContainerClosed(cluster, containerID,
datanodeDetails),
500, 5 * 1000);
// Make sure the closeContainerCommandHandler is Invoked
- assertTrue(
- closeContainerHandler.getInvocationCount() > lastInvocationCount);
+
assertThat(closeContainerHandler.getInvocationCount()).isGreaterThan(lastInvocationCount);
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestDeleteContainerHandler.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestDeleteContainerHandler.java
index b74e6f3c91..00654d943f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestDeleteContainerHandler.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestDeleteContainerHandler.java
@@ -76,6 +76,7 @@ import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_DATANODE_RATIS_VOLUME_FREE_SPACE_MIN;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_BLOCK_DELETING_SERVICE_INTERVAL;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -243,7 +244,7 @@ public class TestDeleteContainerHandler {
500,
5 * 2000);
assertTrue(!isContainerDeleted(hddsDatanodeService, containerId.getId()));
- assertTrue(beforeDeleteFailedCount <
metrics.getContainerDeleteFailedNonEmpty());
+
assertThat(beforeDeleteFailedCount).isLessThan(metrics.getContainerDeleteFailedNonEmpty());
// Send the delete command. It should pass with force flag.
// Deleting a non-empty container should pass on the DN when the force flag
// is true
@@ -258,7 +259,7 @@ public class TestDeleteContainerHandler {
isContainerDeleted(hddsDatanodeService, containerId.getId()),
500, 5 * 1000);
assertTrue(isContainerDeleted(hddsDatanodeService, containerId.getId()));
- assertTrue(beforeForceCount < metrics.getContainerForceDelete());
+ assertThat(beforeForceCount).isLessThan(metrics.getContainerForceDelete());
kv.setCheckChunksFilePath(false);
}
@@ -438,8 +439,8 @@ public class TestDeleteContainerHandler {
5 * 2000);
assertTrue(!isContainerDeleted(hddsDatanodeService,
containerId.getId()));
- assertTrue(containerDeleteFailedNonEmptyBlockDB <
- metrics.getContainerDeleteFailedNonEmpty());
+ assertThat(containerDeleteFailedNonEmptyBlockDB)
+ .isLessThan(metrics.getContainerDeleteFailedNonEmpty());
// Now empty the container Dir and try with a non-empty block table
Container containerToDelete = getContainerfromDN(
@@ -474,8 +475,7 @@ public class TestDeleteContainerHandler {
500, 5 * 1000);
assertTrue(isContainerDeleted(hddsDatanodeService,
containerId.getId()));
- assertTrue(beforeForceCount <
- metrics.getContainerForceDelete());
+ assertThat(beforeForceCount).isLessThan(metrics.getContainerForceDelete());
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestCSMMetrics.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestCSMMetrics.java
index 76a0f1ed21..8c35d5011a 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestCSMMetrics.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestCSMMetrics.java
@@ -53,8 +53,8 @@ import org.apache.ozone.test.GenericTestUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import static org.apache.ratis.rpc.SupportedRpcType.GRPC;
+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 org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.util.ExitUtils;
@@ -168,10 +168,10 @@ public class TestCSMMetrics {
assertCounter("NumApplyTransactionOps", 1L, metric);
applyTransactionLatency = getDoubleGauge(
"ApplyTransactionNsAvgTime", metric);
- assertTrue(applyTransactionLatency > 0.0);
+ assertThat(applyTransactionLatency).isGreaterThan(0.0);
writeStateMachineLatency = getDoubleGauge(
"WriteStateMachineDataNsAvgTime", metric);
- assertTrue(writeStateMachineLatency > 0.0);
+ assertThat(writeStateMachineLatency).isGreaterThan(0.0);
} finally {
if (client != null) {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
index b3c8b732c1..73910ef00f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainerWithTLS.java
@@ -80,12 +80,13 @@ import static
org.apache.hadoop.ozone.container.ContainerTestHelper.getTestConta
import static
org.apache.hadoop.ozone.container.replication.CopyContainerCompression.NO_COMPRESSION;
import static org.apache.ozone.test.GenericTestUtils.LogCapturer.captureLogs;
import static org.apache.ozone.test.GenericTestUtils.waitFor;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+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.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.slf4j.LoggerFactory.getLogger;
@@ -256,7 +257,7 @@ public class TestOzoneContainerWithTLS {
while (e.getCause() != null) {
e = e.getCause();
}
- assertTrue((e instanceof CertificateExpiredException));
+ assertInstanceOf(CertificateExpiredException.class, e);
} finally {
clientManager.releaseClient(client, true);
}
@@ -287,10 +288,12 @@ public class TestOzoneContainerWithTLS {
}
private void assertClientTrustManagerFailedAndRetried(LogCapturer logs) {
- assertTrue(logs.getOutput().contains("trying to re-fetch rootCA"),
- "Check client failed first, and initiates a reload.");
- assertTrue(logs.getOutput().contains("Loading certificates for client."),
- "Check client loaded certificates.");
+ assertThat(logs.getOutput())
+ .withFailMessage("Check client failed first, and initiates a reload.")
+ .contains("trying to re-fetch rootCA");
+ assertThat(logs.getOutput())
+ .withFailMessage("Check client loaded certificates.")
+ .contains("Loading certificates for client.");
logs.clearOutput();
}
@@ -319,8 +322,8 @@ public class TestOzoneContainerWithTLS {
sourceDatanodes, tempFolder.resolve("tmp"), NO_COMPRESSION);
downloader.close();
assertNull(file);
- assertTrue(logCapture.getOutput().contains(
- "java.security.cert.CertificateExpiredException"));
+ assertThat(logCapture.getOutput())
+ .contains("java.security.cert.CertificateExpiredException");
}
private void assertDownloadContainerWorks(List<Long> containers,
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/server/TestSecureContainerServer.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/server/TestSecureContainerServer.java
index 3e2e092c2f..53420c0e22 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/server/TestSecureContainerServer.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/server/TestSecureContainerServer.java
@@ -105,11 +105,11 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.apache.ratis.rpc.SupportedRpcType.GRPC;
+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;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Container servers when security is enabled.
@@ -316,7 +316,7 @@ public class TestSecureContainerServer {
ContainerCommandResponseProto response = client.sendCommand(request);
assertNotEquals(response.getResult(), ContainerProtos.Result.SUCCESS);
String msg = response.getMessage();
- assertTrue(msg.contains(BLOCK_TOKEN_VERIFICATION_FAILED.name()), msg);
+ assertThat(msg).contains(BLOCK_TOKEN_VERIFICATION_FAILED.name());
} else {
final Throwable t = assertThrows(Throwable.class,
() -> client.sendCommand(request));
@@ -329,7 +329,7 @@ public class TestSecureContainerServer {
Throwable rootCause = ExceptionUtils.getRootCause(t);
assertNotNull(rootCause);
String msg = rootCause.getMessage();
- assertTrue(msg.contains(contained), msg);
+ assertThat(msg).contains(contained);
}
private static String getToken(ContainerID containerID) throws IOException {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLDBCli.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLDBCli.java
index a5264fd0b4..c97b156f8b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLDBCli.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLDBCli.java
@@ -61,8 +61,8 @@ import java.util.TreeMap;
import java.util.stream.Stream;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This class tests `ozone debug ldb` CLI that reads from a RocksDB directory.
@@ -236,7 +236,7 @@ public class TestLDBCli {
// Check stderr
final String stderrShouldContain = expectedExitCodeStderrPair.getRight();
- assertTrue(stderr.toString().contains(stderrShouldContain));
+ assertThat(stderr.toString()).contains(stderrShouldContain);
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestFreonWithDatanodeFastRestart.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestFreonWithDatanodeFastRestart.java
index d530a6312c..0798731a83 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestFreonWithDatanodeFastRestart.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestFreonWithDatanodeFastRestart.java
@@ -34,8 +34,8 @@ import org.junit.jupiter.api.Timeout;
import picocli.CommandLine;
import java.util.concurrent.TimeUnit;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests Freon with Datanode restarts without waiting for pipeline to close.
@@ -93,8 +93,8 @@ public class TestFreonWithDatanodeFastRestart {
// After restart the term index might have progressed to apply pending
// transactions.
TermIndex termIndexAfterRestart = sm.getLastAppliedTermIndex();
- assertTrue(termIndexAfterRestart.getIndex() >=
- termIndexBeforeRestart.getIndex());
+ assertThat(termIndexAfterRestart.getIndex())
+ .isGreaterThanOrEqualTo(termIndexBeforeRestart.getIndex());
// TODO: fix me
// Give some time for the datanode to register again with SCM.
// If we try to use the pipeline before the datanode registers with SCM
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
index 651e5350cf..3140681d3d 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
@@ -46,8 +46,8 @@ import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Test for HadoopDirTreeGenerator.
@@ -183,9 +183,10 @@ public class TestHadoopDirTreeGenerator {
} else {
assertEquals(perFileSize.toBytes(), fileStatus.getLen(), "Mismatches
file len");
String fName = fileStatus.getPath().getName();
- assertFalse(files.contains(fName), actualNumFiles + "actualNumFiles:"
+ fName +
- ", fName:" + expectedFileCnt + ", expectedFileCnt:" + depth
- + ", depth:");
+ assertThat(files)
+ .withFailMessage(actualNumFiles + "actualNumFiles:" + fName +
+ ", fName:" + expectedFileCnt + ", expectedFileCnt:" + depth +
", depth:")
+ .doesNotContain(fName);
files.add(fName);
actualNumFiles++;
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
index ad10c4d476..b74022b83e 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
@@ -44,8 +44,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for OmBucketReadWriteKeyOps.
@@ -206,7 +206,7 @@ public class TestOmBucketReadWriteKeyOps {
omLockMetrics.getLongestReadLockWaitingTimeMs());
int readWaitingSamples =
Integer.parseInt(readLockWaitingTimeMsStat.split(" ")[2]);
- assertTrue(readWaitingSamples > 0, "Read Lock Waiting Samples should be
positive");
+ assertThat(readWaitingSamples).isGreaterThan(0);
String readLockHeldTimeMsStat = omLockMetrics.getReadLockHeldTimeMsStat();
LOG.info("Read Lock Held Time Stat: " + readLockHeldTimeMsStat);
@@ -214,7 +214,7 @@ public class TestOmBucketReadWriteKeyOps {
omLockMetrics.getLongestReadLockHeldTimeMs());
int readHeldSamples =
Integer.parseInt(readLockHeldTimeMsStat.split(" ")[2]);
- assertTrue(readHeldSamples > 0, "Read Lock Held Samples should be
positive");
+ assertThat(readHeldSamples).isGreaterThan(0);
String writeLockWaitingTimeMsStat =
omLockMetrics.getWriteLockWaitingTimeMsStat();
@@ -223,7 +223,7 @@ public class TestOmBucketReadWriteKeyOps {
omLockMetrics.getLongestWriteLockWaitingTimeMs());
int writeWaitingSamples =
Integer.parseInt(writeLockWaitingTimeMsStat.split(" ")[2]);
- assertTrue(writeWaitingSamples > 0, "Write Lock Waiting Samples should be
positive");
+ assertThat(writeWaitingSamples).isGreaterThan(0);
String writeLockHeldTimeMsStat =
omLockMetrics.getWriteLockHeldTimeMsStat();
LOG.info("Write Lock Held Time Stat: " + writeLockHeldTimeMsStat);
@@ -231,7 +231,7 @@ public class TestOmBucketReadWriteKeyOps {
omLockMetrics.getLongestWriteLockHeldTimeMs());
int writeHeldSamples =
Integer.parseInt(writeLockHeldTimeMsStat.split(" ")[2]);
- assertTrue(writeHeldSamples > 0, "Write Lock Held Samples should be
positive");
+ assertThat(writeHeldSamples).isGreaterThan(0);
}
private static class ParameterBuilder {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
index c07a48b105..c9e6e13806 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestNSSummaryAdmin.java
@@ -38,8 +38,7 @@ import java.io.UnsupportedEncodingException;
import java.util.UUID;
import static
org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_ADDRESS_KEY;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Test for Namespace CLI.
@@ -116,9 +115,9 @@ public class TestNSSummaryAdmin extends
StandardOutputTestBase {
String path = "/";
executeAdminCommands(path);
// Should throw warning - only buckets can have bucket layout.
- assertTrue(getOutContentString().contains("[Warning] Namespace CLI is not
designed for OBS bucket layout."));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize DU"));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize file size distribution"));
+ assertThat(getOutContentString()).contains("[Warning] Namespace CLI is not
designed for OBS bucket layout.");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize DU");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize file size distribution");
}
/**
@@ -130,9 +129,10 @@ public class TestNSSummaryAdmin extends
StandardOutputTestBase {
String path = "/" + volumeName + "/" + bucketFSO;
executeAdminCommands(path);
// Should not throw warning, since bucket is in FSO bucket layout.
- assertFalse(getOutContentString().contains("[Warning] Namespace CLI is not
designed for OBS bucket layout."));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize DU"));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize file size distribution"));
+ assertThat(getOutContentString())
+ .doesNotContain("[Warning] Namespace CLI is not designed for OBS
bucket layout.");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize DU");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize file size distribution");
}
/**
@@ -144,9 +144,9 @@ public class TestNSSummaryAdmin extends
StandardOutputTestBase {
String path = "/" + volumeName + "/" + bucketOBS;
executeAdminCommands(path);
// Should throw warning, since bucket is in OBS bucket layout.
- assertTrue(getOutContentString().contains("[Warning] Namespace CLI is not
designed for OBS bucket layout."));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize DU"));
- assertTrue(getOutContentString().contains("Put more files into it to
visualize file size distribution"));
+ assertThat(getOutContentString()).contains("[Warning] Namespace CLI is not
designed for OBS bucket layout.");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize DU");
+ assertThat(getOutContentString()).contains("Put more files into it to
visualize file size distribution");
}
/**
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDatanodeShell.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDatanodeShell.java
index df668bf44c..5bbdd4feba 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDatanodeShell.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneDatanodeShell.java
@@ -35,7 +35,7 @@ import picocli.CommandLine.ParameterException;
import picocli.CommandLine.ParseResult;
import picocli.CommandLine.RunLast;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -99,9 +99,7 @@ public class TestOzoneDatanodeShell {
if (exceptionToCheck.getCause() != null) {
exceptionToCheck = exceptionToCheck.getCause();
}
- assertTrue(exceptionToCheck.getMessage().contains(expectedError),
- String.format("Error of shell code doesn't contain the " +
"exception [%s] in [%s]", expectedError,
- exceptionToCheck.getMessage()));
+ assertThat(exceptionToCheck.getMessage()).contains(expectedError);
}
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
index de25f24f33..6bd3f5f22f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
@@ -82,8 +82,10 @@ import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCK
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_EMPTY;
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND;
+import static org.assertj.core.api.Assertions.assertThat;
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.assertThrows;
@@ -278,10 +280,7 @@ public class TestOzoneShellHA {
if (exceptionToCheck.getCause() != null) {
exceptionToCheck = exceptionToCheck.getCause();
}
- assertTrue(exceptionToCheck.getMessage().contains(expectedError),
- String.format("Error of OzoneShell code doesn't contain the " +
- "exception [%s] in [%s]",
- expectedError, exceptionToCheck.getMessage()));
+ assertThat(exceptionToCheck.getMessage()).contains(expectedError);
}
}
}
@@ -429,7 +428,7 @@ public class TestOzoneShellHA {
Throwable t = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, args));
Throwable c = t.getCause();
- assertTrue(c instanceof IllegalArgumentException);
+ assertInstanceOf(IllegalArgumentException.class, c);
assertEquals("rs-3-2-1024k is not supported for " +
ReplicationType.RATIS + " replication type", c.getMessage());
}
@@ -1046,36 +1045,36 @@ public class TestOzoneShellHA {
"--space-quota", "0GB"};
ExecutionException eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, volumeArgs1));
- assertTrue(eException.getMessage()
- .contains("Invalid value for space quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for space quota");
out.reset();
String[] volumeArgs2 = new String[]{"volume", "setquota", "vol4",
"--space-quota", "-1GB"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, volumeArgs2));
- assertTrue(eException.getMessage()
- .contains("Invalid value for space quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for space quota");
out.reset();
String[] volumeArgs3 = new String[]{"volume", "setquota", "vol4",
"--space-quota", "test"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, volumeArgs3));
- assertTrue(eException.getMessage()
+ assertThat(eException.getMessage())
.contains("test is invalid. " +
"The quota value should be a positive integer " +
- "with byte numeration(B, KB, MB, GB and TB)"));
+ "with byte numeration(B, KB, MB, GB and TB)");
out.reset();
String[] volumeArgs4 = new String[]{"volume", "setquota", "vol4",
"--space-quota", "1.5GB"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, volumeArgs4));
- assertTrue(eException.getMessage()
+ assertThat(eException.getMessage())
.contains("1.5GB is invalid. " +
"The quota value should be a positive integer " +
- "with byte numeration(B, KB, MB, GB and TB)"));
+ "with byte numeration(B, KB, MB, GB and TB)");
out.reset();
String[] volumeArgs5 = new String[]{"volume", "setquota", "vol4",
@@ -1083,24 +1082,24 @@ public class TestOzoneShellHA {
MissingParameterException mException = assertThrows(
MissingParameterException.class,
() -> execute(ozoneShell, volumeArgs5));
- assertTrue(mException.getMessage()
- .contains("Missing required parameter"));
+ assertThat(mException.getMessage())
+ .contains("Missing required parameter");
out.reset();
String[] volumeArgs6 = new String[]{"volume", "setquota", "vol4",
"--namespace-quota", "0"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, volumeArgs6));
- assertTrue(eException.getMessage()
- .contains("Invalid value for namespace quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for namespace quota");
out.reset();
String[] volumeArgs7 = new String[]{"volume", "setquota", "vol4",
"--namespace-quota"};
mException = assertThrows(MissingParameterException.class,
() -> execute(ozoneShell, volumeArgs7));
- assertTrue(mException.getMessage()
- .contains("Missing required parameter"));
+ assertThat(mException.getMessage())
+ .contains("Missing required parameter");
out.reset();
// Test set bucket quota to invalid values
@@ -1108,60 +1107,60 @@ public class TestOzoneShellHA {
"--space-quota", "0GB"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, bucketArgs1));
- assertTrue(eException.getMessage()
- .contains("Invalid value for space quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for space quota");
out.reset();
String[] bucketArgs2 = new String[]{"bucket", "setquota", "vol4/buck4",
"--space-quota", "-1GB"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, bucketArgs2));
- assertTrue(eException.getMessage()
- .contains("Invalid value for space quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for space quota");
out.reset();
String[] bucketArgs3 = new String[]{"bucket", "setquota", "vol4/buck4",
"--space-quota", "test"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, bucketArgs3));
- assertTrue(eException.getMessage()
+ assertThat(eException.getMessage())
.contains("test is invalid. " +
"The quota value should be a positive integer " +
- "with byte numeration(B, KB, MB, GB and TB)"));
+ "with byte numeration(B, KB, MB, GB and TB)");
out.reset();
String[] bucketArgs4 = new String[]{"bucket", "setquota", "vol4/buck4",
"--space-quota", "1.5GB"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, bucketArgs4));
- assertTrue(eException.getMessage()
+ assertThat(eException.getMessage())
.contains("1.5GB is invalid. " +
"The quota value should be a positive integer " +
- "with byte numeration(B, KB, MB, GB and TB)"));
+ "with byte numeration(B, KB, MB, GB and TB)");
out.reset();
String[] bucketArgs5 = new String[]{"bucket", "setquota", "vol4/buck4",
"--space-quota"};
mException = assertThrows(MissingParameterException.class,
() -> execute(ozoneShell, bucketArgs5));
- assertTrue(mException.getMessage()
- .contains("Missing required parameter"));
+ assertThat(mException.getMessage())
+ .contains("Missing required parameter");
out.reset();
String[] bucketArgs6 = new String[]{"bucket", "setquota", "vol4/buck4",
"--namespace-quota", "0"};
eException = assertThrows(ExecutionException.class,
() -> execute(ozoneShell, bucketArgs6));
- assertTrue(eException.getMessage()
- .contains("Invalid value for namespace quota"));
+ assertThat(eException.getMessage())
+ .contains("Invalid value for namespace quota");
out.reset();
String[] bucketArgs7 = new String[]{"bucket", "setquota", "vol4/buck4",
"--namespace-quota"};
mException = assertThrows(MissingParameterException.class,
() -> execute(ozoneShell, bucketArgs7));
- assertTrue(mException.getMessage()
- .contains("Missing required parameter"));
+ assertThat(mException.getMessage())
+ .contains("Missing required parameter");
out.reset();
// Test set bucket spaceQuota or nameSpaceQuota to normal value.
@@ -1249,7 +1248,7 @@ public class TestOzoneShellHA {
client.getObjectStore().getVolume(volumeName);
OzoneBucket bucket = volume.getBucket("bucket0");
try (OzoneOutputStream out = bucket.createKey("myKey", 2000)) {
- assertTrue(out.getOutputStream() instanceof ECKeyOutputStream);
+ assertInstanceOf(ECKeyOutputStream.class, out.getOutputStream());
}
}
@@ -1313,7 +1312,7 @@ public class TestOzoneShellHA {
client.getObjectStore().getVolume(volumeName);
OzoneBucket bucket = volume.getBucket("bucket1");
try (OzoneOutputStream out = bucket.createKey("myKey", 2000)) {
- assertTrue(out.getOutputStream() instanceof KeyOutputStream);
+ assertInstanceOf(KeyOutputStream.class, out.getOutputStream());
assertFalse(out.getOutputStream() instanceof ECKeyOutputStream);
}
}
@@ -1338,7 +1337,7 @@ public class TestOzoneShellHA {
execute(ozoneShell, args);
bucket = volume.getBucket("bucket0");
try (OzoneOutputStream out = bucket.createKey("newECKey", 1024)) {
- assertTrue(out.getOutputStream() instanceof ECKeyOutputStream);
+ assertInstanceOf(ECKeyOutputStream.class, out.getOutputStream());
}
args = new String[] {"bucket", "set-replication-config", bucketPath, "-t",
@@ -1677,7 +1676,7 @@ public class TestOzoneShellHA {
parseOutputIntoArrayList();
// Can include s3v and volumes from other test cases that aren't cleaned
up,
// hence >= instead of equals.
- assertTrue(volumeListOut.size() >= testVolumes.size());
+
assertThat(volumeListOut.size()).isGreaterThanOrEqualTo(testVolumes.size());
final HashSet<String> volumeSet = new HashSet<>(testVolumes);
volumeListOut.forEach(map -> volumeSet.remove(map.get("name")));
// Should have found all the volumes created for this test
@@ -1731,9 +1730,9 @@ public class TestOzoneShellHA {
};
ParameterException exception = assertThrows(ParameterException.class,
() -> execute(ozoneShell, arg2));
- assertTrue(exception.getMessage()
+ assertThat(exception.getMessage())
.contains("expected one of [FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, " +
- "LEGACY]"));
+ "LEGACY]");
String[] arg3 = new String[]{
@@ -1743,9 +1742,9 @@ public class TestOzoneShellHA {
exception = assertThrows(ParameterException.class,
() -> execute(ozoneShell, arg3));
- assertTrue(exception.getMessage()
+ assertThat(exception.getMessage())
.contains("expected one of [FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, " +
- "LEGACY] "));
+ "LEGACY] ");
}
@Test
@@ -1778,7 +1777,7 @@ public class TestOzoneShellHA {
// Number of keys should return less than 120(100 by default)
args = new String[]{"key", "list", volumeName};
execute(ozoneShell, args);
- assertTrue(getNumOfKeys() < 120);
+ assertThat(getNumOfKeys()).isLessThan(120);
out.reset();
// Use --all option to get all the keys
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java
index e542e9494d..8b9866aef4 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java
@@ -65,9 +65,9 @@ import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RANGER_HTTPS_ADMI
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RANGER_HTTPS_ADMIN_API_USER;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_RANGER_HTTPS_ADDRESS_KEY;
import static
org.apache.hadoop.ozone.om.OMMultiTenantManagerImpl.OZONE_OM_TENANT_DEV_SKIP_RANGER;
+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.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -263,9 +263,7 @@ public class TestOzoneTenantShell {
if (exceptionToCheck.getCause() != null) {
exceptionToCheck = exceptionToCheck.getCause();
}
- assertTrue(exceptionToCheck.getMessage().contains(expectedError),
- String.format("Error of OzoneShell code doesn't contain the
exception [%s] in [%s]", expectedError,
- exceptionToCheck.getMessage()));
+ assertThat(exceptionToCheck.getMessage()).contains(expectedError);
}
}
}
@@ -358,7 +356,7 @@ public class TestOzoneTenantShell {
if (exactMatch) {
assertEquals(stringToMatch, str);
} else {
- assertTrue(str.contains(stringToMatch), str);
+ assertThat(str).contains(stringToMatch);
}
}
@@ -447,7 +445,7 @@ public class TestOzoneTenantShell {
checkOutput(err, "", true);
lines = FileUtils.readLines(AUDIT_LOG_FILE, (String)null);
- assertTrue(lines.size() > 0);
+ assertThat(lines.size()).isGreaterThan(0);
checkOutput(lines.get(lines.size() - 1), "ret=SUCCESS", false);
// Check volume creation
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestReconfigShell.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestReconfigShell.java
index 5074279128..231301cb35 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestReconfigShell.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestReconfigShell.java
@@ -42,8 +42,8 @@ import org.junit.jupiter.api.Timeout;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState.DECOMMISSIONED;
import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState.IN_SERVICE;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* * Integration test for {@code ozone admin reconfig} command. HA enabled.
@@ -138,7 +138,7 @@ public class TestReconfigShell {
List<String> outs =
Arrays.asList(output.split(System.getProperty("line.separator")));
for (String property : except) {
- assertTrue(outs.contains(property), String.format("Not found %s in
output: %s", property, output));
+ assertThat(outs).contains(property);
}
}
@@ -176,8 +176,7 @@ public class TestReconfigShell {
"reconfig", "--in-service-datanodes", "properties"});
String output = capture.getOutput();
- assertTrue(capture.getOutput().contains(String.format("successfully %d",
except)),
- String.format("Excepted successfully %d. output: %s%n", except,
output));
+ assertThat(capture.getOutput()).contains(String.format("successfully
%d", except));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]