-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix HTTP/2 Upgrade flow for requests with content (post/put/...) #7105
Conversation
final HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler( | ||
sourceCodec, | ||
upgradeCodecFactory, | ||
handlingSettings.getMaxContentLength() |
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.
Found this one while prototyping #3000: by default, Netty assumes the upgrade is initiated by GET requests, but in case of OpenSearch, that is not necessarily the case.
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Andriy Redko <[email protected]>
return false; // enable http | ||
} | ||
|
||
public void testThatNettyHttpServerSupportsHttp2() throws Exception { |
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 not make the post operation another test case in Netty4Http2IT
as opposed to creating a separate test class?
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.
Because we need "clean state" when no upgrade happened yet, if we bundle both tests cases, the server side upgrade flow would be already exercised by one of the test cases.
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.
Scope.TEST
doesn't give you that clean state on each test method?
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.
Hm ... that's interesting, it should but I have test run issues ... let me check
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.
Should be good now, the failure was caused by client state (https://github.com/opensearch-project/OpenSearch/pull/7105/files#diff-2916f5f80f95ddf8143e294a081d207c058c16e3e2dd637cf6502feb60bf36b2R373), not server state, fixed now
} | ||
} | ||
|
||
private void assertOpaqueIdsInAnyOrder(Collection<String> opaqueIds) { |
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 think you could replace this whole method with assertThat(opaqueIds, equalTo(List.of("0")));
, no? The matcher should give a good error message by default.
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.
or even assertThat(opaqueIds, contains("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.
Sure, thanks!
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Andriy Redko <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Andriy Redko <[email protected]>
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #7105 +/- ##
============================================
- Coverage 70.77% 70.60% -0.18%
+ Complexity 59367 59226 -141
============================================
Files 4825 4825
Lines 284369 284370 +1
Branches 41021 41021
============================================
- Hits 201263 200780 -483
- Misses 66603 67014 +411
- Partials 16503 16576 +73
... and 500 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
} | ||
} | ||
|
||
private void assertOpaqueIdsInAnyOrder(int expected, Collection<String> opaqueIds) { | ||
// check if opaque ids are present in any order, since for HTTP/2 we use streaming (no head of line blocking) | ||
// and responses may come back at any order | ||
int i = 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 think this local variable is unused
} | ||
} | ||
|
||
private void assertOpaqueIdsInAnyOrder(int expected, Collection<String> opaqueIds) { | ||
// check if opaque ids are present in any order, since for HTTP/2 we use streaming (no head of line blocking) | ||
// and responses may come back at any order | ||
int i = 0; | ||
String msg = String.format(Locale.ROOT, "Expected list of opaque ids to be in any order, got [%s]", opaqueIds); |
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.
Not a big deal, but I think you can remove this because assertThat
will generate a good error message by default
import static org.hamcrest.Matchers.hasSize; | ||
|
||
@ClusterScope(scope = Scope.TEST, supportsDedicatedMasters = false, numDataNodes = 1) | ||
public class Netty4Http2PostIT extends OpenSearchNetty4IntegTestCase { |
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.
Can this be removed now?
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.
Oh sure, git
played with me here :(
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Andriy Redko <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
…nsearch-project#7105) * Fix HTTP/2 Upgrade flow for requests with content (post/put/...) Signed-off-by: Andriy Redko <[email protected]> * Address code review comments Signed-off-by: Andriy Redko <[email protected]> * Address code review comments Signed-off-by: Andriy Redko <[email protected]> * Address code review comments Signed-off-by: Andriy Redko <[email protected]> --------- Signed-off-by: Andriy Redko <[email protected]>
Description
[Describe what this change achieves]
Issues Resolved
[List any issues this PR will resolve]
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.