Skip to content

Commit 27173fa

Browse files
committed
Merge branch 'master' into snapshot-lifecycle-management
2 parents c89a5bc + 596df3b commit 27173fa

File tree

179 files changed

+2635
-2168
lines changed

Some content is hidden

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

179 files changed

+2635
-2168
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ attention.
1010
- Have you followed the [contributor guidelines](https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md)?
1111
- If submitting code, have you built your formula locally prior to submission with `gradle check`?
1212
- If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
13-
- If submitting code, have you checked that your submission is for an [OS that we support](https://www.elastic.co/support/matrix#show_os)?
13+
- If submitting code, have you checked that your submission is for an [OS and architecture that we support](https://www.elastic.co/support/matrix#show_os)?
1414
- If you are submitting this code for a class then read our [policy](https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-as-part-of-a-class) for that.

README.textile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ curl -XPUT 'http://localhost:9200/kimchy/_doc/2?pretty' -H 'Content-Type: applic
150150

151151
The above will index information into the @kimchy@ index. Each user will get their own special index.
152152

153-
Complete control on the index level is allowed. As an example, in the above case, we would want to change from the default 5 shards with 1 replica per index, to only 1 shard with 1 replica per index (== per twitter user). Here is how this can be done (the configuration can be in yaml as well):
153+
Complete control on the index level is allowed. As an example, in the above case, we might want to change from the default 1 shard with 1 replica per index, to 2 shards with 1 replica per index (because this user tweets a lot). Here is how this can be done (the configuration can be in yaml as well):
154154

155155
<pre>
156156
curl -XPUT http://localhost:9200/another_user?pretty -H 'Content-Type: application/json' -d '
157157
{
158158
"index" : {
159-
"number_of_shards" : 1,
159+
"number_of_shards" : 2,
160160
"number_of_replicas" : 1
161161
}
162162
}'
@@ -191,7 +191,7 @@ h3. Distributed, Highly Available
191191

192192
Let's face it, things will fail....
193193

194-
Elasticsearch is a highly available and distributed search engine. Each index is broken down into shards, and each shard can have one or more replicas. By default, an index is created with 5 shards and 1 replica per shard (5/1). There are many topologies that can be used, including 1/10 (improve search performance), or 20/1 (improve indexing performance, with search executed in a map reduce fashion across shards).
194+
Elasticsearch is a highly available and distributed search engine. Each index is broken down into shards, and each shard can have one or more replicas. By default, an index is created with 1 shards and 1 replica per shard (1/1). There are many topologies that can be used, including 1/10 (improve search performance), or 20/1 (improve indexing performance, with search executed in a map reduce fashion across shards).
195195

196196
In order to play with the distributed nature of Elasticsearch, simply bring more nodes up and shut down nodes. The system will continue to serve requests (make sure you use the correct http port) with the latest data indexed.
197197

buildSrc/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ if (project != rootProject) {
182182
if (isLuceneSnapshot) {
183183
systemProperty 'test.lucene-snapshot-revision', isLuceneSnapshot[0][1]
184184
}
185-
maxParallelForks System.getProperty('tI', project.rootProject.ext.defaultParallel.toString()) as Integer
185+
maxParallelForks System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel.toString()) as Integer
186+
// These tests run Gradle which doesn't have FIPS support
187+
onlyIf { project.inFipsJvm == false }
186188
}
187189
check.dependsOn(integTest)
188190

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,7 @@ class BuildPlugin implements Plugin<Project> {
256256
}
257257
}
258258

259-
if (ext.get('buildDocker')) {
260-
(ext.get('requiresDocker') as List<Task>).add(task)
261-
} else {
262-
task.onlyIf { false }
263-
}
259+
(ext.get('requiresDocker') as List<Task>).add(task)
264260
}
265261

266262
protected static void checkDockerVersionRecent(String dockerVersion) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class SnippetsTask extends DefaultTask {
4343
private static final String SKIP = /skip:([^\]]+)/
4444
private static final String SETUP = /setup:([^ \]]+)/
4545
private static final String WARNING = /warning:(.+)/
46-
private static final String CAT = /(_cat)/
46+
private static final String NON_JSON = /(non_json)/
4747
private static final String TEST_SYNTAX =
4848
/(?:$CATCH|$SUBSTITUTION|$SKIP|(continued)|$SETUP|$WARNING|(skip_shard_failures)) ?/
4949

@@ -255,12 +255,12 @@ public class SnippetsTask extends DefaultTask {
255255
substitutions = []
256256
}
257257
String loc = "$file:$lineNumber"
258-
parse(loc, matcher.group(2), /(?:$SUBSTITUTION|$CAT|$SKIP) ?/) {
258+
parse(loc, matcher.group(2), /(?:$SUBSTITUTION|$NON_JSON|$SKIP) ?/) {
259259
if (it.group(1) != null) {
260260
// TESTRESPONSE[s/adsf/jkl/]
261261
substitutions.add([it.group(1), it.group(2)])
262262
} else if (it.group(3) != null) {
263-
// TESTRESPONSE[_cat]
263+
// TESTRESPONSE[non_json]
264264
substitutions.add(['^', '/'])
265265
substitutions.add(['\n$', '\\\\s*/'])
266266
substitutions.add(['( +)', '$1\\\\s+'])

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClusterConfiguration.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ default void waitForConditions(
122122
} catch (TestClustersException e) {
123123
throw e;
124124
} catch (Exception e) {
125-
if (lastException == null) {
126-
lastException = e;
127-
} else {
128-
lastException = e;
129-
}
125+
throw e;
130126
}
131127
}
132128
if (conditionMet == false) {
@@ -135,7 +131,7 @@ default void waitForConditions(
135131
if (lastException == null) {
136132
throw new TestClustersException(message);
137133
} else {
138-
throw new TestClustersException(message, lastException);
134+
throw new TestClustersException(message + message, lastException);
139135
}
140136
}
141137
logger.info(

buildSrc/src/main/java/org/elasticsearch/gradle/testfixtures/TestFixturesPlugin.java

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.gradle.api.tasks.TaskContainer;
3737
import org.gradle.api.tasks.testing.Test;
3838

39+
import java.io.File;
3940
import java.util.Collections;
4041
import java.util.function.BiConsumer;
4142

@@ -58,46 +59,47 @@ public void apply(Project project) {
5859
disableTaskByType(tasks, ThirdPartyAuditTask.class);
5960
disableTaskByType(tasks, JarHellTask.class);
6061

62+
// the project that defined a test fixture can also use it
63+
extension.fixtures.add(project);
64+
6165
Task buildFixture = project.getTasks().create("buildFixture");
6266
Task pullFixture = project.getTasks().create("pullFixture");
6367
Task preProcessFixture = project.getTasks().create("preProcessFixture");
6468
buildFixture.dependsOn(preProcessFixture);
6569
pullFixture.dependsOn(preProcessFixture);
6670
Task postProcessFixture = project.getTasks().create("postProcessFixture");
71+
postProcessFixture.dependsOn(buildFixture);
72+
preProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
73+
postProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
6774

68-
if (dockerComposeSupported(project) == false) {
75+
if (dockerComposeSupported() == false) {
6976
preProcessFixture.setEnabled(false);
7077
postProcessFixture.setEnabled(false);
7178
buildFixture.setEnabled(false);
7279
pullFixture.setEnabled(false);
73-
return;
74-
}
75-
preProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
76-
postProcessFixture.onlyIf(spec -> buildFixture.getEnabled());
77-
78-
project.apply(spec -> spec.plugin(BasePlugin.class));
79-
project.apply(spec -> spec.plugin(DockerComposePlugin.class));
80-
ComposeExtension composeExtension = project.getExtensions().getByType(ComposeExtension.class);
81-
composeExtension.setUseComposeFiles(Collections.singletonList(DOCKER_COMPOSE_YML));
82-
composeExtension.setRemoveContainers(true);
83-
composeExtension.setExecutable(
84-
project.file("/usr/local/bin/docker-compose").exists() ?
85-
"/usr/local/bin/docker-compose" : "/usr/bin/docker-compose"
86-
);
80+
} else {
81+
project.apply(spec -> spec.plugin(BasePlugin.class));
82+
project.apply(spec -> spec.plugin(DockerComposePlugin.class));
83+
ComposeExtension composeExtension = project.getExtensions().getByType(ComposeExtension.class);
84+
composeExtension.setUseComposeFiles(Collections.singletonList(DOCKER_COMPOSE_YML));
85+
composeExtension.setRemoveContainers(true);
86+
composeExtension.setExecutable(
87+
project.file("/usr/local/bin/docker-compose").exists() ?
88+
"/usr/local/bin/docker-compose" : "/usr/bin/docker-compose"
89+
);
8790

88-
buildFixture.dependsOn(tasks.getByName("composeUp"));
89-
pullFixture.dependsOn(tasks.getByName("composePull"));
90-
tasks.getByName("composeUp").mustRunAfter(preProcessFixture);
91-
tasks.getByName("composePull").mustRunAfter(preProcessFixture);
92-
postProcessFixture.dependsOn(buildFixture);
91+
buildFixture.dependsOn(tasks.getByName("composeUp"));
92+
pullFixture.dependsOn(tasks.getByName("composePull"));
93+
tasks.getByName("composeUp").mustRunAfter(preProcessFixture);
94+
tasks.getByName("composePull").mustRunAfter(preProcessFixture);
9395

94-
configureServiceInfoForTask(
95-
postProcessFixture,
96-
project,
97-
(name, port) -> postProcessFixture.getExtensions()
98-
.getByType(ExtraPropertiesExtension.class).set(name, port)
99-
);
100-
extension.fixtures.add(project);
96+
configureServiceInfoForTask(
97+
postProcessFixture,
98+
project,
99+
(name, port) -> postProcessFixture.getExtensions()
100+
.getByType(ExtraPropertiesExtension.class).set(name, port)
101+
);
102+
}
101103
}
102104

103105
extension.fixtures
@@ -109,7 +111,7 @@ public void apply(Project project) {
109111
conditionTaskByType(tasks, extension, TestingConventionsTasks.class);
110112
conditionTaskByType(tasks, extension, ComposeUp.class);
111113

112-
if (dockerComposeSupported(project) == false) {
114+
if (dockerComposeSupported() == false) {
113115
project.getLogger().warn(
114116
"Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " +
115117
"but none could be found so these will be skipped", project.getPath()
@@ -138,7 +140,9 @@ private void conditionTaskByType(TaskContainer tasks, TestFixtureExtension exten
138140
taskClass,
139141
task -> task.onlyIf(spec ->
140142
extension.fixtures.stream()
141-
.anyMatch(fixtureProject -> fixtureProject.getTasks().getByName("buildFixture").getEnabled() == false) == false
143+
.anyMatch(fixtureProject ->
144+
fixtureProject.getTasks().getByName("buildFixture").getEnabled() == false
145+
) == false
142146
)
143147
);
144148
}
@@ -175,12 +179,12 @@ public void execute(Task theTask) {
175179
);
176180
}
177181

178-
public boolean dockerComposeSupported(Project project) {
182+
public static boolean dockerComposeSupported() {
179183
if (OS.current().equals(OS.WINDOWS)) {
180184
return false;
181185
}
182-
final boolean hasDockerCompose = project.file("/usr/local/bin/docker-compose").exists() ||
183-
project.file("/usr/bin/docker-compose").exists();
186+
final boolean hasDockerCompose = (new File("/usr/local/bin/docker-compose")).exists() ||
187+
(new File("/usr/bin/docker-compose").exists());
184188
return hasDockerCompose && Boolean.parseBoolean(System.getProperty("tests.fixture.enabled", "true"));
185189
}
186190

distribution/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ task run(type: RunTask) {
400400
setting 'xpack.graph.enabled', 'true'
401401
setting 'xpack.watcher.enabled', 'true'
402402
setting 'xpack.license.self_generated.type', 'trial'
403-
setupCommand 'setupTestAdmin',
404-
'bin/elasticsearch-users', 'useradd', 'elastic-admin', '-p', 'elastic-password', '-r', 'superuser'
405403
} else if (licenseType != 'basic') {
406404
throw new IllegalArgumentException("Unsupported self-generated license type: [" + licenseType + "[basic] or [trial].")
407405
}
406+
setupCommand 'setupTestAdmin',
407+
'bin/elasticsearch-users', 'useradd', 'elastic-admin', '-p', 'elastic-password', '-r', 'superuser'
408408
setting 'xpack.security.enabled', 'true'
409409
setting 'xpack.monitoring.enabled', 'true'
410410
setting 'xpack.sql.enabled', 'true'

distribution/docker/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.elasticsearch.gradle.BuildPlugin
22
import org.elasticsearch.gradle.LoggedExec
33
import org.elasticsearch.gradle.MavenFilteringHack
44
import org.elasticsearch.gradle.VersionProperties
5+
import org.elasticsearch.gradle.testfixtures.TestFixturesPlugin
56

67
apply plugin: 'base'
78
apply plugin: 'elasticsearch.test.fixtures'
@@ -77,7 +78,10 @@ void addCopyDockerContextTask(final boolean oss) {
7778
}
7879

7980
preProcessFixture {
80-
dependsOn assemble
81+
// don't add the tasks to build the docker images if we have no way of testing them
82+
if (TestFixturesPlugin.dockerComposeSupported()) {
83+
dependsOn assemble
84+
}
8185
}
8286

8387
postProcessFixture.doLast {

docs/README.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ for its modifiers:
6262
them" which looks like `// TESTRESPONSE[s/\d+/$body.$_path/]`.
6363
* You can't use `// TESTRESPONSE` immediately after `// TESTSETUP`. Instead,
6464
consider using `// TEST[continued]` or rearrange your snippets.
65-
* `// TESTRESPONSE[_cat]`: Add substitutions for testing `_cat` responses. Use
66-
this after all other substitutions so it doesn't make other substitutions
67-
difficult.
65+
* `// TESTRESPONSE[non_json]`: Add substitutions for testing responses in a
66+
format other than JSON. Use this after all other substitutions so it doesn't
67+
make other substitutions difficult.
6868
* `// TESTRESPONSE[skip:reason]`: Skip the assertions specified by this
6969
response.
7070
* `// TESTSETUP`: Marks this snippet as the "setup" for all other snippets in

0 commit comments

Comments
 (0)