Skip to content

Commit

Permalink
Reduce number of MockNode constructors
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Jan 22, 2025
1 parent 49ec944 commit 4cf427c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ private Node startNode() throws NodeValidationException {
Node node = new MockNode(
settings,
Arrays.asList(MockNioTransportPlugin.class, MockHttpTransport.TestPlugin.class, InternalSettingsPlugin.class),
true
null,
true,
Collections.emptyMap()
);
node.start();
return node;
Expand Down
37 changes: 1 addition & 36 deletions test/framework/src/main/java/org/opensearch/node/MockNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ public class MockNode extends Node {

private final Collection<Class<? extends Plugin>> classpathPlugins;

public MockNode(
final Settings settings,
final Collection<Class<? extends Plugin>> classpathPlugins,
final boolean forbidPrivateIndexSettings
) {
this(settings, classpathPlugins, null, forbidPrivateIndexSettings);
}

public MockNode(
final Settings settings,
final Collection<Class<? extends Plugin>> classpathPlugins,
Expand All @@ -115,20 +107,6 @@ public MockNode(
);
}

public MockNode(
final Settings settings,
final Collection<Class<? extends Plugin>> classpathPlugins,
final Path configPath,
final boolean forbidPrivateIndexSettings
) {
this(
InternalSettingsPreparer.prepareEnvironment(settings, Collections.emptyMap(), configPath, () -> "mock_ node"),
classpathPlugins,
forbidPrivateIndexSettings,
Collections.emptyMap()
);
}

private MockNode(
final Environment environment,
final Collection<Class<? extends Plugin>> classpathPlugins,
Expand Down Expand Up @@ -160,20 +138,7 @@ private MockNode(
}

public MockNode(final Settings settings, final Collection<Class<? extends Plugin>> classpathPlugins) {
this(settings, classpathPlugins, true);
}

public MockNode(
final Settings settings,
final Collection<Class<? extends Plugin>> classpathPlugins,
final Map<Class<? extends Plugin>, Class<? extends Plugin>> extendedPlugins
) {
this(
InternalSettingsPreparer.prepareEnvironment(settings, Collections.emptyMap(), null, () -> "mock_ node"),
classpathPlugins,
true,
extendedPlugins
);
this(settings, classpathPlugins, null, true, Collections.emptyMap());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public ExternalTestCluster(
pluginClasses = new ArrayList<>(pluginClasses);
pluginClasses.add(MockHttpTransport.TestPlugin.class);
Settings clientSettings = clientSettingsBuilder.build();
MockNode node = new MockNode(clientSettings, pluginClasses, extendedPlugins);
MockNode node = new MockNode(clientSettings, pluginClasses, null, true, extendedPlugins);
Client client = clientWrapper.apply(node.client());
try {
node.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private Node newNode() {
plugins.add(MockScriptService.TestPlugin.class);

plugins.add(MockTelemetryPlugin.class);
Node node = new MockNode(settingsBuilder.build(), plugins, forbidPrivateIndexSettings());
Node node = new MockNode(settingsBuilder.build(), plugins, null, forbidPrivateIndexSettings(), Collections.emptyMap());
try {
node.start();
} catch (NodeValidationException e) {
Expand Down

0 comments on commit 4cf427c

Please sign in to comment.