Skip to content

Commit 98a1b6b

Browse files
committed
Merge branch 'master' into unknown-or-invalid-settings-updates
* master: (28 commits) Maybe die before failing engine (elastic#28973) Remove special handling for _all in nodes info Remove Booleans use from XContent and ToXContent (elastic#28768) Update Gradle Testing Docs (elastic#28970) Make primary-replica resync failures less lenient (elastic#28534) Remove temporary file 10_basic.yml~ Use different pipeline id in test. (pipelines do not get removed between tests extending from ESIntegTestCase) Use fixture to test the repository-gcs plugin (elastic#28788) Use String.join() to describe a list of tasks (elastic#28941) Fixed incorrect test try-catch statement Plugins: Consolidate plugin and module loading code (elastic#28815) percolator: Take `matchAllDocs` and `verified` of the sub result into account when analyzing a function_score query. Build: Remove rest tests on archive distribution projects (elastic#28952) Remove FastStringReader in favor of vanilla StringReader (elastic#28944) Remove FastCharArrayReader and FastCharArrayWriter (elastic#28951) Continue registering pipelines after one pipeline parse failure. (elastic#28752) Build: Fix ability to ignore when no tests are run (elastic#28930) [rest-api-spec] update doc link for /_rank_eval Switch XContentBuilder from BytesStreamOutput to ByteArrayOutputStream (elastic#28945) Factor UnknownNamedObjectException into its own class (elastic#28931) ...
2 parents fe756a3 + 4ba80a7 commit 98a1b6b

File tree

76 files changed

+1400
-1376
lines changed

Some content is hidden

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

76 files changed

+1400
-1376
lines changed

TESTING.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ The REST tests are run automatically when executing the "./gradlew check" comman
270270
REST tests use the following command:
271271

272272
---------------------------------------------------------------------------
273-
./gradlew :distribution:integ-test-zip:integTest \
273+
./gradlew :distribution:archives:integ-test-zip:integTest \
274274
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
275275
---------------------------------------------------------------------------
276276

277277
A specific test case can be run with
278278

279279
---------------------------------------------------------------------------
280-
./gradlew :distribution:integ-test-zip:integTest \
280+
./gradlew :distribution:archives:integ-test-zip:integTest \
281281
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
282282
-Dtests.method="test {p0=cat.shards/10_basic/Help}"
283283
---------------------------------------------------------------------------
@@ -407,7 +407,7 @@ destructive. When working with a single package it's generally faster to run its
407407
tests in a tighter loop than Gradle provides. In one window:
408408

409409
--------------------------------
410-
./gradlew :distribution:rpm:assemble
410+
./gradlew :distribution:packages:rpm:assemble
411411
--------------------------------
412412

413413
and in another window:

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ class TestProgressLogger implements AggregatedEventListener {
100100

101101
@Subscribe
102102
void onQuit(AggregatedQuitEvent e) throws IOException {
103-
suiteLogger.completed()
104-
testLogger.completed()
105-
for (ProgressLogger slaveLogger : slaveLoggers) {
106-
slaveLogger.completed()
103+
// if onStart was never called (eg no matching tests), suiteLogger and all the other loggers will be null
104+
if (suiteLogger != null) {
105+
suiteLogger.completed()
106+
testLogger.completed()
107+
for (ProgressLogger slaveLogger : slaveLoggers) {
108+
slaveLogger.completed()
109+
}
110+
parentProgressLogger.completed()
107111
}
108-
parentProgressLogger.completed()
109112
}
110113

111114
@Subscribe

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class BuildPlugin implements Plugin<Project> {
558558
return {
559559
jvm "${project.runtimeJavaHome}/bin/java"
560560
parallelism System.getProperty('tests.jvms', 'auto')
561-
ifNoTests 'fail'
561+
ifNoTests System.getProperty('tests.ifNoTests', 'fail')
562562
onNonEmptyWorkDirectory 'wipe'
563563
leaveTemporary true
564564

@@ -582,8 +582,6 @@ class BuildPlugin implements Plugin<Project> {
582582
systemProperty 'tests.task', path
583583
systemProperty 'tests.security.manager', 'true'
584584
systemProperty 'jna.nosys', 'true'
585-
// default test sysprop values
586-
systemProperty 'tests.ifNoTests', 'fail'
587585
// TODO: remove setting logging level via system property
588586
systemProperty 'tests.logger.level', 'WARN'
589587
for (Map.Entry<String, String> property : System.properties.entrySet()) {

buildSrc/src/main/resources/forbidden/es-server-signatures.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ java.util.concurrent.Executors#privilegedThreadFactory()
2929
java.lang.Character#codePointBefore(char[],int) @ Implicit start offset is error-prone when the char[] is a buffer and the first chars are random chars
3030
java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone when the char[] is a buffer and the last chars are random chars
3131

32-
java.io.StringReader#<init>(java.lang.String) @ Use FastStringReader instead
33-
3432
@defaultMessage Reference management is tricky, leave it to SearcherManager
3533
org.apache.lucene.index.IndexReader#decRef()
3634
org.apache.lucene.index.IndexReader#incRef()

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public void testSearch() throws Exception {
129129
SearchRequest searchRequest = new SearchRequest(); // <1>
130130
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); // <2>
131131
searchSourceBuilder.query(QueryBuilders.matchAllQuery()); // <3>
132+
searchRequest.source(searchSourceBuilder); // <4>
132133
// end::search-request-basic
133134
}
134135
{

distribution/archives/build.gradle

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
2121
import org.apache.tools.ant.filters.FixCrLfFilter
2222
import org.elasticsearch.gradle.BuildPlugin
2323
import org.elasticsearch.gradle.EmptyDirTask
24+
import org.elasticsearch.gradle.LoggedExec
2425
import org.elasticsearch.gradle.MavenFilteringHack
2526
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2627

@@ -125,19 +126,39 @@ subprojects {
125126
artifacts {
126127
'default' buildDist
127128
}
129+
130+
// sanity checks if a archives can be extracted
131+
File extractionDir = new File(buildDir, 'extracted')
132+
task testExtraction(type: LoggedExec) {
133+
dependsOn buildDist
134+
doFirst {
135+
project.delete(extractionDir)
136+
extractionDir.mkdirs()
137+
}
138+
}
139+
if (project.name.contains('zip')) {
140+
testExtraction {
141+
onlyIf { new File('/bin/unzip').exists() || new File('/usr/bin/unzip').exists() || new File('/usr/local/bin/unzip').exists() }
142+
commandLine 'unzip', "${-> buildDist.outputs.files.singleFile}", '-d', extractionDir
143+
}
144+
} else { // tar
145+
testExtraction {
146+
onlyIf { new File('/bin/tar').exists() || new File('/usr/bin/tar').exists() || new File('/usr/local/bin/tar').exists() }
147+
commandLine 'tar', '-xvzf', "${-> buildDist.outputs.files.singleFile}", '-C', extractionDir
148+
}
149+
}
150+
check.dependsOn testExtraction
128151
}
129152

130153
/*****************************************************************************
131154
* Rest test config *
132155
*****************************************************************************/
133-
subprojects {
156+
configure(subprojects.findAll { it.name == 'integ-test-zip' }) {
134157
apply plugin: 'elasticsearch.standalone-rest-test'
135158
apply plugin: 'elasticsearch.rest-test'
136159

137-
if (project.name == 'integ-test-zip') {
138-
integTest {
139-
includePackaged true
140-
}
160+
integTest {
161+
includePackaged true
141162
}
142163

143164
integTestCluster {

distribution/archives/tar/src/test/java/org/elasticsearch/test/rest/TarClientYamlTestSuiteIT.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

distribution/archives/tar/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

distribution/archives/zip/src/test/java/org/elasticsearch/test/rest/ZipClientYamlTestSuiteIT.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

distribution/archives/zip/src/test/resources/rest-api-spec/test/smoke_test_plugins/10_modules.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/java-rest/high-level/search/search.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ include-tagged::{doc-tests}/SearchDocumentationIT.java[search-request-basic]
1818
<1> Creates the `SeachRequest`. Without arguments this runs against all indices.
1919
<2> Most search parameters are added to the `SearchSourceBuilder`. It offers setters for everything that goes into the search request body.
2020
<3> Add a `match_all` query to the `SearchSourceBuilder`.
21+
<4> Add the `SearchSourceBuilder` to the `SeachRequest`.
2122

2223
===== Optional arguments
2324

docs/reference/aggregations/pipeline/bucket-sort-aggregation.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ A `bucket_sort` aggregation looks like this in isolation:
2020
{
2121
"bucket_sort": {
2222
"sort": [
23-
{"sort_field_1": {"order": "asc"},<1>
24-
{"sort_field_2": {"order": "desc"},
23+
{"sort_field_1": {"order": "asc"}},<1>
24+
{"sort_field_2": {"order": "desc"}},
2525
"sort_field_3"
2626
],
2727
"from": 1,

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/IngestRestartIT.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
*/
1919
package org.elasticsearch.ingest.common;
2020

21+
import org.elasticsearch.ElasticsearchException;
22+
import org.elasticsearch.ExceptionsHelper;
2123
import org.elasticsearch.action.support.WriteRequest;
24+
import org.elasticsearch.common.Strings;
2225
import org.elasticsearch.common.bytes.BytesArray;
2326
import org.elasticsearch.common.bytes.BytesReference;
2427
import org.elasticsearch.common.settings.Settings;
28+
import org.elasticsearch.common.util.set.Sets;
2529
import org.elasticsearch.common.xcontent.XContentType;
2630
import org.elasticsearch.plugins.Plugin;
2731
import org.elasticsearch.script.MockScriptEngine;
@@ -33,6 +37,7 @@
3337
import java.util.Collection;
3438
import java.util.Collections;
3539
import java.util.Map;
40+
import java.util.function.Consumer;
3641
import java.util.function.Function;
3742

3843
import static org.hamcrest.Matchers.equalTo;
@@ -64,6 +69,66 @@ protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
6469
}
6570
}
6671

72+
public void testScriptDisabled() throws Exception {
73+
String pipelineIdWithoutScript = randomAlphaOfLengthBetween(5, 10);
74+
String pipelineIdWithScript = pipelineIdWithoutScript + "_script";
75+
internalCluster().startNode();
76+
77+
BytesReference pipelineWithScript = new BytesArray("{\n" +
78+
" \"processors\" : [\n" +
79+
" {\"script\" : {\"lang\": \"" + MockScriptEngine.NAME + "\", \"source\": \"my_script\"}}\n" +
80+
" ]\n" +
81+
"}");
82+
BytesReference pipelineWithoutScript = new BytesArray("{\n" +
83+
" \"processors\" : [\n" +
84+
" {\"set\" : {\"field\": \"y\", \"value\": 0}}\n" +
85+
" ]\n" +
86+
"}");
87+
88+
Consumer<String> checkPipelineExists = (id) -> assertThat(client().admin().cluster().prepareGetPipeline(id)
89+
.get().pipelines().get(0).getId(), equalTo(id));
90+
91+
client().admin().cluster().preparePutPipeline(pipelineIdWithScript, pipelineWithScript, XContentType.JSON).get();
92+
client().admin().cluster().preparePutPipeline(pipelineIdWithoutScript, pipelineWithoutScript, XContentType.JSON).get();
93+
94+
checkPipelineExists.accept(pipelineIdWithScript);
95+
checkPipelineExists.accept(pipelineIdWithoutScript);
96+
97+
98+
internalCluster().stopCurrentMasterNode();
99+
internalCluster().startNode(Settings.builder().put("script.allowed_types", "none"));
100+
101+
checkPipelineExists.accept(pipelineIdWithoutScript);
102+
checkPipelineExists.accept(pipelineIdWithScript);
103+
104+
client().prepareIndex("index", "doc", "1")
105+
.setSource("x", 0)
106+
.setPipeline(pipelineIdWithoutScript)
107+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
108+
.get();
109+
110+
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
111+
() -> client().prepareIndex("index", "doc", "2")
112+
.setSource("x", 0)
113+
.setPipeline(pipelineIdWithScript)
114+
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
115+
.get());
116+
assertThat(exception.getHeaderKeys(), equalTo(Sets.newHashSet("processor_type")));
117+
assertThat(exception.getHeader("processor_type"), equalTo(Arrays.asList("unknown")));
118+
assertThat(exception.getRootCause().getMessage(),
119+
equalTo("pipeline with id [" + pipelineIdWithScript + "] could not be loaded, caused by " +
120+
"[ElasticsearchParseException[Error updating pipeline with id [" + pipelineIdWithScript + "]]; " +
121+
"nested: ElasticsearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " +
122+
"nested: IllegalArgumentException[cannot execute [inline] scripts];; " +
123+
"ElasticsearchException[java.lang.IllegalArgumentException: cannot execute [inline] scripts]; " +
124+
"nested: IllegalArgumentException[cannot execute [inline] scripts];; java.lang.IllegalArgumentException: " +
125+
"cannot execute [inline] scripts]"));
126+
127+
Map<String, Object> source = client().prepareGet("index", "doc", "1").get().getSource();
128+
assertThat(source.get("x"), equalTo(0));
129+
assertThat(source.get("y"), equalTo(0));
130+
}
131+
67132
public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exception {
68133
internalCluster().startNode();
69134

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MustacheScriptEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.github.mustachejava.Mustache;
2222
import com.github.mustachejava.MustacheFactory;
2323

24+
import java.io.StringReader;
2425
import org.apache.logging.log4j.Logger;
2526
import org.apache.logging.log4j.message.ParameterizedMessage;
2627
import org.apache.logging.log4j.util.Supplier;
2728
import org.elasticsearch.SpecialPermission;
28-
import org.elasticsearch.common.io.FastStringReader;
2929
import org.elasticsearch.common.logging.ESLoggerFactory;
3030
import org.elasticsearch.script.GeneralScriptException;
3131
import org.elasticsearch.script.Script;
@@ -65,7 +65,7 @@ public <T> T compile(String templateName, String templateSource, ScriptContext<T
6565
throw new IllegalArgumentException("mustache engine does not know how to handle context [" + context.name + "]");
6666
}
6767
final MustacheFactory factory = createMustacheFactory(options);
68-
Reader reader = new FastStringReader(templateSource);
68+
Reader reader = new StringReader(templateSource);
6969
Mustache template = factory.compile(reader, "query-template");
7070
TemplateScript.Factory compiled = params -> new MustacheExecutableScript(template, params);
7171
return context.factoryClazz.cast(compiled);

0 commit comments

Comments
 (0)