
org.xbib.gradle.task.elasticsearch.test.ClusterConfiguration.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin-elasticsearch-build Show documentation
Show all versions of gradle-plugin-elasticsearch-build Show documentation
Gradle plugins for the developer kit for building and testing Elasticsearch and Elasticsearch plugins
The newest version!
package org.xbib.gradle.task.elasticsearch.test
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.tasks.Input
/** Configuration for an elasticsearch cluster, used for integration tests. */
class ClusterConfiguration {
private final Project project
@Input
String distribution = 'integ-test-tar'
@Input
int numNodes = 1
@Input
int numBwcNodes = 0
@Input
String bwcVersion = null
@Input
int httpPort = 0
@Input
int transportPort = 0
/**
* An override of the data directory. Input is the node number and output
* is the override data directory.
*/
@Input
Closure dataDir = null
/** Optional override of the cluster name. */
@Input
String clusterName = null
@Input
boolean daemonize = true
@Input
boolean debug = false
/**
* Configuration of the setting discovery.zen.minimum_master_nodes on the nodes.
* In case of more than one node, this defaults to the number of nodes
*/
@Input
Closure minimumMasterNodes = { getNumNodes() > 1 ? getNumNodes() : -1 }
@Input
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '1g') +
" " + "-Xmx" + System.getProperty('tests.heap.size', '1g') +
" " + 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.
*
* This allows multi node clusters, or a new cluster to connect to an existing cluster.
* The closure takes two arguments, the NodeInfo for the first node in the cluster, and
* an AntBuilder which may be used to wait on conditions before returning.
*/
@Input
Closure unicastTransportUri = { NodeInfo seedNode, NodeInfo node, AntBuilder ant ->
if (seedNode == node) {
return null
}
ant.waitfor(maxwait: '40', maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond') {
resourceexists {
file(file: seedNode.transportPortsFile.toString())
}
}
return seedNode.transportUri()
}
/**
* A closure to call before the cluster is considered ready. The closure is passed the node info,
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
* condition is for http on the http port.
*/
@Input
Closure waitCondition = { NodeInfo node, AntBuilder ant ->
File tmpFile = new File(node.cwd, 'wait.success')
String waitUrl = "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow"
ant.echo(message: "==> [${new Date()}] checking health: ${waitUrl}",
level: 'info')
// checking here for wait_for_nodes to be >= the number of nodes because its possible
// this cluster is attempting to connect to nodes created by another task (same cluster name),
// so there will be more nodes in that case in the cluster state
ant.get(src: waitUrl,
dest: tmpFile.toString(),
ignoreerrors: true, // do not fail on error, so logging buffers can be flushed by the wait task
retries: 10)
return tmpFile.exists()
}
/**
* The maximum number of seconds to wait for nodes to complete startup, which includes writing
* the ports files for the transports and the pid file. This wait time occurs before the wait
* condition is executed.
*/
@Input
int nodeStartupWaitSeconds = 30
public ClusterConfiguration(Project project) {
this.project = project
}
Map systemProperties = new HashMap<>()
Map environmentVariables = new HashMap<>()
Map settings = new HashMap<>()
Map keystoreSettings = new HashMap<>()
// map from destination path, to source file
Map extraConfigFiles = new HashMap<>()
LinkedHashMap plugins = new LinkedHashMap<>()
List modules = new ArrayList<>()
LinkedHashMap setupCommands = new LinkedHashMap<>()
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy