-
Notifications
You must be signed in to change notification settings - Fork 32
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
Type mappings transformation #1154
Merged
gregschohn
merged 30 commits into
opensearch-project:main
from
gregschohn:TypeMappingsTransformation
Dec 10, 2024
Merged
Changes from 18 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
21fb34b
Initial checkin for type mapping removal transformer and experimentin…
gregschohn 926e6e8
Further building out the jinjava and index type mappings transformers…
gregschohn 9bd5c60
Checkpoint on jinjava and loading template transformations.
gregschohn f1e1d50
Checkpoint add support for macros and feature flags for different par…
gregschohn dd98377
Cleanup + added a "preserve" flag to let templates inline source node…
gregschohn 357a6a6
Add jinja-style regex matching to jinjava transformations.
gregschohn 12c0cfa
Checkpoint - I've added a new invoke_macro java function to lookup a …
gregschohn e8dfb3f
Get a test that changes some contents via the route macro to pass.
gregschohn 93dc5c8
Assorted jinjava template changes for replayer...
gregschohn 4b32d42
Setup regex type mappings where one can specify index and types as re…
gregschohn 0712eae
Further work to support bulk delete, index create with type mapping m…
gregschohn e6c0229
Updated READMEs and finished implementing a basic version of bulk tra…
gregschohn 071368a
Transformation cleanup in light of new type mappings transformation.
gregschohn 5c885fe
Merge branch 'main' into TypeMappingsTransformation
gregschohn 59fd4d9
Simple bugfixes, especially around more carefully staying away from r…
gregschohn fb9c20c
Remove YAML support for feature flags - nobody is using it and no rea…
gregschohn f5c4fed
Change how the transformation netty pipeline discovers if the payload…
gregschohn 5be3ddc
Minor cleanup + the addition of a resource cache for jinjava java res…
gregschohn 73c8e13
Lots of improvements for jinjava and type mappings transformations an…
gregschohn 739d5d7
Implement a simple take on translating RFS bulk requests to use index…
gregschohn 95b71f4
Checkpoint with further refactoring improvements, mostly around tests.
gregschohn 2b1f3e0
Add a new preserve tag (preserveWhenMissing) to copy only when the ke…
gregschohn 4e59965
Enable type mappings transform for the replayer in the docker-compose…
gregschohn 09377de
Flip the default should throw behavior for HttpJsonMessageWithFaultin…
gregschohn fcf6bbc
Update type mapping sanitization READMEs to use backslash backreferen…
gregschohn 39ead16
Merge branch 'main' into TypeMappingsTransformation
gregschohn 1df1642
Merge branch 'SaferPayloadFaults' into TypeMappingsTransformation
gregschohn fbc0291
Update remaining preserve calls so that protocol will be carried forw…
gregschohn c13ef4a
Bugfixes for type mappings removal transformations, README + other si…
gregschohn 00968cd
Merge branch 'main' into TypeMappingsTransformation
gregschohn 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 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 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 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 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 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 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 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
37 changes: 37 additions & 0 deletions
37
...e/trafficReplayer/src/test/java/org/opensearch/migrations/replay/PayloadNotFoundTest.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.opensearch.migrations.replay; | ||
|
||
|
||
import org.opensearch.migrations.replay.datahandlers.PayloadAccessFaultingMap; | ||
import org.opensearch.migrations.replay.datahandlers.http.HttpJsonRequestWithFaultingPayload; | ||
import org.opensearch.migrations.replay.datahandlers.http.ListKeyAdaptingCaseInsensitiveHeadersMap; | ||
import org.opensearch.migrations.replay.datahandlers.http.StrictCaseInsensitiveHttpHeadersMap; | ||
import org.opensearch.migrations.transform.TransformationLoader; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PayloadNotFoundTest { | ||
@Test | ||
public void testTransformsPropagateExceptionProperly() throws JsonProcessingException { | ||
final HttpJsonRequestWithFaultingPayload FAULTING_MAP = new HttpJsonRequestWithFaultingPayload(); | ||
FAULTING_MAP.setMethod("PUT"); | ||
FAULTING_MAP.setPath("/_bulk"); | ||
FAULTING_MAP.setHeaders(new ListKeyAdaptingCaseInsensitiveHeadersMap(new StrictCaseInsensitiveHttpHeadersMap())); | ||
FAULTING_MAP.headers().put("Content-Type", "application/json"); | ||
FAULTING_MAP.setPayloadFaultMap(new PayloadAccessFaultingMap(FAULTING_MAP.headers().asStrictMap())); | ||
final String EXPECTED = "{\n" | ||
+ " \"method\": \"PUT\",\n" | ||
+ " \"URI\": \"/_bulk\",\n" | ||
+ " \"headers\": {\n" | ||
+ " \"Content-Type\": \"application/json\"\n" | ||
+ " }\n" | ||
+ "}\n"; | ||
|
||
var transformer = new TransformationLoader().getTransformerFactoryLoader("newhost", null, | ||
"[{\"TypeMappingSanitizationTransformerProvider\":\"\"}]"); | ||
var e = Assertions.assertThrows(Exception.class, | ||
() -> transformer.transformJson(FAULTING_MAP)); | ||
Assertions.assertTrue(((PayloadAccessFaultingMap)FAULTING_MAP.payload()).missingPaylaodWasAccessed()); | ||
} | ||
} |
This file contains 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 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
23 changes: 23 additions & 0 deletions
23
...perFixtures/src/testFixtures/java/org/opensearch/migrations/testutils/JsonNormalizer.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.opensearch.migrations.testutils; | ||
|
||
import java.util.SortedMap; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import lombok.SneakyThrows; | ||
|
||
public class JsonNormalizer { | ||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() | ||
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) | ||
.configure(SerializationFeature.INDENT_OUTPUT, true); | ||
|
||
@SneakyThrows | ||
public static String fromString(String input) { | ||
return OBJECT_MAPPER.writeValueAsString(OBJECT_MAPPER.readValue(input, SortedMap.class)); | ||
} | ||
|
||
@SneakyThrows | ||
public static String fromObject(Object obj) { | ||
return fromString(OBJECT_MAPPER.writeValueAsString(obj)); | ||
} | ||
} |
Oops, something went wrong.
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.
Typo:
Paylaod
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.
fixed