Copilot commented on code in PR #8899:
URL: https://github.com/apache/ozone/pull/8899#discussion_r2280045709
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -317,8 +319,30 @@ public void testContentsOfTarballWithSnapshot(boolean
includeSnapshot) throws Ex
assertFalse(inodesFromTarball.isEmpty());
assertTrue(inodesFromTarball.containsAll(inodesFromOmDataDir));
+ long actualYamlFiles = Files.list(newDbDir.toPath())
+ .filter(f -> f.getFileName().toString()
+ .endsWith(".yaml")).count();
+ assertEquals(numSnapshots, actualYamlFiles,
+ "Number of generated YAML files should match the number of
snapshots.");
+
// create hardlinks now
OmSnapshotUtils.createHardLinks(newDbDir.toPath(), true);
+
+ if (includeSnapshot) {
+ List<String> yamlRelativePaths = snapshotPaths.stream().map(path -> {
+ int startIndex = path.indexOf("db.snapshots");
+ if (startIndex != -1) {
+ return path.substring(startIndex) + ".yaml";
+ }
+ return path + ".yaml";
+ }).collect(Collectors.toList());
+
+ for (String yamlRelativePath : yamlRelativePaths) {
+ String yamlFileName = newDbDir.getPath() + "/" + yamlRelativePath;
Review Comment:
Use Path.resolve() or Paths.get() instead of string concatenation for file
path construction to ensure proper path handling across different operating
systems.
```suggestion
String yamlFileName = Paths.get(newDbDir.getPath(),
yamlRelativePath).toString();
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -317,8 +319,30 @@ public void testContentsOfTarballWithSnapshot(boolean
includeSnapshot) throws Ex
assertFalse(inodesFromTarball.isEmpty());
assertTrue(inodesFromTarball.containsAll(inodesFromOmDataDir));
+ long actualYamlFiles = Files.list(newDbDir.toPath())
+ .filter(f -> f.getFileName().toString()
+ .endsWith(".yaml")).count();
+ assertEquals(numSnapshots, actualYamlFiles,
+ "Number of generated YAML files should match the number of
snapshots.");
+
// create hardlinks now
OmSnapshotUtils.createHardLinks(newDbDir.toPath(), true);
+
+ if (includeSnapshot) {
+ List<String> yamlRelativePaths = snapshotPaths.stream().map(path -> {
+ int startIndex = path.indexOf("db.snapshots");
+ if (startIndex != -1) {
+ return path.substring(startIndex) + ".yaml";
+ }
+ return path + ".yaml";
+ }).collect(Collectors.toList());
Review Comment:
[nitpick] Consider using toList() instead of collect(Collectors.toList())
for better performance and readability in Java 16+.
```suggestion
}).toList();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]