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

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

commit 2e7280b7ba513b12475a1348b815b04d4ce8e221
Author: Julien Nioche <[email protected]>
AuthorDate: Tue Mar 3 08:26:57 2026 +0000

    Fix tests that relied on silent exception swallowing in 
LocalFsBlobStore.prepare()
    
    Both tests called prepare() without a reachable ZooKeeper, relying on the
    now-fixed silent catch to let prepare() succeed with a null 
stormClusterState.
    
    LocalFsBlobStoreSynchronizerTest: add InProcessZookeeper to 
@BeforeEach/@AfterEach
    and pass its port in the conf used by initLocalFs(), matching the pattern
    already established in LocalFsBlobStoreTest.
    
    AsyncLocalizerTest.testKeyNotFoundException: wrap the test body in a
    try-with-resources InProcessZookeeper and pass its port in the conf,
    so that prepare() can initialise cluster state successfully before
    getBlob() is called to exercise the KeyNotFoundException path.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../LocalFsBlobStoreSynchronizerTest.java          |  9 +++++--
 .../apache/storm/localizer/AsyncLocalizerTest.java | 28 ++++++++++++----------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git 
a/storm-server/src/test/java/org/apache/storm/blobstore/LocalFsBlobStoreSynchronizerTest.java
 
b/storm-server/src/test/java/org/apache/storm/blobstore/LocalFsBlobStoreSynchronizerTest.java
index 7ba65b41e..f1f947395 100644
--- 
a/storm-server/src/test/java/org/apache/storm/blobstore/LocalFsBlobStoreSynchronizerTest.java
+++ 
b/storm-server/src/test/java/org/apache/storm/blobstore/LocalFsBlobStoreSynchronizerTest.java
@@ -30,6 +30,7 @@ import 
org.apache.storm.shade.org.apache.curator.framework.CuratorFramework;
 import 
org.apache.storm.shade.org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.storm.shade.org.apache.curator.retry.ExponentialBackoffRetry;
 import org.apache.storm.utils.Utils;
+import org.apache.storm.testing.InProcessZookeeper;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
@@ -46,6 +47,7 @@ public class LocalFsBlobStoreSynchronizerTest {
     private static Map<String, Object> conf = new HashMap<>();
 
     private File baseFile;
+    private InProcessZookeeper zk;
 
     // Method which initializes nimbus admin
     @BeforeAll
@@ -55,13 +57,15 @@ public class LocalFsBlobStoreSynchronizerTest {
     }
 
     @BeforeEach
-    public void init() {
+    public void init() throws Exception {
         baseFile = new File("target/blob-store-test-" + UUID.randomUUID());
+        zk = new InProcessZookeeper();
     }
 
     @AfterEach
-    public void cleanUp() throws IOException {
+    public void cleanUp() throws Exception {
         FileUtils.deleteDirectory(baseFile);
+        zk.close();
     }
 
     private LocalFsBlobStore initLocalFs() {
@@ -70,6 +74,7 @@ public class LocalFsBlobStoreSynchronizerTest {
         conf.putAll(Utils.readStormConfig());
         conf.put(Config.STORM_LOCAL_DIR, baseFile.getAbsolutePath());
         conf.put(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN, 
"org.apache.storm.security.auth.DefaultPrincipalToLocal");
+        conf.put(Config.STORM_ZOOKEEPER_PORT, zk.getPort());
         store.prepare(conf, null, null, null);
         return store;
     }
diff --git 
a/storm-server/src/test/java/org/apache/storm/localizer/AsyncLocalizerTest.java 
b/storm-server/src/test/java/org/apache/storm/localizer/AsyncLocalizerTest.java
index 1fef27cc0..1c55c1c65 100644
--- 
a/storm-server/src/test/java/org/apache/storm/localizer/AsyncLocalizerTest.java
+++ 
b/storm-server/src/test/java/org/apache/storm/localizer/AsyncLocalizerTest.java
@@ -51,6 +51,7 @@ import org.apache.storm.generated.ReadableBlobMeta;
 import org.apache.storm.generated.SettableBlobMeta;
 import org.apache.storm.generated.StormTopology;
 import org.apache.storm.security.auth.DefaultPrincipalToLocal;
+import org.apache.storm.testing.InProcessZookeeper;
 import org.apache.storm.testing.TmpPath;
 import org.apache.storm.utils.ConfigUtils;
 import org.apache.storm.utils.ReflectionUtils;
@@ -791,18 +792,21 @@ public class AsyncLocalizerTest {
     }
 
     @Test
-    public void testKeyNotFoundException() {
-        assertThrows(KeyNotFoundException.class, () -> {
-            Map<String, Object> conf = Utils.readStormConfig();
-            String key1 = "key1";
-            conf.put(Config.STORM_LOCAL_DIR, "target");
-            LocalFsBlobStore bs = new LocalFsBlobStore();
-            LocalFsBlobStore spy = spy(bs);
-            Mockito.doReturn(true).when(spy).checkForBlobOrDownload(key1);
-            Mockito.doNothing().when(spy).checkForBlobUpdate(key1);
-            spy.prepare(conf, null, null, null);
-            spy.getBlob(key1, null);
-        });
+    public void testKeyNotFoundException() throws Exception {
+        try (InProcessZookeeper zk = new InProcessZookeeper()) {
+            assertThrows(KeyNotFoundException.class, () -> {
+                Map<String, Object> conf = Utils.readStormConfig();
+                String key1 = "key1";
+                conf.put(Config.STORM_LOCAL_DIR, "target");
+                conf.put(Config.STORM_ZOOKEEPER_PORT, zk.getPort());
+                LocalFsBlobStore bs = new LocalFsBlobStore();
+                LocalFsBlobStore spy = spy(bs);
+                Mockito.doReturn(true).when(spy).checkForBlobOrDownload(key1);
+                Mockito.doNothing().when(spy).checkForBlobUpdate(key1);
+                spy.prepare(conf, null, null, null);
+                spy.getBlob(key1, null);
+            });
+        }
     }
 
     @Test

Reply via email to