use of org.opensearch.ad.ml.ModelManager in project anomaly-detection by opensearch-project.
the class AnomalyResultTests method testInsufficientCapacityExceptionDuringColdStart.
@SuppressWarnings("unchecked")
public void testInsufficientCapacityExceptionDuringColdStart() {
ModelManager rcfManager = mock(ModelManager.class);
doThrow(ResourceNotFoundException.class).when(rcfManager).getTRcfResult(any(String.class), any(String.class), any(double[].class), any(ActionListener.class));
when(stateManager.fetchExceptionAndClear(any(String.class))).thenReturn(Optional.of(new LimitExceededException(adID, CommonErrorMessages.MEMORY_LIMIT_EXCEEDED_ERR_MSG)));
// These constructors register handler in transport service
new RCFResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, rcfManager, adCircuitBreakerService, hashRing);
new ThresholdResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, normalModelManager);
AnomalyResultTransportAction action = new AnomalyResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, settings, client, stateManager, featureQuery, normalModelManager, hashRing, clusterService, indexNameResolver, adCircuitBreakerService, adStats, threadPool, NamedXContentRegistry.EMPTY, adTaskManager);
AnomalyResultRequest request = new AnomalyResultRequest(adID, 100, 200);
PlainActionFuture<AnomalyResultResponse> listener = new PlainActionFuture<>();
action.doExecute(null, request, listener);
assertException(listener, LimitExceededException.class);
}
use of org.opensearch.ad.ml.ModelManager in project anomaly-detection by opensearch-project.
the class AnomalyResultTests method testInsufficientCapacityExceptionDuringRestoringModel.
@SuppressWarnings("unchecked")
public void testInsufficientCapacityExceptionDuringRestoringModel() {
ModelManager rcfManager = mock(ModelManager.class);
doThrow(new NotSerializableExceptionWrapper(new LimitExceededException(adID, CommonErrorMessages.MEMORY_LIMIT_EXCEEDED_ERR_MSG))).when(rcfManager).getTRcfResult(any(String.class), any(String.class), any(double[].class), any(ActionListener.class));
// These constructors register handler in transport service
new RCFResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, rcfManager, adCircuitBreakerService, hashRing);
new ThresholdResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, normalModelManager);
AnomalyResultTransportAction action = new AnomalyResultTransportAction(new ActionFilters(Collections.emptySet()), transportService, settings, client, stateManager, featureQuery, normalModelManager, hashRing, clusterService, indexNameResolver, adCircuitBreakerService, adStats, threadPool, NamedXContentRegistry.EMPTY, adTaskManager);
AnomalyResultRequest request = new AnomalyResultRequest(adID, 100, 200);
PlainActionFuture<AnomalyResultResponse> listener = new PlainActionFuture<>();
action.doExecute(null, request, listener);
assertException(listener, LimitExceededException.class);
}
use of org.opensearch.ad.ml.ModelManager in project anomaly-detection by opensearch-project.
the class CronTransportActionTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
ThreadPool threadPool = mock(ThreadPool.class);
ClusterService clusterService = mock(ClusterService.class);
localNodeID = "foo";
when(clusterService.localNode()).thenReturn(new DiscoveryNode(localNodeID, buildNewFakeTransportAddress(), Version.CURRENT));
when(clusterService.getClusterName()).thenReturn(new ClusterName("test"));
TransportService transportService = mock(TransportService.class);
ActionFilters actionFilters = mock(ActionFilters.class);
NodeStateManager tarnsportStatemanager = mock(NodeStateManager.class);
ModelManager modelManager = mock(ModelManager.class);
FeatureManager featureManager = mock(FeatureManager.class);
CacheProvider cacheProvider = mock(CacheProvider.class);
EntityCache entityCache = mock(EntityCache.class);
EntityColdStarter entityColdStarter = mock(EntityColdStarter.class);
when(cacheProvider.get()).thenReturn(entityCache);
ADTaskManager adTaskManager = mock(ADTaskManager.class);
action = new CronTransportAction(threadPool, clusterService, transportService, actionFilters, tarnsportStatemanager, modelManager, featureManager, cacheProvider, entityColdStarter, adTaskManager);
}
Aggregations