Skip to content

Commit

Permalink
Disable feature flag for streams
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhmaurya committed Jan 4, 2025
1 parent 7c896c7 commit ac7b12f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
import org.opensearch.arrow.flight.bootstrap.FlightService;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.FeatureFlagSetter;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.junit.BeforeClass;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -27,6 +30,11 @@ public class ArrowFlightServerIT extends OpenSearchIntegTestCase {

private FlightClientManager flightClientManager;

@BeforeClass
public static void setupFeatureFlags() {
FeatureFlagSetter.set(FeatureFlags.ARROW_STREAMS_SETTING.getKey());
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(FlightStreamPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.plugins.SecureTransportSettingsProvider;
import org.opensearch.test.FeatureFlagSetter;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.ExecutorBuilder;
import org.opensearch.threadpool.ThreadPool;
Expand All @@ -32,7 +33,6 @@

public class FlightStreamPluginTests extends OpenSearchTestCase {
private Settings settings;
private FlightStreamPlugin plugin;
private ClusterService clusterService;

@Override
Expand All @@ -45,12 +45,44 @@ public void setUp() throws Exception {
when(clusterService.state()).thenReturn(clusterState);
when(clusterState.nodes()).thenReturn(nodes);
when(nodes.getLocalNodeId()).thenReturn("test-node");
plugin = new FlightStreamPlugin(settings);
}

public void testPluginEnableAndDisable() throws IOException {
FeatureFlags.initializeFeatureFlags(settings);

Settings disabledSettings = Settings.builder()
.put("node.attr.transport.stream.port", "9880")
.put(ARROW_STREAMS_SETTING.getKey(), false)
.build();
FeatureFlags.initializeFeatureFlags(disabledSettings);
FlightStreamPlugin disabledPlugin = new FlightStreamPlugin(disabledSettings);

Collection<Object> disabledPluginComponents = disabledPlugin.createComponents(
null,
clusterService,
mock(ThreadPool.class),
null,
null,
null,
null,
null,
null,
null,
null
);

assertTrue(disabledPluginComponents.isEmpty());
assertNull(disabledPlugin.getStreamManager().get());
assertTrue(disabledPlugin.getExecutorBuilders(disabledSettings).isEmpty());
assertNotNull(disabledPlugin.getSettings());
assertTrue(disabledPlugin.getSettings().isEmpty());

assertNotNull(disabledPlugin.getSecureTransports(null, null, null, null, null, null, null, null));

disabledPlugin.close();

FeatureFlags.initializeFeatureFlags(settings);
FeatureFlagSetter.set(ARROW_STREAMS_SETTING.getKey());
FlightStreamPlugin plugin = new FlightStreamPlugin(settings);
Collection<Object> components = plugin.createComponents(
null,
clusterService,
Expand Down Expand Up @@ -83,38 +115,6 @@ public void testPluginEnableAndDisable() throws IOException {
assertFalse(settings.isEmpty());

assertNotNull(plugin.getSecureTransports(null, null, null, null, null, null, mock(SecureTransportSettingsProvider.class), null));

plugin.close();

Settings disabledSettings = Settings.builder()
.put("node.attr.transport.stream.port", "9880")
.put(ARROW_STREAMS_SETTING.getKey(), false)
.build();
FeatureFlags.initializeFeatureFlags(disabledSettings);
FlightStreamPlugin disabledPlugin = new FlightStreamPlugin(disabledSettings);

Collection<Object> disabledPluginComponents = disabledPlugin.createComponents(
null,
clusterService,
mock(ThreadPool.class),
null,
null,
null,
null,
null,
null,
null,
null
);

assertTrue(disabledPluginComponents.isEmpty());
assertNull(disabledPlugin.getStreamManager().get());
assertTrue(disabledPlugin.getExecutorBuilders(disabledSettings).isEmpty());
assertNotNull(disabledPlugin.getSettings());
assertTrue(disabledPlugin.getSettings().isEmpty());

assertNotNull(disabledPlugin.getSecureTransports(null, null, null, null, null, null, null, null));

disabledPlugin.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class FeatureFlags {
);

public static final String ARROW_STREAMS = "opensearch.experimental.feature.arrow.streams.enabled";
public static final Setting<Boolean> ARROW_STREAMS_SETTING = Setting.boolSetting(ARROW_STREAMS, true, Property.NodeScope);
public static final Setting<Boolean> ARROW_STREAMS_SETTING = Setting.boolSetting(ARROW_STREAMS, false, Property.NodeScope);

private static final List<Setting<Boolean>> ALL_FEATURE_FLAG_SETTINGS = List.of(
REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
Expand Down

0 comments on commit ac7b12f

Please sign in to comment.