Skip to content

Commit 009a345

Browse files
authored
fix ignoreFailure flag (opensearch-project#3564)
Signed-off-by: Mingshi Liu <[email protected]>
1 parent 62ce55b commit 009a345

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

plugin/src/main/java/org/opensearch/ml/processor/MLInferenceSearchRequestProcessor.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,6 @@ public MLInferenceSearchRequestProcessor create(
597597
boolean fullResponsePath = ConfigurationUtils
598598
.readBooleanProperty(TYPE, processorTag, config, FULL_RESPONSE_PATH, defaultFullResponsePath);
599599

600-
ignoreFailure = ConfigurationUtils
601-
.readBooleanProperty(TYPE, processorTag, config, ConfigurationUtils.IGNORE_FAILURE_KEY, false);
602-
603600
// convert model config user input data structure to Map<String, String>
604601
Map<String, String> modelConfigMaps = null;
605602
if (modelConfigInput != null) {

plugin/src/main/java/org/opensearch/ml/processor/MLInferenceSearchResponseProcessor.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,6 @@ public MLInferenceSearchResponseProcessor create(
840840
boolean fullResponsePath = ConfigurationUtils
841841
.readBooleanProperty(TYPE, processorTag, config, FULL_RESPONSE_PATH, defaultFullResponsePath);
842842

843-
ignoreFailure = ConfigurationUtils
844-
.readBooleanProperty(TYPE, processorTag, config, ConfigurationUtils.IGNORE_FAILURE_KEY, false);
845-
846843
// convert model config user input data structure to Map<String, String>
847844
Map<String, String> modelConfigMaps = null;
848845
if (modelConfigInput != null) {

plugin/src/test/java/org/opensearch/ml/processor/MLInferenceSearchRequestProcessorTests.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public void onFailure(Exception ex) {
706706
};
707707

708708
requestProcessor.processRequestAsync(request, requestContext, listener);
709-
709+
assertEquals(requestProcessor.isIgnoreFailure(), true);
710710
}
711711

712712
/**
@@ -749,7 +749,7 @@ public void onFailure(Exception ex) {
749749
};
750750

751751
requestProcessor.processRequestAsync(request, requestContext, Listener);
752-
752+
assertEquals(requestProcessor.isIgnoreFailure(), false);
753753
}
754754

755755
/**
@@ -788,7 +788,7 @@ public void onFailure(Exception ex) {
788788
};
789789

790790
requestProcessor.processRequestAsync(request, requestContext, Listener);
791-
791+
assertEquals(requestProcessor.isIgnoreFailure(), true);
792792
}
793793

794794
/**
@@ -851,7 +851,7 @@ public void onFailure(Exception e) {
851851
};
852852

853853
requestProcessor.processRequestAsync(request, requestContext, Listener);
854-
854+
assertEquals(requestProcessor.isIgnoreFailure(), false);
855855
}
856856

857857
/**
@@ -998,7 +998,7 @@ public void onFailure(Exception ex) {
998998
}
999999
};
10001000
requestProcessor.processRequestAsync(request, requestContext, Listener);
1001-
1001+
assertEquals(requestProcessor.isIgnoreFailure(), true);
10021002
}
10031003

10041004
/**
@@ -1444,6 +1444,7 @@ public void testCreateRequiredFields() throws Exception {
14441444
assertNotNull(MLInferenceSearchRequestProcessor);
14451445
assertEquals(MLInferenceSearchRequestProcessor.getTag(), processorTag);
14461446
assertEquals(MLInferenceSearchRequestProcessor.getType(), MLInferenceSearchRequestProcessor.TYPE);
1447+
assertEquals(MLInferenceSearchRequestProcessor.isIgnoreFailure(), false);
14471448
}
14481449

14491450
/**
@@ -1478,6 +1479,7 @@ public void testCreateLocalModelProcessor() throws Exception {
14781479
assertNotNull(MLInferenceSearchRequestProcessor);
14791480
assertEquals(MLInferenceSearchRequestProcessor.getTag(), processorTag);
14801481
assertEquals(MLInferenceSearchRequestProcessor.getType(), MLInferenceSearchRequestProcessor.TYPE);
1482+
assertEquals(MLInferenceSearchRequestProcessor.isIgnoreFailure(), false);
14811483
}
14821484

14831485
/**
@@ -1675,9 +1677,11 @@ public void testCreateOptionalFields() throws Exception {
16751677
String processorTag = randomAlphaOfLength(10);
16761678

16771679
MLInferenceSearchRequestProcessor MLInferenceSearchRequestProcessor = factory
1678-
.create(Collections.emptyMap(), processorTag, null, false, config, null);
1680+
.create(Collections.emptyMap(), processorTag, "test", true, config, null);
16791681
assertNotNull(MLInferenceSearchRequestProcessor);
16801682
assertEquals(MLInferenceSearchRequestProcessor.getTag(), processorTag);
16811683
assertEquals(MLInferenceSearchRequestProcessor.getType(), MLInferenceSearchRequestProcessor.TYPE);
1684+
assertEquals(MLInferenceSearchRequestProcessor.isIgnoreFailure(), true);
1685+
assertEquals(MLInferenceSearchRequestProcessor.getDescription(), "test");
16821686
}
16831687
}

plugin/src/test/java/org/opensearch/ml/processor/MLInferenceSearchResponseProcessorTests.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,7 @@ public void onFailure(Exception e) {
14491449
};
14501450
responseProcessor.processResponseAsync(request, response, responseContext, listener);
14511451
verify(client, times(1)).execute(any(), any(), any());
1452+
assertEquals(responseProcessor.isIgnoreFailure(), true);
14521453
}
14531454

14541455
/**
@@ -1540,6 +1541,7 @@ public void onFailure(Exception e) {
15401541
};
15411542
responseProcessor.processResponseAsync(request, mockResponse, responseContext, listener);
15421543
verify(client, times(1)).execute(any(), any(), any());
1544+
assertEquals(responseProcessor.isIgnoreFailure(), true);
15431545
}
15441546

15451547
/**
@@ -1923,6 +1925,7 @@ public void onFailure(Exception e) {
19231925
};
19241926
responseProcessor.processResponseAsync(request, response, responseContext, listener);
19251927
verify(client, times(1)).execute(any(), any(), any());
1928+
assertEquals(responseProcessor.isIgnoreFailure(), true);
19261929
}
19271930

19281931
/**
@@ -2104,6 +2107,7 @@ public void onFailure(Exception e) {
21042107
};
21052108
responseProcessor.processResponseAsync(request, response, responseContext, listener);
21062109
verify(client, times(5)).execute(any(), any(), any());
2110+
assertEquals(responseProcessor.isIgnoreFailure(), true);
21072111
}
21082112

21092113
/**
@@ -2542,6 +2546,7 @@ public void onFailure(Exception e) {
25422546
};
25432547
responseProcessor.processResponseAsync(request, response, responseContext, listener);
25442548
verify(client, times(0)).execute(any(), any(), any());
2549+
assertEquals(responseProcessor.isIgnoreFailure(), true);
25452550
}
25462551

25472552
/**
@@ -3466,6 +3471,7 @@ public void onFailure(Exception e) {
34663471
};
34673472

34683473
responseProcessor.processResponseAsync(request, response, responseContext, listener);
3474+
assertEquals(responseProcessor.isIgnoreFailure(), true);
34693475
}
34703476

34713477
/**
@@ -3691,6 +3697,7 @@ public void onFailure(Exception e) {
36913697
when(mockResponse.getAggregations()).thenThrow(mockException);
36923698

36933699
responseProcessor.processResponseAsync(request, mockResponse, responseContext, listener);
3700+
assertEquals(responseProcessor.isIgnoreFailure(), true);
36943701
}
36953702

36963703
/**
@@ -4310,6 +4317,7 @@ public void testCreateRequiredFields() throws Exception {
43104317
assertNotNull(MLInferenceSearchResponseProcessor);
43114318
assertEquals(MLInferenceSearchResponseProcessor.getTag(), processorTag);
43124319
assertEquals(MLInferenceSearchResponseProcessor.getType(), MLInferenceSearchResponseProcessor.TYPE);
4320+
assertEquals(MLInferenceSearchResponseProcessor.isIgnoreFailure(), false);
43134321
}
43144322

43154323
/**
@@ -4343,6 +4351,7 @@ public void testCreateLocalModelProcessor() throws Exception {
43434351
assertNotNull(MLInferenceSearchResponseProcessor);
43444352
assertEquals(MLInferenceSearchResponseProcessor.getTag(), processorTag);
43454353
assertEquals(MLInferenceSearchResponseProcessor.getType(), MLInferenceSearchResponseProcessor.TYPE);
4354+
assertEquals(MLInferenceSearchResponseProcessor.isIgnoreFailure(), false);
43464355
}
43474356

43484357
/**
@@ -4501,10 +4510,12 @@ public void testCreateOptionalFields() throws Exception {
45014510
String processorTag = randomAlphaOfLength(10);
45024511

45034512
MLInferenceSearchResponseProcessor MLInferenceSearchResponseProcessor = factory
4504-
.create(Collections.emptyMap(), processorTag, null, false, config, null);
4513+
.create(Collections.emptyMap(), processorTag, "test", true, config, null);
45054514
assertNotNull(MLInferenceSearchResponseProcessor);
45064515
assertEquals(MLInferenceSearchResponseProcessor.getTag(), processorTag);
45074516
assertEquals(MLInferenceSearchResponseProcessor.getType(), MLInferenceSearchResponseProcessor.TYPE);
4517+
assertEquals(MLInferenceSearchResponseProcessor.isIgnoreFailure(), true);
4518+
assertEquals(MLInferenceSearchResponseProcessor.getDescription(), "test");
45084519
}
45094520

45104521
/**

0 commit comments

Comments
 (0)