Skip to content

Commit 74d496e

Browse files
Fix failing tests
Signed-off-by: rithin-pullela-aws <rithinp@amazon.com>
1 parent 7cd8d62 commit 74d496e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutorTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import org.opensearch.ml.common.output.model.ModelTensor;
7777
import org.opensearch.ml.common.output.model.ModelTensorOutput;
7878
import org.opensearch.ml.common.output.model.ModelTensors;
79+
import org.opensearch.ml.common.settings.MLFeatureEnabledSetting;
7980
import org.opensearch.ml.common.spi.memory.Memory;
8081
import org.opensearch.ml.common.spi.tools.Tool;
8182
import org.opensearch.ml.engine.memory.ConversationIndexMemory;
@@ -130,6 +131,9 @@ public class MLAgentExecutorTest {
130131
private MLMemoryManager memoryManager;
131132
private MLAgentExecutor mlAgentExecutor;
132133

134+
@Mock
135+
private MLFeatureEnabledSetting mlFeatureEnabledSetting;
136+
133137
@Captor
134138
private ArgumentCaptor<Output> objectCaptor;
135139

@@ -177,9 +181,26 @@ public void setup() {
177181
when(this.clusterService.getClusterSettings())
178182
.thenReturn(new ClusterSettings(settings, Set.of(ML_COMMONS_MCP_CONNECTOR_ENABLED, ML_COMMONS_AGENTIC_SEARCH_ENABLED)));
179183

184+
// Mock MLFeatureEnabledSetting
185+
when(mlFeatureEnabledSetting.isMultiTenancyEnabled()).thenReturn(false);
186+
when(mlFeatureEnabledSetting.isMcpConnectorEnabled()).thenReturn(true);
187+
when(mlFeatureEnabledSetting.isAgenticSearchEnabled()).thenReturn(true);
188+
180189
settings = Settings.builder().build();
181190
mlAgentExecutor = Mockito
182-
.spy(new MLAgentExecutor(client, sdkClient, settings, clusterService, xContentRegistry, toolFactories, memoryMap, false, null));
191+
.spy(
192+
new MLAgentExecutor(
193+
client,
194+
sdkClient,
195+
settings,
196+
clusterService,
197+
xContentRegistry,
198+
toolFactories,
199+
memoryMap,
200+
mlFeatureEnabledSetting,
201+
null
202+
)
203+
);
183204

184205
}
185206

@@ -816,8 +837,25 @@ public void test_query_planning_requires_agentic_search_enabled() throws IOExcep
816837
GetResponse agentGetResponse = new GetResponse(getResult);
817838

818839
// Create a new MLAgentExecutor with agentic search disabled
840+
MLFeatureEnabledSetting disabledSearchSetting = Mockito.mock(MLFeatureEnabledSetting.class);
841+
when(disabledSearchSetting.isMultiTenancyEnabled()).thenReturn(false);
842+
when(disabledSearchSetting.isMcpConnectorEnabled()).thenReturn(true);
843+
when(disabledSearchSetting.isAgenticSearchEnabled()).thenReturn(false);
844+
819845
MLAgentExecutor mlAgentExecutorWithDisabledSearch = Mockito
820-
.spy(new MLAgentExecutor(client, sdkClient, settings, clusterService, xContentRegistry, toolFactories, memoryMap, false, null));
846+
.spy(
847+
new MLAgentExecutor(
848+
client,
849+
sdkClient,
850+
settings,
851+
clusterService,
852+
xContentRegistry,
853+
toolFactories,
854+
memoryMap,
855+
disabledSearchSetting,
856+
null
857+
)
858+
);
821859

822860
// Mock the agent get response
823861
Mockito.doAnswer(invocation -> {

0 commit comments

Comments
 (0)