diff --git a/.gitignore b/.gitignore index 8b2a7335ade..b1a78d832e9 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ html_docs # random old stuff that we should look at the necessity of... /tmp/ eclipse-build + +# projects using testfixtures +testfixtures_shared/ diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java index a69448ecea7..bcde32b787b 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java @@ -35,6 +35,9 @@ import org.gradle.api.tasks.TaskContainer; import org.gradle.api.tasks.testing.Test; import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; import java.util.Collections; import java.util.function.BiConsumer; @@ -50,6 +53,10 @@ public class TestFixturesPlugin implements Plugin { "testFixtures", TestFixtureExtension.class, project ); + ExtraPropertiesExtension ext = project.getExtensions().getByType(ExtraPropertiesExtension.class); + File testfixturesDir = project.file("testfixtures_shared"); + ext.set("testFixturesDir", testfixturesDir); + if (project.file(DOCKER_COMPOSE_YML).exists()) { // convenience boilerplate with build plugin // Can't reference tasks that are implemented in Groovy, use reflection instead @@ -63,6 +70,14 @@ public class TestFixturesPlugin implements Plugin { Task buildFixture = project.getTasks().create("buildFixture"); Task pullFixture = project.getTasks().create("pullFixture"); Task preProcessFixture = project.getTasks().create("preProcessFixture"); + preProcessFixture.doFirst((task) -> { + try { + Files.createDirectories(testfixturesDir.toPath()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + preProcessFixture.getOutputs().dir(testfixturesDir); buildFixture.dependsOn(preProcessFixture); pullFixture.dependsOn(preProcessFixture); Task postProcessFixture = project.getTasks().create("postProcessFixture"); @@ -90,6 +105,9 @@ public class TestFixturesPlugin implements Plugin { pullFixture.dependsOn(tasks.getByName("composePull")); tasks.getByName("composeUp").mustRunAfter(preProcessFixture); tasks.getByName("composePull").mustRunAfter(preProcessFixture); + tasks.getByName("composeDown").doLast((task) -> { + project.delete(testfixturesDir); + }); configureServiceInfoForTask( postProcessFixture, diff --git a/plugins/repository-s3/docker-compose.yml b/plugins/repository-s3/docker-compose.yml index e44750550e2..74ef6d102dc 100644 --- a/plugins/repository-s3/docker-compose.yml +++ b/plugins/repository-s3/docker-compose.yml @@ -6,4 +6,4 @@ services: dockerfile: Dockerfile ports: - "9000" - command: ["server", "/minio/data"] \ No newline at end of file + command: ["server", "/minio/data"] diff --git a/test/fixtures/krb5kdc-fixture/build.gradle b/test/fixtures/krb5kdc-fixture/build.gradle index 8f145ba9092..0b9a40eca7f 100644 --- a/test/fixtures/krb5kdc-fixture/build.gradle +++ b/test/fixtures/krb5kdc-fixture/build.gradle @@ -29,14 +29,14 @@ List services = ["peppa", "hdfs"] preProcessFixture.doLast { // We need to create these up-front because if docker creates them they will be owned by root and we won't be // able to clean them up - services.each { file("${buildDir}/shared/${it}").mkdirs() } + services.each { file("${testFixturesDir}/shared/${it}").mkdirs() } } postProcessFixture { - inputs.dir("${buildDir}/shared") + inputs.dir("${testFixturesDir}/shared") services.each { service -> - File confTemplate = file("${buildDir}/shared/${service}/krb5.conf.template") - File confFile = file("${buildDir}/shared/${service}/krb5.conf") + File confTemplate = file("${testFixturesDir}/shared/${service}/krb5.conf.template") + File confFile = file("${testFixturesDir}/shared/${service}/krb5.conf") outputs.file(confFile) doLast { assert confTemplate.exists() @@ -47,7 +47,7 @@ postProcessFixture { } } -project.ext.krb5Conf = { service -> file("$buildDir/shared/${service}/krb5.conf") } -project.ext.krb5Keytabs = { service, fileName -> file("$buildDir/shared/${service}/keytabs/${fileName}") } +project.ext.krb5Conf = { service -> file("$testFixturesDir/shared/${service}/krb5.conf") } +project.ext.krb5Keytabs = { service, fileName -> file("$testFixturesDir/shared/${service}/keytabs/${fileName}") } test.enabled = false diff --git a/test/fixtures/krb5kdc-fixture/docker-compose.yml b/test/fixtures/krb5kdc-fixture/docker-compose.yml index 8e7108d58e5..f41e7a3c584 100644 --- a/test/fixtures/krb5kdc-fixture/docker-compose.yml +++ b/test/fixtures/krb5kdc-fixture/docker-compose.yml @@ -7,7 +7,7 @@ services: dockerfile: Dockerfile command: "bash /fixture/src/main/resources/provision/peppa.sh" volumes: - - ./build/shared/peppa:/fixture/build + - ./testfixtures_shared/shared/peppa:/fixture/build # containers have bad entropy so mount /dev/urandom. Less secure but this is a test fixture. - /dev/urandom:/dev/random ports: @@ -20,7 +20,7 @@ services: dockerfile: Dockerfile command: "bash /fixture/src/main/resources/provision/hdfs.sh" volumes: - - ./build/shared/hdfs:/fixture/build + - ./testfixtures_shared/shared/hdfs:/fixture/build # containers have bad entropy so mount /dev/urandom. Less secure but this is a test fixture. - /dev/urandom:/dev/random ports: