Skip to content

Commit 2a19e56

Browse files
Add IT for explain.
Signed-off-by: Yury-Fridlyand <[email protected]>
1 parent dd6fcd6 commit 2a19e56

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

integ-test/src/test/java/org/opensearch/sql/sql/StandalonePaginationIT.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.DisplayNameGenerator;
2323
import org.opensearch.client.Request;
2424
import org.opensearch.client.Response;
25+
import org.opensearch.client.ResponseException;
2526
import org.opensearch.client.RestHighLevelClient;
2627
import org.opensearch.common.inject.Injector;
2728
import org.opensearch.common.inject.ModulesBuilder;
@@ -133,6 +134,7 @@ public void onFailure(Exception e) {
133134
// act 3: confirm that there's no cursor.
134135
}
135136

137+
// Test takes 3+ min due to a big amount of requests issued
136138
@Test
137139
@SneakyThrows
138140
public void test_pagination_blackbox() {
@@ -173,6 +175,25 @@ public void test_pagination_blackbox() {
173175
}
174176
}
175177

178+
@Test
179+
@SneakyThrows
180+
public void test_explain_not_supported() {
181+
var request = new Request("POST", "_plugins/_sql/_explain");
182+
// Request should be rejected before index names are resolved
183+
request.setJsonEntity("{ \"query\": \"select * from something\", \"fetch_size\": 10 }");
184+
var exception = assertThrows(ResponseException.class, () -> client().performRequest(request));
185+
var response = new JSONObject(new String(exception.getResponse().getEntity().getContent().readAllBytes()));
186+
assertEquals("`explain` feature for paginated requests is not implemented yet.",
187+
response.getJSONObject("error").getString("details"));
188+
189+
// Request should be rejected before cursor parsed
190+
request.setJsonEntity("{ \"cursor\" : \"n:0000\" }");
191+
exception = assertThrows(ResponseException.class, () -> client().performRequest(request));
192+
response = new JSONObject(new String(exception.getResponse().getEntity().getContent().readAllBytes()));
193+
assertEquals("`explain` request for cursor requests is not supported. Use `explain` for the initial query request.",
194+
response.getJSONObject("error").getString("details"));
195+
}
196+
176197
private Settings defaultSettings() {
177198
return new Settings() {
178199
private final Map<Key, Integer> defaultSettings = new ImmutableMap.Builder<Key, Integer>()

0 commit comments

Comments
 (0)