Add test for index with two types (elastic/x-pack-elasticsearch#2194)

Adds a test that shows *how* SQL fails to address an index with two types
to the full cluster restart tests. Because we're writing this code
against 7.0 don't actually execute the test, but we will execute it when
we merge to 6.x and it *should* work.

Original commit: elastic/x-pack-elasticsearch@b536e9a142
This commit is contained in:
Nik Everett 2017-08-08 13:32:13 -04:00 committed by GitHub
parent e09eb41340
commit 570b66638e
2 changed files with 15 additions and 8 deletions

View File

@ -248,6 +248,21 @@ public class FullClusterRestartIT extends ESRestTestCase {
} }
} }
public void testSqlFailsOnIndexWithTwoTypes() throws IOException {
// TODO this isn't going to trigger until we backport to 6.1
assumeTrue("It is only possible to build an index that sql doesn't like before 6.0.0",
oldClusterVersion.onOrAfter(Version.V_6_0_0_alpha1));
if (runningAgainstOldCluster) {
client().performRequest("POST", "/testsqlfailsonindexwithtwotypes/type1", emptyMap(), new StringEntity("{}"));
client().performRequest("POST", "/testsqlfailsonindexwithtwotypes/type2", emptyMap(), new StringEntity("{}"));
return;
}
ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest("POST", "/_sql", emptyMap(),
new StringEntity("{\"query\":\"SELECT * FROM testsqlfailsonindexwithtwotypes\"}")));
assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
assertThat(e.getMessage(), containsString("Invalid index testsqlfailsonindexwithtwotypes; contains more than one type"));
}
private String loadWatch(String watch) throws IOException { private String loadWatch(String watch) throws IOException {
return StreamsUtils.copyToStringFromClasspath("/org/elasticsearch/xpack/restart/" + watch); return StreamsUtils.copyToStringFromClasspath("/org/elasticsearch/xpack/restart/" + watch);
} }

View File

@ -20,12 +20,4 @@ public class ErrorsIT extends JdbcIntegrationTestCase {
assertEquals("line 1:15: Cannot resolve index [test]", e.getMessage()); assertEquals("line 1:15: Cannot resolve index [test]", e.getMessage());
} }
} }
// public void testMultiTypeIndex() throws Exception {
// NOCOMMIT bwc tests
// try (Connection c = esJdbc()) {
// SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT * from multi_type").executeQuery());
// assertEquals(message("multi_type"), e.getMessage());
// }
// }
} }