Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script: Configuration driven validation for CtxMap #6

Open
wants to merge 44 commits into
base: ingest_sm_to_ctx_map
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4cc8484
Improve error when sorting on incompatible types (#88399)
mayya-sharipova Jul 11, 2022
86b35ed
Script: Configuration driven validation for CtxMap
stu-elastic Jul 11, 2022
472b824
Fix hashCode in CtxMap
stu-elastic Jul 11, 2022
1a0ef93
Merge branch 'ingest_ctx_map' of github.com:stu-elastic/elasticsearch…
stu-elastic Jul 11, 2022
48c62de
Merge branch 'ingest_sm_to_ctx_map' of github.com:stu-elastic/elastic…
stu-elastic Jul 12, 2022
b55a0bc
Fix test memory leak (#88362)
grcevski Jul 12, 2022
f9ac7ae
Fix unit tests
stu-elastic Jul 12, 2022
15328b1
FieldProperty javadoc
stu-elastic Jul 12, 2022
824cdc8
Implement getTimestamp() in IngestMetadata
stu-elastic Jul 12, 2022
c39bb9d
Use extended validators, add hashcode and equals for Metadata
stu-elastic Jul 12, 2022
e81f5fa
_type can be updated
stu-elastic Jul 12, 2022
7276bb0
Fix testExecutePropagateAllMetadataUpdates rather than allow _type to…
stu-elastic Jul 12, 2022
78244b7
Remove usages of TestGeoShapeFieldMapperPlugin from enrich module (#8…
iverase Jul 12, 2022
dd1bd83
Don't index geo_shape field in AbstractBuilderTestCase (#88437)
iverase Jul 12, 2022
47510ad
Reduce map lookups (#88418)
idegtiarenko Jul 12, 2022
9ebbe1c
Make ClusterInfo use immutable maps in all cases (#88447)
original-brownbear Jul 12, 2022
a4ec9c6
Correct some typos/mistakes in comments/docs (#88446)
pxsalehi Jul 12, 2022
ecc9605
[TSDB] Cache rollup bucket timestamp to reduce rounding cost (#88420)
weizijun Jul 12, 2022
4889650
Pass IndexMetadata to AllocationDecider.can_remain (#88453)
original-brownbear Jul 12, 2022
a2ee4c5
Polish reworked LoggedExec task (#88424)
breskeby Jul 12, 2022
c56715f
Updatable API keys - logging audit trail event (#88276)
n1v0lg Jul 12, 2022
5628b87
Bound random negative size test in SearchSourceBuilderTests#testNegat…
matschaffer Jul 12, 2022
24d2520
Audit API key ID when create or grant API keys (#88456)
ywangd Jul 12, 2022
3ed549b
TSDB: RollupShardIndexer logging improvements (#88416)
weizijun Jul 12, 2022
4af02b8
Stop registering TestGeoShapeFieldMapperPlugin in ESIntegTestCase (#8…
iverase Jul 12, 2022
47ecd20
Use consistent shard map type in IndexService (#88465)
original-brownbear Jul 12, 2022
67cacde
Corrected an incomplete sentence. (#86542)
local-ghost-127 Jul 12, 2022
28048a5
Updatable API keys - noop check (#88346)
n1v0lg Jul 12, 2022
bb95041
unmute test (#88454)
jakelandis Jul 12, 2022
1e07915
INFO logging of snapshot restore and completion (#88257)
kingherc Jul 12, 2022
84af493
Fix ReactiveStorageDeciderServiceTests testNodeSizeForDataBelowLowWat…
original-brownbear Jul 12, 2022
ba46bd4
Avoid noisy exceptions on data nodes when aborting snapshots (#88476)
original-brownbear Jul 12, 2022
7be1f41
Merge branch 'master' of github.com:stu-elastic/elasticsearch into in…
stu-elastic Jul 12, 2022
b790256
Track the count of failed invocations since last successful policy sn…
jbaiera Jul 12, 2022
c636e43
Mute ReactiveStorageIT#testScaleDuringSplitOrClone (#88480)
pxsalehi Jul 12, 2022
08c54f1
Enable TRACE Logging for test and increase timeout (#88477)
pxsalehi Jul 12, 2022
c271d39
Move runtime fields base scripts out of scripting fields api package.…
jdconrad Jul 12, 2022
39de085
Ingest: Start separating Metadata from IngestSourceAndMetadata (#88401)
stu-elastic Jul 12, 2022
e27d73a
Merge branch 'master' of github.com:stu-elastic/elasticsearch into in…
stu-elastic Jul 12, 2022
9c7b389
Remove getIngestSourceAndMetadata
stu-elastic Jul 12, 2022
5a45f97
Don't clone properties, add MetadataTests
stu-elastic Jul 12, 2022
dc1fc58
IngestMetadata -> IngestDocMetadata, remove splitSourceAndMetadta, fi…
stu-elastic Jul 13, 2022
a08afb8
Don't copy source
stu-elastic Jul 13, 2022
8eb42c6
Revert "Don't copy source"
stu-elastic Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LoggedExecFuncTest extends AbstractGradleFuncTest {
import org.elasticsearch.gradle.LoggedExec
tasks.register('loggedExec', LoggedExec) {
commandLine 'ls', '-lh'
spoolOutput = $spooling
getSpoolOutput().set($spooling)
}
"""
when:
Expand All @@ -54,7 +54,7 @@ class LoggedExecFuncTest extends AbstractGradleFuncTest {
import org.elasticsearch.gradle.LoggedExec
tasks.register('loggedExec', LoggedExec) {
commandLine 'ls', 'wtf'
spoolOutput = $spooling
getSpoolOutput().set($spooling)
}
"""
when:
Expand Down Expand Up @@ -97,7 +97,7 @@ class LoggedExecFuncTest extends AbstractGradleFuncTest {
tasks.register('loggedExec', LoggedExec) {
commandLine 'echo', 'HELLO'
getCaptureOutput().set(true)
spoolOutput = true
getSpoolOutput().set(true)
}
"""
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
protected FileSystemOperations fileSystemOperations;
private ProjectLayout projectLayout;
private ExecOperations execOperations;
private boolean spoolOutput;

@Input
@Optional
Expand Down Expand Up @@ -84,6 +83,9 @@ public abstract class LoggedExec extends DefaultTask implements FileSystemOperat
@Input
abstract public Property<File> getWorkingDir();

@Internal
abstract public Property<Boolean> getSpoolOutput();

private String output;

@Inject
Expand All @@ -95,14 +97,16 @@ public LoggedExec(ProjectLayout projectLayout, ExecOperations execOperations, Fi
// For now mimic default behaviour of Gradle Exec task here
getEnvironment().putAll(System.getenv());
getCaptureOutput().convention(false);
getSpoolOutput().convention(false);
}

@TaskAction
public void run() {
boolean spoolOutput = getSpoolOutput().get();
if (spoolOutput && getCaptureOutput().get()) {
throw new GradleException("Capturing output is not supported when spoolOutput is true.");
}
if (getCaptureOutput().getOrElse(false) && getIndentingConsoleOutput().isPresent()) {
if (getCaptureOutput().get() && getIndentingConsoleOutput().isPresent()) {
throw new GradleException("Capturing output is not supported when indentingConsoleOutput is configured.");
}
Consumer<Logger> outputLogger;
Expand Down Expand Up @@ -156,7 +160,9 @@ public void run() {
if (getLogger().isInfoEnabled() == false) {
if (exitValue != 0) {
try {
getLogger().error("Output for " + getExecutable().get() + ":");
if (getIndentingConsoleOutput().isPresent() == false) {
getLogger().error("Output for " + getExecutable().get() + ":");
}
outputLogger.accept(getLogger());
} catch (Exception e) {
throw new GradleException("Failed to read exec output", e);
Expand All @@ -173,10 +179,6 @@ private String byteStreamToString(OutputStream out) {
return ((ByteArrayOutputStream) out).toString(StandardCharsets.UTF_8);
}

public void setSpoolOutput(boolean spoolOutput) {
this.spoolOutput = spoolOutput;
}

public static ExecResult exec(ExecOperations execOperations, Action<ExecSpec> action) {
return genericExec(execOperations::exec, action);
}
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/88257.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 88257
summary: INFO logging of snapshot restore and completion
area: Snapshot/Restore
type: enhancement
issues:
- 86610
5 changes: 5 additions & 0 deletions docs/changelog/88276.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88276
summary: Updatable API keys - logging audit trail event
area: Audit
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/88346.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88346
summary: Updatable API keys - noop check
area: Security
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/88398.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88398
summary: Track the count of failed invocations since last successful policy snapshot
area: ILM+SLM
type: enhancement
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/88399.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 88399
summary: Improve error when sorting on incompatible types
area: Search
type: enhancement
issues:
- 73146
5 changes: 5 additions & 0 deletions docs/changelog/88456.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88456
summary: Audit API key ID when create or grant API keys
area: Audit
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<titleabbrev>Avg</titleabbrev>
++++

A `single-value` metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents. These values can be extracted either from specific numeric fields in the documents.
A `single-value` metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents. These values can be extracted either from specific numeric or <<histogram,histogram>> fields in the documents.

Assuming the data consists of documents representing exams grades (between 0
and 100) of students we can average their scores with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.ingest.RandomDocumentPicks;
import org.elasticsearch.ingest.TestIngestDocument;
import org.elasticsearch.ingest.TestTemplateService;
import org.elasticsearch.script.Metadata;
import org.elasticsearch.test.ESTestCase;

import java.util.ArrayList;
Expand Down Expand Up @@ -140,11 +141,14 @@ public void testRenameAtomicOperationSetFails() throws Exception {
Map<String, Object> metadata = new HashMap<>();
metadata.put("list", Collections.singletonList("item"));

IngestDocument ingestDocument = TestIngestDocument.ofMetadataWithValidator(metadata, Map.of("new_field", (o, k, v) -> {
if (v != null) {
throw new UnsupportedOperationException();
}
}, "list", (o, k, v) -> {}));
IngestDocument ingestDocument = TestIngestDocument.ofMetadataWithValidator(
metadata,
Map.of("new_field", new Metadata.FieldProperty<>(Object.class, true, true, (k, v) -> {
if (v != null) {
throw new UnsupportedOperationException();
}
}), "list", new Metadata.FieldProperty<>(Object.class, true, true, null))
);
Processor processor = createRenameProcessor("list", "new_field", false);
try {
processor.execute(ingestDocument);
Expand All @@ -160,16 +164,15 @@ public void testRenameAtomicOperationRemoveFails() throws Exception {
Map<String, Object> metadata = new HashMap<>();
metadata.put("list", Collections.singletonList("item"));

IngestDocument ingestDocument = TestIngestDocument.ofMetadataWithValidator(metadata, Map.of("list", (o, k, v) -> {
if (v == null) {
throw new UnsupportedOperationException();
}
}));
IngestDocument ingestDocument = TestIngestDocument.ofMetadataWithValidator(
metadata,
Map.of("list", new Metadata.FieldProperty<>(Object.class, false, true, null))
);
Processor processor = createRenameProcessor("list", "new_field", false);
try {
processor.execute(ingestDocument);
fail("processor execute should have failed");
} catch (UnsupportedOperationException e) {
} catch (IllegalArgumentException e) {
// the set failed, the old field has not been removed
assertThat(ingestDocument.getSourceAndMetadata().containsKey("list"), equalTo(true));
assertThat(ingestDocument.getSourceAndMetadata().containsKey("new_field"), equalTo(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void testInlineIsCompiled() throws Exception {
assertThat(processor.getScript().getParams(), equalTo(Collections.emptyMap()));
assertNotNull(processor.getPrecompiledIngestScriptFactory());
IngestDocument doc = TestIngestDocument.emptyIngestDocument();
Map<String, Object> ctx = TestIngestDocument.emptyIngestDocument().getIngestSourceAndMetadata();
Map<String, Object> ctx = TestIngestDocument.emptyIngestDocument().getSourceAndMetadata();
processor.getPrecompiledIngestScriptFactory().newInstance(null, doc.getMetadata(), ctx).execute();
assertThat(ctx.get("foo"), equalTo("bar"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

public class GeoBoundingBoxQueryLegacyGeoShapeIT extends GeoBoundingBoxQueryIntegTestCase {

@Override
protected boolean addMockGeoShapeFieldMapper() {
return false;
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(TestLegacyGeoShapeFieldMapperPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

public class LegacyGeoShapeIT extends GeoShapeIntegTestCase {

@Override
protected boolean addMockGeoShapeFieldMapper() {
return false;
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(TestLegacyGeoShapeFieldMapperPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.elasticsearch.index.query.SearchExecutionContext;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -54,7 +53,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(MapperExtrasPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.join.ParentJoinPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.aggregations.BaseAggregationTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -20,7 +19,7 @@ public class ChildrenTests extends BaseAggregationTestCase<ChildrenAggregationBu

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(ParentJoinPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.join.ParentJoinPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.aggregations.BaseAggregationTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -20,7 +19,7 @@ public class ParentTests extends BaseAggregationTestCase<ParentAggregationBuilde

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(ParentJoinPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down Expand Up @@ -77,7 +76,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase<HasChildQue

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(ParentJoinPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down Expand Up @@ -60,7 +59,7 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase<HasParentQ

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(ParentJoinPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.join.ParentJoinPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.xcontent.XContentBuilder;
import org.hamcrest.Matchers;

Expand All @@ -48,7 +47,7 @@ public class ParentIdQueryBuilderTests extends AbstractQueryTestCase<ParentIdQue

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(ParentJoinPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@

public class PercolatorQuerySearchIT extends ESIntegTestCase {

@Override
protected boolean addMockGeoShapeFieldMapper() {
return false;
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.ingest.RandomDocumentPicks;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.AbstractQueryTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -77,7 +76,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ

@Override
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(PercolatorPlugin.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.plugins.EnginePlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xcontent.XContentBuilder;
Expand Down Expand Up @@ -57,6 +58,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
List<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins());
plugins.add(EngineTestPlugin.class);
plugins.add(MockTransportService.TestPlugin.class);
plugins.add(TestGeoShapeFieldMapperPlugin.class);
return plugins;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ public ClusterState.Custom randomCreate(String name) {
UUIDs.randomBase64UUID(),
new Snapshot(randomName("repo"), new SnapshotId(randomName("snap"), UUIDs.randomBase64UUID())),
RestoreInProgress.State.fromValue((byte) randomIntBetween(0, 3)),
randomBoolean(),
emptyList(),
ImmutableOpenMap.of()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
package org.elasticsearch.search.geo;

import org.elasticsearch.Version;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;

public class GeoBoundingBoxQueryGeoPointIT extends GeoBoundingBoxQueryIntegTestCase {

@SuppressWarnings("deprecation")
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(TestGeoShapeFieldMapperPlugin.class);
}

@Override
public XContentBuilder getMapping() throws IOException {
XContentBuilder xContentBuilder = XContentFactory.jsonBuilder()
Expand Down
Loading