Skip to content

Commit 3ecf401

Browse files
committed
Make reuse of sql test code explicit
The sql project uses a common set of security tests, which are run in subprojects. Currently these are shared through a shared directory, but this is not setup correctly to ensure it is built before tests run. This commit changes the test classes to be an artifact of the sql/qa/security project and makes the test runner use the built artifact (a directory of classes) for tests. closes elastic#45866
1 parent 0412504 commit 3ecf401

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

x-pack/plugin/sql/qa/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ forbiddenApisMain {
4747
thirdPartyAudit.enabled = false
4848

4949
subprojects {
50+
if (subprojects.isEmpty() == false) {
51+
return // not a leaf project
52+
}
5053
apply plugin: 'elasticsearch.standalone-rest-test'
5154
dependencies {
5255

x-pack/plugin/sql/qa/security/build.gradle

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
apply plugin: 'elasticsearch.build'
3+
14
dependencies {
25
testCompile project(':x-pack:plugin:core')
36
}
@@ -6,27 +9,23 @@ Project mainProject = project
69

710
group = "${group}.x-pack.qa.sql.security"
811

12+
configurations.create('testClasses')
13+
14+
String classesDir = project.file(project.sourceSets.main.output.classesDirs.singleFile).toString()
15+
artifacts.add('testClasses', project.layout.projectDirectory.dir(classesDir)) {
16+
builtBy tasks.named('testClasses')
17+
}
18+
919
// Tests are pushed down to subprojects and will be checked there.
1020
testingConventions.enabled = false
1121

1222
subprojects {
13-
// Use resources from the parent project in subprojects
14-
sourceSets {
15-
test {
16-
mainProject.sourceSets.test.output.classesDirs.each { dir ->
17-
output.addClassesDir { dir }
18-
output.builtBy(mainProject.tasks.testClasses)
19-
}
20-
runtimeClasspath += mainProject.sourceSets.test.output
21-
}
22-
}
23-
24-
processTestResources {
25-
from mainProject.file('src/test/resources')
26-
}
23+
// Use tests from the root security qa project in subprojects
24+
configurations.create('testClasses')
2725

2826
dependencies {
2927
testCompile project(":x-pack:plugin:core")
28+
testClasses project(path: mainProject.path, configuration: 'testClasses')
3029
}
3130

3231
testClusters.integTest {
@@ -43,6 +42,8 @@ subprojects {
4342
}
4443

4544
integTest.runner {
45+
dependsOn configurations.testClasses
46+
testClassesDirs += project.files(configurations.testClasses.singleFile)
4647
nonInputProperties.systemProperty 'tests.audit.logfile',
4748
"${ -> testClusters.integTest.singleNode().getAuditLog()}"
4849
nonInputProperties.systemProperty 'tests.audit.yesterday.logfile',

0 commit comments

Comments
 (0)