Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in TextImageEmbeddingProcessor integration tests #1093

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
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";
This conversation was marked as resolved.
Show resolved Hide resolved
private static final String FROM_INDEX_NAME = "test-reindex-from";
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 +48,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 @@ -65,20 +68,18 @@ private String uploadModel() throws Exception {

public void testEmbeddingProcessor_whenReindexingDocument_thenSuccessful() throws Exception {
// create a simple index and indexing data into this index.
String fromIndexName = "test-reindex-from";
createIndexWithConfiguration(fromIndexName, "{ \"settings\": { \"number_of_shards\": 1, \"number_of_replicas\": 0 } }", null);
ingestDocument(fromIndexName, "{ \"text\": \"hello world\" }");
createIndexWithConfiguration(FROM_INDEX_NAME, "{ \"settings\": { \"number_of_shards\": 1, \"number_of_replicas\": 0 } }", null);
ingestDocument(FROM_INDEX_NAME, "{ \"text\": \"hello world\" }");
String modelId = null;
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(FROM_INDEX_NAME, 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);
}
}
}
Loading