Skip to content

Commit 0348221

Browse files
Merge branch 'master' into pause-auto-followers
2 parents 98c63ad + ead99f1 commit 0348221

File tree

602 files changed

+11033
-5757
lines changed

Some content is hidden

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

602 files changed

+11033
-5757
lines changed

.ci/os.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ $ErrorActionPreference="Continue"
3333
-x :distribution:packages:buildOssRpm `
3434
-x :distribution:packages:buildRpm `
3535

36-
exit $?
36+
exit $LastExitCode

Vagrantfile

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- mode: ruby -*-
2-
# vi: set ft=ruby :
2+
# vim: ft=ruby ts=2 sw=2 sts=2 et:
33

44
# This Vagrantfile exists to test packaging. Read more about its use in the
55
# vagrant section in TESTING.asciidoc.
@@ -63,6 +63,7 @@ Vagrant.configure(2) do |config|
6363
# Install Jayatana so we can work around it being present.
6464
[ -f /usr/share/java/jayatanaag.jar ] || install jayatana
6565
SHELL
66+
ubuntu_docker config
6667
end
6768
end
6869
'ubuntu-1804'.tap do |box|
@@ -72,6 +73,7 @@ Vagrant.configure(2) do |config|
7273
# Install Jayatana so we can work around it being present.
7374
[ -f /usr/share/java/jayatanaag.jar ] || install jayatana
7475
SHELL
76+
ubuntu_docker config
7577
end
7678
end
7779
'debian-8'.tap do |box|
@@ -87,6 +89,7 @@ Vagrant.configure(2) do |config|
8789
config.vm.define box, define_opts do |config|
8890
config.vm.box = 'elastic/debian-9-x86_64'
8991
deb_common config, box
92+
deb_docker config
9093
end
9194
end
9295
'centos-6'.tap do |box|
@@ -99,6 +102,7 @@ Vagrant.configure(2) do |config|
99102
config.vm.define box, define_opts do |config|
100103
config.vm.box = 'elastic/centos-7-x86_64'
101104
rpm_common config, box
105+
rpm_docker config
102106
end
103107
end
104108
'oel-6'.tap do |box|
@@ -117,12 +121,14 @@ Vagrant.configure(2) do |config|
117121
config.vm.define box, define_opts do |config|
118122
config.vm.box = 'elastic/fedora-28-x86_64'
119123
dnf_common config, box
124+
dnf_docker config
120125
end
121126
end
122127
'fedora-29'.tap do |box|
123128
config.vm.define box, define_opts do |config|
124129
config.vm.box = 'elastic/fedora-28-x86_64'
125130
dnf_common config, box
131+
dnf_docker config
126132
end
127133
end
128134
'opensuse-42'.tap do |box|
@@ -185,6 +191,63 @@ def deb_common(config, name, extra: '')
185191
)
186192
end
187193

194+
def ubuntu_docker(config)
195+
config.vm.provision 'install Docker using apt', type: 'shell', inline: <<-SHELL
196+
# Install packages to allow apt to use a repository over HTTPS
197+
apt-get install -y \
198+
apt-transport-https \
199+
ca-certificates \
200+
curl \
201+
gnupg2 \
202+
software-properties-common
203+
204+
# Add Docker’s official GPG key
205+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
206+
207+
# Set up the stable Docker repository
208+
add-apt-repository \
209+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
210+
$(lsb_release -cs) \
211+
stable"
212+
213+
# Install Docker. Unlike Fedora and CentOS, this also start the daemon.
214+
apt-get update
215+
apt-get install -y docker-ce docker-ce-cli containerd.io
216+
217+
# Add vagrant to the Docker group, so that it can run commands
218+
usermod -aG docker vagrant
219+
SHELL
220+
end
221+
222+
223+
def deb_docker(config)
224+
config.vm.provision 'install Docker using apt', type: 'shell', inline: <<-SHELL
225+
# Install packages to allow apt to use a repository over HTTPS
226+
apt-get install -y \
227+
apt-transport-https \
228+
ca-certificates \
229+
curl \
230+
gnupg2 \
231+
software-properties-common
232+
233+
# Add Docker’s official GPG key
234+
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
235+
236+
# Set up the stable Docker repository
237+
add-apt-repository \
238+
"deb [arch=amd64] https://download.docker.com/linux/debian \
239+
$(lsb_release -cs) \
240+
stable"
241+
242+
# Install Docker. Unlike Fedora and CentOS, this also start the daemon.
243+
apt-get update
244+
apt-get install -y docker-ce docker-ce-cli containerd.io
245+
246+
# Add vagrant to the Docker group, so that it can run commands
247+
usermod -aG docker vagrant
248+
SHELL
249+
end
250+
188251
def rpm_common(config, name)
189252
linux_common(
190253
config,
@@ -195,6 +258,25 @@ def rpm_common(config, name)
195258
)
196259
end
197260

261+
def rpm_docker(config)
262+
config.vm.provision 'install Docker using yum', type: 'shell', inline: <<-SHELL
263+
# Install prerequisites
264+
yum install -y yum-utils device-mapper-persistent-data lvm2
265+
266+
# Add repository
267+
yum-config-manager -y --add-repo https://download.docker.com/linux/centos/docker-ce.repo
268+
269+
# Install Docker
270+
yum install -y docker-ce docker-ce-cli containerd.io
271+
272+
# Start Docker
273+
systemctl enable --now docker
274+
275+
# Add vagrant to the Docker group, so that it can run commands
276+
usermod -aG docker vagrant
277+
SHELL
278+
end
279+
198280
def dnf_common(config, name)
199281
# Autodetect doesn't work....
200282
if Vagrant.has_plugin?('vagrant-cachier')
@@ -211,6 +293,25 @@ def dnf_common(config, name)
211293
)
212294
end
213295

296+
def dnf_docker(config)
297+
config.vm.provision 'install Docker using dnf', type: 'shell', inline: <<-SHELL
298+
# Install prerequisites
299+
dnf -y install dnf-plugins-core
300+
301+
# Add repository
302+
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
303+
304+
# Install Docker
305+
dnf install -y docker-ce docker-ce-cli containerd.io
306+
307+
# Start Docker
308+
systemctl enable --now docker
309+
310+
# Add vagrant to the Docker group, so that it can run commands
311+
usermod -aG docker vagrant
312+
SHELL
313+
end
314+
214315
def suse_common(config, name, extra: '')
215316
linux_common(
216317
config,
@@ -268,7 +369,7 @@ def linux_common(config,
268369

269370
# This prevents leftovers from previous tests using the
270371
# same VM from messing up the current test
271-
config.vm.provision 'clean es installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
372+
config.vm.provision 'clean es installs in tmp', type: 'shell', inline: <<-SHELL
272373
rm -rf /tmp/elasticsearch*
273374
SHELL
274375

buildSrc/src/main/groovy/org/elasticsearch/gradle/DependenciesInfoTask.groovy

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@
2020
package org.elasticsearch.gradle
2121

2222
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
23-
import org.gradle.api.DefaultTask
2423
import org.gradle.api.artifacts.Configuration
2524
import org.gradle.api.artifacts.Dependency
26-
import org.gradle.api.artifacts.DependencyResolutionListener
2725
import org.gradle.api.artifacts.DependencySet
2826
import org.gradle.api.internal.ConventionTask
2927
import org.gradle.api.tasks.Input
3028
import org.gradle.api.tasks.InputDirectory
29+
import org.gradle.api.tasks.InputFiles
3130
import org.gradle.api.tasks.OutputFile
3231
import org.gradle.api.tasks.TaskAction
3332

34-
import java.util.regex.Matcher
35-
import java.util.regex.Pattern
36-
3733
/**
3834
* A task to gather information about the dependencies and export them into a csv file.
3935
*
@@ -46,31 +42,31 @@ import java.util.regex.Pattern
4642
* </ul>
4743
*
4844
*/
49-
public class DependenciesInfoTask extends ConventionTask {
45+
class DependenciesInfoTask extends ConventionTask {
5046

5147
/** Dependencies to gather information from. */
52-
@Input
53-
public Configuration runtimeConfiguration
48+
@InputFiles
49+
Configuration runtimeConfiguration
5450

5551
/** We subtract compile-only dependencies. */
56-
@Input
57-
public Configuration compileOnlyConfiguration
58-
59-
private LinkedHashMap<String, String> mappings
52+
@InputFiles
53+
Configuration compileOnlyConfiguration
6054

6155
/** Directory to read license files */
6256
@InputDirectory
63-
public File licensesDir = new File(project.projectDir, 'licenses')
57+
File licensesDir = new File(project.projectDir, 'licenses')
6458

6559
@OutputFile
6660
File outputFile = new File(project.buildDir, "reports/dependencies/dependencies.csv")
6761

68-
public DependenciesInfoTask() {
62+
private LinkedHashMap<String, String> mappings
63+
64+
DependenciesInfoTask() {
6965
description = 'Create a CSV file with dependencies information.'
7066
}
7167

7268
@TaskAction
73-
public void generateDependenciesInfo() {
69+
void generateDependenciesInfo() {
7470

7571
final DependencySet runtimeDependencies = runtimeConfiguration.getAllDependencies()
7672
// we have to resolve the transitive dependencies and create a group:artifactId:version map

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import java.nio.file.Path
3131
/**
3232
* Generates REST tests for each snippet marked // TEST.
3333
*/
34-
public class RestTestsFromSnippetsTask extends SnippetsTask {
34+
class RestTestsFromSnippetsTask extends SnippetsTask {
3535
/**
3636
* These languages aren't supported by the syntax highlighter so we
3737
* shouldn't use them.
@@ -58,7 +58,9 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
5858
@OutputDirectory
5959
File testRoot = project.file('build/rest')
6060

61-
public RestTestsFromSnippetsTask() {
61+
Set<String> names = new HashSet<>()
62+
63+
RestTestsFromSnippetsTask() {
6264
project.afterEvaluate {
6365
// Wait to set this so testRoot can be customized
6466
project.sourceSets.test.output.dir(testRoot, builtBy: this)
@@ -238,7 +240,14 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
238240
}
239241
} else {
240242
current.println('---')
241-
current.println("\"line_$test.start\":")
243+
if (test.name != null && test.name.isBlank() == false) {
244+
if(names.add(test.name) == false) {
245+
throw new InvalidUserDataException("Duplicated snippet name '$test.name': $test")
246+
}
247+
current.println("\"$test.name\":")
248+
} else {
249+
current.println("\"line_$test.start\":")
250+
}
242251
/* The Elasticsearch test runner doesn't support quite a few
243252
* constructs unless we output this skip. We don't know if
244253
* we're going to use these constructs, but we might so we
@@ -406,6 +415,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
406415
if (lastDocsPath == test.path) {
407416
return
408417
}
418+
names.clear()
409419
finishLastTest()
410420
lastDocsPath = test.path
411421

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/SnippetsTask.groovy

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import org.gradle.api.InvalidUserDataException
2828
import org.gradle.api.file.ConfigurableFileTree
2929
import org.gradle.api.tasks.Input
3030
import org.gradle.api.tasks.InputFiles
31+
import org.gradle.api.tasks.Internal
3132
import org.gradle.api.tasks.TaskAction
3233

3334
import java.nio.file.Path
@@ -36,7 +37,7 @@ import java.util.regex.Matcher
3637
/**
3738
* A task which will run a closure on each snippet in the documentation.
3839
*/
39-
public class SnippetsTask extends DefaultTask {
40+
class SnippetsTask extends DefaultTask {
4041
private static final String SCHAR = /(?:\\\/|[^\/])/
4142
private static final String SUBSTITUTION = /s\/($SCHAR+)\/($SCHAR*)\//
4243
private static final String CATCH = /catch:\s*((?:\/[^\/]+\/)|[^ \]]+)/
@@ -51,6 +52,7 @@ public class SnippetsTask extends DefaultTask {
5152
* Action to take on each snippet. Called with a single parameter, an
5253
* instance of Snippet.
5354
*/
55+
@Internal
5456
Closure perSnippet
5557

5658
/**
@@ -73,13 +75,14 @@ public class SnippetsTask extends DefaultTask {
7375
Map<String, String> defaultSubstitutions = [:]
7476

7577
@TaskAction
76-
public void executeTask() {
78+
void executeTask() {
7779
/*
7880
* Walks each line of each file, building snippets as it encounters
7981
* the lines that make up the snippet.
8082
*/
8183
for (File file: docs) {
8284
String lastLanguage
85+
String name
8386
int lastLanguageLine
8487
Snippet snippet = null
8588
StringBuilder contents = null
@@ -153,19 +156,21 @@ public class SnippetsTask extends DefaultTask {
153156
if (line ==~ /-{4,}\s*/) { // Four dashes looks like a snippet
154157
if (snippet == null) {
155158
Path path = docs.dir.toPath().relativize(file.toPath())
156-
snippet = new Snippet(path: path, start: lineNumber, testEnv: testEnv)
159+
snippet = new Snippet(path: path, start: lineNumber, testEnv: testEnv, name: name)
157160
if (lastLanguageLine == lineNumber - 1) {
158161
snippet.language = lastLanguage
159162
}
163+
name = null
160164
} else {
161165
snippet.end = lineNumber
162166
}
163167
return
164168
}
165-
matcher = line =~ /\["?source"?,\s*"?([-\w]+)"?(,.*)?].*/
166-
if (matcher.matches()) {
167-
lastLanguage = matcher.group(1)
169+
def source = matchSource(line)
170+
if (source.matches) {
171+
lastLanguage = source.language
168172
lastLanguageLine = lineNumber
173+
name = source.name
169174
return
170175
}
171176
if (line ==~ /\/\/\s*AUTOSENSE\s*/) {
@@ -308,6 +313,20 @@ public class SnippetsTask extends DefaultTask {
308313
}
309314
}
310315

316+
static Source matchSource(String line) {
317+
def matcher = line =~ /\["?source"?,\s*"?([-\w]+)"?(,((?!id=).)*(id="?([-\w]+)"?)?(.*))?].*/
318+
if(matcher.matches()){
319+
return new Source(matches: true, language: matcher.group(1), name: matcher.group(5))
320+
}
321+
return new Source(matches: false)
322+
}
323+
324+
static class Source {
325+
boolean matches
326+
String language
327+
String name
328+
}
329+
311330
static class Snippet {
312331
static final int NOT_FINISHED = -1
313332

@@ -334,6 +353,7 @@ public class SnippetsTask extends DefaultTask {
334353
boolean curl
335354
List warnings = new ArrayList()
336355
boolean skipShardsFailures = false
356+
String name
337357

338358
@Override
339359
public String toString() {

0 commit comments

Comments
 (0)