From 33e3822c5ded4a36742c354608f9ce4220a61029 Mon Sep 17 00:00:00 2001 From: Tim Vernum Date: Wed, 25 Jul 2018 14:14:19 +1000 Subject: [PATCH 1/4] Fix JarHell on X-Pack protocol Ports 466bc8c from 6.x --- x-pack/qa/kerberos-tests/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/qa/kerberos-tests/build.gradle b/x-pack/qa/kerberos-tests/build.gradle index 5caf5d6947e..2981c0e4ec6 100644 --- a/x-pack/qa/kerberos-tests/build.gradle +++ b/x-pack/qa/kerberos-tests/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') } From d0fd23669add7e72e0f344337dc66f6c1c43a2f1 Mon Sep 17 00:00:00 2001 From: Ioannis Kakavas Date: Wed, 25 Jul 2018 08:48:19 +0300 Subject: [PATCH 2/4] Enable FIPS JVM in CI (#32330) Now that #31666 and #31989 are merged we can run our tests in fips JVM. This commits enables us to run tests on a Java 8 JVM using BouncyCastleFIPS as a security Provider. --- .ci/matrix-runtime-javas.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/matrix-runtime-javas.yml b/.ci/matrix-runtime-javas.yml index 737e15ada20..ca7db3b5513 100644 --- a/.ci/matrix-runtime-javas.yml +++ b/.ci/matrix-runtime-javas.yml @@ -7,5 +7,6 @@ ES_RUNTIME_JAVA: - java8 + - java8fips - java10 - java11 From b6c14935d725bbe404707ef1d363d8c504a88155 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 25 Jul 2018 06:21:03 +0000 Subject: [PATCH 3/4] Determine the minimum gradle version based on the wrapper (#32226) * Determine the minimum gradle version based on the wrapper This is restrictive and forces users of the plugin to move together with us, but without integration tests it's close to impossible to make sure that the claimed compatability is really there. If we do want to offer more flexibility, we should add those tests first. * Track gradle version in individual file * PR review --- build.gradle | 14 ++++++------- buildSrc/build.gradle | 5 +++-- .../elasticsearch/gradle/BuildPlugin.groovy | 19 +++++++++--------- .../src/main/resources/minimumGradleVersion | 1 + gradle/wrapper/gradle-wrapper.jar | Bin 54417 -> 54413 bytes 5 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 buildSrc/src/main/resources/minimumGradleVersion diff --git a/build.gradle b/build.gradle index 8df89cb064c..3674e0a540b 100644 --- a/build.gradle +++ b/build.gradle @@ -16,21 +16,17 @@ * specific language governing permissions and limitations * under the License. */ - import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin -import org.apache.tools.ant.taskdefs.condition.Os -import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionCollection import org.elasticsearch.gradle.VersionProperties import org.gradle.plugins.ide.eclipse.model.SourceFolder - -import org.gradle.api.tasks.wrapper.Wrapper -import org.gradle.api.tasks.wrapper.Wrapper.DistributionType import org.gradle.util.GradleVersion import org.gradle.util.DistributionLocator +import org.apache.tools.ant.taskdefs.condition.Os +import org.apache.tools.ant.filters.ReplaceTokens import java.nio.file.Files import java.nio.file.Path @@ -562,7 +558,7 @@ task run(type: Run) { } wrapper { - distributionType = DistributionType.ALL + distributionType = 'ALL' doLast { final DistributionLocator locator = new DistributionLocator() final GradleVersion version = GradleVersion.version(wrapper.gradleVersion) @@ -571,6 +567,10 @@ wrapper { final String sha256Sum = new String(sha256Uri.toURL().bytes) wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n" println "Added checksum to wrapper properties" + // Update build-tools to reflect the Gradle upgrade + // TODO: we can remove this once we have tests to make sure older versions work. + project(':build-tools').file('src/main/resources/minimumGradleVersion').text = gradleVersion + println "Updated minimum Gradle Version" } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 55520728812..d507c54c45a 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -25,8 +25,9 @@ plugins { group = 'org.elasticsearch.gradle' -if (GradleVersion.current() < GradleVersion.version('4.9')) { - throw new GradleException('Gradle 4.9+ is required to build elasticsearch') +String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim() +if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) { + throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch") } if (JavaVersion.current() < JavaVersion.VERSION_1_8) { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 94a8bf26177..5a962a5138b 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -20,6 +20,7 @@ package org.elasticsearch.gradle import com.carrotsearch.gradle.junit4.RandomizedTestingTask import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin +import org.apache.commons.io.IOUtils import org.apache.tools.ant.taskdefs.condition.Os import org.eclipse.jgit.lib.Constants import org.eclipse.jgit.lib.RepositoryBuilder @@ -53,6 +54,7 @@ import org.gradle.internal.jvm.Jvm import org.gradle.process.ExecResult import org.gradle.util.GradleVersion +import java.nio.charset.StandardCharsets import java.time.ZoneOffset import java.time.ZonedDateTime /** @@ -67,8 +69,13 @@ class BuildPlugin implements Plugin { + 'elasticearch.standalone-rest-test, and elasticsearch.build ' + 'are mutually exclusive') } - if (GradleVersion.current() < GradleVersion.version('4.9')) { - throw new GradleException('Gradle 4.9+ is required to use elasticsearch.build plugin') + final String minimumGradleVersion + InputStream is = getClass().getResourceAsStream("/minimumGradleVersion") + try { minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString()) } finally { is.close() } + if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) { + throw new GradleException( + "Gradle ${minimumGradleVersion}+ is required to use elasticsearch.build plugin" + ) } project.pluginManager.apply('java') project.pluginManager.apply('carrotsearch.randomized-testing') @@ -153,14 +160,6 @@ class BuildPlugin implements Plugin { } println " Random Testing Seed : ${project.testSeed}" - // enforce Gradle version - final GradleVersion currentGradleVersion = GradleVersion.current(); - - final GradleVersion minGradle = GradleVersion.version('4.3') - if (currentGradleVersion < minGradle) { - throw new GradleException("${minGradle} or above is required to build Elasticsearch") - } - // enforce Java version if (compilerJavaVersionEnum < minimumCompilerVersion) { final String message = diff --git a/buildSrc/src/main/resources/minimumGradleVersion b/buildSrc/src/main/resources/minimumGradleVersion new file mode 100644 index 00000000000..899dd4f5927 --- /dev/null +++ b/buildSrc/src/main/resources/minimumGradleVersion @@ -0,0 +1 @@ +4.9 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 758de960ec7947253b058ff79c88ce51f3abe08a..0d4a9516871afd710a9d84d89e31ba77745607bd 100644 GIT binary patch delta 732 zcmYk4Ur19?9LINl)~4m3n;~1*r8tRj;+ldsTG*&j;mD0LiLwYROK2iKWQ|?~A0o3h zzap4_7J?6pUPQ=BD%&6DHm6Q~$R4bh2%#5!>&Z@s+uDW0{d~^%+{^czdwqed{y>)Z zc+T&yL!MJAm8!{SYf|rYZFe!1SDt!vF<7`q<#K4UACyiSVEQmpTWJ* zCH4Yyp=$OKJ0T0(LXSg>)8PuzGk9Y~a55RAVIwuGg?b~|_z|w56PmQvMb6Mjj-nRY z(x#K25gTpjgx1eD(Bo2p{&_ncGbpGYh+64zl`vOT0mdT|v?eK+msKu}NrWG2H3&p& z=t-@jdDx8_DRo|`ZJ~~CIRy4EIH}`;f_VcmGv8lz>^k${dF(1Rx9~&{Z%aNJQWB2D zW!4H?+{J?M#ZR(rEX8loqq`_*JA`wIMk;e7)u+cbw-)h)k!CuCwj@e%v@^4%wo?S{ zi*>97FBdP?lmGw# delta 674 zcmYk)T}V@590u^ce`_BwX^}IxS%%_;lVr!`V#{7~K>D!@P~?^<`NH4(Ing@BclV!#Ts#S?=kqkqXuP zh4b|_GMTK^ZEaC})BWsS?`2rD8(zFT^*$$2zD;)0rchoVsqNJAp+Rb5f&VDlMi zQYES(UnQk?Z>@gyS?N=rh)4VlG+4lCz=!dlOI4&Q6MV!u zbVzV*se)1`1TBHXk#o* z@F>~s=(iW+T*%107!Fxz!;Wl6Iev$X)Yr|aLv6T;iY{T%osXGt4SR+4a4YGYqG)!i z`5iSFi0EnGRbCZgAz~)AORzt>9ZfDROi?2}zLBXcG2Lu~p&2;mQ;Ja8o z&D|9&iPzEWJ Date: Wed, 25 Jul 2018 06:22:54 +0000 Subject: [PATCH 4/4] Number of utilities for writing gradle integration tests (#32282) These are collected from a number of open PRs and are required to improove existing and write more readable future tests. I am extracting them to their own PR hoping to be able to merge and use them sooner. --- .../test/GradleIntegrationTestCase.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java b/buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java index 26da663182f..5c36fa61550 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java @@ -1,6 +1,11 @@ package org.elasticsearch.gradle.test; +import org.gradle.testkit.runner.GradleRunner; + import java.io.File; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; public abstract class GradleIntegrationTestCase extends GradleUnitTestCase { @@ -13,4 +18,47 @@ public abstract class GradleIntegrationTestCase extends GradleUnitTestCase { return new File(root, name); } + protected GradleRunner getGradleRunner(String sampleProject) { + return GradleRunner.create() + .withProjectDir(getProjectDir(sampleProject)) + .withPluginClasspath(); + } + + protected File getBuildDir(String name) { + return new File(getProjectDir(name), "build"); + } + + protected void assertOutputContains(String output, String... lines) { + for (String line : lines) { + assertOutputContains(output, line); + } + List index = Stream.of(lines).map(line -> output.indexOf(line)).collect(Collectors.toList()); + if (index.equals(index.stream().sorted().collect(Collectors.toList())) == false) { + fail("Expected the following lines to appear in this order:\n" + + Stream.of(lines).map(line -> " - `" + line + "`").collect(Collectors.joining("\n")) + + "\nBut they did not. Output is:\n\n```" + output + "\n```\n" + ); + } + } + + protected void assertOutputContains(String output, String line) { + assertTrue( + "Expected the following line in output:\n\n" + line + "\n\nOutput is:\n" + output, + output.contains(line) + ); + } + + protected void assertOutputDoesNotContain(String output, String line) { + assertFalse( + "Expected the following line not to be in output:\n\n" + line + "\n\nOutput is:\n" + output, + output.contains(line) + ); + } + + protected void assertOutputDoesNotContain(String output, String... lines) { + for (String line : lines) { + assertOutputDoesNotContain(line); + } + } + }