From eeb55d6af6b6cabdca20311a7896f55e5b398e12 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Mon, 22 Mar 2021 17:43:34 +0100 Subject: [PATCH 1/4] Fix test to not run as a newer jdbc than server Fix test simulating running an newer JDBC driver against an older server. This scenario's no longer supported. --- .../xpack/sql/qa/mixed_node/SqlSearchIT.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java index b216f86f3bb27..6e3fc28bc529d 100644 --- a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java +++ b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java @@ -120,7 +120,7 @@ public void testAllTypesWithRequestToOldNodes() throws Exception { } } ); - assertAllTypesWithNodes(expectedResponse, bwcNodes); + assertAllTypesWithNodes(expectedResponse, bwcNodes, false); } public void testAllTypesWithRequestToUpgradedNodes() throws Exception { @@ -149,7 +149,7 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception { } } ); - assertAllTypesWithNodes(expectedResponse, newNodes); + assertAllTypesWithNodes(expectedResponse, newNodes, true); } @SuppressWarnings("unchecked") @@ -230,12 +230,14 @@ private Map columnInfo(String name, String type) { return unmodifiableMap(column); } - private void assertAllTypesWithNodes(Map expectedResponse, List nodesList) throws Exception { + private void assertAllTypesWithNodes(Map expectedResponse, List nodesList, boolean asDriver) + throws Exception { try ( RestClient client = buildClient(restClientSettings(), nodesList.stream().map(TestNode::getPublishAddress).toArray(HttpHost[]::new)) ) { Request request = new Request("POST", "_sql"); + String mode = "\"mode\":" + (asDriver ? "\"jdbc\"" : "\"plain\""); String version = ",\"version\":\"" + newVersion.toString() + "\""; String binaryFormat = ",\"binary_format\":\"false\""; @@ -250,7 +252,7 @@ private void assertAllTypesWithNodes(Map expectedResponse, List< .collect(Collectors.toList()).stream().collect(Collectors.joining(", ")); String query = "SELECT " + intervalYearMonth + intervalDayTime + fieldsList + " FROM " + index + " ORDER BY id"; request.setJsonEntity( - "{\"mode\":\"jdbc\"" + version + binaryFormat + ",\"query\":\"" + query + "\"}" + "{" + mode + version + binaryFormat + ",\"query\":\"" + query + "\"}" ); assertBusy(() -> { assertResponse(expectedResponse, runSql(client, request)); }); } From d41ed394473b33fbb5d2740a88b8a2c4ac623556 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Mon, 22 Mar 2021 19:26:58 +0100 Subject: [PATCH 2/4] Remove driver mode altogether The mode and subsequent required parameters are all removed, as they aren't needed. --- .../xpack/sql/qa/mixed_node/SqlSearchIT.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java index 6e3fc28bc529d..1ef4de2691c5b 100644 --- a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java +++ b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java @@ -120,7 +120,7 @@ public void testAllTypesWithRequestToOldNodes() throws Exception { } } ); - assertAllTypesWithNodes(expectedResponse, bwcNodes, false); + assertAllTypesWithNodes(expectedResponse, bwcNodes); } public void testAllTypesWithRequestToUpgradedNodes() throws Exception { @@ -149,7 +149,7 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception { } } ); - assertAllTypesWithNodes(expectedResponse, newNodes, true); + assertAllTypesWithNodes(expectedResponse, newNodes); } @SuppressWarnings("unchecked") @@ -226,21 +226,15 @@ private Map columnInfo(String name, String type) { Map column = new HashMap<>(); column.put("name", name); column.put("type", type); - column.put("display_size", SqlDataTypes.displaySize(SqlDataTypes.fromTypeName(type))); return unmodifiableMap(column); } - private void assertAllTypesWithNodes(Map expectedResponse, List nodesList, boolean asDriver) + private void assertAllTypesWithNodes(Map expectedResponse, List nodesList) throws Exception { try ( RestClient client = buildClient(restClientSettings(), nodesList.stream().map(TestNode::getPublishAddress).toArray(HttpHost[]::new)) ) { - Request request = new Request("POST", "_sql"); - String mode = "\"mode\":" + (asDriver ? "\"jdbc\"" : "\"plain\""); - String version = ",\"version\":\"" + newVersion.toString() + "\""; - String binaryFormat = ",\"binary_format\":\"false\""; - @SuppressWarnings("unchecked") List> columns = (List>) expectedResponse.get("columns"); String intervalYearMonth = "INTERVAL '150' YEAR AS interval_year, "; @@ -251,9 +245,8 @@ private void assertAllTypesWithNodes(Map expectedResponse, List< String fieldsList = columns.stream().map(m -> (String) m.get("name")).filter(str -> str.startsWith("interval") == false) .collect(Collectors.toList()).stream().collect(Collectors.joining(", ")); String query = "SELECT " + intervalYearMonth + intervalDayTime + fieldsList + " FROM " + index + " ORDER BY id"; - request.setJsonEntity( - "{" + mode + version + binaryFormat + ",\"query\":\"" + query + "\"}" - ); + Request request = new Request("POST", "_sql"); + request.setJsonEntity("{\"query\":\"" + query + "\"}"); assertBusy(() -> { assertResponse(expectedResponse, runSql(client, request)); }); } } From 12e837dc997d5c749711c186270f7cefe43971c5 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Mon, 22 Mar 2021 19:38:00 +0100 Subject: [PATCH 3/4] Strip test disablign tag Reenable test. --- .../org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java index 1ef4de2691c5b..ba5c91f5ab7ce 100644 --- a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java +++ b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java @@ -90,7 +90,6 @@ public void cleanUpIndex() throws IOException { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/70630") public void testAllTypesWithRequestToOldNodes() throws Exception { Map expectedResponse = prepareTestData( columns -> { From bd697968cf72501d395aed3c235508bea706c71b Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Tue, 23 Mar 2021 08:09:23 +0100 Subject: [PATCH 4/4] Checkstyle fix Remove unused import. --- .../org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java index ba5c91f5ab7ce..7480700bbd8eb 100644 --- a/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java +++ b/x-pack/plugin/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlSearchIT.java @@ -20,7 +20,6 @@ import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xpack.ql.TestNode; import org.elasticsearch.xpack.ql.TestNodes; -import org.elasticsearch.xpack.sql.type.SqlDataTypes; import org.junit.After; import org.junit.Before;