|
22 | 22 | import org.junit.jupiter.api.DisplayNameGenerator; |
23 | 23 | import org.opensearch.client.Request; |
24 | 24 | import org.opensearch.client.Response; |
| 25 | +import org.opensearch.client.ResponseException; |
25 | 26 | import org.opensearch.client.RestHighLevelClient; |
26 | 27 | import org.opensearch.common.inject.Injector; |
27 | 28 | import org.opensearch.common.inject.ModulesBuilder; |
@@ -133,6 +134,7 @@ public void onFailure(Exception e) { |
133 | 134 | // act 3: confirm that there's no cursor. |
134 | 135 | } |
135 | 136 |
|
| 137 | + // Test takes 3+ min due to a big amount of requests issued |
136 | 138 | @Test |
137 | 139 | @SneakyThrows |
138 | 140 | public void test_pagination_blackbox() { |
@@ -173,6 +175,25 @@ public void test_pagination_blackbox() { |
173 | 175 | } |
174 | 176 | } |
175 | 177 |
|
| 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 | + |
176 | 197 | private Settings defaultSettings() { |
177 | 198 | return new Settings() { |
178 | 199 | private final Map<Key, Integer> defaultSettings = new ImmutableMap.Builder<Key, Integer>() |
|
0 commit comments