|
9 | 9 | package org.opensearch.indices.pollingingest;
|
10 | 10 |
|
11 | 11 | import org.opensearch.action.DocWriteRequest;
|
| 12 | +import org.opensearch.index.IngestionShardPointer; |
12 | 13 | import org.opensearch.index.Message;
|
13 | 14 | import org.opensearch.index.engine.Engine;
|
14 | 15 | import org.opensearch.index.engine.FakeIngestionSource;
|
|
23 | 24 |
|
24 | 25 | import java.io.IOException;
|
25 | 26 | import java.nio.charset.StandardCharsets;
|
| 27 | +import java.util.Collections; |
26 | 28 | import java.util.concurrent.ArrayBlockingQueue;
|
27 | 29 | import java.util.concurrent.TimeUnit;
|
28 | 30 |
|
@@ -240,29 +242,28 @@ public void testMessageRetrySuccess() throws Exception {
|
240 | 242 | thread.interrupt();
|
241 | 243 | }
|
242 | 244 |
|
243 |
| - public void testMessageRetryFail() throws Exception { |
| 245 | + public void testDropPolicyMessageRetryFail() throws Exception { |
244 | 246 | MessageProcessorRunnable.MessageProcessor processor = mock(MessageProcessorRunnable.MessageProcessor.class);
|
245 | 247 | DropIngestionErrorStrategy errorStrategy = new DropIngestionErrorStrategy("ingestion_source");
|
246 | 248 | MessageProcessorRunnable messageProcessorRunnable = new MessageProcessorRunnable(
|
247 | 249 | new ArrayBlockingQueue<>(5),
|
248 | 250 | processor,
|
249 | 251 | errorStrategy
|
250 | 252 | );
|
251 |
| - messageProcessorRunnable.getBlockingQueue().put(new ShardUpdateMessage(null, null, null, 0)); |
| 253 | + messageProcessorRunnable.getBlockingQueue() |
| 254 | + .put(new ShardUpdateMessage(mock(IngestionShardPointer.class), null, Collections.emptyMap(), 0)); |
| 255 | + messageProcessorRunnable.getBlockingQueue() |
| 256 | + .put(new ShardUpdateMessage(mock(IngestionShardPointer.class), null, Collections.emptyMap(), -1)); |
252 | 257 |
|
253 |
| - doThrow(new RuntimeException()).doThrow(new RuntimeException()) |
254 |
| - .doThrow(new RuntimeException()) |
255 |
| - .doNothing() |
256 |
| - .when(processor) |
257 |
| - .process(any(), any()); |
| 258 | + doThrow(new RuntimeException()).when(processor).process(any(), any()); |
258 | 259 |
|
259 | 260 | Thread thread = new Thread(messageProcessorRunnable::run);
|
260 | 261 | thread.start();
|
261 | 262 | assertBusy(() -> {
|
262 |
| - verify(processor, times(3)).process(any(), any()); |
263 |
| - assertEquals(1, messageProcessorRunnable.getMessageProcessorMetrics().failedMessageDroppedCounter().count()); |
264 |
| - assertEquals(3, messageProcessorRunnable.getMessageProcessorMetrics().failedMessageCounter().count()); |
265 |
| - }, 1, TimeUnit.MINUTES); |
| 263 | + verify(processor, times(6)).process(any(), any()); |
| 264 | + assertEquals(2, messageProcessorRunnable.getMessageProcessorMetrics().failedMessageDroppedCounter().count()); |
| 265 | + assertEquals(6, messageProcessorRunnable.getMessageProcessorMetrics().failedMessageCounter().count()); |
| 266 | + }, 2, TimeUnit.MINUTES); |
266 | 267 |
|
267 | 268 | messageProcessorRunnable.close();
|
268 | 269 | thread.interrupt();
|
|
0 commit comments