diff options
author | Craig Tiller <ctiller@google.com> | 2016-02-22 22:22:22 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-02-22 22:22:22 -0800 |
commit | 521423c8cf471bfdc4c7e1294890252220518416 (patch) | |
tree | fa0173dfd40a153ef9da08230ea783b3f93fd02f /test | |
parent | 732a875fe82c80a735cc9ca6a430f962811188ab (diff) | |
parent | bfc7adaa714b5d8a3b0dca4a25d572dbd92039be (diff) |
Regenerate files, fix bugs
Diffstat (limited to 'test')
-rw-r--r-- | test/core/end2end/end2end_nosec_tests.c | 36 | ||||
-rw-r--r-- | test/core/end2end/end2end_tests.c | 36 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_ssl+poll.c | 2 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_ssl.c | 2 | ||||
-rw-r--r-- | test/core/end2end/fixtures/h2_ssl_proxy.c | 2 | ||||
-rw-r--r-- | test/core/end2end/tests/connectivity.c | 2 | ||||
-rw-r--r-- | test/core/end2end/tests/ping.c | 2 | ||||
-rw-r--r-- | test/core/end2end/tests/simple_metadata.c | 2 | ||||
-rw-r--r-- | test/core/security/credentials_test.c | 2 | ||||
-rw-r--r-- | test/core/security/security_connector_test.c | 2 | ||||
-rw-r--r-- | test/core/support/load_file_test.c | 1 | ||||
-rw-r--r-- | test/cpp/interop/client.cc | 8 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.cc | 72 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.h | 3 | ||||
-rw-r--r-- | test/cpp/interop/server_main.cc | 35 |
15 files changed, 159 insertions, 48 deletions
diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 9ff46d62e4..17dc190d14 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -46,9 +46,8 @@ extern void cancel_after_invoke(grpc_end2end_test_config config); extern void cancel_before_invoke(grpc_end2end_test_config config); extern void cancel_in_a_vacuum(grpc_end2end_test_config config); extern void cancel_with_status(grpc_end2end_test_config config); -extern void channel_connectivity(grpc_end2end_test_config config); -extern void channel_ping(grpc_end2end_test_config config); extern void compressed_payload(grpc_end2end_test_config config); +extern void connectivity(grpc_end2end_test_config config); extern void default_host(grpc_end2end_test_config config); extern void disappearing_server(grpc_end2end_test_config config); extern void empty_batch(grpc_end2end_test_config config); @@ -59,10 +58,10 @@ extern void invoke_large_request(grpc_end2end_test_config config); extern void large_metadata(grpc_end2end_test_config config); extern void max_concurrent_streams(grpc_end2end_test_config config); extern void max_message_length(grpc_end2end_test_config config); -extern void metadata(grpc_end2end_test_config config); extern void negative_deadline(grpc_end2end_test_config config); extern void no_op(grpc_end2end_test_config config); extern void payload(grpc_end2end_test_config config); +extern void ping(grpc_end2end_test_config config); extern void ping_pong_streaming(grpc_end2end_test_config config); extern void registered_call(grpc_end2end_test_config config); extern void request_with_flags(grpc_end2end_test_config config); @@ -71,6 +70,7 @@ extern void server_finishes_request(grpc_end2end_test_config config); extern void shutdown_finishes_calls(grpc_end2end_test_config config); extern void shutdown_finishes_tags(grpc_end2end_test_config config); extern void simple_delayed_request(grpc_end2end_test_config config); +extern void simple_metadata(grpc_end2end_test_config config); extern void simple_request(grpc_end2end_test_config config); extern void trailing_metadata(grpc_end2end_test_config config); @@ -87,9 +87,8 @@ void grpc_end2end_tests(int argc, char **argv, cancel_before_invoke(config); cancel_in_a_vacuum(config); cancel_with_status(config); - channel_connectivity(config); - channel_ping(config); compressed_payload(config); + connectivity(config); default_host(config); disappearing_server(config); empty_batch(config); @@ -100,10 +99,10 @@ void grpc_end2end_tests(int argc, char **argv, large_metadata(config); max_concurrent_streams(config); max_message_length(config); - metadata(config); negative_deadline(config); no_op(config); payload(config); + ping(config); ping_pong_streaming(config); registered_call(config); request_with_flags(config); @@ -112,6 +111,7 @@ void grpc_end2end_tests(int argc, char **argv, shutdown_finishes_calls(config); shutdown_finishes_tags(config); simple_delayed_request(config); + simple_metadata(config); simple_request(config); trailing_metadata(config); return; @@ -150,18 +150,14 @@ void grpc_end2end_tests(int argc, char **argv, cancel_with_status(config); continue; } - if (0 == strcmp("channel_connectivity", argv[i])) { - channel_connectivity(config); - continue; - } - if (0 == strcmp("channel_ping", argv[i])) { - channel_ping(config); - continue; - } if (0 == strcmp("compressed_payload", argv[i])) { compressed_payload(config); continue; } + if (0 == strcmp("connectivity", argv[i])) { + connectivity(config); + continue; + } if (0 == strcmp("default_host", argv[i])) { default_host(config); continue; @@ -202,10 +198,6 @@ void grpc_end2end_tests(int argc, char **argv, max_message_length(config); continue; } - if (0 == strcmp("metadata", argv[i])) { - metadata(config); - continue; - } if (0 == strcmp("negative_deadline", argv[i])) { negative_deadline(config); continue; @@ -218,6 +210,10 @@ void grpc_end2end_tests(int argc, char **argv, payload(config); continue; } + if (0 == strcmp("ping", argv[i])) { + ping(config); + continue; + } if (0 == strcmp("ping_pong_streaming", argv[i])) { ping_pong_streaming(config); continue; @@ -250,6 +246,10 @@ void grpc_end2end_tests(int argc, char **argv, simple_delayed_request(config); continue; } + if (0 == strcmp("simple_metadata", argv[i])) { + simple_metadata(config); + continue; + } if (0 == strcmp("simple_request", argv[i])) { simple_request(config); continue; diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 397ff446a9..6f2f5aff78 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -47,9 +47,8 @@ extern void cancel_after_invoke(grpc_end2end_test_config config); extern void cancel_before_invoke(grpc_end2end_test_config config); extern void cancel_in_a_vacuum(grpc_end2end_test_config config); extern void cancel_with_status(grpc_end2end_test_config config); -extern void channel_connectivity(grpc_end2end_test_config config); -extern void channel_ping(grpc_end2end_test_config config); extern void compressed_payload(grpc_end2end_test_config config); +extern void connectivity(grpc_end2end_test_config config); extern void default_host(grpc_end2end_test_config config); extern void disappearing_server(grpc_end2end_test_config config); extern void empty_batch(grpc_end2end_test_config config); @@ -60,10 +59,10 @@ extern void invoke_large_request(grpc_end2end_test_config config); extern void large_metadata(grpc_end2end_test_config config); extern void max_concurrent_streams(grpc_end2end_test_config config); extern void max_message_length(grpc_end2end_test_config config); -extern void metadata(grpc_end2end_test_config config); extern void negative_deadline(grpc_end2end_test_config config); extern void no_op(grpc_end2end_test_config config); extern void payload(grpc_end2end_test_config config); +extern void ping(grpc_end2end_test_config config); extern void ping_pong_streaming(grpc_end2end_test_config config); extern void registered_call(grpc_end2end_test_config config); extern void request_with_flags(grpc_end2end_test_config config); @@ -72,6 +71,7 @@ extern void server_finishes_request(grpc_end2end_test_config config); extern void shutdown_finishes_calls(grpc_end2end_test_config config); extern void shutdown_finishes_tags(grpc_end2end_test_config config); extern void simple_delayed_request(grpc_end2end_test_config config); +extern void simple_metadata(grpc_end2end_test_config config); extern void simple_request(grpc_end2end_test_config config); extern void trailing_metadata(grpc_end2end_test_config config); @@ -89,9 +89,8 @@ void grpc_end2end_tests(int argc, char **argv, cancel_before_invoke(config); cancel_in_a_vacuum(config); cancel_with_status(config); - channel_connectivity(config); - channel_ping(config); compressed_payload(config); + connectivity(config); default_host(config); disappearing_server(config); empty_batch(config); @@ -102,10 +101,10 @@ void grpc_end2end_tests(int argc, char **argv, large_metadata(config); max_concurrent_streams(config); max_message_length(config); - metadata(config); negative_deadline(config); no_op(config); payload(config); + ping(config); ping_pong_streaming(config); registered_call(config); request_with_flags(config); @@ -114,6 +113,7 @@ void grpc_end2end_tests(int argc, char **argv, shutdown_finishes_calls(config); shutdown_finishes_tags(config); simple_delayed_request(config); + simple_metadata(config); simple_request(config); trailing_metadata(config); return; @@ -156,18 +156,14 @@ void grpc_end2end_tests(int argc, char **argv, cancel_with_status(config); continue; } - if (0 == strcmp("channel_connectivity", argv[i])) { - channel_connectivity(config); - continue; - } - if (0 == strcmp("channel_ping", argv[i])) { - channel_ping(config); - continue; - } if (0 == strcmp("compressed_payload", argv[i])) { compressed_payload(config); continue; } + if (0 == strcmp("connectivity", argv[i])) { + connectivity(config); + continue; + } if (0 == strcmp("default_host", argv[i])) { default_host(config); continue; @@ -208,10 +204,6 @@ void grpc_end2end_tests(int argc, char **argv, max_message_length(config); continue; } - if (0 == strcmp("metadata", argv[i])) { - metadata(config); - continue; - } if (0 == strcmp("negative_deadline", argv[i])) { negative_deadline(config); continue; @@ -224,6 +216,10 @@ void grpc_end2end_tests(int argc, char **argv, payload(config); continue; } + if (0 == strcmp("ping", argv[i])) { + ping(config); + continue; + } if (0 == strcmp("ping_pong_streaming", argv[i])) { ping_pong_streaming(config); continue; @@ -256,6 +252,10 @@ void grpc_end2end_tests(int argc, char **argv, simple_delayed_request(config); continue; } + if (0 == strcmp("simple_metadata", argv[i])) { + simple_metadata(config); + continue; + } if (0 == strcmp("simple_request", argv[i])) { simple_request(config); continue; diff --git a/test/core/end2end/fixtures/h2_ssl+poll.c b/test/core/end2end/fixtures/h2_ssl+poll.c index 0d489d62e2..02bf16642d 100644 --- a/test/core/end2end/fixtures/h2_ssl+poll.c +++ b/test/core/end2end/fixtures/h2_ssl+poll.c @@ -43,7 +43,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/security/credentials.h" #include "src/core/support/env.h" -#include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index 187399cad1..04bfb70303 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -43,7 +43,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/security/credentials.h" #include "src/core/support/env.h" -#include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index dc758061f8..5288318a83 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -43,7 +43,7 @@ #include "src/core/channel/channel_args.h" #include "src/core/security/credentials.h" #include "src/core/support/env.h" -#include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/tests/connectivity.c b/test/core/end2end/tests/connectivity.c index 0e21e65557..edef2ff68b 100644 --- a/test/core/end2end/tests/connectivity.c +++ b/test/core/end2end/tests/connectivity.c @@ -168,7 +168,7 @@ static void test_connectivity(grpc_end2end_test_config config) { cq_verifier_destroy(cqv); } -void channel_connectivity(grpc_end2end_test_config config) { +void connectivity(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_connectivity(config); } diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.c index 73fab206fb..f42f186502 100644 --- a/test/core/end2end/tests/ping.c +++ b/test/core/end2end/tests/ping.c @@ -91,7 +91,7 @@ static void test_ping(grpc_end2end_test_config config) { cq_verifier_destroy(cqv); } -void channel_ping(grpc_end2end_test_config config) { +void ping(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_ping(config); } diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 5e92091eb7..376ffb670a 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -260,6 +260,6 @@ static void test_request_response_with_metadata_and_payload( config.tear_down_data(&f); } -void metadata(grpc_end2end_test_config config) { +void simple_metadata(grpc_end2end_test_config config) { test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 2c3d4cd0d6..98133ef5e5 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -47,7 +47,7 @@ #include "src/core/httpcli/httpcli.h" #include "src/core/security/json_token.h" #include "src/core/support/env.h" -#include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "test/core/util/test_config.h" diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c index edb45b6680..420e3a4c52 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -43,7 +43,7 @@ #include "src/core/security/security_connector.h" #include "src/core/security/security_context.h" #include "src/core/support/env.h" -#include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/transport_security.h" diff --git a/test/core/support/load_file_test.c b/test/core/support/load_file_test.c index 59d6ba8912..9ba0dc80a1 100644 --- a/test/core/support/load_file_test.c +++ b/test/core/support/load_file_test.c @@ -39,6 +39,7 @@ #include <grpc/support/slice.h> #include "src/core/support/load_file.h" +#include "src/core/support/tmpfile.h" #include "src/core/support/string.h" #include "test/core/util/test_config.h" diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index cb9b396beb..788adefd24 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,6 +74,7 @@ DEFINE_string(test_case, "large_unary", "oauth2_auth_token: raw oauth2 access token auth; " "per_rpc_creds: raw oauth2 access token on a single rpc; " "status_code_and_message: verify status code & message; " + "custom_metadata: server will echo custom metadata;" "all : all of above."); DEFINE_string(default_service_account, "", "Email of GCE default service account"); @@ -129,6 +130,8 @@ int main(int argc, char** argv) { client.DoPerRpcCreds(json_key); } else if (FLAGS_test_case == "status_code_and_message") { client.DoStatusWithMessage(); + } else if (FLAGS_test_case == "custom_metadata") { + client.DoCustomMetadata(); } else if (FLAGS_test_case == "all") { client.DoEmpty(); client.DoLargeUnary(); @@ -142,6 +145,7 @@ int main(int argc, char** argv) { client.DoTimeoutOnSleepingServer(); client.DoEmptyStream(); client.DoStatusWithMessage(); + client.DoCustomMetadata(); // service_account_creds and jwt_token_creds can only run with ssl. if (FLAGS_use_tls) { grpc::string json_key = GetServiceAccountJsonKey(); @@ -159,7 +163,7 @@ int main(int argc, char** argv) { "server_compressed_streaming|half_duplex|ping_pong|cancel_after_begin|" "cancel_after_first_response|timeout_on_sleeping_server|empty_stream|" "compute_engine_creds|jwt_token_creds|oauth2_auth_token|per_rpc_creds", - FLAGS_test_case.c_str()); + "status_code_and_message|custom_metadata", FLAGS_test_case.c_str()); ret = 1; } diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index b06310781a..46f6fdac40 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -625,5 +625,77 @@ void InteropClient::DoStatusWithMessage() { gpr_log(GPR_DEBUG, "Done testing Status and Message"); } +void InteropClient::DoCustomMetadata() { + const grpc::string kEchoInitialMetadataKey("x-grpc-test-echo-initial"); + const grpc::string kInitialMetadataValue("test_initial_metadata_value"); + const grpc::string kEchoTrailingBinMetadataKey( + "x-grpc-test-echo-trailing-bin"); + const grpc::string kTrailingBinValue("\x0a\x0b\x0a\x0b\x0a\x0b"); + ; + + { + gpr_log(GPR_DEBUG, "Sending RPC with custom metadata"); + ClientContext context; + context.AddMetadata(kEchoInitialMetadataKey, kInitialMetadataValue); + context.AddMetadata(kEchoTrailingBinMetadataKey, kTrailingBinValue); + SimpleRequest request; + SimpleResponse response; + request.set_response_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + + Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); + AssertOkOrPrintErrorStatus(s); + const auto& server_initial_metadata = context.GetServerInitialMetadata(); + auto iter = server_initial_metadata.find(kEchoInitialMetadataKey); + GPR_ASSERT(iter != server_initial_metadata.end()); + GPR_ASSERT(iter->second.data() == kInitialMetadataValue); + const auto& server_trailing_metadata = context.GetServerTrailingMetadata(); + iter = server_trailing_metadata.find(kEchoTrailingBinMetadataKey); + GPR_ASSERT(iter != server_trailing_metadata.end()); + GPR_ASSERT(grpc::string(iter->second.begin(), iter->second.end()) == + kTrailingBinValue); + + gpr_log(GPR_DEBUG, "Done testing RPC with custom metadata"); + } + + { + gpr_log(GPR_DEBUG, "Sending stream with custom metadata"); + ClientContext context; + context.AddMetadata(kEchoInitialMetadataKey, kInitialMetadataValue); + context.AddMetadata(kEchoTrailingBinMetadataKey, kTrailingBinValue); + std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest, + StreamingOutputCallResponse>> + stream(serviceStub_.Get()->FullDuplexCall(&context)); + + StreamingOutputCallRequest request; + request.set_response_type(PayloadType::COMPRESSABLE); + ResponseParameters* response_parameter = request.add_response_parameters(); + response_parameter->set_size(kLargeResponseSize); + grpc::string payload(kLargeRequestSize, '\0'); + request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); + StreamingOutputCallResponse response; + GPR_ASSERT(stream->Write(request)); + stream->WritesDone(); + GPR_ASSERT(stream->Read(&response)); + GPR_ASSERT(response.payload().body() == + grpc::string(kLargeResponseSize, '\0')); + GPR_ASSERT(!stream->Read(&response)); + Status s = stream->Finish(); + AssertOkOrPrintErrorStatus(s); + const auto& server_initial_metadata = context.GetServerInitialMetadata(); + auto iter = server_initial_metadata.find(kEchoInitialMetadataKey); + GPR_ASSERT(iter != server_initial_metadata.end()); + GPR_ASSERT(iter->second.data() == kInitialMetadataValue); + const auto& server_trailing_metadata = context.GetServerTrailingMetadata(); + iter = server_trailing_metadata.find(kEchoTrailingBinMetadataKey); + GPR_ASSERT(iter != server_trailing_metadata.end()); + GPR_ASSERT(grpc::string(iter->second.begin(), iter->second.end()) == + kTrailingBinValue); + + gpr_log(GPR_DEBUG, "Done testing stream with custom metadata"); + } +} + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 3ecd380398..3f57f3c733 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,6 +75,7 @@ class InteropClient { void DoTimeoutOnSleepingServer(); void DoEmptyStream(); void DoStatusWithMessage(); + void DoCustomMetadata(); // Auth tests. // username is a string containing the user email void DoJwtTokenCreds(const grpc::string& username); diff --git a/test/cpp/interop/server_main.cc b/test/cpp/interop/server_main.cc index cdca060c23..18ac35d551 100644 --- a/test/cpp/interop/server_main.cc +++ b/test/cpp/interop/server_main.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,6 +80,36 @@ using grpc::Status; static bool got_sigint = false; static const char* kRandomFile = "test/cpp/interop/rnd.dat"; +const char kEchoInitialMetadataKey[] = "x-grpc-test-echo-initial"; +const char kEchoTrailingBinMetadataKey[] = "x-grpc-test-echo-trailing-bin"; +const char kEchoUserAgentKey[] = "x-grpc-test-echo-useragent"; + +void MaybeEchoMetadata(ServerContext* context) { + const auto& client_metadata = context->client_metadata(); + GPR_ASSERT(client_metadata.count(kEchoInitialMetadataKey) <= 1); + GPR_ASSERT(client_metadata.count(kEchoTrailingBinMetadataKey) <= 1); + + auto iter = client_metadata.find(kEchoInitialMetadataKey); + if (iter != client_metadata.end()) { + context->AddInitialMetadata(kEchoInitialMetadataKey, iter->second.data()); + } + iter = client_metadata.find(kEchoTrailingBinMetadataKey); + if (iter != client_metadata.end()) { + context->AddTrailingMetadata( + kEchoTrailingBinMetadataKey, + grpc::string(iter->second.begin(), iter->second.end())); + } + // Check if client sent a magic key in the header that makes us echo + // back the user-agent (for testing purpose) + iter = client_metadata.find(kEchoUserAgentKey); + if (iter != client_metadata.end()) { + iter = client_metadata.find("user-agent"); + if (iter != client_metadata.end()) { + context->AddInitialMetadata(kEchoUserAgentKey, iter->second.data()); + } + } +} + bool SetPayload(PayloadType type, int size, Payload* payload) { PayloadType response_type; if (type == PayloadType::RANDOM) { @@ -130,11 +160,13 @@ class TestServiceImpl : public TestService::Service { public: Status EmptyCall(ServerContext* context, const grpc::testing::Empty* request, grpc::testing::Empty* response) { + MaybeEchoMetadata(context); return Status::OK; } Status UnaryCall(ServerContext* context, const SimpleRequest* request, SimpleResponse* response) { + MaybeEchoMetadata(context); SetResponseCompression(context, *request); if (request->response_size() > 0) { if (!SetPayload(request->response_type(), request->response_size(), @@ -192,6 +224,7 @@ class TestServiceImpl : public TestService::Service { ServerContext* context, ServerReaderWriter<StreamingOutputCallResponse, StreamingOutputCallRequest>* stream) { + MaybeEchoMetadata(context); StreamingOutputCallRequest request; StreamingOutputCallResponse response; bool write_success = true; |