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

TESTS: Use File Based Discovery in REST Tests #34560

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5d9d619
TESTS: Use File Based Discovery in REST Tests
original-brownbear Oct 17, 2018
48decc7
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 17, 2018
50a8033
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 17, 2018
cd50d89
Use file based discovery in 6.x as well
original-brownbear Oct 17, 2018
a3128ac
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 18, 2018
ca832d2
Don't use file based discovery when other discovery mechanism is conf…
original-brownbear Oct 18, 2018
dcf5625
Merge branch 'master' into rest-tests-file-discovery
original-brownbear Oct 18, 2018
8ba68ce
only use file based discovery in 6.5+
original-brownbear Oct 18, 2018
3e0251c
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 19, 2018
48d2c87
Fix unicast hosts returned as csv erring out and order of ready checks
original-brownbear Oct 19, 2018
8dfc3d2
CR comments
original-brownbear Oct 19, 2018
0fd5217
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 19, 2018
a3b9e55
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 20, 2018
2052e0c
CR: only compute unicast hosts txt once
original-brownbear Oct 20, 2018
391a8a6
CR: Don't depend on the seed node starting up for other nodes to star…
original-brownbear Oct 20, 2018
fca6c93
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 22, 2018
33f044a
CR: Different code paths for 6.5+ and older versions, minimum number …
original-brownbear Oct 22, 2018
7d32ba4
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 23, 2018
61bc8ad
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 23, 2018
f641b82
increase timeout
original-brownbear Oct 23, 2018
97420c5
TEST: Make other nodes depend on first node
original-brownbear Oct 23, 2018
5c332d0
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 23, 2018
ed3b328
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 24, 2018
9a9bf8d
Merge remote-tracking branch 'elastic/master' into rest-tests-file-di…
original-brownbear Oct 24, 2018
ac02a81
back to correct task order
original-brownbear Oct 24, 2018
622231d
try reverting master node count change
original-brownbear Oct 24, 2018
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 @@ -68,7 +68,13 @@ class ClusterConfiguration {
* In case of more than one node, this defaults to the number of nodes
*/
@Input
Closure<Integer> minimumMasterNodes = { getNumNodes() > 1 ? getNumNodes() : -1 }
Closure<Integer> minimumMasterNodes = {
if (bwcVersion != null && bwcVersion.before("6.5.0-SNAPSHOT")) {
return getNumNodes() > 1 ? getNumNodes() : -1
} else {
return getNumNodes() > 1 ? getNumNodes().intdiv(2) + 1 : -1
}
}

@Input
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
Expand Down Expand Up @@ -131,7 +137,7 @@ class ClusterConfiguration {
* condition is executed.
*/
@Input
int nodeStartupWaitSeconds = 30
int nodeStartupWaitSeconds = 120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not do this - I think there's something wrong with the discovery plugin tests.


public ClusterConfiguration(Project project) {
this.project = project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,31 @@ class ClusterFormationTasks {
}
NodeInfo node = new NodeInfo(config, i, project, prefix, elasticsearchVersion, sharedDir)
nodes.add(node)
Object dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, nodes.get(0)))
Closure<Map> writeConfigSetup
Object dependsOn
if (node.nodeVersion.onOrAfter("6.5.0-SNAPSHOT")) {
writeConfigSetup = { Map esConfig ->
// Don't force discovery provider if one is set by the test cluster specs already
if (esConfig.containsKey('discovery.zen.hosts_provider') == false) {
esConfig['discovery.zen.hosts_provider'] = 'file'
}
esConfig['discovery.zen.ping.unicast.hosts'] = []
esConfig
}
dependsOn = startDependencies
} else {
dependsOn = startTasks.empty ? startDependencies : startTasks.get(0)
writeConfigSetup = { Map esConfig ->
String unicastTransportUri = node.config.unicastTransportUri(nodes[0], node, project.ant)
if (unicastTransportUri == null) {
esConfig['discovery.zen.ping.unicast.hosts'] = []
} else {
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
}
esConfig
}
}
startTasks.add(configureNode(project, prefix, runner, dependsOn, node, config, distro, writeConfigSetup))
}

Task wait = configureWaitTask("${prefix}#wait", project, nodes, startTasks, config.nodeStartupWaitSeconds)
Expand Down Expand Up @@ -182,7 +205,7 @@ class ClusterFormationTasks {
* @return a task which starts the node.
*/
static Task configureNode(Project project, String prefix, Task runner, Object dependsOn, NodeInfo node, ClusterConfiguration config,
Configuration distribution, NodeInfo seedNode) {
Configuration distribution, Closure<Map> writeConfig) {

// tasks are chained so their execution order is maintained
Task setup = project.tasks.create(name: taskName(prefix, node, 'clean'), type: Delete, dependsOn: dependsOn) {
Expand All @@ -198,7 +221,7 @@ class ClusterFormationTasks {
setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node)
setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node)
setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution)
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, seedNode)
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, writeConfig)
setup = configureCreateKeystoreTask(taskName(prefix, node, 'createKeystore'), project, setup, node)
setup = configureAddKeystoreSettingTasks(prefix, project, setup, node)
setup = configureAddKeystoreFileTasks(prefix, project, setup, node)
Expand Down Expand Up @@ -301,7 +324,7 @@ class ClusterFormationTasks {
}

/** Adds a task to write elasticsearch.yml for the given node configuration */
static Task configureWriteConfigTask(String name, Project project, Task setup, NodeInfo node, NodeInfo seedNode) {
static Task configureWriteConfigTask(String name, Project project, Task setup, NodeInfo node, Closure<Map> configFilter) {
Map esConfig = [
'cluster.name' : node.clusterName,
'node.name' : "node-" + node.nodeNum,
Expand Down Expand Up @@ -347,10 +370,7 @@ class ClusterFormationTasks {

Task writeConfig = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup)
writeConfig.doFirst {
String unicastTransportUri = node.config.unicastTransportUri(seedNode, node, project.ant)
if (unicastTransportUri != null) {
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
}
esConfig = configFilter.call(esConfig)
File configFile = new File(node.pathConf, 'elasticsearch.yml')
logger.info("Configuring ${configFile}")
configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8')
Expand Down Expand Up @@ -681,6 +701,19 @@ class ClusterFormationTasks {
static Task configureWaitTask(String name, Project project, List<NodeInfo> nodes, List<Task> startTasks, int waitSeconds) {
Task wait = project.tasks.create(name: name, dependsOn: startTasks)
wait.doLast {

Collection<String> unicastHosts = new HashSet<>()
nodes.forEach { otherNode ->
String unicastHost = otherNode.config.unicastTransportUri(otherNode, null, project.ant)
if (unicastHost != null) {
unicastHosts.addAll(Arrays.asList(unicastHost.split(",")))
}
}
String unicastHostsTxt = String.join("\n", unicastHosts)
nodes.forEach { node ->
node.pathConf.toPath().resolve("unicast_hosts.txt").setText(unicastHostsTxt)
}

ant.waitfor(maxwait: "${waitSeconds}", maxwaitunit: 'second', checkevery: '500', checkeveryunit: 'millisecond', timeoutproperty: "failed${name}") {
or {
for (NodeInfo node : nodes) {
Expand Down