Skip to content

Commit

Permalink
add IT for failure case
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Kao <[email protected]>
  • Loading branch information
seankao-az committed Apr 27, 2023
1 parent 10d1ff6 commit 30971b1
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package org.opensearch.sql.ppl;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.util.MatcherUtils.columnName;
Expand All @@ -15,13 +16,20 @@

import java.io.IOException;
import org.json.JSONObject;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import org.opensearch.client.ResponseException;

public class CrossClusterSearchIT extends PPLIntegTestCase {

@Rule
public ExpectedException exceptionRule = ExpectedException.none();

private final static String TEST_INDEX_BANK_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_BANK;
private final static String TEST_INDEX_DOG_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private final static String TEST_INDEX_DOG_MATCH_ALL_REMOTE = MATCH_ALL_REMOTE_CLUSTER + ":" + TEST_INDEX_DOG;
private final static String TEST_INDEX_ACCOUNT_REMOTE = REMOTE_CLUSTER + ":" + TEST_INDEX_ACCOUNT;

@Override
public void init() throws IOException {
Expand All @@ -30,6 +38,7 @@ public void init() throws IOException {
loadIndex(Index.BANK, remoteClient());
loadIndex(Index.DOG);
loadIndex(Index.DOG, remoteClient());
loadIndex(Index.ACCOUNT, remoteClient());
}

@Test
Expand All @@ -44,6 +53,15 @@ public void testMatchAllCrossClusterSearchAllFields() throws IOException {
verifyColumn(result, columnName("dog_name"), columnName("holdersName"), columnName("age"));
}

@Test
public void testCrossClusterSearchWithoutLocalFieldMappingShouldFail() throws IOException {
exceptionRule.expect(ResponseException.class);
exceptionRule.expectMessage("400 Bad Request");
exceptionRule.expectMessage("IndexNotFoundException");

executeQuery(String.format("search source=%s", TEST_INDEX_ACCOUNT_REMOTE));
}

@Test
public void testCrossClusterSearchCommandWithLogicalExpression() throws IOException {
JSONObject result = executeQuery(String.format(
Expand Down

0 comments on commit 30971b1

Please sign in to comment.