This is an automated email from the ASF dual-hosted git repository.

MartijnVisser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 191cec9f568 [FLINK-40977][state/forst] Complete JUnit 5 migration of 
flink-statebackend-forst (#29535)
191cec9f568 is described below

commit 191cec9f568a470d5e9582d24a19600022190748
Author: Purushottam Sinha <[email protected]>
AuthorDate: Fri Oct 23 12:09:35 2026 +0530

    [FLINK-40977][state/forst] Complete JUnit 5 migration of 
flink-statebackend-forst (#29535)
    
    * [FLINK-40977][state/forst] Complete JUnit 5 migration of 
flink-statebackend-forst
    
    Replace the remaining JUnit 4 usages: the TemporaryFolder rule in
    ForStExtension, org.junit.Assert and TestLogger in the ForSt tests.
    Also drop the @Timeout on testCleanRelocatedDbLogs, which only became
    active after the migration.
    
    Use FileUtils.deleteDirectoryQuietly in ForStExtension
    
    Generated-by: Claude Code (Sonnet 5.5)
---
 .../apache/flink/state/forst/ForStExtension.java    | 12 ++++++------
 .../state/forst/ForStStateBackendConfigTest.java    |  2 --
 .../flink/state/forst/ForStStateMigrationTest.java  |  2 +-
 .../datatransfer/ForStStateDataTransferTest.java    | 21 ++++++++-------------
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStExtension.java
 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStExtension.java
index 99b4c5c68b5..bd46ea08d95 100644
--- 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStExtension.java
+++ 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStExtension.java
@@ -21,6 +21,7 @@ package org.apache.flink.state.forst;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.core.fs.Path;
 import org.apache.flink.testutils.junit.utils.TempDirUtils;
+import org.apache.flink.util.FileUtils;
 import org.apache.flink.util.FlinkRuntimeException;
 import org.apache.flink.util.IOUtils;
 import org.apache.flink.util.ResourceGuard;
@@ -36,13 +37,13 @@ import org.forstdb.WriteOptions;
 import org.junit.jupiter.api.extension.AfterEachCallback;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nonnull;
 
 import java.io.File;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -58,7 +59,7 @@ public class ForStExtension implements BeforeEachCallback, 
AfterEachCallback {
     private final boolean enableStatistics;
 
     /** Temporary folder that provides the working directory for the ForSt 
instance. */
-    private TemporaryFolder temporaryFolder;
+    private java.nio.file.Path temporaryFolder;
 
     /** The options for the ForSt instance. */
     private DBOptions dbOptions;
@@ -157,10 +158,9 @@ public class ForStExtension implements BeforeEachCallback, 
AfterEachCallback {
     }
 
     public void before() throws Exception {
-        this.temporaryFolder = new TemporaryFolder();
-        this.temporaryFolder.create();
+        this.temporaryFolder = Files.createTempDirectory("forst-extension");
 
-        final File rocksFolder = temporaryFolder.newFolder();
+        final File rocksFolder = TempDirUtils.newFolder(temporaryFolder);
 
         resourceGuard = new ResourceGuard();
         File localWorkingDir = TempDirUtils.newFolder(rocksFolder.toPath(), 
"local-working-dir");
@@ -216,7 +216,7 @@ public class ForStExtension implements BeforeEachCallback, 
AfterEachCallback {
         IOUtils.closeQuietly(this.db);
         IOUtils.closeQuietly(this.resourceContainer);
         IOUtils.closeQuietly(this.resourceGuard);
-        temporaryFolder.delete();
+        FileUtils.deleteDirectoryQuietly(temporaryFolder.toFile());
     }
 
     @Override
diff --git 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateBackendConfigTest.java
 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateBackendConfigTest.java
index ce0df3d38b4..7287e7edc85 100644
--- 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateBackendConfigTest.java
+++ 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateBackendConfigTest.java
@@ -56,7 +56,6 @@ import org.forstdb.FlushOptions;
 import org.forstdb.InfoLogLevel;
 import org.forstdb.util.SizeUnit;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
 import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
@@ -271,7 +270,6 @@ class ForStStateBackendConfigTest {
     }
 
     @Test
-    @Timeout(value = 60)
     void testCleanRelocatedDbLogs() throws Exception {
         final File folder = TempDirUtils.newFolder(tempFolder);
         final File relocatedDBLogDir = TempDirUtils.newFolder(tempFolder, 
"db_logs");
diff --git 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateMigrationTest.java
 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateMigrationTest.java
index aef6116a804..ad95287bfec 100644
--- 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateMigrationTest.java
+++ 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/ForStStateMigrationTest.java
@@ -49,7 +49,7 @@ import java.util.concurrent.RunnableFuture;
 
 import static 
org.apache.flink.state.forst.ForStTestUtils.createKeyedStateBackend;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.fail;
 
 /** Tests for the State Migration of {@link ForStKeyedStateBackend}. */
 public class ForStStateMigrationTest extends ForStStateTestBase {
diff --git 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/datatransfer/ForStStateDataTransferTest.java
 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/datatransfer/ForStStateDataTransferTest.java
index 3b161ad1384..707acdad8dd 100644
--- 
a/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/datatransfer/ForStStateDataTransferTest.java
+++ 
b/flink-state-backends/flink-statebackend-forst/src/test/java/org/apache/flink/state/forst/datatransfer/ForStStateDataTransferTest.java
@@ -40,9 +40,7 @@ import org.apache.flink.state.forst.StateHandleTransferSpec;
 import org.apache.flink.testutils.junit.utils.TempDirUtils;
 import org.apache.flink.util.IOUtils;
 import org.apache.flink.util.Preconditions;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
@@ -62,13 +60,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.fail;
 
 /** Test class for {@link ForStStateDataTransfer}. */
-class ForStStateDataTransferTest extends TestLogger {
+class ForStStateDataTransferTest {
 
     @TempDir private java.nio.file.Path temporaryFolder;
 
@@ -483,9 +478,9 @@ class ForStStateDataTransferTest extends TestLogger {
                                     pathContainer.getRemoteForStPath())),
                     new CloseableRegistry(),
                     RecoveryClaimMode.DEFAULT);
-            fail();
+            fail("Exception is expected");
         } catch (Exception e) {
-            assertEquals(expectedCause, e.getCause());
+            assertThat(e.getCause()).isEqualTo(expectedCause);
         }
     }
 
@@ -517,7 +512,7 @@ class ForStStateDataTransferTest extends TestLogger {
             StateHandleTransferSpec transferRequest = transferRequests.get(i);
             Path dstPath = transferRequest.getTransferDestination();
 
-            assertTrue(dstPath.getFileSystem().exists(dstPath));
+            assertThat(dstPath.getFileSystem().exists(dstPath)).isTrue();
 
             for (int j = 0; j < numSubHandles; ++j) {
                 assertStateContentEqual(
@@ -565,15 +560,15 @@ class ForStStateDataTransferTest extends TestLogger {
         // Check that all transfer directories have been deleted
         for (StateHandleTransferSpec transferRequest : transferRequests) {
             Path dstPath = transferRequest.getTransferDestination();
-            assertFalse(dstPath.getFileSystem().exists(dstPath));
+            assertThat(dstPath.getFileSystem().exists(dstPath)).isFalse();
         }
         // The passed in closable registry should not be closed by us on 
failure.
-        assertFalse(closeableRegistry.isClosed());
+        assertThat(closeableRegistry.isClosed()).isFalse();
     }
 
     private void assertStateContentEqual(byte[] expected, Path path) throws 
IOException {
         byte[] actual = readHeadBytes(path, -1);
-        Assertions.assertEquals(expected.length, actual.length);
+        assertThat(actual).hasSameSizeAs(expected);
         assertThat(actual).isEqualTo(expected);
     }
 

Reply via email to