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: [Tests] Move JDBC integration tests to new module (#56872) #57074

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/reference/sql/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
[[xpack-sql]]
= SQL access

:sql-tests: {xes-repo-dir}/../../plugin/sql/qa
:sql-specs: {sql-tests}/src/main/resources/
:jdbc-tests: {sql-tests}/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc
:security-tests: {sql-tests}/security/src/test/java/org/elasticsearch/xpack/sql/qa/security
:sql-tests: {xes-repo-dir}/../../plugin/sql/qa/
:sql-specs: {sql-tests}server/src/main/resources/
:jdbc-tests: {sql-tests}jdbc/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc
:security-tests: {sql-tests}server/security/src/test/java/org/elasticsearch/xpack/sql/qa/security
:es-sql: Elasticsearch SQL

[partintro]
--
Expand All @@ -15,7 +16,7 @@ X-Pack includes a SQL feature to execute SQL queries against {es}
indices and return results in tabular format.

The following chapters aim to cover everything from usage, to syntax and drivers.
Experience users or those in a hurry might want to jump directly to
Experience users or those in a hurry might want to jump directly to
the list of SQL <<sql-commands, commands>> and <<sql-functions, functions>>.

<<sql-overview, Overview>>::
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sql/security.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ indices:

[source, yaml]
--------------------------------------------------
include-tagged::{sql-tests}/security/roles.yml[cli_drivers]
include-tagged::{sql-tests}server/security/roles.yml[cli_drivers]
--------------------------------------------------

127 changes: 0 additions & 127 deletions x-pack/plugin/sql/qa/build.gradle
Original file line number Diff line number Diff line change
@@ -1,128 +1 @@
description = 'Integration tests for SQL'
apply plugin: 'elasticsearch.build'
archivesBaseName = 'qa-sql'
group = "org.elasticsearch.x-pack.qa.sql"

dependencies {
compile project(":test:framework")

// JDBC testing dependencies
compile project(path: xpackModule('sql:jdbc'))

compile "net.sourceforge.csvjdbc:csvjdbc:${csvjdbcVersion}"

// CLI testing dependencies
compile project(path: xpackModule('sql:sql-cli'))

// H2GIS testing dependencies
compile("org.orbisgis:h2gis:${h2gisVersion}") {
exclude group: "org.locationtech.jts"
}

// select just the parts of JLine that are needed
compile("org.jline:jline-terminal-jna:${jlineVersion}") {
exclude group: "net.java.dev.jna"
}
compile "org.jline:jline-terminal:${jlineVersion}"
compile "org.jline:jline-reader:${jlineVersion}"
compile "org.jline:jline-style:${jlineVersion}"

testRuntime "org.elasticsearch:jna:${versions.jna}"
}

/* disable unit tests because these are all integration tests used
* other qa projects. */
test.enabled = false

dependencyLicenses.enabled = false
dependenciesInfo.enabled = false

// the main files are actually test files, so use the appropriate forbidden api sigs
tasks.named('forbiddenApisMain').configure {
replaceSignatureFiles 'es-all-signatures', 'es-test-signatures'
}

// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks
thirdPartyAudit.enabled = false

subprojects {
if (subprojects.isEmpty()) {
// leaf project
apply plugin: 'elasticsearch.standalone-rest-test'
} else {
apply plugin: 'elasticsearch.build'
}

configurations.testRuntimeClasspath {
resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25"
}
configurations.testRuntime {
// This is also required to make resolveAllDependencies work
resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25"
}
dependencies {

/* Since we're a standalone rest test we actually get transitive
* dependencies but we don't really want them because they cause
* all kinds of trouble with the jar hell checks. So we suppress
* them explicitly for non-es projects. */
testCompile(xpackProject('plugin:sql:qa')) {
transitive = false
}
testCompile project(":test:framework")

// JDBC testing dependencies
testRuntime "net.sourceforge.csvjdbc:csvjdbc:${csvjdbcVersion}"
testRuntime "com.h2database:h2:${h2Version}"

// H2GIS testing dependencies
testRuntime("org.orbisgis:h2gis:${h2gisVersion}") {
exclude group: "org.locationtech.jts"
exclude group: "com.fasterxml.jackson.core"
}

testRuntime project(path: xpackModule('sql:jdbc'))
testRuntime xpackProject('plugin:sql:sql-client')

// TODO check if needed
testRuntime("org.antlr:antlr4-runtime:${antlrVersion}") {
transitive = false
}

// CLI testing dependencies
testRuntime project(path: xpackModule('sql:sql-cli'))
testRuntime(xpackProject('plugin:sql:sql-action')) {
transitive = false
}

testRuntime("org.jline:jline-terminal-jna:${jlineVersion}") {
exclude group: "net.java.dev.jna"
}
testRuntime "org.jline:jline-terminal:${jlineVersion}"
testRuntime "org.jline:jline-reader:${jlineVersion}"
testRuntime "org.jline:jline-style:${jlineVersion}"

testRuntime "org.elasticsearch:jna:${versions.jna}"

// spatial dependency
testRuntime project(path: xpackModule('spatial'))
}

if (project.name != 'security') {
// The security project just configures its subprojects
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.rest-test'

testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
}

task runqa {
doFirst {
println "Run with `-Dtestclusters.inspect.failure=true integTest` to leave the cluster running after failure"
}
}
}
}
61 changes: 61 additions & 0 deletions x-pack/plugin/sql/qa/jdbc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
description = 'Integration tests for SQL JDBC driver'
apply plugin: 'elasticsearch.build'

// Avoid circular dependency
group = "org.elasticsearch.x-pack.qa.sql.jdbc"

dependencies {
compile project(":test:framework")

// JDBC testing dependencies
compile project(path: xpackModule('sql:jdbc'))
}

/* disable unit tests because these are all integration tests used
* other qa projects. */
test.enabled = false

dependencyLicenses.enabled = false
dependenciesInfo.enabled = false

// the main files are actually test files, so use the appropriate forbidden api sigs
tasks.named('forbiddenApisMain').configure {
replaceSignatureFiles 'es-all-signatures', 'es-test-signatures'
}

// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks
thirdPartyAudit.enabled = false

subprojects {
if (subprojects.isEmpty()) {
// leaf project
apply plugin: 'elasticsearch.standalone-rest-test'
} else {
apply plugin: 'elasticsearch.build'
}

dependencies {
/* Since we're a standalone rest test we actually get transitive
* dependencies but we don't really want them because they cause
* all kinds of trouble with the jar hell checks. So we suppress
* them explicitly for non-es projects. */
testCompile(xpackProject('plugin:sql:qa:jdbc')) {
transitive = false
}
testCompile project(":test:framework")

testRuntime project(path: xpackModule('sql:jdbc'))
}

if (project.name != 'security') {
// The security project just configures its subprojects
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.rest-test'

testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
}
}
}
7 changes: 7 additions & 0 deletions x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description = 'Run SQL JDBC tests against multiple nodes'

testClusters.integTest {
numberOfNodes = 2
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.qa.single_node;
package org.elasticsearch.xpack.sql.qa.jdbc.multi_node;

import org.elasticsearch.xpack.sql.qa.jdbc.ConnectionTestCase;

public class JdbcConnectionIT extends ConnectionTestCase {
}
public class JdbcConnectionIT extends ConnectionTestCase {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.qa.single_node;
package org.elasticsearch.xpack.sql.qa.jdbc.multi_node;

import org.elasticsearch.xpack.sql.qa.jdbc.FetchSizeTestCase;

public class JdbcFetchSizeIT extends FetchSizeTestCase {
}
public class JdbcFetchSizeIT extends FetchSizeTestCase {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.qa.jdbc.multi_node;

import org.elasticsearch.xpack.sql.qa.jdbc.JdbcErrorsTestCase;

public class JdbcJdbcErrorsIT extends JdbcErrorsTestCase {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql.qa.multi_node;
package org.elasticsearch.xpack.sql.qa.jdbc.multi_node;

import org.elasticsearch.xpack.sql.qa.jdbc.PreparedStatementTestCase;

public class JdbcPreparedStatementIT extends PreparedStatementTestCase {
}
public class JdbcPreparedStatementIT extends PreparedStatementTestCase {}
4 changes: 4 additions & 0 deletions x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testClusters.integTest {
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

package org.elasticsearch.xpack.sql.qa.no_sql;
package org.elasticsearch.xpack.sql.qa.jdbc.no_sql;

import org.elasticsearch.xpack.sql.qa.jdbc.JdbcNoSqlTestCase;

public class JdbcNoSqlIT extends JdbcNoSqlTestCase {

}
public class JdbcNoSqlIT extends JdbcNoSqlTestCase {}
61 changes: 61 additions & 0 deletions x-pack/plugin/sql/qa/jdbc/security/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
dependencies {
testCompile project(':x-pack:plugin:core')
}

Project mainProject = project

configurations.create('testArtifacts')

TaskProvider testJar = tasks.register("testJar", Jar) {
appendix 'test'
from sourceSets.test.output
}

artifacts {
testArtifacts testJar
}

// Tests are pushed down to subprojects and will be checked there.
testingConventions.enabled = false

subprojects {
// Use tests from the root security qa project in subprojects
configurations.create('testArtifacts')

dependencies {
testCompile project(":x-pack:plugin:core")
testArtifacts project(path: mainProject.path, configuration: 'testArtifacts')
}

testClusters.integTest {
testDistribution = 'DEFAULT'
// Setup auditing so we can use it in some tests
setting 'xpack.security.audit.enabled', 'true'
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
// Setup roles used by tests
extraConfigFile 'roles.yml', mainProject.file('roles.yml')
/* Setup the one admin user that we run the tests as.
* Tests use "run as" to get different users. */
user username: "test_admin", password: "x-pack-test-password"
}

File testArtifactsDir = project.file("$buildDir/testArtifacts")
TaskProvider copyTestClasses = tasks.register("copyTestClasses", Copy) {
dependsOn configurations.testArtifacts
from { zipTree(configurations.testArtifacts.singleFile) }
into testArtifactsDir
}

integTest.runner {
dependsOn copyTestClasses
testClassesDirs += project.files(testArtifactsDir)
classpath += configurations.testArtifacts
nonInputProperties.systemProperty 'tests.audit.logfile',
"${-> testClusters.integTest.singleNode().getAuditLog()}"
nonInputProperties.systemProperty 'tests.audit.yesterday.logfile',
"${-> testClusters.integTest.singleNode().getAuditLog().getParentFile()}/integTest_audit-${new Date().format('yyyy-MM-dd')}.json"
}

testingConventions.enabled = false
}
Loading