[Backport 7.x] Fix the OS sensing code in ClusterFormationTasks (#38457)

This fixes a bug in the sensing of the current OS family in the test cluster
formation code. Previously all builds would assume every environment 
was windows and would jump to using the windows zip build. This fixes 
the OS sensing code as well as updates some tests to account for 
different build flavors.

Backport of #38457
This commit is contained in:
James Baiera 2019-02-25 14:39:34 -05:00 committed by GitHub
parent 1897883adc
commit e6a124c118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 9 deletions

View File

@ -20,6 +20,7 @@ package org.elasticsearch.gradle.doc
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.test.ClusterFormationTasks
import org.elasticsearch.gradle.test.RestTestPlugin
import org.gradle.api.Project
import org.gradle.api.Task
@ -46,6 +47,7 @@ public class DocsTestPlugin extends RestTestPlugin {
'\\{version_qualified\\}': VersionProperties.elasticsearch,
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
'\\{build_flavor\\}' : project.integTestCluster.distribution,
'\\{build_type\\}' : ClusterFormationTasks.getOs().equals("windows") ? "zip" : "tar",
]
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
listSnippets.group 'Docs'

View File

@ -274,7 +274,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 = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution, config.distribution)
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)
@ -343,14 +343,15 @@ class ClusterFormationTasks {
}
/** Adds a task to extract the elasticsearch distribution */
static Task configureExtractTask(String name, Project project, Task setup, NodeInfo node, Configuration configuration) {
static Task configureExtractTask(String name, Project project, Task setup, NodeInfo node,
Configuration configuration, String distribution) {
List extractDependsOn = [configuration, setup]
/* configuration.singleFile will be an external artifact if this is being run by a plugin not living in the
elasticsearch source tree. If this is a plugin built in the elasticsearch source tree or this is a distro in
the elasticsearch source tree then this should be the version of elasticsearch built by the source tree.
If it isn't then Bad Things(TM) will happen. */
Task extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
if (getOs().equals("windows")) {
if (getOs().equals("windows") || distribution.equals("integ-test-zip") || node.nodeVersion.before("7.0.0")) {
from {
project.zipTree(configuration.singleFile)
}
@ -971,9 +972,9 @@ class ClusterFormationTasks {
/** Find the current OS */
static String getOs() {
String os = "linux"
if (Os.FAMILY_WINDOWS) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
os = "windows"
} else if (Os.FAMILY_MAC) {
} else if (Os.isFamily(Os.FAMILY_MAC)) {
os = "darwin"
}
return os

View File

@ -6,6 +6,7 @@
:jdk: 1.8.0_131
:jdk_major: 8
:build_flavor: default
:build_type: tar
//////////
release-state can be: released | prerelease | unreleased

View File

@ -374,7 +374,7 @@ This command should give you a JSON result:
"version" : {
"number" : "{version_qualified}",
"build_flavor" : "{build_flavor}",
"build_type" : "zip",
"build_type" : "{build_type}",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,

View File

@ -143,7 +143,7 @@ The result will look similar to:
"ip": "192.168.17",
"version": "{version}",
"build_flavor": "{build_flavor}",
"build_type": "zip",
"build_type": "{build_type}",
"build_hash": "587409e",
"roles": [
"master",
@ -224,7 +224,7 @@ The result will look similar to:
"ip": "192.168.17",
"version": "{version}",
"build_flavor": "{build_flavor}",
"build_type": "zip",
"build_type": "{build_type}",
"build_hash": "587409e",
"roles": [],
"attributes": {},

View File

@ -20,7 +20,7 @@ which should give you a response something like this:
"version" : {
"number" : "{version_qualified}",
"build_flavor" : "{build_flavor}",
"build_type" : "zip",
"build_type" : "{build_type}",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,