From e6a124c1184e4be2f80ba69221b7c4a0bef9dc0b Mon Sep 17 00:00:00 2001 From: James Baiera Date: Mon, 25 Feb 2019 14:39:34 -0500 Subject: [PATCH] [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 --- .../elasticsearch/gradle/doc/DocsTestPlugin.groovy | 2 ++ .../gradle/test/ClusterFormationTasks.groovy | 11 ++++++----- docs/Versions.asciidoc | 1 + docs/plugins/discovery-azure-classic.asciidoc | 2 +- docs/reference/cluster/nodes-info.asciidoc | 4 ++-- docs/reference/setup/install/check-running.asciidoc | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index ce76ad5d28f..a0ce24e45c7 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -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' diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 7a0a7d9436e..e750385a669 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -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 diff --git a/docs/Versions.asciidoc b/docs/Versions.asciidoc index 0ca2bcf0be2..f1c93cdf88f 100644 --- a/docs/Versions.asciidoc +++ b/docs/Versions.asciidoc @@ -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 diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index 61161836e1a..d1088a764e7 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -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, diff --git a/docs/reference/cluster/nodes-info.asciidoc b/docs/reference/cluster/nodes-info.asciidoc index 9d53c8715d5..c51167ca9f9 100644 --- a/docs/reference/cluster/nodes-info.asciidoc +++ b/docs/reference/cluster/nodes-info.asciidoc @@ -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": {}, diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index 150252ecc5d..6a9bab2ae09 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -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,