Skip to content

Commit b15c0e7

Browse files
committed
Merge branch 'master' into searchable-snapshots
2 parents 003bb24 + a32d4cf commit b15c0e7

File tree

2,000 files changed

+37873
-21532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,000 files changed

+37873
-21532
lines changed

.ci/bwcVersions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ BWC_VERSION:
2626
- "7.9.2"
2727
- "7.9.3"
2828
- "7.10.0"
29+
- "7.11.0"
2930
- "8.0.0"

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ specifically these lines tell you that Elasticsearch is ready:
137137
[2020-05-29T14:50:35,167][INFO ][o.e.h.AbstractHttpServerTransport] [runTask-0] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
138138
[2020-05-29T14:50:35,169][INFO ][o.e.n.Node ] [runTask-0] started
139139

140-
But to be honest its typically easier to wait until the console stopps scrolling
140+
But to be honest its typically easier to wait until the console stops scrolling
141141
and then run `curl` in another window like this:
142142

143143
curl -u elastic:password localhost:9200
@@ -166,7 +166,7 @@ You can import the Elasticsearch project into IntelliJ IDEA via:
166166
Elasticsearch builds using Gradle and Java 14. When importing into Eclipse you
167167
will either need to use an appropriate JDK to run Eclipse itself (e.g. by
168168
specifying the VM in [eclipse.ini](https://wiki.eclipse.org/Eclipse.ini) or by
169-
defining the JDK Gradle uses by setting **Prefercences** > **Gradle** >
169+
defining the JDK Gradle uses by setting **Preferences** > **Gradle** >
170170
**Advanced Options** > **Java home** to an appropriate version.
171171

172172
IMPORTANT: If you have previously imported the project by running `./gradlew eclipse`
@@ -587,13 +587,13 @@ allows you to use these configurations arbitrarily. Here are some of the most
587587
common configurations in our build and how we use them:
588588

589589
<dl>
590-
<dt>`implementation`</dt><dd>Dependencies that are used by the project
590+
<dt>`implementation`</dt><dd>Dependencies that are used by the project
591591
at compile and runtime but are not exposed as a compile dependency to other dependent projects.
592-
Dependencies added to the `implementation` configuration are considered an implementation detail
592+
Dependencies added to the `implementation` configuration are considered an implementation detail
593593
that can be changed at a later date without affecting any dependent projects.</dd>
594-
<dt>`api`</dt><dd>Dependencies that are used as compile and runtime depdendencies of a project
594+
<dt>`api`</dt><dd>Dependencies that are used as compile and runtime dependencies of a project
595595
and are considered part of the external api of the project.
596-
<dt>`runtimeOnly`</dt><dd>Dependencies that not on the classpath at compile time but
596+
<dt>`runtimeOnly`</dt><dd>Dependencies that not on the classpath at compile time but
597597
are on the classpath at runtime. We mostly use this configuration to make sure that
598598
we do not accidentally compile against dependencies of our dependencies also
599599
known as "transitive" dependencies".</dd>

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.common.transport.TransportAddress;
3636
import org.elasticsearch.common.util.set.Sets;
3737
import org.elasticsearch.gateway.GatewayAllocator;
38+
import org.elasticsearch.snapshots.EmptySnapshotsInfoService;
3839

3940
import java.util.Collection;
4041
import java.util.Collections;
@@ -79,7 +80,8 @@ public static AllocationService createAllocationService(Settings settings, Clust
7980
defaultAllocationDeciders(settings, clusterSettings),
8081
NoopGatewayAllocator.INSTANCE,
8182
new BalancedShardsAllocator(settings),
82-
EmptyClusterInfoService.INSTANCE
83+
EmptyClusterInfoService.INSTANCE,
84+
EmptySnapshotsInfoService.INSTANCE
8385
);
8486
}
8587

buildSrc/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ dependencies {
9696
api 'org.apache.ant:ant:1.10.8'
9797
api 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
9898
api 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
99-
api 'com.netflix.nebula:gradle-info-plugin:7.1.3'
99+
api 'com.netflix.nebula:gradle-info-plugin:9.1.1'
100100
api 'org.apache.rat:apache-rat:0.11'
101101
api "org.elasticsearch:jna:5.5.0"
102-
api 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
103-
api 'de.thetaphi:forbiddenapis:3.0'
104-
api 'com.avast.gradle:gradle-docker-compose-plugin:0.12.1'
102+
api 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
103+
api 'de.thetaphi:forbiddenapis:3.1'
104+
api 'com.avast.gradle:gradle-docker-compose-plugin:0.13.4'
105105
api 'org.apache.maven:maven-model:3.6.2'
106106
api 'com.networknt:json-schema-validator:1.0.36'
107107
compileOnly "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/JdkDownloadPluginFuncTest.groovy

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
8989
"darwin" | VENDOR_ADOPTOPENJDK | ADOPT_JDK_VERSION | "Contents/Home/bin/java" | ""
9090
"darwin" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | ""
9191
"darwin" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)"
92+
"mac" | VENDOR_OPENJDK | OPEN_JDK_VERSION | "Contents/Home/bin/java" | ""
93+
"mac" | VENDOR_OPENJDK | OPENJDK_VERSION_OLD | "Contents/Home/bin/java" | "(old version)"
9294
}
9395

9496
def "transforms are reused across projects"() {
@@ -200,10 +202,10 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
200202

201203
private static String urlPath(final String vendor, final String version, final String platform) {
202204
if (vendor.equals(VENDOR_ADOPTOPENJDK)) {
203-
final String module = platform.equals("darwin") ? "mac" : platform;
205+
final String module = isMac(platform) ? "mac" : platform;
204206
return "/jdk-12.0.2+10/" + module + "/x64/jdk/hotspot/normal/adoptopenjdk";
205207
} else if (vendor.equals(VENDOR_OPENJDK)) {
206-
final String effectivePlatform = platform.equals("darwin") ? "osx" : platform;
208+
final String effectivePlatform = isMac(platform) ? "osx" : platform;
207209
final boolean isOld = version.equals(OPENJDK_VERSION_OLD);
208210
final String versionPath = isOld ? "jdk1/99" : "jdk12.0.1/123456789123456789123456789abcde/99";
209211
final String filename = "openjdk-" + (isOld ? "1" : "12.0.1") + "_" + effectivePlatform + "-x64_bin." + extension(platform);
@@ -212,14 +214,18 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
212214
}
213215

214216
private static byte[] filebytes(final String vendor, final String platform) throws IOException {
215-
final String effectivePlatform = platform.equals("darwin") ? "osx" : platform;
217+
final String effectivePlatform = isMac(platform) ? "osx" : platform;
216218
if (vendor.equals(VENDOR_ADOPTOPENJDK)) {
217219
return JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_adoptopenjdk_" + effectivePlatform + "." + extension(platform)).getBytes()
218220
} else if (vendor.equals(VENDOR_OPENJDK)) {
219221
JdkDownloadPluginFuncTest.class.getResourceAsStream("fake_openjdk_" + effectivePlatform + "." + extension(platform)).getBytes()
220222
}
221223
}
222224

225+
private static boolean isMac(String platform) {
226+
platform.equals("darwin") || platform.equals("mac")
227+
}
228+
223229
private static String extension(String platform) {
224230
platform.equals("windows") ? "zip" : "tar.gz";
225231
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.gradle.fixtures
21+
22+
import org.apache.commons.io.FileUtils
23+
import org.gradle.testkit.runner.GradleRunner
24+
import org.junit.Rule
25+
import org.junit.rules.TemporaryFolder
26+
27+
abstract class AbstractGitAwareGradleFuncTest extends AbstractGradleFuncTest {
28+
29+
@Rule
30+
TemporaryFolder remoteRepoDirs = new TemporaryFolder()
31+
32+
File remoteGitRepo
33+
34+
def setup() {
35+
remoteGitRepo = new File(setupGitRemote(), '.git')
36+
"git clone ${remoteGitRepo.absolutePath} cloned".execute(Collections.emptyList(), testProjectDir.root).waitFor()
37+
buildFile = new File(testProjectDir.root, 'cloned/build.gradle')
38+
settingsFile = new File(testProjectDir.root, 'cloned/settings.gradle')
39+
}
40+
41+
File setupGitRemote() {
42+
URL fakeRemote = getClass().getResource("fake_git/remote")
43+
File workingRemoteGit = new File(remoteRepoDirs.root, 'remote')
44+
FileUtils.copyDirectory(new File(fakeRemote.file), workingRemoteGit)
45+
fakeRemote.file + "/.git"
46+
gradleRunner(workingRemoteGit, "wrapper").build()
47+
48+
execute("git init", workingRemoteGit)
49+
execute('git config user.email "[email protected]"', workingRemoteGit)
50+
execute('git config user.name "Build tool"', workingRemoteGit)
51+
execute("git add .", workingRemoteGit)
52+
execute('git commit -m"Initial"', workingRemoteGit)
53+
execute("git checkout -b origin/8.0", workingRemoteGit)
54+
return workingRemoteGit;
55+
}
56+
57+
GradleRunner gradleRunner(String... arguments) {
58+
gradleRunner(new File(testProjectDir.root, "cloned"), arguments)
59+
}
60+
61+
}

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,19 @@ abstract class AbstractGradleFuncTest extends Specification {
112112
}
113113

114114
void setupLocalGitRepo() {
115-
"git init".execute(Collections.emptyList(), testProjectDir.root).waitFor()
116-
"git add .".execute(Collections.emptyList(), testProjectDir.root).waitFor()
117-
'git commit -m "Initial"'.execute(Collections.emptyList(), testProjectDir.root).waitFor()
115+
execute("git init")
116+
execute('git config user.email "[email protected]"')
117+
execute('git config user.name "Build tool"')
118+
execute("git add .")
119+
execute('git commit -m "Initial"')
120+
}
121+
122+
void execute(String command, File workingDir = testProjectDir.root) {
123+
def proc = command.execute(Collections.emptyList(), workingDir)
124+
proc.waitFor()
125+
if(proc.exitValue()) {
126+
System.err.println("Error running command ${command}:")
127+
System.err.println("Syserr: " + proc.errorStream.text)
128+
}
118129
}
119130
}

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalBwcGitPluginFuncTest.groovy

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,60 @@
1919

2020
package org.elasticsearch.gradle.internal
2121

22-
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
22+
import org.elasticsearch.gradle.fixtures.AbstractGitAwareGradleFuncTest
2323
import org.gradle.testkit.runner.TaskOutcome
2424

25-
class InternalBwcGitPluginFuncTest extends AbstractGradleFuncTest {
25+
class InternalBwcGitPluginFuncTest extends AbstractGitAwareGradleFuncTest {
2626

2727
def setup() {
28-
setupLocalGitRepo()
29-
}
30-
31-
def "current repository can be cloned"() {
32-
given:
33-
internalBuild();
28+
internalBuild()
3429
buildFile << """
3530
import org.elasticsearch.gradle.Version;
3631
apply plugin: org.elasticsearch.gradle.internal.InternalBwcGitPlugin
3732
3833
bwcGitConfig {
39-
bwcVersion = project.provider { Version.fromString("7.10.0") }
40-
bwcBranch = project.provider { "7.x" }
34+
bwcVersion = project.provider { Version.fromString("8.1.0") }
35+
bwcBranch = project.provider { "8.0" }
4136
checkoutDir = project.provider{file("build/checkout")}
4237
}
4338
"""
39+
}
40+
41+
def "current repository can be cloned"() {
4442
when:
4543
def result = gradleRunner("createClone", '--stacktrace').build()
4644
then:
4745
result.task(":createClone").outcome == TaskOutcome.SUCCESS
48-
file("build/checkout/build.gradle").exists()
49-
file("build/checkout/settings.gradle").exists()
46+
file("cloned/build/checkout/build.gradle").exists()
47+
file("cloned/build/checkout/settings.gradle").exists()
48+
}
49+
50+
def "can resolve checkout folder as project artifact"() {
51+
given:
52+
settingsFile << "include ':consumer'"
53+
file("cloned/consumer/build.gradle") << """
54+
configurations {
55+
consumeCheckout
56+
}
57+
dependencies {
58+
consumeCheckout project(path:":", configuration: "checkout")
59+
}
60+
61+
tasks.register("register") {
62+
dependsOn configurations.consumeCheckout
63+
doLast {
64+
configurations.consumeCheckout.files.each {
65+
println "checkoutDir artifact: " + it
66+
}
67+
}
68+
}
69+
"""
70+
when:
71+
def result = gradleRunner(":consumer:register", '--stacktrace', "-DtestRemoteRepo=" + remoteGitRepo,
72+
"-Dbwc.remote=origin").build()
73+
then:
74+
result.task(":checkoutBwcBranch").outcome == TaskOutcome.SUCCESS
75+
result.task(":consumer:register").outcome == TaskOutcome.SUCCESS
76+
normalizedOutput(result.output).contains("/cloned/build/checkout")
5077
}
5178
}

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncT
9999
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
100100
import org.gradle.api.internal.artifacts.ArtifactAttributes;
101101
102+
def snapshotFile = file("snapshot-\${version}.txt")
103+
snapshotFile << 'some snapshot content'
102104
distribution_archives {
103105
producerTar {
104106
content {
105107
project.copySpec {
106108
from 'someFile.txt'
109+
from snapshotFile
107110
}
108111
}
109112
}
@@ -134,19 +137,27 @@ class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncT
134137
when:
135138
def result = gradleRunner("copyArchive").build()
136139

137-
then:"tar task executed and target folder contains plain tar"
140+
then: "tar task executed and target folder contains plain tar"
138141
result.task(':buildProducerTar').outcome == TaskOutcome.SUCCESS
139142
result.task(':consumer:copyArchive').outcome == TaskOutcome.SUCCESS
140143
file("producer-tar/build/distributions/elasticsearch.tar.gz").exists()
141144
file("consumer/build/archives/elasticsearch.tar.gz").exists()
142145

143146
when:
144-
result = gradleRunner("copyDir").build()
145-
then:"plain copy task executed and target folder contains plain content"
147+
result = gradleRunner("copyDir", "-Pversion=1.0").build()
148+
then: "plain copy task executed and target folder contains plain content"
146149
result.task(':buildProducer').outcome == TaskOutcome.SUCCESS
147150
result.task(':consumer:copyDir').outcome == TaskOutcome.SUCCESS
148151
file("producer-tar/build/install/someFile.txt").exists()
152+
file("producer-tar/build/install/snapshot-1.0.txt").exists()
149153
file("consumer/build/dir/someFile.txt").exists()
154+
155+
when:
156+
gradleRunner("copyDir", "-Pversion=2.0").build()
157+
then: "old content is cleared out"
158+
file("producer-tar/build/install/someFile.txt").exists()
159+
!file("producer-tar/build/install/snapshot-1.0.txt").exists()
160+
file("producer-tar/build/install/snapshot-2.0.txt").exists()
150161
}
151162

152163
private static boolean assertTarPermissionDefaults(File tarArchive) {

0 commit comments

Comments
 (0)