You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/05/14 10:00:00 UTC

[GitHub] [ozone] kaijchen opened a new pull request, #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

kaijchen opened a new pull request, #3415:
URL: https://github.com/apache/ozone/pull/3415

   ## What changes were proposed in this pull request?
   
   Tests migrated:
   
   ```
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificate/utils/TestCRLCodec.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificate/utils/TestCertificateCodec.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificate/authority/TestDefaultCAServer.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificate/authority/TestDefaultProfile.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificates/TestCertificateSignRequest.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/certificates/TestRootCertificate.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/x509/keys/TestKeyCodec.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/server/TestServerUtils.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBTableStore.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestTypedRDBTableStore.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBConfigFromFile.java
   ./hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestDBStoreBuilder.java 
   ```
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-6738
   
   ## How was this patch tested?
   
   CI


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r875545104


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBTableStore.java:
##########
@@ -218,131 +219,100 @@ public void forEachAndIterator() throws Exception {
           localCount++;
         }
 
-        Assert.assertEquals(iterCount, localCount);
+        Assertions.assertEquals(iterCount, localCount);
         iter.seekToFirst();
         iter.forEachRemaining(TestRDBTableStore::consume);
-        Assert.assertEquals(iterCount, count);
+        Assertions.assertEquals(iterCount, count);
 
       }
     }
   }
 
   @Test
   public void testIsExist() throws Exception {
-    DBOptions rocksDBOptions = new DBOptions();
-    rocksDBOptions.setCreateIfMissing(true);
-    rocksDBOptions.setCreateMissingColumnFamilies(true);
-
-    String tableName = StringUtils.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY);
-
-    Set<TableConfig> configSet = new HashSet<>();
-    TableConfig newConfig = new TableConfig(tableName,
-        new ColumnFamilyOptions());
-    configSet.add(newConfig);
 
-    File rdbLocation = folder.newFolder();
-    RDBStore dbStore = new RDBStore(rdbLocation, rocksDBOptions, configSet);

Review Comment:
   I'm not sure this (and other similar blocks below) should be removed at all, but certainly not part of a junit upgrade patch.



##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   Can we keep these?  I'm not sure why a new store is created, but let's clean them up in separate Jira.



##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBTableStore.java:
##########
@@ -374,9 +344,12 @@ public void testIteratorRemoveFromDB() throws Exception {
       TableIterator<byte[], ? extends Table.KeyValue<byte[], byte[]>> iterator =
           testTable.iterator();
       iterator.removeFromDB();
-      Assert.assertNull(testTable.get("1".getBytes(StandardCharsets.UTF_8)));
-      Assert.assertNotNull(testTable.get("2".getBytes(StandardCharsets.UTF_8)));
-      Assert.assertNotNull(testTable.get("3".getBytes(StandardCharsets.UTF_8)));
+      Assertions.assertNull(
+          testTable.get("1".getBytes(StandardCharsets.UTF_8)));
+      Assertions.assertNotNull(
+          testTable.get("2".getBytes(StandardCharsets.UTF_8)));
+      Assertions.assertNotNull(
+          testTable.get("3".getBytes(StandardCharsets.UTF_8)));

Review Comment:
   Instead of line wrapping, can you please extract constants for `"1".getBytes(StandardCharsets.UTF_8)`, etc.?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877223715


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   With old junit these were opened in a new location, unrelated to the old DB store.  We could pass another temp dir to the methods.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] kaijchen commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
kaijchen commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877227034


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   I've tried before, `@TempDir` will be same in `@BeforeEach` method and the `@Test` method. That's why I changed these code in the first place.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877231691


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   I see.  Then we can probably keep your original code.  Thanks.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai merged pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
adoroszlai merged PR #3415:
URL: https://github.com/apache/ozone/pull/3415


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] kaijchen commented on pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
kaijchen commented on PR #3415:
URL: https://github.com/apache/ozone/pull/3415#issuecomment-1132371510

   Thanks @adoroszlai for the review.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] kaijchen commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
kaijchen commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877228026


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBTableStore.java:
##########
@@ -218,131 +219,100 @@ public void forEachAndIterator() throws Exception {
           localCount++;
         }
 
-        Assert.assertEquals(iterCount, localCount);
+        Assertions.assertEquals(iterCount, localCount);
         iter.seekToFirst();
         iter.forEachRemaining(TestRDBTableStore::consume);
-        Assert.assertEquals(iterCount, count);
+        Assertions.assertEquals(iterCount, count);
 
       }
     }
   }
 
   @Test
   public void testIsExist() throws Exception {
-    DBOptions rocksDBOptions = new DBOptions();
-    rocksDBOptions.setCreateIfMissing(true);
-    rocksDBOptions.setCreateMissingColumnFamilies(true);
-
-    String tableName = StringUtils.bytes2String(RocksDB.DEFAULT_COLUMN_FAMILY);
-
-    Set<TableConfig> configSet = new HashSet<>();
-    TableConfig newConfig = new TableConfig(tableName,
-        new ColumnFamilyOptions());
-    configSet.add(newConfig);
 
-    File rdbLocation = folder.newFolder();
-    RDBStore dbStore = new RDBStore(rdbLocation, rocksDBOptions, configSet);

Review Comment:
   Agreed. I have created HDDS-6773 to do this.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] kaijchen commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
kaijchen commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877702684


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   Seems `@TempDir` behavior is changed in [JUnit 5.8](https://junit.org/junit5/docs/5.8.0/release-notes/index.html#:~:text=%40TempDir%20can%20now,to%20per_context.)



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] kaijchen commented on a diff in pull request #3415: HDDS-6738. Migrate tests with rules in hdds-server-framework to JUnit5

Posted by GitBox <gi...@apache.org>.
kaijchen commented on code in PR #3415:
URL: https://github.com/apache/ozone/pull/3415#discussion_r877216192


##########
hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/utils/db/TestRDBStore.java:
##########
@@ -239,101 +226,84 @@ public void listTables() throws Exception {
     int count = families.size();
     // Assert that we have all the tables in the list and no more.
     for (String name : families) {
-      Assert.assertTrue(hashTable.containsKey(name));
+      Assertions.assertTrue(hashTable.containsKey(name));
       count--;
     }
-    Assert.assertEquals(0, count);
+    Assertions.assertEquals(0, count);
   }
 
   @Test
   public void testRocksDBCheckpoint() throws Exception {
-    try (RDBStore newStore =
-             new RDBStore(folder.newFolder(), options, configSet)) {

Review Comment:
   OK, I think we can close the old one before open the new one. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org