Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void prepare(Map<String, Object> conf, String overrideBase, NimbusInfo ni
try {
this.stormClusterState = ClusterUtils.mkStormClusterState(conf, new ClusterStateContext(DaemonType.NIMBUS, conf));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed to initialize cluster state for LocalFsBlobStore", e);
}
timer = new Timer("BLOB-STORE-TIMER", true);
this.leaderElector = leaderElector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;
Expand All @@ -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
Expand All @@ -55,13 +57,15 @@ public static void initializeConfigs() {
}

@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() {
Expand All @@ -70,6 +74,7 @@ private LocalFsBlobStore initLocalFs() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
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;
Expand Down Expand Up @@ -791,18 +792,21 @@ public void testFailAcls() {
}

@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
Expand Down