Build: Allow preserving shared dir (#24962)
This adds an option to `ClusterConfiguration` to preserve the `shared` directory when starting up a new cluster and switches the `qa:full-cluster-restart` tests to use it rather than disable the clean shared task. Relates to #24846
This commit is contained in:
parent
e22a68295c
commit
66007078d4
|
@ -76,6 +76,14 @@ class ClusterConfiguration {
|
|||
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +
|
||||
" " + System.getProperty('tests.jvm.argline', '')
|
||||
|
||||
/**
|
||||
* Should the shared environment be cleaned on cluster startup? Defaults
|
||||
* to {@code true} so we run with a clean cluster but some tests wish to
|
||||
* preserve snapshots between clusters so they set this to true.
|
||||
*/
|
||||
@Input
|
||||
boolean cleanShared = true
|
||||
|
||||
/**
|
||||
* A closure to call which returns the unicast host to connect to for cluster formation.
|
||||
*
|
||||
|
|
|
@ -54,14 +54,24 @@ class ClusterFormationTasks {
|
|||
*/
|
||||
static List<NodeInfo> setup(Project project, String prefix, Task runner, ClusterConfiguration config) {
|
||||
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: "${prefix}#prepareCluster.cleanShared", type: Delete, dependsOn: config.dependencies) {
|
||||
delete sharedDir
|
||||
doLast {
|
||||
sharedDir.mkdirs()
|
||||
}
|
||||
Object startDependencies = config.dependencies
|
||||
/* First, if we want a clean environment, 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. */
|
||||
if (config.cleanShared) {
|
||||
Task cleanup = project.tasks.create(
|
||||
name: "${prefix}#prepareCluster.cleanShared",
|
||||
type: Delete,
|
||||
dependsOn: startDependencies) {
|
||||
delete sharedDir
|
||||
doLast {
|
||||
sharedDir.mkdirs()
|
||||
}
|
||||
}
|
||||
startDependencies = cleanup
|
||||
}
|
||||
List<Task> startTasks = []
|
||||
List<NodeInfo> nodes = []
|
||||
|
@ -103,7 +113,7 @@ class ClusterFormationTasks {
|
|||
}
|
||||
NodeInfo node = new NodeInfo(config, i, project, prefix, elasticsearchVersion, sharedDir)
|
||||
nodes.add(node)
|
||||
Task dependsOn = startTasks.empty ? cleanup : startTasks.get(0)
|
||||
Object dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
|
||||
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, nodes.get(0)))
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ for (Version version : indexCompatVersions) {
|
|||
clusterName = 'full-cluster-restart'
|
||||
numNodes = 2
|
||||
dataDir = { nodeNum -> oldClusterTest.nodes[nodeNum].dataDir }
|
||||
cleanShared = false // We want to keep snapshots made by the old cluster!
|
||||
}
|
||||
|
||||
tasks.getByName("${baseName}#upgradedClusterTestRunner").configure {
|
||||
|
@ -78,13 +79,6 @@ for (Version version : indexCompatVersions) {
|
|||
dependsOn = [upgradedClusterTest]
|
||||
}
|
||||
|
||||
/* Delay this change because the task we need to modify isn't created until
|
||||
* after projects are evaluated. */
|
||||
gradle.projectsEvaluated {
|
||||
// Disable cleaning the repository so we can test loading a snapshot
|
||||
tasks.getByName("${baseName}#upgradedClusterTestCluster#prepareCluster.cleanShared").enabled = false
|
||||
}
|
||||
|
||||
bwcTest.dependsOn(versionBwcTest)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue