|
| 1 | +import org.elasticsearch.gradle.BwcVersions.UnreleasedVersionInfo |
| 2 | +import org.elasticsearch.gradle.Version |
| 3 | +import org.elasticsearch.gradle.VersionProperties |
| 4 | +import org.elasticsearch.gradle.info.BuildParams |
| 5 | +import org.elasticsearch.gradle.test.RestIntegTestTask |
| 6 | + |
1 | 7 | description = 'Integration tests for SQL JDBC driver' |
2 | | -apply plugin: 'elasticsearch.build' |
| 8 | +apply plugin: 'elasticsearch.java' |
3 | 9 |
|
4 | 10 | // Avoid circular dependency |
5 | | -group = "org.elasticsearch.x-pack.qa.sql.jdbc" |
| 11 | +group = 'org.elasticsearch.x-pack.qa.sql.jdbc' |
6 | 12 |
|
7 | 13 | dependencies { |
8 | | - api project(":test:framework") |
| 14 | + api project(':test:framework') |
| 15 | + implementation xpackProject('plugin:sql:sql-proto') |
9 | 16 |
|
10 | | - // JDBC testing dependencies |
11 | | - api project(path: xpackModule('sql:jdbc')) |
| 17 | + // Actual tests will use the shadow jar |
| 18 | + compileOnly(project(path: xpackModule('sql:jdbc'))) { |
| 19 | + // Since dependencies will be relocated in the shadow jar, don't attempt to compile against them |
| 20 | + transitive = false |
| 21 | + } |
12 | 22 | } |
13 | 23 |
|
14 | | -/* disable unit tests because these are all integration tests used |
15 | | - * other qa projects. */ |
| 24 | +// disable unit tests because these are all integration tests used other qa projects |
16 | 25 | test.enabled = false |
17 | 26 |
|
18 | | -tasks.named("dependencyLicenses").configure { it.enabled = false } |
19 | | -dependenciesInfo.enabled = false |
| 27 | +subprojects { |
| 28 | + if (subprojects.isEmpty()) { |
| 29 | + // leaf project |
| 30 | + apply plugin: 'elasticsearch.standalone-rest-test' |
| 31 | + apply from: "$rootDir/gradle/bwc-test.gradle" |
| 32 | + } else { |
| 33 | + apply plugin: 'elasticsearch.java' |
| 34 | + } |
20 | 35 |
|
21 | | -// the main files are actually test files, so use the appropriate forbidden api sigs |
22 | | -tasks.named('forbiddenApisMain').configure { |
23 | | - replaceSignatureFiles 'es-all-signatures', 'es-test-signatures' |
24 | | -} |
| 36 | + repositories { |
| 37 | + maven { |
| 38 | + // Repository for downloading BWC compatible JDBC driver releases |
| 39 | + url = 'https://artifacts.elastic.co/maven' |
| 40 | + } |
| 41 | + } |
25 | 42 |
|
26 | | -// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks |
27 | | -thirdPartyAudit.enabled = false |
| 43 | + configurations { |
| 44 | + jdbcDriver |
| 45 | + } |
28 | 46 |
|
29 | | -subprojects { |
30 | | - if (subprojects.isEmpty()) { |
31 | | - // leaf project |
32 | | - apply plugin: 'elasticsearch.standalone-rest-test' |
33 | | - } else { |
34 | | - apply plugin: 'elasticsearch.build' |
35 | | - } |
| 47 | + dependencies { |
| 48 | + testImplementation(xpackProject('plugin:sql:qa:jdbc')) |
36 | 49 |
|
37 | | - dependencies { |
38 | | - /* Since we're a standalone rest test we actually get transitive |
39 | | - * dependencies but we don't really want them because they cause |
40 | | - * all kinds of trouble with the jar hell checks. So we suppress |
41 | | - * them explicitly for non-es projects. */ |
42 | | - testImplementation(xpackProject('plugin:sql:qa:jdbc')) { |
43 | | - transitive = false |
44 | | - } |
45 | | - testImplementation project(":test:framework") |
| 50 | + // We use the shadowjar for testing since that's the actual artifact we deliver to users |
| 51 | + testCompileOnly project(path: xpackModule('sql:jdbc'), configuration: 'shadow') |
| 52 | + jdbcDriver project(path: xpackModule('sql:jdbc'), configuration: 'shadow') |
| 53 | + } |
46 | 54 |
|
47 | | - testRuntimeOnly project(path: xpackModule('sql:jdbc')) |
| 55 | + if (project.name != 'security') { |
| 56 | + // The security project just configures its subprojects |
| 57 | + apply plugin: 'elasticsearch.testclusters' |
| 58 | + apply plugin: 'elasticsearch.rest-test' |
| 59 | + |
| 60 | + testClusters.all { |
| 61 | + testDistribution = 'DEFAULT' |
| 62 | + setting 'xpack.ml.enabled', 'false' |
| 63 | + setting 'xpack.watcher.enabled', 'false' |
| 64 | + } |
| 65 | + |
| 66 | + integTest { |
| 67 | + runner { |
| 68 | + classpath += configurations.jdbcDriver |
| 69 | + systemProperty 'jdbc.driver.version', VersionProperties.elasticsearch |
| 70 | + } |
48 | 71 | } |
49 | 72 |
|
50 | | - if (project.name != 'security') { |
51 | | - // The security project just configures its subprojects |
52 | | - apply plugin: 'elasticsearch.testclusters' |
53 | | - apply plugin: 'elasticsearch.rest-test' |
| 73 | + // Configure compatibility testing tasks |
| 74 | + for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) { |
| 75 | + // Compatibility testing for JDBC driver started with version 7.9.0 |
| 76 | + if (bwcVersion.onOrAfter(Version.fromString("7.9.0")) && (bwcVersion.equals(VersionProperties.elasticsearchVersion) == false)) { |
| 77 | + String baseName = "v${bwcVersion}" |
| 78 | + UnreleasedVersionInfo unreleasedVersion = BuildParams.bwcVersions.unreleasedInfo(bwcVersion) |
| 79 | + Configuration driverConfiguration = configurations.create("jdbcDriver${baseName}") |
| 80 | + Object driverDependency = null |
| 81 | + |
| 82 | + if (unreleasedVersion) { |
| 83 | + // For unreleased snapshot versions, build them from source |
| 84 | + driverDependency = files(project(unreleasedVersion.gradleProjectPath).tasks.named('buildBwcJdbc')) |
| 85 | + } else { |
| 86 | + // For released versions, download it |
| 87 | + driverDependency = "org.elasticsearch.plugin:x-pack-sql-jdbc:${bwcVersion}" |
| 88 | + } |
| 89 | + |
| 90 | + dependencies { |
| 91 | + "jdbcDriver${baseName}"(driverDependency) |
| 92 | + } |
54 | 93 |
|
55 | | - testClusters.integTest { |
56 | | - testDistribution = 'DEFAULT' |
57 | | - setting 'xpack.ml.enabled', 'false' |
58 | | - setting 'xpack.watcher.enabled', 'false' |
| 94 | + tasks.create(bwcTaskName(bwcVersion), RestIntegTestTask) { |
| 95 | + runner { |
| 96 | + classpath += driverConfiguration |
| 97 | + systemProperty 'jdbc.driver.version', bwcVersion.toString() |
| 98 | + } |
59 | 99 | } |
| 100 | + } |
60 | 101 | } |
| 102 | + } |
61 | 103 | } |
0 commit comments