-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Ingest: Add validation and strong typing to sourceAndMetdata map #87673
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
Merged
stu-elastic
merged 62 commits into
elastic:master
from
stu-elastic:ingest_validating-map
Jun 27, 2022
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
d9c1f40
Ingest: IngestDocument requires non-null version
stu-elastic 9a21f12
Fix doc and unit tests
stu-elastic d1286b1
simulate sets version to Versions.MATCH_ANY
stu-elastic d051ec1
Ingest: Add validation and strong typing to sourceAndMetdata map
stu-elastic 466287a
Merge branch 'ingest_long-version' of github.com:stu-elastic/elastics…
stu-elastic 05db222
Fix test compile issues
stu-elastic 02246f3
spotless
stu-elastic 4d7883d
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic aece824
Clean up some tests
stu-elastic d7bbe07
more test cleanup
stu-elastic 94ba063
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic 5444453
update size for version, check for entries individually to avoid type…
stu-elastic 567d159
spotless
stu-elastic d7c61a8
Fix xpack tests by using the test constructor, add ValidatingMap and …
stu-elastic 0121dff
version added in test constructor, no need to add in test
stu-elastic b07a484
comment hashcode in xcontent test, produce valid random metadata
stu-elastic 5e5a899
Ingest: move IngestDocument test ctor usage to static builder
stu-elastic 1801596
Add javadoc and comments
stu-elastic 4d27346
revert modules/ingest-common/build.gradle
stu-elastic 145cd6b
map constructor and fromWire javadoc
stu-elastic 7feb3f7
Use map in CircleProcessorTests
stu-elastic 5b4fdf0
WIP
stu-elastic 26582c0
Move test constructors to test framework
stu-elastic 4f72efb
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic a20642b
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic b4dffc8
Merge branch 'ingest_document-test-constructor' of github.com:stu-ela…
stu-elastic ae3e171
getMetadata returns strings
stu-elastic 6462fbe
New constructors
stu-elastic 0c37da1
Remove version must exist validation
stu-elastic 346c772
IngestDocument.fromWire -> of & TestIngestDocument.{{from -> of}Sourc…
stu-elastic afdbfdd
Revert unnecessary changes from Metadata move
stu-elastic 3edbf05
spotless
stu-elastic 7bcb441
merge of
stu-elastic 821abab
Put all metadata in metadata map, use correct types for if seq and if…
stu-elastic 178b3ec
handle copying IngestSourceAndMetadata in constructor
stu-elastic e436eb7
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic 00d378c
Remove override xcontent test
stu-elastic 5b57462
Correct source and metadata order
stu-elastic f93512a
Fix dynamic template getter
stu-elastic 4b409fe
Fix rename processor tests
stu-elastic 32f31e3
IngestDocumentMatcher matches underlying maps
stu-elastic 902c104
Cleanup IngestDocument
stu-elastic 63ce5eb
Add getter tests
stu-elastic e1ff7c2
Metadata tests
stu-elastic 1735ba4
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic 46cd1ee
Test source and metadata separately in IngestClientIT
stu-elastic 0be9818
IngestSourceAndMetadata covering unit tests
stu-elastic c1ab555
Comments
stu-elastic 79fe344
spotless
stu-elastic 281a6ce
Move IngestSourceAndMetadata package private
stu-elastic 6b52e40
Continue hiding IngestSourceAndMetdata in tests by adding ability to …
stu-elastic 9181ea6
Merge branch 'master' of github.com:elastic/elasticsearch into ingest…
stu-elastic e39ab10
use correct helper in getString test
stu-elastic 1ff3adb
WriteableIngest presize, typo in primate, more tests, type and value …
stu-elastic e8ecf2a
Validators are BiConsumers, fix TestIG javadoc, rm extra setup call
stu-elastic 70becc6
remove return from validator javadoc
stu-elastic 30b89e0
clean up consumer validators
stu-elastic 1460ae9
Remove some IngestDocument and IngestSourceAndMetadata constructors
stu-elastic 13f6898
Move getTimestamp from IngestDocument to IngestSourceAndMetadata
stu-elastic 0849a2f
Merge branch 'master' of github.com:stu-elastic/elasticsearch into in…
stu-elastic 2bad2d0
getIngestSourceAndMetadata pkg private, expect ingestMetadata to be n…
stu-elastic 9de0da6
Merge branch 'master' of github.com:stu-elastic/elasticsearch into in…
stu-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| import org.elasticsearch.common.util.Maps; | ||
| import org.elasticsearch.common.util.set.Sets; | ||
| import org.elasticsearch.ingest.IngestDocument; | ||
| import org.elasticsearch.ingest.IngestDocument.Metadata; | ||
| import org.elasticsearch.ingest.Processor; | ||
| import org.elasticsearch.ingest.RandomDocumentPicks; | ||
| import org.elasticsearch.ingest.TestTemplateService; | ||
|
|
@@ -121,39 +120,6 @@ public void testConvertScalarToList() throws Exception { | |
| } | ||
| } | ||
|
|
||
| public void testAppendMetadataExceptVersion() throws Exception { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this test just abusing metadata?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the only metadata that doesn't fail is |
||
| // here any metadata field value becomes a list, which won't make sense in most of the cases, | ||
| // but support for append is streamlined like for set so we test it | ||
| Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.ID, Metadata.ROUTING); | ||
| List<String> values = new ArrayList<>(); | ||
| Processor appendProcessor; | ||
| if (randomBoolean()) { | ||
| String value = randomAlphaOfLengthBetween(1, 10); | ||
| values.add(value); | ||
| appendProcessor = createAppendProcessor(randomMetadata.getFieldName(), value, true); | ||
| } else { | ||
| int valuesSize = randomIntBetween(0, 10); | ||
| for (int i = 0; i < valuesSize; i++) { | ||
| values.add(randomAlphaOfLengthBetween(1, 10)); | ||
| } | ||
| appendProcessor = createAppendProcessor(randomMetadata.getFieldName(), values, true); | ||
| } | ||
|
|
||
| IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); | ||
| Object initialValue = ingestDocument.getSourceAndMetadata().get(randomMetadata.getFieldName()); | ||
| appendProcessor.execute(ingestDocument); | ||
| List<?> list = ingestDocument.getFieldValue(randomMetadata.getFieldName(), List.class); | ||
| if (initialValue == null) { | ||
| assertThat(list, equalTo(values)); | ||
| } else { | ||
| assertThat(list.size(), equalTo(values.size() + 1)); | ||
| assertThat(list.get(0), equalTo(initialValue)); | ||
| for (int i = 1; i < list.size(); i++) { | ||
| assertThat(list.get(i), equalTo(values.get(i - 1))); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void testAppendingDuplicateValueToScalarDoesNotModifyDocument() throws Exception { | ||
| IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); | ||
| String originalValue = randomAlphaOfLengthBetween(1, 10); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this test removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not valid to append to any metadata field (and thus create an array list) based on my tests in 8.2. This was correctly failing validation.