SQL: Fix testJdbcActionLicense test

The testJdbcActionLicense test broke because we changed the error serialization mechanism in elastic/x-pack-elasticsearch#3034. This commit updates that check to capture an exception instead of checking for ErrorResponse.

Original commit: elastic/x-pack-elasticsearch@17c41426d0
This commit is contained in:
Igor Motov 2017-11-17 15:37:02 -05:00
parent ffcd54de77
commit d011247970
1 changed files with 6 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -23,7 +24,6 @@ import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.transport.Netty4Plugin; import org.elasticsearch.transport.Netty4Plugin;
import org.elasticsearch.xpack.sql.jdbc.net.protocol.ErrorResponse;
import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableRequest; import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableRequest;
import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableResponse; import org.elasticsearch.xpack.sql.jdbc.net.protocol.MetaTableResponse;
import org.elasticsearch.xpack.sql.jdbc.net.protocol.Proto; import org.elasticsearch.xpack.sql.jdbc.net.protocol.Proto;
@ -51,6 +51,7 @@ import static org.elasticsearch.license.XPackLicenseStateTests.randomBasicStanda
import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialBasicStandardGoldOrPlatinumMode; import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialBasicStandardGoldOrPlatinumMode;
import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialOrPlatinumMode; import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialOrPlatinumMode;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsEqual.equalTo;
@ -160,14 +161,11 @@ public class SqlLicenseIT extends AbstractLicensesIntegrationTestCase {
disableJdbcLicensing(); disableJdbcLicensing();
Request request = new MetaTableRequest("test"); Request request = new MetaTableRequest("test");
Response response = jdbc(request); ResponseException responseException = expectThrows(ResponseException.class, () -> jdbc(request));
assertThat(response, instanceOf(ErrorResponse.class)); assertThat(responseException.getMessage(), containsString("current license is non-compliant for [jdbc]"));
ErrorResponse er = (ErrorResponse) response;
assertEquals(ElasticsearchSecurityException.class.getName(), er.cause);
assertEquals("current license is non-compliant for [jdbc]", er.message);
enableJdbcLicensing();
response = jdbc(request); enableJdbcLicensing();
Response response = jdbc(request);
assertThat(response, instanceOf(MetaTableResponse.class)); assertThat(response, instanceOf(MetaTableResponse.class));
} }