Skip to content
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
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ dependencies {
api 'com.netflix.nebula:gradle-info-plugin:7.1.3'
api 'org.apache.rat:apache-rat:0.11'
api "org.elasticsearch:jna:5.5.0"
api 'com.github.jengelman.gradle.plugins:shadow:5.1.0'
api 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
api 'de.thetaphi:forbiddenapis:3.0'
api 'com.avast.gradle:gradle-docker-compose-plugin:0.12.1'
api 'org.apache.maven:maven-model:3.6.2'
Expand Down
5 changes: 5 additions & 0 deletions distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf
createBuildBwcTask(projectName, "${baseDir}/${projectName}", projectArtifact)
}

// Create build tasks for the JDBC driver used for compatibility testing
String jdbcProjectDir = 'x-pack/plugin/sql/jdbc'
File jdbcProjectArtifact = file("${checkoutDir}/${jdbcProjectDir}/build/distributions/x-pack-sql-jdbc-${bwcVersion}-SNAPSHOT.jar")
createBuildBwcTask('jdbc', jdbcProjectDir, jdbcProjectArtifact)

createRunBwcGradleTask("resolveAllBwcDependencies") {
args 'resolveAllDependencies'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/bwc-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ tasks.named("check").configure {
dependsOn(bwcTestSnapshots)
}

test.enabled = false
tasks.findByName("test")?.enabled = false
11 changes: 10 additions & 1 deletion x-pack/plugin/sql/jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ tasks.named("dependencyLicenses").configure {
}

shadowJar {
relocate 'com.fasterxml', 'org.elasticsearch.fasterxml'
relocate 'com.fasterxml', 'shadow.fasterxml'
relocate('org.elasticsearch', 'shadow.org.elasticsearch') {
// Don't relocate the JDBC driver classes themselves as that's (mostly) public API
exclude 'org.elasticsearch.xpack.sql.jdbc.*'
}
}

thirdPartyAudit.ignoreMissingClasses(
'com.fasterxml.jackson.databind.ObjectMapper',
'com.fasterxml.jackson.databind.cfg.MapperBuilder'
)

tasks.named("test").configure {
// reset the unit test classpath as using the shadow jar won't work due to relocated packages
classpath = sourceSets.test.runtimeClasspath
}
122 changes: 82 additions & 40 deletions x-pack/plugin/sql/qa/jdbc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,61 +1,103 @@
import org.elasticsearch.gradle.BwcVersions.UnreleasedVersionInfo
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.RestIntegTestTask

description = 'Integration tests for SQL JDBC driver'
apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.java'

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

dependencies {
api project(":test:framework")
api project(':test:framework')
implementation xpackProject('plugin:sql:sql-proto')

// JDBC testing dependencies
api project(path: xpackModule('sql:jdbc'))
// Actual tests will use the shadow jar
compileOnly(project(path: xpackModule('sql:jdbc'))) {
// Since dependencies will be relocated in the shadow jar, don't attempt to compile against them
transitive = false
}
}

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

tasks.named("dependencyLicenses").configure { it.enabled = false }
dependenciesInfo.enabled = false
subprojects {
if (subprojects.isEmpty()) {
// leaf project
apply plugin: 'elasticsearch.standalone-rest-test'
apply from: "$rootDir/gradle/bwc-test.gradle"
} else {
apply plugin: 'elasticsearch.java'
}

// 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'
}
repositories {
maven {
// Repository for downloading BWC compatible JDBC driver releases
url = 'https://artifacts.elastic.co/maven'
}
}

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

subprojects {
if (subprojects.isEmpty()) {
// leaf project
apply plugin: 'elasticsearch.standalone-rest-test'
} else {
apply plugin: 'elasticsearch.build'
}
dependencies {
testImplementation(xpackProject('plugin:sql:qa:jdbc'))

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. */
testImplementation(xpackProject('plugin:sql:qa:jdbc')) {
transitive = false
}
testImplementation project(":test:framework")
// We use the shadowjar for testing since that's the actual artifact we deliver to users
testCompileOnly project(path: xpackModule('sql:jdbc'), configuration: 'shadow')
jdbcDriver project(path: xpackModule('sql:jdbc'), configuration: 'shadow')
}

testRuntimeOnly 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.all {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
}

integTest {
runner {
classpath += configurations.jdbcDriver
systemProperty 'jdbc.driver.version', VersionProperties.elasticsearch
}
}

if (project.name != 'security') {
// The security project just configures its subprojects
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.rest-test'
// Configure compatibility testing tasks
for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
// Compatibility testing for JDBC driver started with version 7.9.0
if (bwcVersion.onOrAfter(Version.fromString("7.9.0")) && (bwcVersion.equals(VersionProperties.elasticsearchVersion) == false)) {
String baseName = "v${bwcVersion}"
UnreleasedVersionInfo unreleasedVersion = BuildParams.bwcVersions.unreleasedInfo(bwcVersion)
Configuration driverConfiguration = configurations.create("jdbcDriver${baseName}")
Object driverDependency = null

if (unreleasedVersion) {
// For unreleased snapshot versions, build them from source
driverDependency = files(project(unreleasedVersion.gradleProjectPath).tasks.named('buildBwcJdbc'))
} else {
// For released versions, download it
driverDependency = "org.elasticsearch.plugin:x-pack-sql-jdbc:${bwcVersion}"
}

dependencies {
"jdbcDriver${baseName}"(driverDependency)
}

testClusters.integTest {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
tasks.create(bwcTaskName(bwcVersion), RestIntegTestTask) {
runner {
classpath += driverConfiguration
systemProperty 'jdbc.driver.version', bwcVersion.toString()
}
}
}
}
}
}
8 changes: 4 additions & 4 deletions x-pack/plugin/sql/qa/jdbc/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +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'
testClusters.all {
numberOfNodes = 2
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}
6 changes: 3 additions & 3 deletions x-pack/plugin/sql/qa/jdbc/no-sql/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testClusters.integTest {
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
testClusters.all {
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}
92 changes: 46 additions & 46 deletions x-pack/plugin/sql/qa/jdbc/security/build.gradle
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask

dependencies {
testImplementation project(':x-pack:plugin:core')
testImplementation project(':x-pack:plugin:core')
}

Project mainProject = project

configurations.create('testArtifacts')

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

artifacts {
testArtifacts testJar
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 {
testImplementation 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
// Use tests from the root security qa project in subprojects
configurations.create('testArtifacts')

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

testClusters.all {
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
}


tasks.withType(RestTestRunnerTask).configureEach {
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
}
2 changes: 1 addition & 1 deletion x-pack/plugin/sql/qa/jdbc/security/with-ssl/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'elasticsearch.test-with-ssl'

testClusters.integTest {
testClusters.all {
// The setup that we actually want
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.http.ssl.enabled', 'true'
Expand Down
10 changes: 6 additions & 4 deletions x-pack/plugin/sql/qa/jdbc/security/without-ssl/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
integTest.runner {
systemProperty 'tests.ssl.enabled', 'false'
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask

tasks.withType(RestTestRunnerTask).configureEach {
systemProperty 'tests.ssl.enabled', 'false'
}

testClusters.integTest {
setting 'xpack.license.self_generated.type', 'trial'
testClusters.all {
setting 'xpack.license.self_generated.type', 'trial'
}
2 changes: 1 addition & 1 deletion x-pack/plugin/sql/qa/jdbc/single-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testClusters.integTest {
testClusters.all {
setting 'xpack.security.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
}