diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 97073c67cfe..a82fefdc510 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -53,12 +53,15 @@ class ClusterFormationTasks { // no need to add cluster formation tasks if the task won't run! return } - // first we remove everything in the cluster directory to ensure there are no leftovers in repos or anything - // this also forces unpacking of nodes and wipes logfiles etc. to prevent leftovers along those lines + File sharedDir = new File(project.buildDir, "cluster/shared") + // first we remove everything in the shared cluster directory to ensure there are no leftovers in repos or anything // in theory this should not be necessary but repositories are only deleted in the cluster-state and not on-disk // such that snapshots survive failures / test runs and there is no simple way today to fix that. - Task cleanup = project.tasks.create(name: "${task.name}#prepareCluster.clean", type: Delete, dependsOn: task.dependsOn.collect()) { - delete new File(project.buildDir, "cluster"); + Task cleanup = project.tasks.create(name: "${task.name}#prepareCluster.cleanShared", type: Delete, dependsOn: task.dependsOn.collect()) { + delete sharedDir + doLast { + sharedDir.mkdirs() + } } List startTasks = [cleanup] List nodes = [] @@ -93,7 +96,7 @@ class ClusterFormationTasks { elasticsearchVersion = config.bwcVersion configuration = project.configurations.elasticsearchBwcDistro } - NodeInfo node = new NodeInfo(config, i, project, task, elasticsearchVersion) + NodeInfo node = new NodeInfo(config, i, project, task, elasticsearchVersion, sharedDir) if (i == 0) { if (config.seedNodePortsFile != null) { // we might allow this in the future to be set but for now we are the only authority to set this! @@ -252,8 +255,8 @@ class ClusterFormationTasks { Map esConfig = [ 'cluster.name' : node.clusterName, 'pidfile' : node.pidFile, - 'path.repo' : "${node.baseDir}/../repo", - 'path.shared_data' : "${node.baseDir}/../", + 'path.repo' : "${node.sharedDir}/repo", + 'path.shared_data' : "${node.sharedDir}/", // Define a node attribute so we can test that it exists 'node.testattr' : 'test', 'repositories.url.allowed_urls': 'http://snapshot.test*' diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy index 5dcdcbed5f8..6f45cddf77e 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy @@ -40,6 +40,9 @@ class NodeInfo { /** root directory all node files and operations happen under */ File baseDir + /** shared data directory all nodes share */ + File sharedDir + /** the pid file the node will use */ File pidFile @@ -89,9 +92,10 @@ class NodeInfo { ByteArrayOutputStream buffer = new ByteArrayOutputStream() /** Creates a node to run as part of a cluster for the given task */ - NodeInfo(ClusterConfiguration config, int nodeNum, Project project, Task task, String nodeVersion) { + NodeInfo(ClusterConfiguration config, int nodeNum, Project project, Task task, String nodeVersion, File sharedDir) { this.config = config this.nodeNum = nodeNum + this.sharedDir = sharedDir clusterName = "${task.path.replace(':', '_').substring(1)}" baseDir = new File(project.buildDir, "cluster/${task.name} node${nodeNum}") pidFile = new File(baseDir, 'es.pid')