Skip to content

Commit

Permalink
fix pipeline failure
Browse files Browse the repository at this point in the history
Signed-off-by: bfindlay <[email protected]>
  • Loading branch information
Bfindlay committed Nov 27, 2023
1 parent eb666c6 commit 0c8ce3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
import org.opensearch.test.rest.OpenSearchRestTestCase;

public abstract class OpenSearchJavaClientTestCase extends OpenSearchRestTestCase implements OpenSearchTransportSupport {
private static final List<String> systemIndices = List.of(".opensearch-observability", ".opendistro_security", ".plugins-ml-config");
private static final List<String> systemIndices = List.of(
".opensearch-observability",
".opendistro_security",
".plugins-ml-config",
".tasks"
);
private static OpenSearchClient javaClient;
private static OpenSearchClient adminJavaClient;

Expand Down

0 comments on commit 0c8ce3a

Please sign in to comment.