-
Notifications
You must be signed in to change notification settings - Fork 40
Replayer - Add Transformation support for Tuples #1044
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
Replayer - Add Transformation support for Tuples #1044
Conversation
e0b1a7b
to
e7f6db0
Compare
99b5fb8
to
51008c4
Compare
var expectedBytes = (hostTransformation) | ||
? new String(testBytes, StandardCharsets.UTF_8).replace("foo.example", "bar.example") | ||
.getBytes(StandardCharsets.UTF_8) | ||
? replaceBytes(testBytes, |
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.
This enables us to test with gzipped requests without messing up the body bytes by encoding in utf8
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
…transformations Signed-off-by: Andre Kurait <[email protected]>
05e2b7a
to
74df035
Compare
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
d29485f
to
b83ddd0
Compare
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
...rafficReplayer/src/main/java/org/opensearch/migrations/replay/ParsedHttpMessagesAsDicts.java
Show resolved
Hide resolved
...rafficReplayer/src/main/java/org/opensearch/migrations/replay/ParsedHttpMessagesAsDicts.java
Outdated
Show resolved
Hide resolved
...rafficReplayer/src/main/java/org/opensearch/migrations/replay/ParsedHttpMessagesAsDicts.java
Outdated
Show resolved
Hide resolved
...rafficReplayer/src/main/java/org/opensearch/migrations/replay/ParsedHttpMessagesAsDicts.java
Outdated
Show resolved
Hide resolved
...rafficReplayer/src/main/java/org/opensearch/migrations/replay/ParsedHttpMessagesAsDicts.java
Show resolved
Hide resolved
...ain/java/org/opensearch/migrations/replay/datahandlers/http/NettyJsonBodyConvertHandler.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/migrations/replay/datahandlers/http/NettyJsonBodyConvertHandler.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/migrations/replay/datahandlers/http/NettyJsonBodyConvertHandler.java
Outdated
Show resolved
Hide resolved
...ain/java/org/opensearch/migrations/replay/datahandlers/http/NettyJsonBodyConvertHandler.java
Outdated
Show resolved
Hide resolved
this.httpTransactionContext = httpTransactionContext; | ||
} | ||
|
||
public ListKeyAdaptingCaseInsensitiveHeadersMap clone(ListKeyAdaptingCaseInsensitiveHeadersMap original) { |
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.
I suspect that the fix for the gzip decompression bug should require us to pass the netty HTTP Request object through this handler. Since this handler is only used in one spot, I'd prefer to see it just use an original copy of the headers rather than go through any translation. Header translations are extremely sensitive. By writing a clone, we risk doing a normalization that makes differences dissolve away.
Anyway, there are existing bugs in the request transformation pipeline. There's a slight bit more risk here, but I'm fine reevaluating the risk when we tackle the other pipeline bugs. No change is required here to move this tuple transformation change closer to the approval.
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
Signed-off-by: Andre Kurait <[email protected]>
94d7529
to
26545fc
Compare
TrafficCapture/README.md
Outdated
"HTTP-Version": { | ||
"keepAliveDefault": true | ||
$ cat /shared-logs-output/traffic-replayer-default/*/tuples/tuples.log | jq | ||
[ |
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.
Is this right? I thought that it was ndjson in and jq would just keep printing objects at the top-level.
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.
That's correct, i'll update
map.put(STATUS_CODE_KEY, Integer.parseInt(message.code())); | ||
map.put("Reason-Phrase", message.reason()); | ||
map.put(RESPONSE_TIME_MS_KEY, latency.toMillis()); | ||
context.setHttpVersion(message.protocol()); |
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.
nit: why did you move this? There are potentially 2 reasons to have this earlier. 1) if there's an exception within this code, context's side effects will 'escape the stack' and map won't. 2) tightening the calls to protocol() has an ever so-negligible improvement on cache-hit likelihood.
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.
I thought you left an earlier comment to move this to the bottom #1044 (comment)
} | ||
|
||
/** | ||
* Writes a tuple object to an output stream as a JSON object. |
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.
Is this what jackson does? If not, this would be a good comment above too.
"--" + params.getTransformerConfigParameterArgPrefix() + "transformer-config-base64" + ", " + | ||
"--" + params.getTransformerConfigParameterArgPrefix() + "transformer-config" + ", or " + | ||
"--" + params.getTransformerConfigParameterArgPrefix() + "transformer-config-file" + "."); |
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.
nit: a helper function would make this more readable
public class HttpJsonMessageWithFaultingPayload extends LinkedHashMap<String, Object> { | ||
|
||
public static final String MESSAGE_SCHEMA_VERSION = "1.0"; | ||
public static final String MESSAGE_SCHEMA_VERSION = "2.0"; |
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.
I wonder if we want the .0 at all. If this were a flat integer, it probably makes a lot of things simpler (if > 14, etc). Is there any value in bifurcating this schema?
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.
move to an int
// Touch for easier debugging if later leak detected | ||
// e.g. if received unreleasable ByteBuf |
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.
Playing w/ netty & even looking at touch backtraces for years & this comment makes me understand when I would want to use touch(). Thanks!
Signed-off-by: Andre Kurait <[email protected]>
Description
This change includes several bug fixes and enhancements for request and tuple transformations.
Unpooled.unreleaseable
buffer beforehand and unwrapped afterwardsinlinedTextBody
, that is, if the content type is text/* and the payload is successfully encoded in utf-8.inlinedTextBody key
will be populated with the payload value as a string for transformations accessing the body (or tuples as described below)See Example Tuples:
See example tuples:
Issues Resolved
MIGRATIONS-1593
Is this a backport? If so, please add backport PR # and/or commits #
Testing
Unit tests added for cases, some tuple transformations passed in docker startup manually testing e2e workflow.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.