Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: handle SQL not being available in a more graceful way #43665

Merged
merged 6 commits into from
Jul 10, 2019

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Jun 26, 2019

When #36149 was merged, the default requests the JDBC driver was making changed slightly (the mode parameter was not a parameter anymore) and, also, the rest requests the ES server was receiving were handled slightly differently in the RestController.
So differently, that the error message being generated when a SQL request was made to a cluster that didn't have SQL installed (or disabled) was different.

This PR changes this error message handling and, also, adds a much needed integration test to handles this scenario. The test is a separate QA project which, in Gradle configuration, has SQL disabled.

Fixes #41279.

Adds a new qa sub-project that explicitly disables SQL XPack module in
Gradle.
@astefan astefan requested a review from matriv June 26, 2019 21:43
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good, left a question.

public void testJdbcExceptionMessage() throws SQLException {
try (Connection c = esJdbc()) {
SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT * FROM bla").executeQuery());
assertTrue(e.getMessage().startsWith("X-Pack/SQL do not seem to be available on the Elasticsearch node using the access path"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do -> does

+ "] contains unrecognized parameter: [mode]";
private static final String SQL_NOT_AVAILABLE_ERROR_MESSAGE_HTTPMETHOD = "Incorrect HTTP method for uri [" + SQL_QUERY_REST_ENDPOINT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case tested somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The special case of sql not being installed/disabled had no tests before this one.

@astefan
Copy link
Contributor Author

astefan commented Jul 2, 2019

@elastic/es-core-infra is there any other solution that you might think of for this integration test to be possible?
Please, note that I created a new qa sub-project where I am disabling SQL from Gradle config, so that I can test the JDBC driver error message when SQL is not installed or disabled. ESRestTestCase nor ESIntegTestCase allow me, at the same time, to disable SQL from code (since from Gradle I would disable SQL for the entire project) AND get a useful hostname and port number to use for the JDBC driver connection.

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@astefan astefan merged commit 8a1ac8a into elastic:master Jul 10, 2019
astefan added a commit that referenced this pull request Jul 10, 2019
* Add test for SQL not being available error message in JDBC.
* Add a new qa sub-project that explicitly disables SQL XPack module in Gradle.

(cherry picked from commit 8a1ac8a)
astefan added a commit that referenced this pull request Jul 10, 2019
* Add test for SQL not being available error message in JDBC.
* Add a new qa sub-project that explicitly disables SQL XPack module in Gradle.

(cherry picked from commit 8a1ac8a)
astefan added a commit that referenced this pull request Jul 10, 2019
* Add test for SQL not being available error message in JDBC.
* Add a new qa sub-project that explicitly disables SQL XPack module in Gradle.

(cherry picked from commit 8a1ac8a)
@jpountz jpountz added v7.3.0 and removed v7.3.1 labels Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL: handle SQL not being available on server in a more graceful way
5 participants