Skip to content

Commit

Permalink
Fix race condition in TextImageEmbeddingProcessor integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Qin <“[email protected]”>
  • Loading branch information
Andy Qin committed Jan 14, 2025
1 parent b084838 commit 6076d70
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*/
public class TextImageEmbeddingProcessorIT extends BaseNeuralSearchIT {

private static final String INDEX_NAME = "text_image_embedding_index";
private static final String PIPELINE_NAME = "ingest-pipeline";
private static final String INDEX_NAME_1 = "text_image_embedding_index-1";
private static final String INDEX_NAME_2 = "text_image_embedding_index-2";
private static final String PIPELINE_NAME_1 = "text_image_embedding_ingest_pipeline-1";
private static final String PIPELINE_NAME_2 = "text_image_embedding_ingest_pipeline-2";
private static final String INGEST_DOCUMENT = "{\n"
+ " \"title\": \"This is a good day\",\n"
+ " \"description\": \"daily logging\",\n"
Expand Down Expand Up @@ -45,16 +47,16 @@ public void testEmbeddingProcessor_whenIngestingDocumentWithOrWithoutSourceMatch
try {
modelId = uploadModel();
loadModel(modelId);
createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_IMAGE_EMBEDDING);
createIndexWithPipeline(INDEX_NAME, "IndexMappings.json", PIPELINE_NAME);
createPipelineProcessor(modelId, PIPELINE_NAME_1, ProcessorType.TEXT_IMAGE_EMBEDDING);
createIndexWithPipeline(INDEX_NAME_1, "IndexMappings.json", PIPELINE_NAME_1);
// verify doc with mapping
ingestDocument(INDEX_NAME, INGEST_DOCUMENT);
assertEquals(1, getDocCount(INDEX_NAME));
ingestDocument(INDEX_NAME_1, INGEST_DOCUMENT);
assertEquals(1, getDocCount(INDEX_NAME_1));
// verify doc without mapping
ingestDocument(INDEX_NAME, INGEST_DOCUMENT_UNMAPPED_FIELDS);
assertEquals(2, getDocCount(INDEX_NAME));
ingestDocument(INDEX_NAME_1, INGEST_DOCUMENT_UNMAPPED_FIELDS);
assertEquals(2, getDocCount(INDEX_NAME_1));
} finally {
wipeOfTestResources(INDEX_NAME, PIPELINE_NAME, modelId, null);
wipeOfTestResources(INDEX_NAME_1, PIPELINE_NAME_1, modelId, null);
}
}

Expand All @@ -72,13 +74,12 @@ public void testEmbeddingProcessor_whenReindexingDocument_thenSuccessful() throw
try {
modelId = uploadModel();
loadModel(modelId);
String toIndexName = "test-reindex-to";
createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_IMAGE_EMBEDDING);
createIndexWithPipeline(toIndexName, "IndexMappings.json", PIPELINE_NAME);
reindex(fromIndexName, toIndexName);
assertEquals(1, getDocCount(toIndexName));
createPipelineProcessor(modelId, PIPELINE_NAME_2, ProcessorType.TEXT_IMAGE_EMBEDDING);
createIndexWithPipeline(INDEX_NAME_2, "IndexMappings.json", PIPELINE_NAME_2);
reindex(fromIndexName, INDEX_NAME_2);
assertEquals(1, getDocCount(INDEX_NAME_2));
} finally {
wipeOfTestResources(fromIndexName, PIPELINE_NAME, modelId, null);
wipeOfTestResources(INDEX_NAME_2, PIPELINE_NAME_2, modelId, null);
}
}
}

0 comments on commit 6076d70

Please sign in to comment.