Skip to content

Commit f9276cf

Browse files
Merge pull request #151 from elastic/master
🤖 ESQL: Merge upstream
2 parents 684aa9a + e0ced8a commit f9276cf

File tree

60 files changed

+505
-385
lines changed

Some content is hidden

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

60 files changed

+505
-385
lines changed

distribution/src/config/log4j2.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ status = error
33
appender.console.type = Console
44
appender.console.name = console
55
appender.console.layout.type = PatternLayout
6-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n
6+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%consoleException%n
77

88
######## Server JSON ############################
99
appender.rolling.type = RollingFile

docs/changelog/87687.yaml renamed to docs/changelog/87881.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pr: 87687
1+
pr: 87881
22
summary: Make CBE message creation more robust
33
area: Infra/Circuit Breakers
44
type: bug

docs/changelog/87884.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 87884
2+
summary: Add authorization info to ML config listings
3+
area: Machine Learning
4+
type: enhancement
5+
issues: []

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.ingest.common;
1010

1111
import org.elasticsearch.ingest.IngestDocument;
12+
import org.elasticsearch.ingest.TestIngestDocument;
1213
import org.elasticsearch.test.ESTestCase;
1314
import org.junit.Before;
1415

@@ -350,7 +351,7 @@ private void testCommunityIdProcessor(Map<String, Object> source, int seed, Stri
350351
ignoreMissing
351352
);
352353

353-
IngestDocument input = new IngestDocument(source, Map.of());
354+
IngestDocument input = TestIngestDocument.ofSourceAndMetadata(source);
354355
IngestDocument output = processor.execute(input);
355356

356357
String hash = output.getFieldValue(DEFAULT_TARGET, String.class, ignoreMissing);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.ingest.IngestDocument;
1212
import org.elasticsearch.ingest.Processor;
1313
import org.elasticsearch.ingest.RandomDocumentPicks;
14+
import org.elasticsearch.ingest.TestIngestDocument;
1415
import org.elasticsearch.test.ESTestCase;
1516

1617
import java.util.ArrayList;
@@ -585,7 +586,7 @@ public void testAutoConvertMatchFloat() throws Exception {
585586
}
586587

587588
public void testTargetField() throws Exception {
588-
IngestDocument ingestDocument = new IngestDocument(new HashMap<>(), new HashMap<>());
589+
IngestDocument ingestDocument = TestIngestDocument.emptyIngestDocument();
589590
int randomInt = randomInt();
590591
String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, String.valueOf(randomInt));
591592
String targetField = fieldName + randomAlphaOfLength(5);

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.elasticsearch.ingest.IngestDocument;
1212
import org.elasticsearch.ingest.Processor;
13+
import org.elasticsearch.ingest.TestIngestDocument;
1314
import org.elasticsearch.ingest.TestTemplateService;
1415
import org.elasticsearch.test.ESTestCase;
1516

@@ -25,15 +26,15 @@ public class DotExpanderProcessorTests extends ESTestCase {
2526
public void testEscapeFields() throws Exception {
2627
Map<String, Object> source = new HashMap<>();
2728
source.put("foo.bar", "baz1");
28-
IngestDocument document = new IngestDocument(source, Collections.emptyMap());
29+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
2930
DotExpanderProcessor processor = new DotExpanderProcessor("_tag", null, null, "foo.bar");
3031
processor.execute(document);
3132
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
3233
assertThat(document.getFieldValue("foo.bar", String.class), equalTo("baz1"));
3334

3435
source = new HashMap<>();
3536
source.put("foo.bar.baz", "value");
36-
document = new IngestDocument(source, Collections.emptyMap());
37+
document = TestIngestDocument.ofSourceAndMetadata(source);
3738
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar.baz");
3839
processor.execute(document);
3940
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -43,7 +44,7 @@ public void testEscapeFields() throws Exception {
4344
source = new HashMap<>();
4445
source.put("foo.bar", "baz1");
4546
source.put("foo", new HashMap<>(Collections.singletonMap("bar", "baz2")));
46-
document = new IngestDocument(source, Collections.emptyMap());
47+
document = TestIngestDocument.ofSourceAndMetadata(source);
4748
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar");
4849
processor.execute(document);
4950
assertThat(document.getSourceAndMetadata().size(), equalTo(1));
@@ -54,7 +55,7 @@ public void testEscapeFields() throws Exception {
5455
source = new HashMap<>();
5556
source.put("foo.bar", "2");
5657
source.put("foo", new HashMap<>(Collections.singletonMap("bar", 1)));
57-
document = new IngestDocument(source, Collections.emptyMap());
58+
document = TestIngestDocument.ofSourceAndMetadata(source);
5859
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar");
5960
processor.execute(document);
6061
assertThat(document.getSourceAndMetadata().size(), equalTo(1));
@@ -67,15 +68,15 @@ public void testEscapeFields_valueField() throws Exception {
6768
Map<String, Object> source = new HashMap<>();
6869
source.put("foo.bar", "baz1");
6970
source.put("foo", "baz2");
70-
IngestDocument document1 = new IngestDocument(source, Collections.emptyMap());
71+
IngestDocument document1 = TestIngestDocument.ofSourceAndMetadata(source);
7172
Processor processor1 = new DotExpanderProcessor("_tag", null, null, "foo.bar");
7273
// foo already exists and if a leaf field and therefor can't be replaced by a map field:
7374
Exception e = expectThrows(IllegalArgumentException.class, () -> processor1.execute(document1));
7475
assertThat(e.getMessage(), equalTo("cannot expand [foo.bar], because [foo] is not an object field, but a value field"));
7576

7677
// so because foo is no branch field but a value field the `foo.bar` field can't be expanded
7778
// into [foo].[bar], so foo should be renamed first into `[foo].[bar]:
78-
IngestDocument document = new IngestDocument(source, Collections.emptyMap());
79+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
7980
Processor processor = new RenameProcessor(
8081
"_tag",
8182
null,
@@ -92,7 +93,7 @@ public void testEscapeFields_valueField() throws Exception {
9293

9394
source = new HashMap<>();
9495
source.put("foo.bar", "baz1");
95-
document = new IngestDocument(source, Collections.emptyMap());
96+
document = TestIngestDocument.ofSourceAndMetadata(source);
9697
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar");
9798
processor.execute(document);
9899
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -101,7 +102,7 @@ public void testEscapeFields_valueField() throws Exception {
101102
source = new HashMap<>();
102103
source.put("foo.bar.baz", "baz1");
103104
source.put("foo", new HashMap<>(Collections.singletonMap("bar", new HashMap<>())));
104-
document = new IngestDocument(source, Collections.emptyMap());
105+
document = TestIngestDocument.ofSourceAndMetadata(source);
105106
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar.baz");
106107
processor.execute(document);
107108
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -111,7 +112,7 @@ public void testEscapeFields_valueField() throws Exception {
111112
source = new HashMap<>();
112113
source.put("foo.bar.baz", "baz1");
113114
source.put("foo", new HashMap<>(Collections.singletonMap("bar", "baz2")));
114-
IngestDocument document2 = new IngestDocument(source, Collections.emptyMap());
115+
IngestDocument document2 = TestIngestDocument.ofSourceAndMetadata(source);
115116
Processor processor2 = new DotExpanderProcessor("_tag", null, null, "foo.bar.baz");
116117
e = expectThrows(IllegalArgumentException.class, () -> processor2.execute(document2));
117118
assertThat(e.getMessage(), equalTo("cannot expand [foo.bar.baz], because [foo.bar] is not an object field, but a value field"));
@@ -120,7 +121,7 @@ public void testEscapeFields_valueField() throws Exception {
120121
public void testEscapeFields_path() throws Exception {
121122
Map<String, Object> source = new HashMap<>();
122123
source.put("foo", new HashMap<>(Collections.singletonMap("bar.baz", "value")));
123-
IngestDocument document = new IngestDocument(source, Collections.emptyMap());
124+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
124125
DotExpanderProcessor processor = new DotExpanderProcessor("_tag", null, "foo", "bar.baz");
125126
processor.execute(document);
126127
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -129,7 +130,7 @@ public void testEscapeFields_path() throws Exception {
129130

130131
source = new HashMap<>();
131132
source.put("field", new HashMap<>(Collections.singletonMap("foo.bar.baz", "value")));
132-
document = new IngestDocument(source, Collections.emptyMap());
133+
document = TestIngestDocument.ofSourceAndMetadata(source);
133134
processor = new DotExpanderProcessor("_tag", null, "field", "foo.bar.baz");
134135
processor.execute(document);
135136
assertThat(document.getFieldValue("field.foo", Map.class).size(), equalTo(1));
@@ -141,7 +142,7 @@ public void testEscapeFields_doNothingIfFieldNotInSourceDoc() throws Exception {
141142
// asking to expand a (literal) field that is not present in the source document
142143
Map<String, Object> source = new HashMap<>();
143144
source.put("foo.bar", "baz1");
144-
IngestDocument document = new IngestDocument(source, Collections.emptyMap());
145+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
145146
// abc.def does not exist in source, so don't mutate document
146147
DotExpanderProcessor processor = new DotExpanderProcessor("_tag", null, null, "abc.def");
147148
processor.execute(document);
@@ -159,7 +160,7 @@ public void testEscapeFields_doNothingIfFieldNotInSourceDoc() throws Exception {
159160
Map<String, Object> inner = new HashMap<>();
160161
inner.put("bar", "baz1");
161162
source.put("foo", inner);
162-
document = new IngestDocument(source, Collections.emptyMap());
163+
document = TestIngestDocument.ofSourceAndMetadata(source);
163164
// foo.bar, the literal value (as opposed to nested value) does not exist in source, so don't mutate document
164165
processor = new DotExpanderProcessor("_tag", null, null, "foo.bar");
165166
processor.execute(document);
@@ -177,7 +178,7 @@ public void testOverride() throws Exception {
177178
inner.put("qux", "quux");
178179
source.put("foo", inner);
179180
source.put("foo.bar", "baz2");
180-
IngestDocument document = new IngestDocument(source, Map.of());
181+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
181182
DotExpanderProcessor processor = new DotExpanderProcessor("_tag", null, null, "foo.bar", true);
182183
processor.execute(document);
183184
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(2));
@@ -189,7 +190,7 @@ public void testWildcard() throws Exception {
189190
Map<String, Object> source = new HashMap<>();
190191
source.put("foo.bar", "baz");
191192
source.put("qux.quux", "corge");
192-
IngestDocument document = new IngestDocument(source, Map.of());
193+
IngestDocument document = TestIngestDocument.ofSourceAndMetadata(source);
193194
DotExpanderProcessor processor = new DotExpanderProcessor("_tag", null, null, "*");
194195
processor.execute(document);
195196
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -201,7 +202,7 @@ public void testWildcard() throws Exception {
201202
Map<String, Object> inner = new HashMap<>();
202203
inner.put("bar.baz", "qux");
203204
source.put("foo", inner);
204-
document = new IngestDocument(source, Map.of());
205+
document = TestIngestDocument.ofSourceAndMetadata(source);
205206
processor = new DotExpanderProcessor("_tag", null, "foo", "*");
206207
processor.execute(document);
207208
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));
@@ -212,7 +213,7 @@ public void testWildcard() throws Exception {
212213
inner = new HashMap<>();
213214
inner.put("bar.baz", "qux");
214215
source.put("foo", inner);
215-
document = new IngestDocument(source, Map.of());
216+
document = TestIngestDocument.ofSourceAndMetadata(source);
216217
processor = new DotExpanderProcessor("_tag", null, null, "*");
217218
processor.execute(document);
218219
assertThat(document.getFieldValue("foo", Map.class).size(), equalTo(1));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package org.elasticsearch.ingest.common;
1010

11-
import org.elasticsearch.ingest.IngestDocument;
11+
import org.elasticsearch.ingest.TestIngestDocument;
1212
import org.elasticsearch.test.ESTestCase;
1313

1414
import java.security.MessageDigest;
@@ -227,7 +227,7 @@ private String doTestFingerprint(
227227
MessageDigest md = MessageDigest.getInstance(FingerprintProcessor.Factory.DEFAULT_METHOD);
228228
expectedBytes = md.digest(expectedBytes);
229229

230-
var input = new IngestDocument(inputMap, Map.of());
230+
var input = TestIngestDocument.ofSourceAndMetadata(inputMap);
231231
var output = fp.execute(input);
232232
assertTrue(output.hasField("fingerprint"));
233233
String fingerprint = output.getFieldValue("fingerprint", String.class);
@@ -257,7 +257,7 @@ public void testMethod() throws Exception {
257257
config.put("method", FingerprintProcessor.Factory.SUPPORTED_DIGESTS[k]);
258258

259259
FingerprintProcessor fp = factory.create(null, randomAlphaOfLength(10), null, config);
260-
var input = new IngestDocument(inputMap, Map.of());
260+
var input = TestIngestDocument.ofSourceAndMetadata(inputMap);
261261
var output = fp.execute(input);
262262
assertTrue(output.hasField("fingerprint"));
263263
String fingerprint = output.getFieldValue("fingerprint", String.class);
@@ -394,7 +394,7 @@ private void doTestObjectTraversal(Map<String, Object> inputMap, List<String> fi
394394
expectedBytes = concatBytes(expectedBytes, toBytes(value));
395395
}
396396

397-
var input = new IngestDocument(inputMap, Map.of());
397+
var input = TestIngestDocument.ofSourceAndMetadata(inputMap);
398398
var output = fp.execute(input);
399399
var hasher = (TestHasher) threadLocalHasher.get();
400400
assertThat(hasher.getBytesSeen(), equalTo(expectedBytes));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.grok.MatcherWatchdog;
1212
import org.elasticsearch.ingest.IngestDocument;
1313
import org.elasticsearch.ingest.RandomDocumentPicks;
14+
import org.elasticsearch.ingest.TestIngestDocument;
1415
import org.elasticsearch.test.ESTestCase;
1516

1617
import java.util.Arrays;
@@ -99,7 +100,7 @@ public void testNoMatchingPatternName() {
99100

100101
public void testMatchWithoutCaptures() throws Exception {
101102
String fieldName = "value";
102-
IngestDocument originalDoc = new IngestDocument(new HashMap<>(), new HashMap<>());
103+
IngestDocument originalDoc = TestIngestDocument.emptyIngestDocument();
103104
originalDoc.setFieldValue(fieldName, fieldName);
104105
IngestDocument doc = new IngestDocument(originalDoc);
105106
GrokProcessor processor = new GrokProcessor(

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.elasticsearch.ElasticsearchParseException;
1212
import org.elasticsearch.ingest.IngestDocument;
13+
import org.elasticsearch.ingest.TestIngestDocument;
1314
import org.elasticsearch.ingest.TestTemplateService;
1415
import org.elasticsearch.test.ESTestCase;
1516

@@ -149,7 +150,7 @@ public void testReadFromField() throws Exception {
149150
null,
150151
config
151152
);
152-
IngestDocument input = new IngestDocument(source, Map.of());
153+
IngestDocument input = TestIngestDocument.ofSourceAndMetadata(source);
153154
IngestDocument output = processor.execute(input);
154155
String hash = output.getFieldValue(DEFAULT_TARGET, String.class);
155156
assertThat(hash, equalTo("external"));
@@ -195,7 +196,7 @@ private void testNetworkDirectionProcessor(
195196
config
196197
);
197198

198-
IngestDocument input = new IngestDocument(source, Map.of());
199+
IngestDocument input = TestIngestDocument.ofSourceAndMetadata(source);
199200
IngestDocument output = processor.execute(input);
200201

201202
String hash = output.getFieldValue(DEFAULT_TARGET, String.class, ignoreMissing);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.ingest.common;
1010

1111
import org.elasticsearch.ingest.IngestDocument;
12+
import org.elasticsearch.ingest.TestIngestDocument;
1213
import org.elasticsearch.test.ESTestCase;
1314

1415
import java.util.HashMap;
@@ -74,7 +75,7 @@ public void testUseRoot() throws Exception {
7475

7576
var processor = new RegisteredDomainProcessor(null, null, "domain", "", false);
7677

77-
IngestDocument input = new IngestDocument(source, Map.of());
78+
IngestDocument input = TestIngestDocument.ofSourceAndMetadata(source);
7879
IngestDocument output = processor.execute(input);
7980

8081
String domain = output.getFieldValue(domainField, String.class);
@@ -125,7 +126,7 @@ private void testRegisteredDomainProcessor(
125126

126127
var processor = new RegisteredDomainProcessor(null, null, "domain", "url", ignoreMissing);
127128

128-
IngestDocument input = new IngestDocument(source, Map.of());
129+
IngestDocument input = TestIngestDocument.ofSourceAndMetadata(source);
129130
IngestDocument output = processor.execute(input);
130131

131132
String domain = output.getFieldValue(domainField, String.class, expectedDomain == null);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.ingest.IngestDocument;
1212
import org.elasticsearch.ingest.Processor;
1313
import org.elasticsearch.ingest.RandomDocumentPicks;
14+
import org.elasticsearch.ingest.TestIngestDocument;
1415
import org.elasticsearch.ingest.TestTemplateService;
1516
import org.elasticsearch.test.ESTestCase;
1617

@@ -147,7 +148,7 @@ public Object put(String key, Object value) {
147148
};
148149
source.put("list", Collections.singletonList("item"));
149150

150-
IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap());
151+
IngestDocument ingestDocument = TestIngestDocument.ofSourceAndMetadata(source);
151152
Processor processor = createRenameProcessor("list", "new_field", false);
152153
try {
153154
processor.execute(ingestDocument);
@@ -171,7 +172,7 @@ public Object remove(Object key) {
171172
};
172173
source.put("list", Collections.singletonList("item"));
173174

174-
IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap());
175+
IngestDocument ingestDocument = TestIngestDocument.ofSourceAndMetadata(source);
175176
Processor processor = createRenameProcessor("list", "new_field", false);
176177
try {
177178
processor.execute(ingestDocument);
@@ -186,7 +187,7 @@ public Object remove(Object key) {
186187
public void testRenameLeafIntoBranch() throws Exception {
187188
Map<String, Object> source = new HashMap<>();
188189
source.put("foo", "bar");
189-
IngestDocument ingestDocument = new IngestDocument(source, Collections.emptyMap());
190+
IngestDocument ingestDocument = TestIngestDocument.ofSourceAndMetadata(source);
190191
Processor processor1 = createRenameProcessor("foo", "foo.bar", false);
191192
processor1.execute(ingestDocument);
192193
assertThat(ingestDocument.getFieldValue("foo", Map.class), equalTo(Collections.singletonMap("bar", "bar")));

0 commit comments

Comments
 (0)