Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow preserving shared dir for full-cluster-restart tests #24962

Merged
merged 3 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)))
}

Expand Down
8 changes: 1 addition & 7 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down