|
76 | 76 | import org.opensearch.ml.common.output.model.ModelTensor; |
77 | 77 | import org.opensearch.ml.common.output.model.ModelTensorOutput; |
78 | 78 | import org.opensearch.ml.common.output.model.ModelTensors; |
| 79 | +import org.opensearch.ml.common.settings.MLFeatureEnabledSetting; |
79 | 80 | import org.opensearch.ml.common.spi.memory.Memory; |
80 | 81 | import org.opensearch.ml.common.spi.tools.Tool; |
81 | 82 | import org.opensearch.ml.engine.memory.ConversationIndexMemory; |
@@ -130,6 +131,9 @@ public class MLAgentExecutorTest { |
130 | 131 | private MLMemoryManager memoryManager; |
131 | 132 | private MLAgentExecutor mlAgentExecutor; |
132 | 133 |
|
| 134 | + @Mock |
| 135 | + private MLFeatureEnabledSetting mlFeatureEnabledSetting; |
| 136 | + |
133 | 137 | @Captor |
134 | 138 | private ArgumentCaptor<Output> objectCaptor; |
135 | 139 |
|
@@ -177,9 +181,26 @@ public void setup() { |
177 | 181 | when(this.clusterService.getClusterSettings()) |
178 | 182 | .thenReturn(new ClusterSettings(settings, Set.of(ML_COMMONS_MCP_CONNECTOR_ENABLED, ML_COMMONS_AGENTIC_SEARCH_ENABLED))); |
179 | 183 |
|
| 184 | + // Mock MLFeatureEnabledSetting |
| 185 | + when(mlFeatureEnabledSetting.isMultiTenancyEnabled()).thenReturn(false); |
| 186 | + when(mlFeatureEnabledSetting.isMcpConnectorEnabled()).thenReturn(true); |
| 187 | + when(mlFeatureEnabledSetting.isAgenticSearchEnabled()).thenReturn(true); |
| 188 | + |
180 | 189 | settings = Settings.builder().build(); |
181 | 190 | 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 | + ); |
183 | 204 |
|
184 | 205 | } |
185 | 206 |
|
@@ -816,8 +837,25 @@ public void test_query_planning_requires_agentic_search_enabled() throws IOExcep |
816 | 837 | GetResponse agentGetResponse = new GetResponse(getResult); |
817 | 838 |
|
818 | 839 | // 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 | + |
819 | 845 | 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 | + ); |
821 | 859 |
|
822 | 860 | // Mock the agent get response |
823 | 861 | Mockito.doAnswer(invocation -> { |
|
0 commit comments