-
Notifications
You must be signed in to change notification settings - Fork 5.3k
ext_proc: Pass stream_info to gRPC streams #18190
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
Merged
Changes from all commits
Commits
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,12 @@ class StreamingIntegrationTest : public HttpIntegrationTest, | |
| const auto addr = Network::Test::getCanonicalLoopbackAddress(ipVersion()); | ||
| const auto addr_port = Network::Utility::getAddressWithPort(*addr, test_processor_.port()); | ||
| setGrpcService(*proto_config_.mutable_grpc_service(), "ext_proc_server", addr_port); | ||
| // Insert some extra metadata. This ensures that we are actually passing the | ||
| // "stream info" from the original HTTP request all the way down to the | ||
| // ext_proc stream. | ||
| auto* metadata = proto_config_.mutable_grpc_service()->mutable_initial_metadata()->Add(); | ||
|
Comment on lines
+72
to
+75
Contributor
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. Just so I understand, how is this related to stream info? I would have expected this to be used when the grpc stream is created by reading the config, not sure how this would be plumbed though via StreamInfo? |
||
| metadata->set_key("x-request-id"); | ||
| metadata->set_value("%REQ(x-request-id)%"); | ||
|
|
||
| // Merge the filter. | ||
| envoy::config::listener::v3::Filter ext_proc_filter; | ||
|
|
@@ -134,14 +140,15 @@ INSTANTIATE_TEST_SUITE_P(StreamingProtocols, StreamingIntegrationTest, | |
| GRPC_CLIENT_INTEGRATION_PARAMS); | ||
|
|
||
| // Send a body that's larger than the buffer limit, and have the processor return immediately | ||
| // after the headers come in. | ||
| // after the headers come in. Also check the metadata in this test. | ||
| TEST_P(StreamingIntegrationTest, PostAndProcessHeadersOnly) { | ||
| uint32_t num_chunks = 150; | ||
| uint32_t chunk_size = 1000; | ||
|
|
||
| // This starts the gRPC server in the background. It'll be shut down when we stop the tests. | ||
| test_processor_.start( | ||
| ipVersion(), [](grpc::ServerReaderWriter<ProcessingResponse, ProcessingRequest>* stream) { | ||
| ipVersion(), | ||
| [](grpc::ServerReaderWriter<ProcessingResponse, ProcessingRequest>* stream) { | ||
| // This is the same gRPC stream processing code that a "user" of ext_proc | ||
| // would write. In this case, we expect to receive a request_headers | ||
| // message, and then close the stream. | ||
|
|
@@ -154,12 +161,20 @@ TEST_P(StreamingIntegrationTest, PostAndProcessHeadersOnly) { | |
| stream->Write(header_resp); | ||
| // Returning here closes the stream, unless we had an ASSERT failure | ||
| // previously. | ||
| }, | ||
| [](grpc::ServerContext* ctx) { | ||
| // Verify that the metadata set in the grpc client configuration | ||
| // above is actually sent to our RPC. | ||
| auto request_id = ctx->client_metadata().find("x-request-id"); | ||
| ASSERT_NE(request_id, ctx->client_metadata().end()); | ||
| EXPECT_EQ(request_id->second, "sent some metadata"); | ||
| }); | ||
|
|
||
| initializeConfig(); | ||
| HttpIntegrationTest::initialize(); | ||
| auto& encoder = sendClientRequestHeaders([num_chunks, chunk_size](Http::HeaderMap& headers) { | ||
| headers.addCopy(LowerCaseString("expect_request_size_bytes"), num_chunks * chunk_size); | ||
| headers.addCopy(LowerCaseString("x-request-id"), "sent some metadata"); | ||
| }); | ||
|
|
||
| for (uint32_t i = 0; i < num_chunks; i++) { | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.