From 0c8ce3ac5c3032ea04d116f7a6680be83bcaf439 Mon Sep 17 00:00:00 2001 From: bfindlay Date: Mon, 27 Nov 2023 19:51:21 +1100 Subject: [PATCH] fix pipeline failure Signed-off-by: bfindlay --- .../opensearch/integTest/AbstractTasksIT.java | 15 ++++++++++++--- .../integTest/OpenSearchJavaClientTestCase.java | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractTasksIT.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractTasksIT.java index 94b2dbb602..ddf14deabd 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractTasksIT.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractTasksIT.java @@ -8,26 +8,35 @@ public abstract class AbstractTasksIT extends OpenSearchJavaClientTestCase { @Test public void getTasks_waitForCompletionFalse_jsonDataStatusCanBeDeserialized() throws IOException, InterruptedException { - javaClient().indices().create(b -> b.index("test-index-a").settings(s -> s.refreshInterval(v -> v.time("1s")))); - javaClient().index(b -> b.index("test-index-a").id("a").document(new IndexData("test"))); + String indexName = "test_index_tasks_response"; + javaClient().indices().create(_1 -> _1.index(indexName)); + javaClient().index(b -> b.index(indexName).id("a").document(new IndexData("test"))); + // Ensure the document is indexed Thread.sleep(3000); final var deleteByQueryResponse = javaClient().deleteByQuery( - d -> d.index("test-index-a").query(q -> q.matchAll(m -> m.queryName("match-all"))).waitForCompletion(false) + d -> d.index(indexName) + .query(q -> q.match(m -> m.queryName("match").query(_q -> _q.stringValue("test")).field("title"))) + .waitForCompletion(false) ); Thread.sleep(3000); + // Create a task to be used to deserialize a task status from as the test subject final var tasksResponse = javaClient().tasks().get(t -> t.taskId(deleteByQueryResponse.task())); assertTrue(tasksResponse.completed()); // Deserialize the JsonData to a typed Status response + assertNotNull(tasksResponse.task().status()); final Status taskStatus = tasksResponse.task().status().to(Status.class); // Ensure the JsonData can be deserialized assertEquals(1, taskStatus.total()); assertEquals(1, taskStatus.deleted()); + assertEquals(0, taskStatus.created()); + assertEquals(0, taskStatus.noops()); + assertEquals(0, taskStatus.failures().size()); } public class IndexData { diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java index 6403569faa..a672b8762a 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/OpenSearchJavaClientTestCase.java @@ -45,7 +45,12 @@ import org.opensearch.test.rest.OpenSearchRestTestCase; public abstract class OpenSearchJavaClientTestCase extends OpenSearchRestTestCase implements OpenSearchTransportSupport { - private static final List systemIndices = List.of(".opensearch-observability", ".opendistro_security", ".plugins-ml-config"); + private static final List systemIndices = List.of( + ".opensearch-observability", + ".opendistro_security", + ".plugins-ml-config", + ".tasks" + ); private static OpenSearchClient javaClient; private static OpenSearchClient adminJavaClient;