|
9 | 9 | import java.net.URL;
|
10 | 10 | import java.nio.file.Files;
|
11 | 11 | import java.nio.file.Path;
|
| 12 | +import java.util.ArrayList; |
12 | 13 | import java.util.Collections;
|
13 | 14 | import java.util.HashMap;
|
14 | 15 | import java.util.List;
|
|
31 | 32 |
|
32 | 33 | import com.google.common.collect.ImmutableList;
|
33 | 34 | import org.opensearch.neuralsearch.query.NeuralQueryBuilder;
|
| 35 | +import org.opensearch.neuralsearch.stats.events.EventStatName; |
| 36 | +import org.opensearch.neuralsearch.stats.info.InfoStatName; |
34 | 37 |
|
35 | 38 | public class TextEmbeddingProcessorIT extends BaseNeuralSearchIT {
|
36 | 39 |
|
@@ -478,4 +481,53 @@ public void testTextEmbeddingProcessorWithReindexOperation() throws Exception {
|
478 | 481 | reindex(fromIndexName, toIndexName);
|
479 | 482 | assertEquals(1, getDocCount(toIndexName));
|
480 | 483 | }
|
| 484 | + |
| 485 | + public void testTextEmbeddingProcessor_processorStats_successful() throws Exception { |
| 486 | + updateClusterSettings("plugins.neural_search.stats_enabled", true); |
| 487 | + String modelId = uploadTextEmbeddingModel(); |
| 488 | + loadModel(modelId); |
| 489 | + createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_EMBEDDING_WITH_SKIP_EXISTING); |
| 490 | + createIndexWithPipeline(INDEX_NAME, "IndexMappings.json", PIPELINE_NAME); |
| 491 | + ingestDocument(INDEX_NAME, INGEST_DOC1, "1"); |
| 492 | + updateDocument(INDEX_NAME, UPDATE_DOC1, "1"); |
| 493 | + assertEquals(1, getDocCount(INDEX_NAME)); |
| 494 | + assertEquals(2, getDocById(INDEX_NAME, "1").get("_version")); |
| 495 | + // Get stats |
| 496 | + String responseBody = executeNeuralStatRequest(new ArrayList<>(), new ArrayList<>()); |
| 497 | + Map<String, Object> stats = parseInfoStatsResponse(responseBody); |
| 498 | + Map<String, Object> allNodesStats = parseAggregatedNodeStatsResponse(responseBody); |
| 499 | + |
| 500 | + // Parse json to get stats |
| 501 | + assertEquals(2, getNestedValue(allNodesStats, EventStatName.TEXT_EMBEDDING_PROCESSOR_EXECUTIONS)); |
| 502 | + assertEquals(2, getNestedValue(allNodesStats, EventStatName.TEXT_EMBEDDING_PROCESSOR_SKIP_EXISTING_EXECUTIONS)); |
| 503 | + |
| 504 | + assertEquals(1, getNestedValue(stats, InfoStatName.TEXT_EMBEDDING_PROCESSORS)); |
| 505 | + assertEquals(1, getNestedValue(stats, InfoStatName.TEXT_EMBEDDING_SKIP_EXISTING_PROCESSORS)); |
| 506 | + // Reset stats |
| 507 | + updateClusterSettings("plugins.neural_search.stats_enabled", false); |
| 508 | + } |
| 509 | + |
| 510 | + public void testTextEmbeddingProcessor_batch__processorStats_successful() throws Exception { |
| 511 | + updateClusterSettings("plugins.neural_search.stats_enabled", true); |
| 512 | + String modelId = uploadTextEmbeddingModel(); |
| 513 | + loadModel(modelId); |
| 514 | + createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_EMBEDDING_WITH_SKIP_EXISTING); |
| 515 | + createIndexWithPipeline(INDEX_NAME, "IndexMappings.json", PIPELINE_NAME); |
| 516 | + ingestBatchDocumentWithBulk("batch_", 2, Collections.emptySet(), Collections.emptySet(), List.of(INGEST_DOC1, INGEST_DOC2)); |
| 517 | + assertEquals(2, getDocCount(INDEX_NAME)); |
| 518 | + |
| 519 | + // Get stats |
| 520 | + String responseBody = executeNeuralStatRequest(new ArrayList<>(), new ArrayList<>()); |
| 521 | + Map<String, Object> stats = parseInfoStatsResponse(responseBody); |
| 522 | + Map<String, Object> allNodesStats = parseAggregatedNodeStatsResponse(responseBody); |
| 523 | + |
| 524 | + // Parse json to get stats |
| 525 | + assertEquals(2, getNestedValue(allNodesStats, EventStatName.TEXT_EMBEDDING_PROCESSOR_EXECUTIONS)); |
| 526 | + assertEquals(2, getNestedValue(allNodesStats, EventStatName.TEXT_EMBEDDING_PROCESSOR_SKIP_EXISTING_EXECUTIONS)); |
| 527 | + |
| 528 | + assertEquals(1, getNestedValue(stats, InfoStatName.TEXT_EMBEDDING_PROCESSORS)); |
| 529 | + assertEquals(1, getNestedValue(stats, InfoStatName.TEXT_EMBEDDING_SKIP_EXISTING_PROCESSORS)); |
| 530 | + updateClusterSettings("plugins.neural_search.stats_enabled", false); |
| 531 | + } |
| 532 | + |
481 | 533 | }
|
0 commit comments