More cleanup
Big change here is that we start to use ES's base test clases for testing. This should give us access to randomized testing and makes sure that the reproduction lines are correct. Original commit: elastic/x-pack-elasticsearch@bcab64a028
This commit is contained in:
parent
857f60dd99
commit
50aa97e3cf
|
@ -27,22 +27,14 @@ subprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile("junit:junit:${versions.junit}") {
|
testCompile "org.elasticsearch.test:framework:${version}"
|
||||||
exclude group:'org.hamcrest', module:'hamcrest-core'
|
|
||||||
}
|
|
||||||
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.checkstyle.enabled = false // not worth it yet
|
tasks.checkstyleMain.enabled = false // not worth it yet
|
||||||
tasks.checkstyleTest.enabled = false // not worth it yet
|
tasks.checkstyleTest.enabled = false // not worth it yet
|
||||||
|
|
||||||
forbiddenApisMain {
|
forbiddenApisMain {
|
||||||
// does not depend on core, so only jdk and http signatures should be checked
|
// does not depend on core, so only jdk and http signatures should be checked
|
||||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
|
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
|
||||||
}
|
}
|
||||||
|
|
||||||
forbiddenApisTest {
|
|
||||||
// does not depend on core, so only jdk signatures should be checked
|
|
||||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,24 +3,6 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
w * Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.xpack.sql.cli.net.protocol;
|
package org.elasticsearch.xpack.sql.cli.net.protocol;
|
||||||
|
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
|
|
|
@ -34,3 +34,62 @@ run {
|
||||||
|
|
||||||
// Needed so we can launch graphviz if it is installed
|
// Needed so we can launch graphviz if it is installed
|
||||||
project.compactProfile = 'full'
|
project.compactProfile = 'full'
|
||||||
|
|
||||||
|
forbiddenApisTest {
|
||||||
|
//we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
|
||||||
|
bundledSignatures -= 'jdk-non-portable'
|
||||||
|
bundledSignatures += 'jdk-internal'
|
||||||
|
}
|
||||||
|
|
||||||
|
thirdPartyAudit.excludes = [
|
||||||
|
// included by jline but not used
|
||||||
|
// NOCOMMIT maybe we need some of these?
|
||||||
|
'com.sun.jna.Library',
|
||||||
|
'com.sun.jna.Native',
|
||||||
|
'com.sun.jna.NativeLong',
|
||||||
|
'com.sun.jna.Platform',
|
||||||
|
'com.sun.jna.Pointer',
|
||||||
|
'com.sun.jna.Structure$ByReference',
|
||||||
|
'com.sun.jna.Structure$ByValue',
|
||||||
|
'com.sun.jna.Structure',
|
||||||
|
'com.sun.jna.Union',
|
||||||
|
'com.sun.jna.ptr.IntByReference',
|
||||||
|
'com.sun.jna.win32.StdCallLibrary',
|
||||||
|
'com.sun.jna.win32.W32APIOptions',
|
||||||
|
'org.apache.sshd.client.SshClient',
|
||||||
|
'org.apache.sshd.client.auth.keyboard.UserInteraction',
|
||||||
|
'org.apache.sshd.client.channel.ChannelShell',
|
||||||
|
'org.apache.sshd.client.channel.ClientChannel',
|
||||||
|
'org.apache.sshd.client.channel.ClientChannelEvent',
|
||||||
|
'org.apache.sshd.client.future.AuthFuture',
|
||||||
|
'org.apache.sshd.client.future.ConnectFuture',
|
||||||
|
'org.apache.sshd.client.future.OpenFuture',
|
||||||
|
'org.apache.sshd.client.session.ClientSession',
|
||||||
|
'org.apache.sshd.common.Factory',
|
||||||
|
'org.apache.sshd.common.channel.PtyMode',
|
||||||
|
'org.apache.sshd.common.config.keys.FilePasswordProvider',
|
||||||
|
'org.apache.sshd.common.util.io.NoCloseInputStream',
|
||||||
|
'org.apache.sshd.common.util.io.NoCloseOutputStream',
|
||||||
|
'org.apache.sshd.server.Command',
|
||||||
|
'org.apache.sshd.server.Environment',
|
||||||
|
'org.apache.sshd.server.ExitCallback',
|
||||||
|
'org.apache.sshd.server.SessionAware',
|
||||||
|
'org.apache.sshd.server.Signal',
|
||||||
|
'org.apache.sshd.server.SshServer',
|
||||||
|
'org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider',
|
||||||
|
'org.apache.sshd.server.scp.ScpCommandFactory$Builder',
|
||||||
|
'org.apache.sshd.server.session.ServerSession',
|
||||||
|
'org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory$Builder',
|
||||||
|
'org.fusesource.jansi.Ansi',
|
||||||
|
'org.fusesource.jansi.WindowsAnsiOutputStream',
|
||||||
|
'org.fusesource.jansi.internal.CLibrary$Termios',
|
||||||
|
'org.fusesource.jansi.internal.CLibrary$WinSize',
|
||||||
|
'org.fusesource.jansi.internal.CLibrary',
|
||||||
|
'org.fusesource.jansi.internal.Kernel32$CONSOLE_SCREEN_BUFFER_INFO',
|
||||||
|
'org.fusesource.jansi.internal.Kernel32$COORD',
|
||||||
|
'org.fusesource.jansi.internal.Kernel32$INPUT_RECORD',
|
||||||
|
'org.fusesource.jansi.internal.Kernel32$KEY_EVENT_RECORD',
|
||||||
|
'org.fusesource.jansi.internal.Kernel32',
|
||||||
|
'org.fusesource.jansi.internal.WindowsSupport',
|
||||||
|
'org.mozilla.universalchardet.UniversalDetector'
|
||||||
|
]
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.sql.cli.integration.net.protocol;
|
||||||
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
||||||
import org.elasticsearch.xpack.sql.cli.CliConfiguration;
|
import org.elasticsearch.xpack.sql.cli.CliConfiguration;
|
||||||
import org.elasticsearch.xpack.sql.cli.integration.server.CliHttpServer;
|
import org.elasticsearch.xpack.sql.cli.integration.server.CliHttpServer;
|
||||||
|
@ -15,7 +16,6 @@ import org.elasticsearch.xpack.sql.cli.net.protocol.CommandResponse;
|
||||||
import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse;
|
import org.elasticsearch.xpack.sql.cli.net.protocol.InfoResponse;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -24,23 +24,20 @@ import static org.hamcrest.Matchers.isEmptyOrNullString;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
public class ProtoTest {
|
|
||||||
|
|
||||||
|
public class ProtoTests extends ESTestCase {
|
||||||
private static Client esClient;
|
private static Client esClient;
|
||||||
private static CliHttpServer server;
|
private static CliHttpServer server;
|
||||||
private static HttpCliClient client;
|
private static HttpCliClient client;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setupServer() throws Exception {
|
||||||
if (esClient == null) {
|
if (esClient == null) {
|
||||||
esClient = new PreBuiltTransportClient(Settings.EMPTY);
|
esClient = new PreBuiltTransportClient(Settings.EMPTY);
|
||||||
}
|
}
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
server = new CliHttpServer(esClient);
|
server = new CliHttpServer(esClient);
|
||||||
server.start(0);
|
server.start(0);
|
||||||
System.out.println("Server started at " + server.address().getPort());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
|
@ -50,7 +47,7 @@ public class ProtoTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void tearDown() {
|
public static void shutdownServer() {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
server.stop();
|
server.stop();
|
||||||
server = null;
|
server = null;
|
||||||
|
@ -67,7 +64,6 @@ public class ProtoTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInfoAction() throws Exception {
|
public void testInfoAction() throws Exception {
|
||||||
InfoResponse esInfo = client.serverInfo();
|
InfoResponse esInfo = client.serverInfo();
|
||||||
assertThat(esInfo, notNullValue());
|
assertThat(esInfo, notNullValue());
|
||||||
|
@ -79,9 +75,9 @@ public class ProtoTest {
|
||||||
//assertThat(esInfo.minorVersion(), is(0));
|
//assertThat(esInfo.minorVersion(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBasicQuery() throws Exception {
|
public void testBasicQuery() throws Exception {
|
||||||
CommandResponse command = client.command("SHOW TABLES", null);
|
CommandResponse command = client.command("SHOW TABLES", null);
|
||||||
System.out.println(command.data);
|
// System.out.println(command.data);
|
||||||
|
// NOCOMMIT test this
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@ class JdbcStatement implements Statement, JdbcWrapper {
|
||||||
@Override
|
@Override
|
||||||
public ResultSet executeQuery(String sql) throws SQLException {
|
public ResultSet executeQuery(String sql) throws SQLException {
|
||||||
if (!execute(sql)) {
|
if (!execute(sql)) {
|
||||||
throw new SQLException(String.format("Invalid sql query %s", sql));
|
throw new SQLException("Invalid sql query [" + sql + "]");
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue