|
102 | 102 | import static org.mockito.ArgumentMatchers.anyInt; |
103 | 103 | import static org.mockito.ArgumentMatchers.anyLong; |
104 | 104 | import static org.mockito.ArgumentMatchers.anyString; |
| 105 | +import static org.mockito.ArgumentMatchers.eq; |
| 106 | +import static org.mockito.ArgumentMatchers.longThat; |
105 | 107 | import static org.mockito.Mockito.any; |
106 | 108 | import static org.mockito.Mockito.doAnswer; |
107 | 109 | import static org.mockito.Mockito.mock; |
@@ -498,9 +500,6 @@ public void testIndexingPressure() throws Exception { |
498 | 500 | final InstrumentedIndexingPressure indexingPressure = new InstrumentedIndexingPressure(Settings.EMPTY); |
499 | 501 | final StaticModel sparseModel = StaticModel.createRandomInstance(TaskType.SPARSE_EMBEDDING); |
500 | 502 | final StaticModel denseModel = StaticModel.createRandomInstance(TaskType.TEXT_EMBEDDING); |
501 | | - final int denseModelEmbeddingBytes = denseModel.getServiceSettings() |
502 | | - .elementType() |
503 | | - .getNumBytes(denseModel.getServiceSettings().dimensions()); |
504 | 503 | final Function<XContentBuilder, Long> bytesUsed = b -> BytesReference.bytes(b).ramBytesUsed(); |
505 | 504 | final ShardBulkInferenceActionFilter filter = createFilter( |
506 | 505 | threadPool, |
@@ -554,14 +553,20 @@ public void testIndexingPressure() throws Exception { |
554 | 553 |
|
555 | 554 | IndexingPressure.Coordinating coordinatingIndexingPressure = indexingPressure.getCoordinating(); |
556 | 555 | assertThat(coordinatingIndexingPressure, notNullValue()); |
557 | | - verify(coordinatingIndexingPressure).increment(1, 128 + bytesUsed.apply(doc0Source)); |
558 | | - verify(coordinatingIndexingPressure).increment(1, denseModelEmbeddingBytes + bytesUsed.apply(doc1Source)); |
559 | | - verify(coordinatingIndexingPressure).increment(1, 128 + denseModelEmbeddingBytes + bytesUsed.apply(doc2Source)); |
560 | | - verify(coordinatingIndexingPressure).increment(1, denseModelEmbeddingBytes * 2L + bytesUsed.apply(doc3Source)); |
561 | | - verify(coordinatingIndexingPressure).increment(1, 128 + bytesUsed.apply(doc0UpdateSource)); |
| 556 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc0Source)); |
| 557 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc1Source)); |
| 558 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc2Source)); |
| 559 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc3Source)); |
| 560 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc4Source)); |
| 561 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc0UpdateSource)); |
| 562 | + if (useLegacyFormat == false) { |
| 563 | + verify(coordinatingIndexingPressure).increment(1, bytesUsed.apply(doc1UpdateSource)); |
| 564 | + } |
| 565 | + |
| 566 | + verify(coordinatingIndexingPressure, times(useLegacyFormat ? 6 : 7)).increment(eq(0), longThat(l -> l > 0)); |
562 | 567 |
|
563 | 568 | // Verify that the only times that increment is called are the times verified above |
564 | | - verify(coordinatingIndexingPressure, times(5)).increment(anyInt(), anyLong()); |
| 569 | + verify(coordinatingIndexingPressure, times(useLegacyFormat ? 12 : 14)).increment(anyInt(), anyLong()); |
565 | 570 |
|
566 | 571 | // Verify that the coordinating indexing pressure is maintained through downstream action filters |
567 | 572 | verify(coordinatingIndexingPressure, never()).close(); |
|
0 commit comments