From 25770b02d634ba69dfef6bc2d68fbce167acfcef Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 27 Feb 2015 15:30:58 -0800 Subject: add jwt token creds test_case --- test/cpp/interop/client.cc | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index f7537c2d7b..73a6ad107d 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -73,6 +73,7 @@ DEFINE_string(test_case, "large_unary", "ping_pong : full-duplex streaming; " "service_account_creds : large_unary with service_account auth; " "compute_engine_creds: large_unary with compute engine auth; " + "jwt_token_creds: large_unary with JWT token auth; " "all : all of above."); DEFINE_string(default_service_account, "", "Email of GCE default service account"); @@ -145,6 +146,13 @@ std::shared_ptr CreateChannelForTestCase( creds = CredentialsFactory::ComputeEngineCredentials(); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_enable_ssl, FLAGS_use_prod_roots, creds); + } else if (test_case == "jwt_token_creds") { + std::unique_ptr creds; + GPR_ASSERT(FLAGS_enable_ssl); + grpc::string json_key = GetServiceAccountJsonKey(); + creds = CredentialsFactory::JWTCredentials(json_key, std::chrono::hours(1)); + return CreateTestChannel(host_port, FLAGS_server_host_override, + FLAGS_enable_ssl, FLAGS_use_prod_roots, creds); } else { return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_enable_ssl, FLAGS_use_prod_roots); @@ -226,6 +234,21 @@ void DoServiceAccountCreds() { gpr_log(GPR_INFO, "Large unary with service account creds done."); } +void DoJwtTokenCreds() { + gpr_log(GPR_INFO, + "Sending a large unary rpc with JWT token credentials ..."); + std::shared_ptr channel = + CreateChannelForTestCase("jwt_token_creds"); + SimpleRequest request; + SimpleResponse response; + request.set_fill_username(true); + PerformLargeUnary(channel, &request, &response); + GPR_ASSERT(!response.username().empty()); + grpc::string json_key = GetServiceAccountJsonKey(); + GPR_ASSERT(json_key.find(response.username()) != grpc::string::npos); + gpr_log(GPR_INFO, "Large unary with JWT token creds done."); +} + void DoLargeUnary() { gpr_log(GPR_INFO, "Sending a large unary rpc..."); std::shared_ptr channel = @@ -414,6 +437,8 @@ int main(int argc, char** argv) { DoServiceAccountCreds(); } else if (FLAGS_test_case == "compute_engine_creds") { DoComputeEngineCreds(); + } else if (FLAGS_test_case == "jwt_token_creds") { + DoJwtTokenCreds(); } else if (FLAGS_test_case == "all") { DoEmpty(); DoLargeUnary(); @@ -421,9 +446,10 @@ int main(int argc, char** argv) { DoResponseStreaming(); DoHalfDuplex(); DoPingPong(); - // service_account_creds can only run with ssl. + // service_account_creds and jwt_token_creds can only run with ssl. if (FLAGS_enable_ssl) { DoServiceAccountCreds(); + DoJwtTokenCreds(); } // compute_engine_creds only runs in GCE. } else { @@ -431,7 +457,7 @@ int main(int argc, char** argv) { GPR_ERROR, "Unsupported test case %s. Valid options are all|empty_unary|" "large_unary|client_streaming|server_streaming|half_duplex|ping_pong|" - "service_account_creds|compute_engine_creds", + "service_account_creds|compute_engine_creds|jwt_token_creds", FLAGS_test_case.c_str()); } -- cgit v1.2.3 From 0cb6c25e711ea32b4f2be1126cf0270837e0bc5f Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Wed, 11 Mar 2015 00:30:57 -0700 Subject: A first test with typed async client and untyped service for a simple rpc --- Makefile | 47 ++- build.json | 16 + test/cpp/end2end/anonymous_end2end_test.cc | 563 +++++++++++++++++++++++++++++ tools/run_tests/tests.json | 5 + 4 files changed, 630 insertions(+), 1 deletion(-) create mode 100644 test/cpp/end2end/anonymous_end2end_test.cc (limited to 'test') diff --git a/Makefile b/Makefile index d228adcd7b..1b8161e846 100644 --- a/Makefile +++ b/Makefile @@ -531,6 +531,7 @@ time_test: $(BINDIR)/$(CONFIG)/time_test timeout_encoding_test: $(BINDIR)/$(CONFIG)/timeout_encoding_test transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test +anonymous_end2end_test: $(BINDIR)/$(CONFIG)/anonymous_end2end_test async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test credentials_test: $(BINDIR)/$(CONFIG)/credentials_test @@ -965,7 +966,7 @@ buildtests: buildtests_c buildtests_cxx buildtests_c: privatelibs_c $(BINDIR)/$(CONFIG)/alarm_heap_test $(BINDIR)/$(CONFIG)/alarm_list_test $(BINDIR)/$(CONFIG)/alarm_test $(BINDIR)/$(CONFIG)/alpn_test $(BINDIR)/$(CONFIG)/bin_encoder_test $(BINDIR)/$(CONFIG)/census_hash_table_test $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_test $(BINDIR)/$(CONFIG)/census_statistics_performance_test $(BINDIR)/$(CONFIG)/census_statistics_quick_test $(BINDIR)/$(CONFIG)/census_statistics_small_log_test $(BINDIR)/$(CONFIG)/census_stub_test $(BINDIR)/$(CONFIG)/census_window_stats_test $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test $(BINDIR)/$(CONFIG)/chttp2_stream_encoder_test $(BINDIR)/$(CONFIG)/chttp2_stream_map_test $(BINDIR)/$(CONFIG)/chttp2_transport_end2end_test $(BINDIR)/$(CONFIG)/dualstack_socket_test $(BINDIR)/$(CONFIG)/echo_client $(BINDIR)/$(CONFIG)/echo_server $(BINDIR)/$(CONFIG)/echo_test $(BINDIR)/$(CONFIG)/fd_posix_test $(BINDIR)/$(CONFIG)/fling_client $(BINDIR)/$(CONFIG)/fling_server $(BINDIR)/$(CONFIG)/fling_stream_test $(BINDIR)/$(CONFIG)/fling_test $(BINDIR)/$(CONFIG)/gpr_cancellable_test $(BINDIR)/$(CONFIG)/gpr_cmdline_test $(BINDIR)/$(CONFIG)/gpr_env_test $(BINDIR)/$(CONFIG)/gpr_file_test $(BINDIR)/$(CONFIG)/gpr_histogram_test $(BINDIR)/$(CONFIG)/gpr_host_port_test $(BINDIR)/$(CONFIG)/gpr_log_test $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test $(BINDIR)/$(CONFIG)/gpr_slice_test $(BINDIR)/$(CONFIG)/gpr_string_test $(BINDIR)/$(CONFIG)/gpr_sync_test $(BINDIR)/$(CONFIG)/gpr_thd_test $(BINDIR)/$(CONFIG)/gpr_time_test $(BINDIR)/$(CONFIG)/gpr_useful_test $(BINDIR)/$(CONFIG)/grpc_base64_test $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test $(BINDIR)/$(CONFIG)/grpc_channel_stack_test $(BINDIR)/$(CONFIG)/grpc_completion_queue_test $(BINDIR)/$(CONFIG)/grpc_credentials_test $(BINDIR)/$(CONFIG)/grpc_json_token_test $(BINDIR)/$(CONFIG)/grpc_stream_op_test $(BINDIR)/$(CONFIG)/hpack_parser_test $(BINDIR)/$(CONFIG)/hpack_table_test $(BINDIR)/$(CONFIG)/httpcli_format_request_test $(BINDIR)/$(CONFIG)/httpcli_parser_test $(BINDIR)/$(CONFIG)/httpcli_test $(BINDIR)/$(CONFIG)/json_rewrite $(BINDIR)/$(CONFIG)/json_rewrite_test $(BINDIR)/$(CONFIG)/json_test $(BINDIR)/$(CONFIG)/lame_client_test $(BINDIR)/$(CONFIG)/message_compress_test $(BINDIR)/$(CONFIG)/metadata_buffer_test $(BINDIR)/$(CONFIG)/multi_init_test $(BINDIR)/$(CONFIG)/murmur_hash_test $(BINDIR)/$(CONFIG)/no_server_test $(BINDIR)/$(CONFIG)/poll_kick_posix_test $(BINDIR)/$(CONFIG)/resolve_address_test $(BINDIR)/$(CONFIG)/secure_endpoint_test $(BINDIR)/$(CONFIG)/sockaddr_utils_test $(BINDIR)/$(CONFIG)/tcp_client_posix_test $(BINDIR)/$(CONFIG)/tcp_posix_test $(BINDIR)/$(CONFIG)/tcp_server_posix_test $(BINDIR)/$(CONFIG)/time_averaged_stats_test $(BINDIR)/$(CONFIG)/time_test $(BINDIR)/$(CONFIG)/timeout_encoding_test $(BINDIR)/$(CONFIG)/transport_metadata_test $(BINDIR)/$(CONFIG)/transport_security_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_legacy_test -buildtests_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/async_end2end_test $(BINDIR)/$(CONFIG)/channel_arguments_test $(BINDIR)/$(CONFIG)/credentials_test $(BINDIR)/$(CONFIG)/end2end_test $(BINDIR)/$(CONFIG)/interop_client $(BINDIR)/$(CONFIG)/interop_server $(BINDIR)/$(CONFIG)/interop_test $(BINDIR)/$(CONFIG)/pubsub_client $(BINDIR)/$(CONFIG)/pubsub_publisher_test $(BINDIR)/$(CONFIG)/pubsub_subscriber_test $(BINDIR)/$(CONFIG)/qps_driver $(BINDIR)/$(CONFIG)/qps_worker $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/thread_pool_test +buildtests_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/anonymous_end2end_test $(BINDIR)/$(CONFIG)/async_end2end_test $(BINDIR)/$(CONFIG)/channel_arguments_test $(BINDIR)/$(CONFIG)/credentials_test $(BINDIR)/$(CONFIG)/end2end_test $(BINDIR)/$(CONFIG)/interop_client $(BINDIR)/$(CONFIG)/interop_server $(BINDIR)/$(CONFIG)/interop_test $(BINDIR)/$(CONFIG)/pubsub_client $(BINDIR)/$(CONFIG)/pubsub_publisher_test $(BINDIR)/$(CONFIG)/pubsub_subscriber_test $(BINDIR)/$(CONFIG)/qps_driver $(BINDIR)/$(CONFIG)/qps_worker $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/thread_pool_test test: test_c test_cxx @@ -1793,6 +1794,8 @@ test_c: buildtests_c test_cxx: buildtests_cxx + $(E) "[RUN] Testing anonymous_end2end_test" + $(Q) $(BINDIR)/$(CONFIG)/anonymous_end2end_test || ( echo test anonymous_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing async_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/async_end2end_test || ( echo test async_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing channel_arguments_test" @@ -7776,6 +7779,48 @@ endif endif +ANONYMOUS_END2END_TEST_SRC = \ + test/cpp/end2end/anonymous_end2end_test.cc \ + +ANONYMOUS_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ANONYMOUS_END2END_TEST_SRC)))) + +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL with ALPN. + +$(BINDIR)/$(CONFIG)/anonymous_end2end_test: openssl_dep_error + +else + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/anonymous_end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/anonymous_end2end_test: $(PROTOBUF_DEP) $(ANONYMOUS_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(ANONYMOUS_END2END_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/anonymous_end2end_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/anonymous_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_anonymous_end2end_test: $(ANONYMOUS_END2END_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(ANONYMOUS_END2END_TEST_OBJS:.o=.dep) +endif +endif + + ASYNC_END2END_TEST_SRC = \ test/cpp/end2end/async_end2end_test.cc \ diff --git a/build.json b/build.json index eeb0755f4b..9b217dc909 100644 --- a/build.json +++ b/build.json @@ -1646,6 +1646,22 @@ "gpr" ] }, + { + "name": "anonymous_end2end_test", + "build": "test", + "language": "c++", + "src": [ + "test/cpp/end2end/anonymous_end2end_test.cc" + ], + "deps": [ + "grpc++_test_util", + "grpc_test_util", + "grpc++", + "grpc", + "gpr_test_util", + "gpr" + ] + }, { "name": "async_end2end_test", "build": "test", diff --git a/test/cpp/end2end/anonymous_end2end_test.cc b/test/cpp/end2end/anonymous_end2end_test.cc new file mode 100644 index 0000000000..362c0cd4a4 --- /dev/null +++ b/test/cpp/end2end/anonymous_end2end_test.cc @@ -0,0 +1,563 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.pb.h" +#include "src/cpp/util/time.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "test/core/util/port.h" +#include + +#include +#include +#include + +using grpc::cpp::test::util::EchoRequest; +using grpc::cpp::test::util::EchoResponse; +using std::chrono::system_clock; + +namespace grpc { +namespace testing { +namespace { + +void* tag(int i) { return (void*)(gpr_intptr)i; } + +void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { + bool ok; + void* got_tag; + EXPECT_TRUE(cq->Next(&got_tag, &ok)); + EXPECT_EQ(expect_ok, ok); + EXPECT_EQ(tag(i), got_tag); +} + +class AnonymousEnd2endTest : public ::testing::Test { + protected: + AnonymousEnd2endTest() {} + + void SetUp() GRPC_OVERRIDE { + int port = grpc_pick_unused_port_or_die(); + server_address_ << "localhost:" << port; + // Setup server + ServerBuilder builder; + builder.AddPort(server_address_.str(), InsecureServerCredentials()); + builder.RegisterAnonymousService(&anonymous_service_); + server_ = builder.BuildAndStart(); + } + + void TearDown() GRPC_OVERRIDE { + server_->Shutdown(); + void* ignored_tag; + bool ignored_ok; + cli_cq_.Shutdown(); + srv_cq_.Shutdown(); + while (cli_cq_.Next(&ignored_tag, &ignored_ok)) + ; + while (srv_cq_.Next(&ignored_tag, &ignored_ok)) + ; + } + + void ResetStub() { + std::shared_ptr channel = + CreateChannel(server_address_.str(), InsecureCredentials(), ChannelArguments()); + stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); + } + + void server_ok(int i) { verify_ok(&srv_cq_, i, true); } + void client_ok(int i) { verify_ok(&cli_cq_, i, true); } + void server_fail(int i) { verify_ok(&srv_cq_, i, false); } + void client_fail(int i) { verify_ok(&cli_cq_, i, false); } + + void SendRpc(int num_rpcs) { + for (int i = 0; i < num_rpcs; i++) { + EchoRequest send_request; + EchoRequest recv_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + + ClientContext cli_ctx; + AnonymousServerContext srv_ctx; + GenericServerReaderWriter stream(&srv_ctx); + + send_request.set_message("Hello"); + std::unique_ptr > response_reader( + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); + client_ok(1); + + anonymous_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2)); + + verify_ok(server_->cq(), 2, true); + EXPECT_EQ(server_address_.str(), srv_ctx.host()); + EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method()); + ByteBuffer recv_buffer; + stream.Read(&recv_buffer, tag(3)); + server_ok(3); + std::vector slices; + recv_buffer.Dump(&slices); + EXPECT_EQ(1, slices.size()); // FIXME(yangg) handle real vector + grpc::string buf(reinterpret_cast(slices[0].begin()), + slices[0].size()); + EXPECT_TRUE(recv_request.ParseFromString(buf)); + EXPECT_EQ(send_request.message(), recv_request.message()); + + send_response.set_message(recv_request.message()); + buf.clear(); + send_response.SerializeToString(&buf); + gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); + Slice slice(s, Slice::STEAL_REF); + ByteBuffer send_buffer(&slice, 1); + stream.Write(send_buffer, tag(4)); + server_ok(4); + + stream.Finish(Status::OK, tag(5)); + server_ok(5); + + response_reader->Finish(&recv_response, &recv_status, tag(4)); + client_ok(4); + + EXPECT_EQ(send_response.message(), recv_response.message()); + EXPECT_TRUE(recv_status.IsOk()); + } + } + + CompletionQueue cli_cq_; + CompletionQueue srv_cq_; + std::unique_ptr stub_; + std::unique_ptr server_; + AnonymousService anonymous_service_; + std::ostringstream server_address_; +}; + +TEST_F(AnonymousEnd2endTest, SimpleRpc) { + ResetStub(); + SendRpc(1); +} + +TEST_F(AnonymousEnd2endTest, SequentialRpcs) { + ResetStub(); + SendRpc(10); +} + +// // Two pings and a final pong. +// TEST_F(AnonymousEnd2endTest, SimpleClientStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncReader srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > cli_stream( +// stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); +// +// service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); +// +// server_ok(2); +// client_ok(1); +// +// cli_stream->Write(send_request, tag(3)); +// client_ok(3); +// +// srv_stream.Read(&recv_request, tag(4)); +// server_ok(4); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// cli_stream->Write(send_request, tag(5)); +// client_ok(5); +// +// srv_stream.Read(&recv_request, tag(6)); +// server_ok(6); +// +// EXPECT_EQ(send_request.message(), recv_request.message()); +// cli_stream->WritesDone(tag(7)); +// client_ok(7); +// +// srv_stream.Read(&recv_request, tag(8)); +// server_fail(8); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Finish(send_response, Status::OK, tag(9)); +// server_ok(9); +// +// cli_stream->Finish(&recv_status, tag(10)); +// client_ok(10); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // One ping, two pongs. +// TEST_F(AnonymousEnd2endTest, SimpleServerStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncWriter srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > cli_stream( +// stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_, +// tag(2)); +// +// server_ok(2); +// client_ok(1); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Write(send_response, tag(3)); +// server_ok(3); +// +// cli_stream->Read(&recv_response, tag(4)); +// client_ok(4); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// srv_stream.Write(send_response, tag(5)); +// server_ok(5); +// +// cli_stream->Read(&recv_response, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// srv_stream.Finish(Status::OK, tag(7)); +// server_ok(7); +// +// cli_stream->Read(&recv_response, tag(8)); +// client_fail(8); +// +// cli_stream->Finish(&recv_status, tag(9)); +// client_ok(9); +// +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // One ping, one pong. +// TEST_F(AnonymousEnd2endTest, SimpleBidiStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncReaderWriter srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > +// cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); +// +// service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); +// +// server_ok(2); +// client_ok(1); +// +// cli_stream->Write(send_request, tag(3)); +// client_ok(3); +// +// srv_stream.Read(&recv_request, tag(4)); +// server_ok(4); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Write(send_response, tag(5)); +// server_ok(5); +// +// cli_stream->Read(&recv_response, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// cli_stream->WritesDone(tag(7)); +// client_ok(7); +// +// srv_stream.Read(&recv_request, tag(8)); +// server_fail(8); +// +// srv_stream.Finish(Status::OK, tag(9)); +// server_ok(9); +// +// cli_stream->Finish(&recv_status, tag(10)); +// client_ok(10); +// +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // Metadata tests +// TEST_F(AnonymousEnd2endTest, ClientInitialMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// cli_ctx.AddMetadata(meta1.first, meta1.second); +// cli_ctx.AddMetadata(meta2.first, meta2.second); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// auto client_initial_metadata = srv_ctx.client_metadata(); +// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); +// client_ok(1); +// +// send_response.set_message(recv_request.message()); +// response_writer.Finish(send_response, Status::OK, tag(3)); +// +// server_ok(3); +// +// response_reader->Finish(&recv_response, &recv_status, tag(4)); +// client_ok(4); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// TEST_F(AnonymousEnd2endTest, ServerInitialMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// srv_ctx.AddInitialMetadata(meta1.first, meta1.second); +// srv_ctx.AddInitialMetadata(meta2.first, meta2.second); +// client_ok(1); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// +// response_reader->ReadInitialMetadata(tag(4)); +// client_ok(4); +// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); +// EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); +// +// send_response.set_message(recv_request.message()); +// response_writer.Finish(send_response, Status::OK, tag(5)); +// server_ok(5); +// +// response_reader->Finish(&recv_response, &recv_status, tag(6)); +// client_ok(6); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// TEST_F(AnonymousEnd2endTest, ServerTrailingMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// client_ok(1); +// +// send_response.set_message(recv_request.message()); +// srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); +// srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); +// response_writer.Finish(send_response, Status::OK, tag(4)); +// +// server_ok(4); +// +// response_reader->Finish(&recv_response, &recv_status, tag(5)); +// client_ok(5); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); +// EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); +// } +// +// TEST_F(AnonymousEnd2endTest, MetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2( +// "key2-bin", {"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13}); +// std::pair meta3("key3", "val3"); +// std::pair meta6( +// "key4-bin", +// {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", 14}); +// std::pair meta5("key5", "val5"); +// std::pair meta4( +// "key6-bin", +// {"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15}); +// +// cli_ctx.AddMetadata(meta1.first, meta1.second); +// cli_ctx.AddMetadata(meta2.first, meta2.second); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// auto client_initial_metadata = srv_ctx.client_metadata(); +// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); +// client_ok(1); +// +// srv_ctx.AddInitialMetadata(meta3.first, meta3.second); +// srv_ctx.AddInitialMetadata(meta4.first, meta4.second); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// response_reader->ReadInitialMetadata(tag(4)); +// client_ok(4); +// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); +// EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second); +// EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second); +// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); +// +// send_response.set_message(recv_request.message()); +// srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); +// srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); +// response_writer.Finish(send_response, Status::OK, tag(5)); +// +// server_ok(5); +// +// response_reader->Finish(&recv_response, &recv_status, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); +// EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); +// EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); +// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); +// } +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int result = RUN_ALL_TESTS(); + grpc_shutdown(); + google::protobuf::ShutdownProtobufLibrary(); + return result; +} diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 6f354452aa..7d2d64f14a 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -336,6 +336,11 @@ "language": "c", "name": "transport_security_test" }, + { + "flaky": false, + "language": "c++", + "name": "anonymous_end2end_test" + }, { "flaky": false, "language": "c++", -- cgit v1.2.3 From 7d6b184f57603fd047bb95776fc78e914c979d8c Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Wed, 11 Mar 2015 14:51:50 -0700 Subject: add a jwt test case for interop test --- test/cpp/interop/client.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 132e6e9068..e5645e568e 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -86,6 +86,7 @@ using grpc::ClientContext; using grpc::ComputeEngineCredentials; using grpc::CreateTestChannel; using grpc::Credentials; +using grpc::JWTCredentials; using grpc::ServiceAccountCredentials; using grpc::testing::ResponseParameters; using grpc::testing::SimpleRequest; @@ -151,7 +152,7 @@ std::shared_ptr CreateChannelForTestCase( std::unique_ptr creds; GPR_ASSERT(FLAGS_enable_ssl); grpc::string json_key = GetServiceAccountJsonKey(); - creds = CredentialsFactory::JWTCredentials(json_key, std::chrono::hours(1)); + creds = JWTCredentials(json_key, std::chrono::hours(1)); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_enable_ssl, FLAGS_use_prod_roots, creds); } else { -- cgit v1.2.3 From 005eb88c45a849ed73d02e9cfbdce939ea34540e Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Wed, 11 Mar 2015 22:17:13 -0700 Subject: Rename anonymous to generic globally --- Makefile | 106 +++--- build.json | 30 +- include/grpc++/anonymous_service.h | 75 ---- include/grpc++/anonymous_stub.h | 59 --- include/grpc++/generic_service.h | 75 ++++ include/grpc++/generic_stub.h | 59 +++ include/grpc++/server.h | 14 +- include/grpc++/server_builder.h | 8 +- src/cpp/server/anonymous_service.cc | 47 --- src/cpp/server/generic_service.cc | 47 +++ src/cpp/server/server.cc | 28 +- src/cpp/server/server_builder.cc | 14 +- test/cpp/end2end/anonymous_end2end_test.cc | 563 ----------------------------- test/cpp/end2end/generic_end2end_test.cc | 563 +++++++++++++++++++++++++++++ tools/run_tests/tests.json | 10 +- 15 files changed, 849 insertions(+), 849 deletions(-) delete mode 100644 include/grpc++/anonymous_service.h delete mode 100644 include/grpc++/anonymous_stub.h create mode 100644 include/grpc++/generic_service.h create mode 100644 include/grpc++/generic_stub.h delete mode 100644 src/cpp/server/anonymous_service.cc create mode 100644 src/cpp/server/generic_service.cc delete mode 100644 test/cpp/end2end/anonymous_end2end_test.cc create mode 100644 test/cpp/end2end/generic_end2end_test.cc (limited to 'test') diff --git a/Makefile b/Makefile index 1b8161e846..853a8a3f4d 100644 --- a/Makefile +++ b/Makefile @@ -531,11 +531,11 @@ time_test: $(BINDIR)/$(CONFIG)/time_test timeout_encoding_test: $(BINDIR)/$(CONFIG)/timeout_encoding_test transport_metadata_test: $(BINDIR)/$(CONFIG)/transport_metadata_test transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test -anonymous_end2end_test: $(BINDIR)/$(CONFIG)/anonymous_end2end_test async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test credentials_test: $(BINDIR)/$(CONFIG)/credentials_test end2end_test: $(BINDIR)/$(CONFIG)/end2end_test +generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test grpc_cpp_plugin: $(BINDIR)/$(CONFIG)/grpc_cpp_plugin grpc_python_plugin: $(BINDIR)/$(CONFIG)/grpc_python_plugin grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin @@ -966,7 +966,7 @@ buildtests: buildtests_c buildtests_cxx buildtests_c: privatelibs_c $(BINDIR)/$(CONFIG)/alarm_heap_test $(BINDIR)/$(CONFIG)/alarm_list_test $(BINDIR)/$(CONFIG)/alarm_test $(BINDIR)/$(CONFIG)/alpn_test $(BINDIR)/$(CONFIG)/bin_encoder_test $(BINDIR)/$(CONFIG)/census_hash_table_test $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_test $(BINDIR)/$(CONFIG)/census_statistics_performance_test $(BINDIR)/$(CONFIG)/census_statistics_quick_test $(BINDIR)/$(CONFIG)/census_statistics_small_log_test $(BINDIR)/$(CONFIG)/census_stub_test $(BINDIR)/$(CONFIG)/census_window_stats_test $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test $(BINDIR)/$(CONFIG)/chttp2_stream_encoder_test $(BINDIR)/$(CONFIG)/chttp2_stream_map_test $(BINDIR)/$(CONFIG)/chttp2_transport_end2end_test $(BINDIR)/$(CONFIG)/dualstack_socket_test $(BINDIR)/$(CONFIG)/echo_client $(BINDIR)/$(CONFIG)/echo_server $(BINDIR)/$(CONFIG)/echo_test $(BINDIR)/$(CONFIG)/fd_posix_test $(BINDIR)/$(CONFIG)/fling_client $(BINDIR)/$(CONFIG)/fling_server $(BINDIR)/$(CONFIG)/fling_stream_test $(BINDIR)/$(CONFIG)/fling_test $(BINDIR)/$(CONFIG)/gpr_cancellable_test $(BINDIR)/$(CONFIG)/gpr_cmdline_test $(BINDIR)/$(CONFIG)/gpr_env_test $(BINDIR)/$(CONFIG)/gpr_file_test $(BINDIR)/$(CONFIG)/gpr_histogram_test $(BINDIR)/$(CONFIG)/gpr_host_port_test $(BINDIR)/$(CONFIG)/gpr_log_test $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test $(BINDIR)/$(CONFIG)/gpr_slice_test $(BINDIR)/$(CONFIG)/gpr_string_test $(BINDIR)/$(CONFIG)/gpr_sync_test $(BINDIR)/$(CONFIG)/gpr_thd_test $(BINDIR)/$(CONFIG)/gpr_time_test $(BINDIR)/$(CONFIG)/gpr_useful_test $(BINDIR)/$(CONFIG)/grpc_base64_test $(BINDIR)/$(CONFIG)/grpc_byte_buffer_reader_test $(BINDIR)/$(CONFIG)/grpc_channel_stack_test $(BINDIR)/$(CONFIG)/grpc_completion_queue_test $(BINDIR)/$(CONFIG)/grpc_credentials_test $(BINDIR)/$(CONFIG)/grpc_json_token_test $(BINDIR)/$(CONFIG)/grpc_stream_op_test $(BINDIR)/$(CONFIG)/hpack_parser_test $(BINDIR)/$(CONFIG)/hpack_table_test $(BINDIR)/$(CONFIG)/httpcli_format_request_test $(BINDIR)/$(CONFIG)/httpcli_parser_test $(BINDIR)/$(CONFIG)/httpcli_test $(BINDIR)/$(CONFIG)/json_rewrite $(BINDIR)/$(CONFIG)/json_rewrite_test $(BINDIR)/$(CONFIG)/json_test $(BINDIR)/$(CONFIG)/lame_client_test $(BINDIR)/$(CONFIG)/message_compress_test $(BINDIR)/$(CONFIG)/metadata_buffer_test $(BINDIR)/$(CONFIG)/multi_init_test $(BINDIR)/$(CONFIG)/murmur_hash_test $(BINDIR)/$(CONFIG)/no_server_test $(BINDIR)/$(CONFIG)/poll_kick_posix_test $(BINDIR)/$(CONFIG)/resolve_address_test $(BINDIR)/$(CONFIG)/secure_endpoint_test $(BINDIR)/$(CONFIG)/sockaddr_utils_test $(BINDIR)/$(CONFIG)/tcp_client_posix_test $(BINDIR)/$(CONFIG)/tcp_posix_test $(BINDIR)/$(CONFIG)/tcp_server_posix_test $(BINDIR)/$(CONFIG)/time_averaged_stats_test $(BINDIR)/$(CONFIG)/time_test $(BINDIR)/$(CONFIG)/timeout_encoding_test $(BINDIR)/$(CONFIG)/transport_metadata_test $(BINDIR)/$(CONFIG)/transport_security_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_no_op_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_fullstack_uds_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_bad_hostname_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_empty_batch_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_with_payload_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_legacy_test $(BINDIR)/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_legacy_test -buildtests_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/anonymous_end2end_test $(BINDIR)/$(CONFIG)/async_end2end_test $(BINDIR)/$(CONFIG)/channel_arguments_test $(BINDIR)/$(CONFIG)/credentials_test $(BINDIR)/$(CONFIG)/end2end_test $(BINDIR)/$(CONFIG)/interop_client $(BINDIR)/$(CONFIG)/interop_server $(BINDIR)/$(CONFIG)/interop_test $(BINDIR)/$(CONFIG)/pubsub_client $(BINDIR)/$(CONFIG)/pubsub_publisher_test $(BINDIR)/$(CONFIG)/pubsub_subscriber_test $(BINDIR)/$(CONFIG)/qps_driver $(BINDIR)/$(CONFIG)/qps_worker $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/thread_pool_test +buildtests_cxx: privatelibs_cxx $(BINDIR)/$(CONFIG)/async_end2end_test $(BINDIR)/$(CONFIG)/channel_arguments_test $(BINDIR)/$(CONFIG)/credentials_test $(BINDIR)/$(CONFIG)/end2end_test $(BINDIR)/$(CONFIG)/generic_end2end_test $(BINDIR)/$(CONFIG)/interop_client $(BINDIR)/$(CONFIG)/interop_server $(BINDIR)/$(CONFIG)/interop_test $(BINDIR)/$(CONFIG)/pubsub_client $(BINDIR)/$(CONFIG)/pubsub_publisher_test $(BINDIR)/$(CONFIG)/pubsub_subscriber_test $(BINDIR)/$(CONFIG)/qps_driver $(BINDIR)/$(CONFIG)/qps_worker $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/thread_pool_test test: test_c test_cxx @@ -1794,8 +1794,6 @@ test_c: buildtests_c test_cxx: buildtests_cxx - $(E) "[RUN] Testing anonymous_end2end_test" - $(Q) $(BINDIR)/$(CONFIG)/anonymous_end2end_test || ( echo test anonymous_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing async_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/async_end2end_test || ( echo test async_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing channel_arguments_test" @@ -1804,6 +1802,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/credentials_test || ( echo test credentials_test failed ; exit 1 ) $(E) "[RUN] Testing end2end_test" $(Q) $(BINDIR)/$(CONFIG)/end2end_test || ( echo test end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing generic_end2end_test" + $(Q) $(BINDIR)/$(CONFIG)/generic_end2end_test || ( echo test generic_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing interop_test" $(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 ) $(E) "[RUN] Testing pubsub_publisher_test" @@ -3108,7 +3108,7 @@ LIBGRPC++_SRC = \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ - src/cpp/server/anonymous_service.cc \ + src/cpp/server/generic_service.cc \ src/cpp/server/insecure_server_credentials.cc \ src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ @@ -3121,7 +3121,6 @@ LIBGRPC++_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ - include/grpc++/anonymous_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/byte_buffer.h \ include/grpc++/channel_arguments.h \ @@ -3131,6 +3130,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/config.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ + include/grpc++/generic_service.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/internal_stub.h \ @@ -3195,7 +3195,7 @@ src/cpp/common/call.cc: $(OPENSSL_DEP) src/cpp/common/completion_queue.cc: $(OPENSSL_DEP) src/cpp/common/rpc_method.cc: $(OPENSSL_DEP) src/cpp/proto/proto_utils.cc: $(OPENSSL_DEP) -src/cpp/server/anonymous_service.cc: $(OPENSSL_DEP) +src/cpp/server/generic_service.cc: $(OPENSSL_DEP) src/cpp/server/insecure_server_credentials.cc: $(OPENSSL_DEP) src/cpp/server/server.cc: $(OPENSSL_DEP) src/cpp/server/server_builder.cc: $(OPENSSL_DEP) @@ -3261,7 +3261,7 @@ $(OBJDIR)/$(CONFIG)/src/cpp/common/call.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/completion_queue.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/rpc_method.o: $(OBJDIR)/$(CONFIG)/src/cpp/proto/proto_utils.o: -$(OBJDIR)/$(CONFIG)/src/cpp/server/anonymous_service.o: +$(OBJDIR)/$(CONFIG)/src/cpp/server/generic_service.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/insecure_server_credentials.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server_builder.o: @@ -3352,7 +3352,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ - src/cpp/server/anonymous_service.cc \ + src/cpp/server/generic_service.cc \ src/cpp/server/insecure_server_credentials.cc \ src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ @@ -3365,7 +3365,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ - include/grpc++/anonymous_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/byte_buffer.h \ include/grpc++/channel_arguments.h \ @@ -3375,6 +3374,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/config.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ + include/grpc++/generic_service.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/internal_stub.h \ @@ -3454,7 +3454,7 @@ $(OBJDIR)/$(CONFIG)/src/cpp/common/call.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/completion_queue.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/rpc_method.o: $(OBJDIR)/$(CONFIG)/src/cpp/proto/proto_utils.o: -$(OBJDIR)/$(CONFIG)/src/cpp/server/anonymous_service.o: +$(OBJDIR)/$(CONFIG)/src/cpp/server/generic_service.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/insecure_server_credentials.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server_builder.o: @@ -7779,48 +7779,6 @@ endif endif -ANONYMOUS_END2END_TEST_SRC = \ - test/cpp/end2end/anonymous_end2end_test.cc \ - -ANONYMOUS_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ANONYMOUS_END2END_TEST_SRC)))) - -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL with ALPN. - -$(BINDIR)/$(CONFIG)/anonymous_end2end_test: openssl_dep_error - -else - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. - -$(BINDIR)/$(CONFIG)/anonymous_end2end_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/anonymous_end2end_test: $(PROTOBUF_DEP) $(ANONYMOUS_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(ANONYMOUS_END2END_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/anonymous_end2end_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/cpp/end2end/anonymous_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_anonymous_end2end_test: $(ANONYMOUS_END2END_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(ANONYMOUS_END2END_TEST_OBJS:.o=.dep) -endif -endif - - ASYNC_END2END_TEST_SRC = \ test/cpp/end2end/async_end2end_test.cc \ @@ -7989,6 +7947,48 @@ endif endif +GENERIC_END2END_TEST_SRC = \ + test/cpp/end2end/generic_end2end_test.cc \ + +GENERIC_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GENERIC_END2END_TEST_SRC)))) + +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL with ALPN. + +$(BINDIR)/$(CONFIG)/generic_end2end_test: openssl_dep_error + +else + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/generic_end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/generic_end2end_test: $(PROTOBUF_DEP) $(GENERIC_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GENERIC_END2END_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/generic_end2end_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/end2end/generic_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_generic_end2end_test: $(GENERIC_END2END_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GENERIC_END2END_TEST_OBJS:.o=.dep) +endif +endif + + GRPC_CPP_PLUGIN_SRC = \ src/compiler/cpp_generator.cc \ src/compiler/cpp_plugin.cc \ diff --git a/build.json b/build.json index 9b217dc909..4ec74b8bc8 100644 --- a/build.json +++ b/build.json @@ -12,7 +12,6 @@ { "name": "grpc++_base", "public_headers": [ - "include/grpc++/anonymous_service.h", "include/grpc++/async_unary_call.h", "include/grpc++/byte_buffer.h", "include/grpc++/channel_arguments.h", @@ -22,6 +21,7 @@ "include/grpc++/config.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", + "include/grpc++/generic_service.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/internal_stub.h", @@ -57,7 +57,7 @@ "src/cpp/common/completion_queue.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", - "src/cpp/server/anonymous_service.cc", + "src/cpp/server/generic_service.cc", "src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/server.cc", "src/cpp/server/server_builder.cc", @@ -1647,11 +1647,11 @@ ] }, { - "name": "anonymous_end2end_test", + "name": "async_end2end_test", "build": "test", "language": "c++", "src": [ - "test/cpp/end2end/anonymous_end2end_test.cc" + "test/cpp/end2end/async_end2end_test.cc" ], "deps": [ "grpc++_test_util", @@ -1663,27 +1663,24 @@ ] }, { - "name": "async_end2end_test", + "name": "channel_arguments_test", "build": "test", "language": "c++", "src": [ - "test/cpp/end2end/async_end2end_test.cc" + "test/cpp/client/channel_arguments_test.cc" ], "deps": [ - "grpc++_test_util", - "grpc_test_util", "grpc++", "grpc", - "gpr_test_util", "gpr" ] }, { - "name": "channel_arguments_test", + "name": "credentials_test", "build": "test", "language": "c++", "src": [ - "test/cpp/client/channel_arguments_test.cc" + "test/cpp/client/credentials_test.cc" ], "deps": [ "grpc++", @@ -1692,24 +1689,27 @@ ] }, { - "name": "credentials_test", + "name": "end2end_test", "build": "test", "language": "c++", "src": [ - "test/cpp/client/credentials_test.cc" + "test/cpp/end2end/end2end_test.cc" ], "deps": [ + "grpc++_test_util", + "grpc_test_util", "grpc++", "grpc", + "gpr_test_util", "gpr" ] }, { - "name": "end2end_test", + "name": "generic_end2end_test", "build": "test", "language": "c++", "src": [ - "test/cpp/end2end/end2end_test.cc" + "test/cpp/end2end/generic_end2end_test.cc" ], "deps": [ "grpc++_test_util", diff --git a/include/grpc++/anonymous_service.h b/include/grpc++/anonymous_service.h deleted file mode 100644 index 78903dbc3b..0000000000 --- a/include/grpc++/anonymous_service.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPCXX_ANONYMOUS_SERVICE_H -#define GRPCXX_ANONYMOUS_SERVICE_H - -#include -#include - -struct grpc_server; - -namespace grpc { - -typedef ServerAsyncReaderWriter GenericServerReaderWriter; - -class AnonymousServerContext : public ServerContext { - public: - const grpc::string& method() const { return method_; } - const grpc::string& host() const { return host_; } - - private: - friend class Server; - - grpc::string method_; - grpc::string host_; -}; - -class AnonymousService { - public: - // TODO(yangg) Once we can add multiple completion queues to the server - // in c core, add a CompletionQueue* argument to the ctor here. - AnonymousService() : server_(nullptr) {} - - void RequestCall(AnonymousServerContext* ctx, - GenericServerReaderWriter* reader_writer, - CompletionQueue* cq, void* tag); - - private: - friend class Server; - Server* server_; -}; - -} // namespace grpc - -#endif // GRPCXX_ANONYMOUS_SERVICE_H diff --git a/include/grpc++/anonymous_stub.h b/include/grpc++/anonymous_stub.h deleted file mode 100644 index ccb474e21b..0000000000 --- a/include/grpc++/anonymous_stub.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPCXX_ANONYMOUS_STUB_H -#define GRPCXX_ANONYMOUS_STUB_H - -#include -#include - -namespace grpc { - -typedef ClientAsyncReaderWriter GenericClientReaderWriter; - -// Anonymous stubs provide a type-unsafe interface to call gRPC methods -// by name. -class AnonymousStub { - public: - explicit AnonymousStub(std::shared_ptr channel) : channel_(channel) {} - - // begin a call to a named method - std::unique_ptr Call(ClientContext* context, const grpc::string& method); - - private: - std::shared_ptr channel_; -}; - -} // namespace grpc - -#endif // GRPCXX_ANONYMOUS_STUB_H diff --git a/include/grpc++/generic_service.h b/include/grpc++/generic_service.h new file mode 100644 index 0000000000..50a36465de --- /dev/null +++ b/include/grpc++/generic_service.h @@ -0,0 +1,75 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_GENERIC_SERVICE_H +#define GRPCXX_GENERIC_SERVICE_H + +#include +#include + +struct grpc_server; + +namespace grpc { + +typedef ServerAsyncReaderWriter GenericServerReaderWriter; + +class GenericServerContext : public ServerContext { + public: + const grpc::string& method() const { return method_; } + const grpc::string& host() const { return host_; } + + private: + friend class Server; + + grpc::string method_; + grpc::string host_; +}; + +class GenericService { + public: + // TODO(yangg) Once we can add multiple completion queues to the server + // in c core, add a CompletionQueue* argument to the ctor here. + GenericService() : server_(nullptr) {} + + void RequestCall(GenericServerContext* ctx, + GenericServerReaderWriter* reader_writer, + CompletionQueue* cq, void* tag); + + private: + friend class Server; + Server* server_; +}; + +} // namespace grpc + +#endif // GRPCXX_GENERIC_SERVICE_H diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h new file mode 100644 index 0000000000..87396f0337 --- /dev/null +++ b/include/grpc++/generic_stub.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_GENERIC_STUB_H +#define GRPCXX_GENERIC_STUB_H + +#include +#include + +namespace grpc { + +typedef ClientAsyncReaderWriter GenericClientReaderWriter; + +// Generic stubs provide a type-unsafe interface to call gRPC methods +// by name. +class GenericStub { + public: + explicit GenericStub(std::shared_ptr channel) : channel_(channel) {} + + // begin a call to a named method + std::unique_ptr Call(ClientContext* context, const grpc::string& method); + + private: + std::shared_ptr channel_; +}; + +} // namespace grpc + +#endif // GRPCXX_GENERIC_STUB_H diff --git a/include/grpc++/server.h b/include/grpc++/server.h index b808351181..a330627747 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -48,9 +48,9 @@ struct grpc_server; namespace grpc { -class AnonymousServerContext; -class AnonymousService; class AsynchronousService; +class GenericServerContext; +class GenericService; class RpcService; class RpcServiceMethod; class ServerCredentials; @@ -73,7 +73,7 @@ class Server GRPC_FINAL : private CallHook, CompletionQueue* cq() { return &cq_; } private: - friend class AnonymousService; + friend class GenericService; friend class ServerBuilder; class SyncRequest; @@ -86,7 +86,7 @@ class Server GRPC_FINAL : private CallHook, // The service must exist for the lifetime of the Server instance. bool RegisterService(RpcService* service); bool RegisterAsyncService(AsynchronousService* service); - void RegisterAnonymousService(AnonymousService* service); + void RegisterGenericService(GenericService* service); // Add a listening port. Can be called multiple times. int AddPort(const grpc::string& addr, ServerCredentials* creds); // Start the server. @@ -104,9 +104,9 @@ class Server GRPC_FINAL : private CallHook, ServerAsyncStreamingInterface* stream, CompletionQueue* cq, void* tag) GRPC_OVERRIDE; - void RequestAsyncAnonymousCall(AnonymousServerContext* context, - ServerAsyncStreamingInterface* stream, - CompletionQueue* cq, void* tag); + void RequestGenericCall(GenericServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* cq, void* tag); // Completion queue. CompletionQueue cq_; diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index cb961bf2ba..dbd9871d38 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -41,9 +41,9 @@ namespace grpc { -class AnonymousService; class AsynchronousService; class CompletionQueue; +class GenericService; class RpcService; class Server; class ServerCredentials; @@ -65,8 +65,8 @@ class ServerBuilder { // instance returned by BuildAndStart(). void RegisterAsyncService(AsynchronousService* service); - // Register an anonymous service. - void RegisterAnonymousService(AnonymousService* service); + // Register a generic service. + void RegisterGenericService(GenericService* service); // Add a listening port. Can be called multiple times. void AddPort(const grpc::string& addr, @@ -91,7 +91,7 @@ class ServerBuilder { std::vector async_services_; std::vector ports_; std::shared_ptr creds_; - AnonymousService* anonymous_service_; + GenericService* generic_service_; ThreadPoolInterface* thread_pool_; }; diff --git a/src/cpp/server/anonymous_service.cc b/src/cpp/server/anonymous_service.cc deleted file mode 100644 index ef20cade34..0000000000 --- a/src/cpp/server/anonymous_service.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include - -namespace grpc { - -void AnonymousService::RequestCall(AnonymousServerContext* ctx, - GenericServerReaderWriter* reader_writer, - CompletionQueue* cq, void* tag) { - server_->RequestAsyncAnonymousCall(ctx, reader_writer, cq, tag); -} - -} // namespace grpc - diff --git a/src/cpp/server/generic_service.cc b/src/cpp/server/generic_service.cc new file mode 100644 index 0000000000..8ced775a67 --- /dev/null +++ b/src/cpp/server/generic_service.cc @@ -0,0 +1,47 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +namespace grpc { + +void GenericService::RequestCall(GenericServerContext* ctx, + GenericServerReaderWriter* reader_writer, + CompletionQueue* cq, void* tag) { + server_->RequestGenericCall(ctx, reader_writer, cq, tag); +} + +} // namespace grpc + diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 4328b2c075..44c8a768d2 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -37,8 +37,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -227,9 +227,9 @@ bool Server::RegisterAsyncService(AsynchronousService* service) { return true; } -void Server::RegisterAnonymousService(AnonymousService* service) { +void Server::RegisterGenericService(GenericService* service) { GPR_ASSERT(service->server_ == nullptr && - "Can only register an anonymous service against one server."); + "Can only register an generic service against one server."); service->server_ = this; } @@ -296,7 +296,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { stream_(stream), cq_(cq), ctx_(ctx), - anonymous_ctx_(nullptr), + generic_ctx_(nullptr), server_(server), call_(nullptr), payload_(nullptr) { @@ -307,7 +307,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { &array_, request ? &payload_ : nullptr, cq->cq(), this); } - AsyncRequest(Server* server, AnonymousServerContext* ctx, + AsyncRequest(Server* server, GenericServerContext* ctx, ServerAsyncStreamingInterface* stream, CompletionQueue* cq, void* tag) : tag_(tag), @@ -315,7 +315,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { stream_(stream), cq_(cq), ctx_(nullptr), - anonymous_ctx_(ctx), + generic_ctx_(ctx), server_(server), call_(nullptr), payload_(nullptr) { @@ -343,7 +343,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { *status = false; } } - ServerContext* ctx = ctx_ ? ctx_ : anonymous_ctx_; + ServerContext* ctx = ctx_ ? ctx_ : generic_ctx_; GPR_ASSERT(ctx); if (*status) { ctx->deadline_ = Timespec2Timepoint(call_details_.deadline); @@ -354,9 +354,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { array_.metadata[i].value, array_.metadata[i].value + array_.metadata[i].value_length))); } - if (anonymous_ctx_) { - anonymous_ctx_->method_ = call_details_.method; - anonymous_ctx_->host_ = call_details_.host; + if (generic_ctx_) { + generic_ctx_->method_ = call_details_.method; + generic_ctx_->host_ = call_details_.host; } } ctx->call_ = call_; @@ -376,7 +376,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { ServerAsyncStreamingInterface* const stream_; CompletionQueue* const cq_; ServerContext* const ctx_; - AnonymousServerContext* const anonymous_ctx_; + GenericServerContext* const generic_ctx_; Server* const server_; grpc_call* call_; grpc_call_details call_details_; @@ -391,9 +391,9 @@ void Server::RequestAsyncCall(void* registered_method, ServerContext* context, new AsyncRequest(this, registered_method, context, request, stream, cq, tag); } -void Server::RequestAsyncAnonymousCall(AnonymousServerContext* context, - ServerAsyncStreamingInterface* stream, - CompletionQueue* cq, void* tag) { +void Server::RequestGenericCall(GenericServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* cq, void* tag) { new AsyncRequest(this, context, stream, cq, tag); } diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index e3b9cdfd7f..083509e797 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -42,7 +42,7 @@ namespace grpc { ServerBuilder::ServerBuilder() - : anonymous_service_(nullptr), thread_pool_(nullptr) {} + : generic_service_(nullptr), thread_pool_(nullptr) {} void ServerBuilder::RegisterService(SynchronousService* service) { services_.push_back(service->service()); @@ -52,14 +52,14 @@ void ServerBuilder::RegisterAsyncService(AsynchronousService* service) { async_services_.push_back(service); } -void ServerBuilder::RegisterAnonymousService(AnonymousService* service) { - if (anonymous_service_) { +void ServerBuilder::RegisterGenericService(GenericService* service) { + if (generic_service_) { gpr_log(GPR_ERROR, - "Adding multiple AnonymousService is unsupported for now. " + "Adding multiple GenericService is unsupported for now. " "Dropping the service %p", service); return; } - anonymous_service_ = service; + generic_service_ = service; } void ServerBuilder::AddPort(const grpc::string& addr, @@ -95,8 +95,8 @@ std::unique_ptr ServerBuilder::BuildAndStart() { return nullptr; } } - if (anonymous_service_) { - server->RegisterAnonymousService(anonymous_service_); + if (generic_service_) { + server->RegisterGenericService(generic_service_); } for (auto& port : ports_) { int r = server->AddPort(port.addr, port.creds.get()); diff --git a/test/cpp/end2end/anonymous_end2end_test.cc b/test/cpp/end2end/anonymous_end2end_test.cc deleted file mode 100644 index 362c0cd4a4..0000000000 --- a/test/cpp/end2end/anonymous_end2end_test.cc +++ /dev/null @@ -1,563 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include - -#include "test/core/util/test_config.h" -#include "test/cpp/util/echo.pb.h" -#include "src/cpp/util/time.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "test/core/util/port.h" -#include - -#include -#include -#include - -using grpc::cpp::test::util::EchoRequest; -using grpc::cpp::test::util::EchoResponse; -using std::chrono::system_clock; - -namespace grpc { -namespace testing { -namespace { - -void* tag(int i) { return (void*)(gpr_intptr)i; } - -void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { - bool ok; - void* got_tag; - EXPECT_TRUE(cq->Next(&got_tag, &ok)); - EXPECT_EQ(expect_ok, ok); - EXPECT_EQ(tag(i), got_tag); -} - -class AnonymousEnd2endTest : public ::testing::Test { - protected: - AnonymousEnd2endTest() {} - - void SetUp() GRPC_OVERRIDE { - int port = grpc_pick_unused_port_or_die(); - server_address_ << "localhost:" << port; - // Setup server - ServerBuilder builder; - builder.AddPort(server_address_.str(), InsecureServerCredentials()); - builder.RegisterAnonymousService(&anonymous_service_); - server_ = builder.BuildAndStart(); - } - - void TearDown() GRPC_OVERRIDE { - server_->Shutdown(); - void* ignored_tag; - bool ignored_ok; - cli_cq_.Shutdown(); - srv_cq_.Shutdown(); - while (cli_cq_.Next(&ignored_tag, &ignored_ok)) - ; - while (srv_cq_.Next(&ignored_tag, &ignored_ok)) - ; - } - - void ResetStub() { - std::shared_ptr channel = - CreateChannel(server_address_.str(), InsecureCredentials(), ChannelArguments()); - stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); - } - - void server_ok(int i) { verify_ok(&srv_cq_, i, true); } - void client_ok(int i) { verify_ok(&cli_cq_, i, true); } - void server_fail(int i) { verify_ok(&srv_cq_, i, false); } - void client_fail(int i) { verify_ok(&cli_cq_, i, false); } - - void SendRpc(int num_rpcs) { - for (int i = 0; i < num_rpcs; i++) { - EchoRequest send_request; - EchoRequest recv_request; - EchoResponse send_response; - EchoResponse recv_response; - Status recv_status; - - ClientContext cli_ctx; - AnonymousServerContext srv_ctx; - GenericServerReaderWriter stream(&srv_ctx); - - send_request.set_message("Hello"); - std::unique_ptr > response_reader( - stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - client_ok(1); - - anonymous_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2)); - - verify_ok(server_->cq(), 2, true); - EXPECT_EQ(server_address_.str(), srv_ctx.host()); - EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method()); - ByteBuffer recv_buffer; - stream.Read(&recv_buffer, tag(3)); - server_ok(3); - std::vector slices; - recv_buffer.Dump(&slices); - EXPECT_EQ(1, slices.size()); // FIXME(yangg) handle real vector - grpc::string buf(reinterpret_cast(slices[0].begin()), - slices[0].size()); - EXPECT_TRUE(recv_request.ParseFromString(buf)); - EXPECT_EQ(send_request.message(), recv_request.message()); - - send_response.set_message(recv_request.message()); - buf.clear(); - send_response.SerializeToString(&buf); - gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); - Slice slice(s, Slice::STEAL_REF); - ByteBuffer send_buffer(&slice, 1); - stream.Write(send_buffer, tag(4)); - server_ok(4); - - stream.Finish(Status::OK, tag(5)); - server_ok(5); - - response_reader->Finish(&recv_response, &recv_status, tag(4)); - client_ok(4); - - EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); - } - } - - CompletionQueue cli_cq_; - CompletionQueue srv_cq_; - std::unique_ptr stub_; - std::unique_ptr server_; - AnonymousService anonymous_service_; - std::ostringstream server_address_; -}; - -TEST_F(AnonymousEnd2endTest, SimpleRpc) { - ResetStub(); - SendRpc(1); -} - -TEST_F(AnonymousEnd2endTest, SequentialRpcs) { - ResetStub(); - SendRpc(10); -} - -// // Two pings and a final pong. -// TEST_F(AnonymousEnd2endTest, SimpleClientStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncReader srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > cli_stream( -// stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); -// -// service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); -// -// server_ok(2); -// client_ok(1); -// -// cli_stream->Write(send_request, tag(3)); -// client_ok(3); -// -// srv_stream.Read(&recv_request, tag(4)); -// server_ok(4); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// cli_stream->Write(send_request, tag(5)); -// client_ok(5); -// -// srv_stream.Read(&recv_request, tag(6)); -// server_ok(6); -// -// EXPECT_EQ(send_request.message(), recv_request.message()); -// cli_stream->WritesDone(tag(7)); -// client_ok(7); -// -// srv_stream.Read(&recv_request, tag(8)); -// server_fail(8); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Finish(send_response, Status::OK, tag(9)); -// server_ok(9); -// -// cli_stream->Finish(&recv_status, tag(10)); -// client_ok(10); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // One ping, two pongs. -// TEST_F(AnonymousEnd2endTest, SimpleServerStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncWriter srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > cli_stream( -// stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_, -// tag(2)); -// -// server_ok(2); -// client_ok(1); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Write(send_response, tag(3)); -// server_ok(3); -// -// cli_stream->Read(&recv_response, tag(4)); -// client_ok(4); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// srv_stream.Write(send_response, tag(5)); -// server_ok(5); -// -// cli_stream->Read(&recv_response, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// srv_stream.Finish(Status::OK, tag(7)); -// server_ok(7); -// -// cli_stream->Read(&recv_response, tag(8)); -// client_fail(8); -// -// cli_stream->Finish(&recv_status, tag(9)); -// client_ok(9); -// -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // One ping, one pong. -// TEST_F(AnonymousEnd2endTest, SimpleBidiStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncReaderWriter srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > -// cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); -// -// service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); -// -// server_ok(2); -// client_ok(1); -// -// cli_stream->Write(send_request, tag(3)); -// client_ok(3); -// -// srv_stream.Read(&recv_request, tag(4)); -// server_ok(4); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Write(send_response, tag(5)); -// server_ok(5); -// -// cli_stream->Read(&recv_response, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// cli_stream->WritesDone(tag(7)); -// client_ok(7); -// -// srv_stream.Read(&recv_request, tag(8)); -// server_fail(8); -// -// srv_stream.Finish(Status::OK, tag(9)); -// server_ok(9); -// -// cli_stream->Finish(&recv_status, tag(10)); -// client_ok(10); -// -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // Metadata tests -// TEST_F(AnonymousEnd2endTest, ClientInitialMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// cli_ctx.AddMetadata(meta1.first, meta1.second); -// cli_ctx.AddMetadata(meta2.first, meta2.second); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// auto client_initial_metadata = srv_ctx.client_metadata(); -// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); -// client_ok(1); -// -// send_response.set_message(recv_request.message()); -// response_writer.Finish(send_response, Status::OK, tag(3)); -// -// server_ok(3); -// -// response_reader->Finish(&recv_response, &recv_status, tag(4)); -// client_ok(4); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// TEST_F(AnonymousEnd2endTest, ServerInitialMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// srv_ctx.AddInitialMetadata(meta1.first, meta1.second); -// srv_ctx.AddInitialMetadata(meta2.first, meta2.second); -// client_ok(1); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// -// response_reader->ReadInitialMetadata(tag(4)); -// client_ok(4); -// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); -// EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); -// -// send_response.set_message(recv_request.message()); -// response_writer.Finish(send_response, Status::OK, tag(5)); -// server_ok(5); -// -// response_reader->Finish(&recv_response, &recv_status, tag(6)); -// client_ok(6); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// TEST_F(AnonymousEnd2endTest, ServerTrailingMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// client_ok(1); -// -// send_response.set_message(recv_request.message()); -// srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); -// srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); -// response_writer.Finish(send_response, Status::OK, tag(4)); -// -// server_ok(4); -// -// response_reader->Finish(&recv_response, &recv_status, tag(5)); -// client_ok(5); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); -// EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); -// } -// -// TEST_F(AnonymousEnd2endTest, MetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2( -// "key2-bin", {"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13}); -// std::pair meta3("key3", "val3"); -// std::pair meta6( -// "key4-bin", -// {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", 14}); -// std::pair meta5("key5", "val5"); -// std::pair meta4( -// "key6-bin", -// {"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15}); -// -// cli_ctx.AddMetadata(meta1.first, meta1.second); -// cli_ctx.AddMetadata(meta2.first, meta2.second); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// auto client_initial_metadata = srv_ctx.client_metadata(); -// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); -// client_ok(1); -// -// srv_ctx.AddInitialMetadata(meta3.first, meta3.second); -// srv_ctx.AddInitialMetadata(meta4.first, meta4.second); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// response_reader->ReadInitialMetadata(tag(4)); -// client_ok(4); -// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); -// EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second); -// EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second); -// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); -// -// send_response.set_message(recv_request.message()); -// srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); -// srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); -// response_writer.Finish(send_response, Status::OK, tag(5)); -// -// server_ok(5); -// -// response_reader->Finish(&recv_response, &recv_status, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); -// EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); -// EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); -// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); -// } -} // namespace -} // namespace testing -} // namespace grpc - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - grpc_init(); - ::testing::InitGoogleTest(&argc, argv); - int result = RUN_ALL_TESTS(); - grpc_shutdown(); - google::protobuf::ShutdownProtobufLibrary(); - return result; -} diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc new file mode 100644 index 0000000000..0dd64007fd --- /dev/null +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -0,0 +1,563 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include "test/core/util/test_config.h" +#include "test/cpp/util/echo.pb.h" +#include "src/cpp/util/time.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "test/core/util/port.h" +#include + +#include +#include +#include + +using grpc::cpp::test::util::EchoRequest; +using grpc::cpp::test::util::EchoResponse; +using std::chrono::system_clock; + +namespace grpc { +namespace testing { +namespace { + +void* tag(int i) { return (void*)(gpr_intptr)i; } + +void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { + bool ok; + void* got_tag; + EXPECT_TRUE(cq->Next(&got_tag, &ok)); + EXPECT_EQ(expect_ok, ok); + EXPECT_EQ(tag(i), got_tag); +} + +class GenericEnd2endTest : public ::testing::Test { + protected: + GenericEnd2endTest() {} + + void SetUp() GRPC_OVERRIDE { + int port = grpc_pick_unused_port_or_die(); + server_address_ << "localhost:" << port; + // Setup server + ServerBuilder builder; + builder.AddPort(server_address_.str(), InsecureServerCredentials()); + builder.RegisterGenericService(&generic_service_); + server_ = builder.BuildAndStart(); + } + + void TearDown() GRPC_OVERRIDE { + server_->Shutdown(); + void* ignored_tag; + bool ignored_ok; + cli_cq_.Shutdown(); + srv_cq_.Shutdown(); + while (cli_cq_.Next(&ignored_tag, &ignored_ok)) + ; + while (srv_cq_.Next(&ignored_tag, &ignored_ok)) + ; + } + + void ResetStub() { + std::shared_ptr channel = + CreateChannel(server_address_.str(), InsecureCredentials(), ChannelArguments()); + stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); + } + + void server_ok(int i) { verify_ok(&srv_cq_, i, true); } + void client_ok(int i) { verify_ok(&cli_cq_, i, true); } + void server_fail(int i) { verify_ok(&srv_cq_, i, false); } + void client_fail(int i) { verify_ok(&cli_cq_, i, false); } + + void SendRpc(int num_rpcs) { + for (int i = 0; i < num_rpcs; i++) { + EchoRequest send_request; + EchoRequest recv_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + + ClientContext cli_ctx; + GenericServerContext srv_ctx; + GenericServerReaderWriter stream(&srv_ctx); + + send_request.set_message("Hello"); + std::unique_ptr > response_reader( + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); + client_ok(1); + + generic_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2)); + + verify_ok(server_->cq(), 2, true); + EXPECT_EQ(server_address_.str(), srv_ctx.host()); + EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method()); + ByteBuffer recv_buffer; + stream.Read(&recv_buffer, tag(3)); + server_ok(3); + std::vector slices; + recv_buffer.Dump(&slices); + EXPECT_EQ(1, slices.size()); // FIXME(yangg) handle real vector + grpc::string buf(reinterpret_cast(slices[0].begin()), + slices[0].size()); + EXPECT_TRUE(recv_request.ParseFromString(buf)); + EXPECT_EQ(send_request.message(), recv_request.message()); + + send_response.set_message(recv_request.message()); + buf.clear(); + send_response.SerializeToString(&buf); + gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); + Slice slice(s, Slice::STEAL_REF); + ByteBuffer send_buffer(&slice, 1); + stream.Write(send_buffer, tag(4)); + server_ok(4); + + stream.Finish(Status::OK, tag(5)); + server_ok(5); + + response_reader->Finish(&recv_response, &recv_status, tag(4)); + client_ok(4); + + EXPECT_EQ(send_response.message(), recv_response.message()); + EXPECT_TRUE(recv_status.IsOk()); + } + } + + CompletionQueue cli_cq_; + CompletionQueue srv_cq_; + std::unique_ptr stub_; + std::unique_ptr server_; + GenericService generic_service_; + std::ostringstream server_address_; +}; + +TEST_F(GenericEnd2endTest, SimpleRpc) { + ResetStub(); + SendRpc(1); +} + +TEST_F(GenericEnd2endTest, SequentialRpcs) { + ResetStub(); + SendRpc(10); +} + +// // Two pings and a final pong. +// TEST_F(GenericEnd2endTest, SimpleClientStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncReader srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > cli_stream( +// stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); +// +// service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); +// +// server_ok(2); +// client_ok(1); +// +// cli_stream->Write(send_request, tag(3)); +// client_ok(3); +// +// srv_stream.Read(&recv_request, tag(4)); +// server_ok(4); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// cli_stream->Write(send_request, tag(5)); +// client_ok(5); +// +// srv_stream.Read(&recv_request, tag(6)); +// server_ok(6); +// +// EXPECT_EQ(send_request.message(), recv_request.message()); +// cli_stream->WritesDone(tag(7)); +// client_ok(7); +// +// srv_stream.Read(&recv_request, tag(8)); +// server_fail(8); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Finish(send_response, Status::OK, tag(9)); +// server_ok(9); +// +// cli_stream->Finish(&recv_status, tag(10)); +// client_ok(10); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // One ping, two pongs. +// TEST_F(GenericEnd2endTest, SimpleServerStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncWriter srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > cli_stream( +// stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_, +// tag(2)); +// +// server_ok(2); +// client_ok(1); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Write(send_response, tag(3)); +// server_ok(3); +// +// cli_stream->Read(&recv_response, tag(4)); +// client_ok(4); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// srv_stream.Write(send_response, tag(5)); +// server_ok(5); +// +// cli_stream->Read(&recv_response, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// srv_stream.Finish(Status::OK, tag(7)); +// server_ok(7); +// +// cli_stream->Read(&recv_response, tag(8)); +// client_fail(8); +// +// cli_stream->Finish(&recv_status, tag(9)); +// client_ok(9); +// +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // One ping, one pong. +// TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// ServerAsyncReaderWriter srv_stream(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::unique_ptr > +// cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); +// +// service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); +// +// server_ok(2); +// client_ok(1); +// +// cli_stream->Write(send_request, tag(3)); +// client_ok(3); +// +// srv_stream.Read(&recv_request, tag(4)); +// server_ok(4); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// +// send_response.set_message(recv_request.message()); +// srv_stream.Write(send_response, tag(5)); +// server_ok(5); +// +// cli_stream->Read(&recv_response, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// +// cli_stream->WritesDone(tag(7)); +// client_ok(7); +// +// srv_stream.Read(&recv_request, tag(8)); +// server_fail(8); +// +// srv_stream.Finish(Status::OK, tag(9)); +// server_ok(9); +// +// cli_stream->Finish(&recv_status, tag(10)); +// client_ok(10); +// +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// // Metadata tests +// TEST_F(GenericEnd2endTest, ClientInitialMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// cli_ctx.AddMetadata(meta1.first, meta1.second); +// cli_ctx.AddMetadata(meta2.first, meta2.second); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// auto client_initial_metadata = srv_ctx.client_metadata(); +// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); +// client_ok(1); +// +// send_response.set_message(recv_request.message()); +// response_writer.Finish(send_response, Status::OK, tag(3)); +// +// server_ok(3); +// +// response_reader->Finish(&recv_response, &recv_status, tag(4)); +// client_ok(4); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// TEST_F(GenericEnd2endTest, ServerInitialMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// srv_ctx.AddInitialMetadata(meta1.first, meta1.second); +// srv_ctx.AddInitialMetadata(meta2.first, meta2.second); +// client_ok(1); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// +// response_reader->ReadInitialMetadata(tag(4)); +// client_ok(4); +// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); +// EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); +// +// send_response.set_message(recv_request.message()); +// response_writer.Finish(send_response, Status::OK, tag(5)); +// server_ok(5); +// +// response_reader->Finish(&recv_response, &recv_status, tag(6)); +// client_ok(6); +// +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// } +// +// TEST_F(GenericEnd2endTest, ServerTrailingMetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2("key2", "val2"); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// client_ok(1); +// +// send_response.set_message(recv_request.message()); +// srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); +// srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); +// response_writer.Finish(send_response, Status::OK, tag(4)); +// +// server_ok(4); +// +// response_reader->Finish(&recv_response, &recv_status, tag(5)); +// client_ok(5); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); +// EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); +// } +// +// TEST_F(GenericEnd2endTest, MetadataRpc) { +// ResetStub(); +// +// EchoRequest send_request; +// EchoRequest recv_request; +// EchoResponse send_response; +// EchoResponse recv_response; +// Status recv_status; +// +// ClientContext cli_ctx; +// ServerContext srv_ctx; +// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); +// +// send_request.set_message("Hello"); +// std::pair meta1("key1", "val1"); +// std::pair meta2( +// "key2-bin", {"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13}); +// std::pair meta3("key3", "val3"); +// std::pair meta6( +// "key4-bin", +// {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", 14}); +// std::pair meta5("key5", "val5"); +// std::pair meta4( +// "key6-bin", +// {"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15}); +// +// cli_ctx.AddMetadata(meta1.first, meta1.second); +// cli_ctx.AddMetadata(meta2.first, meta2.second); +// +// std::unique_ptr > response_reader( +// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); +// +// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, +// tag(2)); +// server_ok(2); +// EXPECT_EQ(send_request.message(), recv_request.message()); +// auto client_initial_metadata = srv_ctx.client_metadata(); +// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); +// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); +// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); +// client_ok(1); +// +// srv_ctx.AddInitialMetadata(meta3.first, meta3.second); +// srv_ctx.AddInitialMetadata(meta4.first, meta4.second); +// response_writer.SendInitialMetadata(tag(3)); +// server_ok(3); +// response_reader->ReadInitialMetadata(tag(4)); +// client_ok(4); +// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); +// EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second); +// EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second); +// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); +// +// send_response.set_message(recv_request.message()); +// srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); +// srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); +// response_writer.Finish(send_response, Status::OK, tag(5)); +// +// server_ok(5); +// +// response_reader->Finish(&recv_response, &recv_status, tag(6)); +// client_ok(6); +// EXPECT_EQ(send_response.message(), recv_response.message()); +// EXPECT_TRUE(recv_status.IsOk()); +// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); +// EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); +// EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); +// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); +// } +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + ::testing::InitGoogleTest(&argc, argv); + int result = RUN_ALL_TESTS(); + grpc_shutdown(); + google::protobuf::ShutdownProtobufLibrary(); + return result; +} diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 7d2d64f14a..355d5735cd 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -336,11 +336,6 @@ "language": "c", "name": "transport_security_test" }, - { - "flaky": false, - "language": "c++", - "name": "anonymous_end2end_test" - }, { "flaky": false, "language": "c++", @@ -361,6 +356,11 @@ "language": "c++", "name": "end2end_test" }, + { + "flaky": false, + "language": "c++", + "name": "generic_end2end_test" + }, { "flaky": false, "language": "c++", -- cgit v1.2.3 From 4999649653b9262d661eb833724ee28cefedb2bd Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Thu, 12 Mar 2015 16:40:19 -0700 Subject: Rename to AsyncGeneric* --- Makefile | 14 +++--- build.json | 4 +- include/grpc++/async_generic_service.h | 75 ++++++++++++++++++++++++++++++++ include/grpc++/generic_service.h | 75 -------------------------------- include/grpc++/generic_stub.h | 9 ++-- include/grpc++/server.h | 12 ++--- include/grpc++/server_builder.h | 6 +-- src/cpp/server/async_generic_service.cc | 47 ++++++++++++++++++++ src/cpp/server/generic_service.cc | 47 -------------------- src/cpp/server/server.cc | 10 ++--- src/cpp/server/server_builder.cc | 6 +-- test/cpp/end2end/generic_end2end_test.cc | 8 ++-- 12 files changed, 158 insertions(+), 155 deletions(-) create mode 100644 include/grpc++/async_generic_service.h delete mode 100644 include/grpc++/generic_service.h create mode 100644 src/cpp/server/async_generic_service.cc delete mode 100644 src/cpp/server/generic_service.cc (limited to 'test') diff --git a/Makefile b/Makefile index 853a8a3f4d..e6b2975057 100644 --- a/Makefile +++ b/Makefile @@ -3108,7 +3108,7 @@ LIBGRPC++_SRC = \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ - src/cpp/server/generic_service.cc \ + src/cpp/server/async_generic_service.cc \ src/cpp/server/insecure_server_credentials.cc \ src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ @@ -3121,6 +3121,7 @@ LIBGRPC++_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ + include/grpc++/async_generic_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/byte_buffer.h \ include/grpc++/channel_arguments.h \ @@ -3130,7 +3131,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/config.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ - include/grpc++/generic_service.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/internal_stub.h \ @@ -3195,7 +3195,7 @@ src/cpp/common/call.cc: $(OPENSSL_DEP) src/cpp/common/completion_queue.cc: $(OPENSSL_DEP) src/cpp/common/rpc_method.cc: $(OPENSSL_DEP) src/cpp/proto/proto_utils.cc: $(OPENSSL_DEP) -src/cpp/server/generic_service.cc: $(OPENSSL_DEP) +src/cpp/server/async_generic_service.cc: $(OPENSSL_DEP) src/cpp/server/insecure_server_credentials.cc: $(OPENSSL_DEP) src/cpp/server/server.cc: $(OPENSSL_DEP) src/cpp/server/server_builder.cc: $(OPENSSL_DEP) @@ -3261,7 +3261,7 @@ $(OBJDIR)/$(CONFIG)/src/cpp/common/call.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/completion_queue.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/rpc_method.o: $(OBJDIR)/$(CONFIG)/src/cpp/proto/proto_utils.o: -$(OBJDIR)/$(CONFIG)/src/cpp/server/generic_service.o: +$(OBJDIR)/$(CONFIG)/src/cpp/server/async_generic_service.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/insecure_server_credentials.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server_builder.o: @@ -3352,7 +3352,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/completion_queue.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ - src/cpp/server/generic_service.cc \ + src/cpp/server/async_generic_service.cc \ src/cpp/server/insecure_server_credentials.cc \ src/cpp/server/server.cc \ src/cpp/server/server_builder.cc \ @@ -3365,6 +3365,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/time.cc \ PUBLIC_HEADERS_CXX += \ + include/grpc++/async_generic_service.h \ include/grpc++/async_unary_call.h \ include/grpc++/byte_buffer.h \ include/grpc++/channel_arguments.h \ @@ -3374,7 +3375,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/config.h \ include/grpc++/create_channel.h \ include/grpc++/credentials.h \ - include/grpc++/generic_service.h \ include/grpc++/impl/call.h \ include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/internal_stub.h \ @@ -3454,7 +3454,7 @@ $(OBJDIR)/$(CONFIG)/src/cpp/common/call.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/completion_queue.o: $(OBJDIR)/$(CONFIG)/src/cpp/common/rpc_method.o: $(OBJDIR)/$(CONFIG)/src/cpp/proto/proto_utils.o: -$(OBJDIR)/$(CONFIG)/src/cpp/server/generic_service.o: +$(OBJDIR)/$(CONFIG)/src/cpp/server/async_generic_service.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/insecure_server_credentials.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server.o: $(OBJDIR)/$(CONFIG)/src/cpp/server/server_builder.o: diff --git a/build.json b/build.json index 4ec74b8bc8..999e140c5a 100644 --- a/build.json +++ b/build.json @@ -12,6 +12,7 @@ { "name": "grpc++_base", "public_headers": [ + "include/grpc++/async_generic_service.h", "include/grpc++/async_unary_call.h", "include/grpc++/byte_buffer.h", "include/grpc++/channel_arguments.h", @@ -21,7 +22,6 @@ "include/grpc++/config.h", "include/grpc++/create_channel.h", "include/grpc++/credentials.h", - "include/grpc++/generic_service.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/internal_stub.h", @@ -57,7 +57,7 @@ "src/cpp/common/completion_queue.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", - "src/cpp/server/generic_service.cc", + "src/cpp/server/async_generic_service.cc", "src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/server.cc", "src/cpp/server/server_builder.cc", diff --git a/include/grpc++/async_generic_service.h b/include/grpc++/async_generic_service.h new file mode 100644 index 0000000000..05fa76149e --- /dev/null +++ b/include/grpc++/async_generic_service.h @@ -0,0 +1,75 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_ASYNC_GENERIC_SERVICE_H +#define GRPCXX_ASYNC_GENERIC_SERVICE_H + +#include +#include + +struct grpc_server; + +namespace grpc { + +typedef ServerAsyncReaderWriter GenericServerAsyncReaderWriter; + +class GenericServerContext GRPC_FINAL : public ServerContext { + public: + const grpc::string& method() const { return method_; } + const grpc::string& host() const { return host_; } + + private: + friend class Server; + + grpc::string method_; + grpc::string host_; +}; + +class AsyncGenericService GRPC_FINAL { + public: + // TODO(yangg) Once we can add multiple completion queues to the server + // in c core, add a CompletionQueue* argument to the ctor here. + AsyncGenericService() : server_(nullptr) {} + + void RequestCall(GenericServerContext* ctx, + GenericServerAsyncReaderWriter* reader_writer, + CompletionQueue* cq, void* tag); + + private: + friend class Server; + Server* server_; +}; + +} // namespace grpc + +#endif // GRPCXX_ASYNC_GENERIC_SERVICE_H diff --git a/include/grpc++/generic_service.h b/include/grpc++/generic_service.h deleted file mode 100644 index 724982e944..0000000000 --- a/include/grpc++/generic_service.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPCXX_GENERIC_SERVICE_H -#define GRPCXX_GENERIC_SERVICE_H - -#include -#include - -struct grpc_server; - -namespace grpc { - -typedef ServerAsyncReaderWriter GenericServerReaderWriter; - -class GenericServerContext GRPC_FINAL : public ServerContext { - public: - const grpc::string& method() const { return method_; } - const grpc::string& host() const { return host_; } - - private: - friend class Server; - - grpc::string method_; - grpc::string host_; -}; - -class GenericService GRPC_FINAL { - public: - // TODO(yangg) Once we can add multiple completion queues to the server - // in c core, add a CompletionQueue* argument to the ctor here. - GenericService() : server_(nullptr) {} - - void RequestCall(GenericServerContext* ctx, - GenericServerReaderWriter* reader_writer, - CompletionQueue* cq, void* tag); - - private: - friend class Server; - Server* server_; -}; - -} // namespace grpc - -#endif // GRPCXX_GENERIC_SERVICE_H diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h index 92c4df1eb1..6038d7c66c 100644 --- a/include/grpc++/generic_stub.h +++ b/include/grpc++/generic_stub.h @@ -39,16 +39,19 @@ namespace grpc { -typedef ClientAsyncReaderWriter GenericClientReaderWriter; +typedef ClientAsyncReaderWriter + GenericClientAsyncReaderWriter; // Generic stubs provide a type-unsafe interface to call gRPC methods // by name. class GenericStub GRPC_FINAL { public: - explicit GenericStub(std::shared_ptr channel) : channel_(channel) {} + explicit GenericStub(std::shared_ptr channel) + : channel_(channel) {} // begin a call to a named method - std::unique_ptr Call(ClientContext* context, const grpc::string& method); + std::unique_ptr Call( + ClientContext* context, const grpc::string& method); private: std::shared_ptr channel_; diff --git a/include/grpc++/server.h b/include/grpc++/server.h index a330627747..e05bde7349 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -50,7 +50,7 @@ struct grpc_server; namespace grpc { class AsynchronousService; class GenericServerContext; -class GenericService; +class AsyncGenericService; class RpcService; class RpcServiceMethod; class ServerCredentials; @@ -73,7 +73,7 @@ class Server GRPC_FINAL : private CallHook, CompletionQueue* cq() { return &cq_; } private: - friend class GenericService; + friend class AsyncGenericService; friend class ServerBuilder; class SyncRequest; @@ -86,7 +86,7 @@ class Server GRPC_FINAL : private CallHook, // The service must exist for the lifetime of the Server instance. bool RegisterService(RpcService* service); bool RegisterAsyncService(AsynchronousService* service); - void RegisterGenericService(GenericService* service); + void RegisterAsyncGenericService(AsyncGenericService* service); // Add a listening port. Can be called multiple times. int AddPort(const grpc::string& addr, ServerCredentials* creds); // Start the server. @@ -104,9 +104,9 @@ class Server GRPC_FINAL : private CallHook, ServerAsyncStreamingInterface* stream, CompletionQueue* cq, void* tag) GRPC_OVERRIDE; - void RequestGenericCall(GenericServerContext* context, - ServerAsyncStreamingInterface* stream, - CompletionQueue* cq, void* tag); + void RequestAsyncGenericCall(GenericServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* cq, void* tag); // Completion queue. CompletionQueue cq_; diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index dbd9871d38..c09c8fee52 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -41,9 +41,9 @@ namespace grpc { +class AsyncGenericService; class AsynchronousService; class CompletionQueue; -class GenericService; class RpcService; class Server; class ServerCredentials; @@ -66,7 +66,7 @@ class ServerBuilder { void RegisterAsyncService(AsynchronousService* service); // Register a generic service. - void RegisterGenericService(GenericService* service); + void RegisterAsyncGenericService(AsyncGenericService* service); // Add a listening port. Can be called multiple times. void AddPort(const grpc::string& addr, @@ -91,7 +91,7 @@ class ServerBuilder { std::vector async_services_; std::vector ports_; std::shared_ptr creds_; - GenericService* generic_service_; + AsyncGenericService* generic_service_; ThreadPoolInterface* thread_pool_; }; diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc new file mode 100644 index 0000000000..67241fee7e --- /dev/null +++ b/src/cpp/server/async_generic_service.cc @@ -0,0 +1,47 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +namespace grpc { + +void AsyncGenericService::RequestCall( + GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, + CompletionQueue* cq, void* tag) { + server_->RequestAsyncGenericCall(ctx, reader_writer, cq, tag); +} + +} // namespace grpc + diff --git a/src/cpp/server/generic_service.cc b/src/cpp/server/generic_service.cc deleted file mode 100644 index 8ced775a67..0000000000 --- a/src/cpp/server/generic_service.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include - -namespace grpc { - -void GenericService::RequestCall(GenericServerContext* ctx, - GenericServerReaderWriter* reader_writer, - CompletionQueue* cq, void* tag) { - server_->RequestGenericCall(ctx, reader_writer, cq, tag); -} - -} // namespace grpc - diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index f72b8a30a6..cc632a7192 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -228,7 +228,7 @@ bool Server::RegisterAsyncService(AsynchronousService* service) { return true; } -void Server::RegisterGenericService(GenericService* service) { +void Server::RegisterAsyncGenericService(AsyncGenericService* service) { GPR_ASSERT(service->server_ == nullptr && "Can only register an generic service against one server."); service->server_ = this; @@ -395,9 +395,9 @@ void Server::RequestAsyncCall(void* registered_method, ServerContext* context, new AsyncRequest(this, registered_method, context, request, stream, cq, tag); } -void Server::RequestGenericCall(GenericServerContext* context, - ServerAsyncStreamingInterface* stream, - CompletionQueue* cq, void* tag) { +void Server::RequestAsyncGenericCall(GenericServerContext* context, + ServerAsyncStreamingInterface* stream, + CompletionQueue* cq, void* tag) { new AsyncRequest(this, context, stream, cq, tag); } diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 083509e797..835596d393 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -52,10 +52,10 @@ void ServerBuilder::RegisterAsyncService(AsynchronousService* service) { async_services_.push_back(service); } -void ServerBuilder::RegisterGenericService(GenericService* service) { +void ServerBuilder::RegisterAsyncGenericService(AsyncGenericService* service) { if (generic_service_) { gpr_log(GPR_ERROR, - "Adding multiple GenericService is unsupported for now. " + "Adding multiple AsyncGenericService is unsupported for now. " "Dropping the service %p", service); return; } @@ -96,7 +96,7 @@ std::unique_ptr ServerBuilder::BuildAndStart() { } } if (generic_service_) { - server->RegisterGenericService(generic_service_); + server->RegisterAsyncGenericService(generic_service_); } for (auto& port : ports_) { int r = server->AddPort(port.addr, port.creds.get()); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 0dd64007fd..b165eaeb8c 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -37,7 +37,7 @@ #include "test/core/util/test_config.h" #include "test/cpp/util/echo.pb.h" #include "src/cpp/util/time.h" -#include +#include #include #include #include @@ -87,7 +87,7 @@ class GenericEnd2endTest : public ::testing::Test { // Setup server ServerBuilder builder; builder.AddPort(server_address_.str(), InsecureServerCredentials()); - builder.RegisterGenericService(&generic_service_); + builder.RegisterAsyncGenericService(&generic_service_); server_ = builder.BuildAndStart(); } @@ -124,7 +124,7 @@ class GenericEnd2endTest : public ::testing::Test { ClientContext cli_ctx; GenericServerContext srv_ctx; - GenericServerReaderWriter stream(&srv_ctx); + GenericServerAsyncReaderWriter stream(&srv_ctx); send_request.set_message("Hello"); std::unique_ptr > response_reader( @@ -171,7 +171,7 @@ class GenericEnd2endTest : public ::testing::Test { CompletionQueue srv_cq_; std::unique_ptr stub_; std::unique_ptr server_; - GenericService generic_service_; + AsyncGenericService generic_service_; std::ostringstream server_address_; }; -- cgit v1.2.3 From 9fbbc7bb13716a78f584fab536efbc03631010e6 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 13 Mar 2015 15:33:08 -0700 Subject: add one bidi test --- test/cpp/end2end/generic_end2end_test.cc | 452 ++++++------------------------- 1 file changed, 80 insertions(+), 372 deletions(-) (limited to 'test') diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index b165eaeb8c..5ea2828db2 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -34,9 +34,11 @@ #include #include +#include "src/cpp/proto/proto_utils.h" +#include "src/cpp/util/time.h" +#include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/util/echo.pb.h" -#include "src/cpp/util/time.h" #include #include #include @@ -52,7 +54,6 @@ #include #include #include -#include "test/core/util/port.h" #include #include @@ -77,6 +78,17 @@ void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { EXPECT_EQ(tag(i), got_tag); } +bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) { + std::vector slices; + buffer->Dump(&slices); + grpc::string buf; + buf.reserve(buffer->Length()); + for (const Slice& s : slices) { + buf.append(reinterpret_cast(s.begin()), s.size()); + } + return message->ParseFromString(buf); +} + class GenericEnd2endTest : public ::testing::Test { protected: GenericEnd2endTest() {} @@ -139,16 +151,11 @@ class GenericEnd2endTest : public ::testing::Test { ByteBuffer recv_buffer; stream.Read(&recv_buffer, tag(3)); server_ok(3); - std::vector slices; - recv_buffer.Dump(&slices); - EXPECT_EQ(1, slices.size()); // FIXME(yangg) handle real vector - grpc::string buf(reinterpret_cast(slices[0].begin()), - slices[0].size()); - EXPECT_TRUE(recv_request.ParseFromString(buf)); + EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); EXPECT_EQ(send_request.message(), recv_request.message()); send_response.set_message(recv_request.message()); - buf.clear(); + grpc::string buf; send_response.SerializeToString(&buf); gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); Slice slice(s, Slice::STEAL_REF); @@ -185,369 +192,70 @@ TEST_F(GenericEnd2endTest, SequentialRpcs) { SendRpc(10); } -// // Two pings and a final pong. -// TEST_F(GenericEnd2endTest, SimpleClientStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncReader srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > cli_stream( -// stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); -// -// service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); -// -// server_ok(2); -// client_ok(1); -// -// cli_stream->Write(send_request, tag(3)); -// client_ok(3); -// -// srv_stream.Read(&recv_request, tag(4)); -// server_ok(4); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// cli_stream->Write(send_request, tag(5)); -// client_ok(5); -// -// srv_stream.Read(&recv_request, tag(6)); -// server_ok(6); -// -// EXPECT_EQ(send_request.message(), recv_request.message()); -// cli_stream->WritesDone(tag(7)); -// client_ok(7); -// -// srv_stream.Read(&recv_request, tag(8)); -// server_fail(8); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Finish(send_response, Status::OK, tag(9)); -// server_ok(9); -// -// cli_stream->Finish(&recv_status, tag(10)); -// client_ok(10); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // One ping, two pongs. -// TEST_F(GenericEnd2endTest, SimpleServerStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncWriter srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > cli_stream( -// stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_, -// tag(2)); -// -// server_ok(2); -// client_ok(1); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Write(send_response, tag(3)); -// server_ok(3); -// -// cli_stream->Read(&recv_response, tag(4)); -// client_ok(4); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// srv_stream.Write(send_response, tag(5)); -// server_ok(5); -// -// cli_stream->Read(&recv_response, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// srv_stream.Finish(Status::OK, tag(7)); -// server_ok(7); -// -// cli_stream->Read(&recv_response, tag(8)); -// client_fail(8); -// -// cli_stream->Finish(&recv_status, tag(9)); -// client_ok(9); -// -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // One ping, one pong. -// TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// ServerAsyncReaderWriter srv_stream(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::unique_ptr > -// cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); -// -// service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); -// -// server_ok(2); -// client_ok(1); -// -// cli_stream->Write(send_request, tag(3)); -// client_ok(3); -// -// srv_stream.Read(&recv_request, tag(4)); -// server_ok(4); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// -// send_response.set_message(recv_request.message()); -// srv_stream.Write(send_response, tag(5)); -// server_ok(5); -// -// cli_stream->Read(&recv_response, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// -// cli_stream->WritesDone(tag(7)); -// client_ok(7); -// -// srv_stream.Read(&recv_request, tag(8)); -// server_fail(8); -// -// srv_stream.Finish(Status::OK, tag(9)); -// server_ok(9); -// -// cli_stream->Finish(&recv_status, tag(10)); -// client_ok(10); -// -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// // Metadata tests -// TEST_F(GenericEnd2endTest, ClientInitialMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// cli_ctx.AddMetadata(meta1.first, meta1.second); -// cli_ctx.AddMetadata(meta2.first, meta2.second); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// auto client_initial_metadata = srv_ctx.client_metadata(); -// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); -// client_ok(1); -// -// send_response.set_message(recv_request.message()); -// response_writer.Finish(send_response, Status::OK, tag(3)); -// -// server_ok(3); -// -// response_reader->Finish(&recv_response, &recv_status, tag(4)); -// client_ok(4); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// TEST_F(GenericEnd2endTest, ServerInitialMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// srv_ctx.AddInitialMetadata(meta1.first, meta1.second); -// srv_ctx.AddInitialMetadata(meta2.first, meta2.second); -// client_ok(1); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// -// response_reader->ReadInitialMetadata(tag(4)); -// client_ok(4); -// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); -// EXPECT_EQ(meta1.second, server_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, server_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); -// -// send_response.set_message(recv_request.message()); -// response_writer.Finish(send_response, Status::OK, tag(5)); -// server_ok(5); -// -// response_reader->Finish(&recv_response, &recv_status, tag(6)); -// client_ok(6); -// -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// } -// -// TEST_F(GenericEnd2endTest, ServerTrailingMetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2("key2", "val2"); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// client_ok(1); -// -// send_response.set_message(recv_request.message()); -// srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); -// srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); -// response_writer.Finish(send_response, Status::OK, tag(4)); -// -// server_ok(4); -// -// response_reader->Finish(&recv_response, &recv_status, tag(5)); -// client_ok(5); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); -// EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); -// } -// -// TEST_F(GenericEnd2endTest, MetadataRpc) { -// ResetStub(); -// -// EchoRequest send_request; -// EchoRequest recv_request; -// EchoResponse send_response; -// EchoResponse recv_response; -// Status recv_status; -// -// ClientContext cli_ctx; -// ServerContext srv_ctx; -// grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); -// -// send_request.set_message("Hello"); -// std::pair meta1("key1", "val1"); -// std::pair meta2( -// "key2-bin", {"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13}); -// std::pair meta3("key3", "val3"); -// std::pair meta6( -// "key4-bin", -// {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", 14}); -// std::pair meta5("key5", "val5"); -// std::pair meta4( -// "key6-bin", -// {"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15}); -// -// cli_ctx.AddMetadata(meta1.first, meta1.second); -// cli_ctx.AddMetadata(meta2.first, meta2.second); -// -// std::unique_ptr > response_reader( -// stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); -// -// service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, -// tag(2)); -// server_ok(2); -// EXPECT_EQ(send_request.message(), recv_request.message()); -// auto client_initial_metadata = srv_ctx.client_metadata(); -// EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second); -// EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second); -// EXPECT_EQ(static_cast(2), client_initial_metadata.size()); -// client_ok(1); -// -// srv_ctx.AddInitialMetadata(meta3.first, meta3.second); -// srv_ctx.AddInitialMetadata(meta4.first, meta4.second); -// response_writer.SendInitialMetadata(tag(3)); -// server_ok(3); -// response_reader->ReadInitialMetadata(tag(4)); -// client_ok(4); -// auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); -// EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second); -// EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second); -// EXPECT_EQ(static_cast(2), server_initial_metadata.size()); -// -// send_response.set_message(recv_request.message()); -// srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); -// srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); -// response_writer.Finish(send_response, Status::OK, tag(5)); -// -// server_ok(5); -// -// response_reader->Finish(&recv_response, &recv_status, tag(6)); -// client_ok(6); -// EXPECT_EQ(send_response.message(), recv_response.message()); -// EXPECT_TRUE(recv_status.IsOk()); -// auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); -// EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); -// EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); -// EXPECT_EQ(static_cast(2), server_trailing_metadata.size()); -// } +// One ping, one pong. +TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { + ResetStub(); + + EchoRequest send_request; + EchoRequest recv_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + ClientContext cli_ctx; + GenericServerContext srv_ctx; + GenericServerAsyncReaderWriter srv_stream(&srv_ctx); + + send_request.set_message("Hello"); + std::unique_ptr > + cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); + client_ok(1); + + generic_service_.RequestCall(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); + + verify_ok(server_->cq(), 2, true); + EXPECT_EQ(server_address_.str(), srv_ctx.host()); + EXPECT_EQ("/grpc.cpp.test.util.TestService/BidiStream", srv_ctx.method()); + + cli_stream->Write(send_request, tag(3)); + client_ok(3); + + ByteBuffer recv_buffer; + srv_stream.Read(&recv_buffer, tag(3)); + server_ok(3); + EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); + EXPECT_EQ(send_request.message(), recv_request.message()); + + send_response.set_message(recv_request.message()); + grpc::string buf; + send_response.SerializeToString(&buf); + gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); + Slice slice(s, Slice::STEAL_REF); + ByteBuffer send_buffer(&slice, 1); + srv_stream.Write(send_buffer, tag(4)); + server_ok(4); + + cli_stream->Read(&recv_response, tag(6)); + client_ok(6); + EXPECT_EQ(send_response.message(), recv_response.message()); + + + cli_stream->WritesDone(tag(7)); + client_ok(7); + + recv_buffer.Clear(); + srv_stream.Read(&recv_buffer, tag(3)); + server_fail(3); + + srv_stream.Finish(Status::OK, tag(5)); + server_ok(5); + + cli_stream->Finish(&recv_status, tag(10)); + client_ok(10); + + EXPECT_EQ(send_response.message(), recv_response.message()); + EXPECT_TRUE(recv_status.IsOk()); +} + } // namespace } // namespace testing } // namespace grpc -- cgit v1.2.3 From 45c09db87c7d57b97112a1118054c2e07bfad45a Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Fri, 13 Mar 2015 15:49:35 -0700 Subject: sort the tags, this is not necessary, just make it look better --- test/cpp/end2end/generic_end2end_test.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 5ea2828db2..102f1c758b 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -220,8 +220,8 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { client_ok(3); ByteBuffer recv_buffer; - srv_stream.Read(&recv_buffer, tag(3)); - server_ok(3); + srv_stream.Read(&recv_buffer, tag(4)); + server_ok(4); EXPECT_TRUE(ParseFromByteBuffer(&recv_buffer, &recv_request)); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -231,8 +231,8 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); Slice slice(s, Slice::STEAL_REF); ByteBuffer send_buffer(&slice, 1); - srv_stream.Write(send_buffer, tag(4)); - server_ok(4); + srv_stream.Write(send_buffer, tag(5)); + server_ok(5); cli_stream->Read(&recv_response, tag(6)); client_ok(6); @@ -243,11 +243,11 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { client_ok(7); recv_buffer.Clear(); - srv_stream.Read(&recv_buffer, tag(3)); - server_fail(3); + srv_stream.Read(&recv_buffer, tag(8)); + server_fail(8); - srv_stream.Finish(Status::OK, tag(5)); - server_ok(5); + srv_stream.Finish(Status::OK, tag(9)); + server_ok(9); cli_stream->Finish(&recv_status, tag(10)); client_ok(10); -- cgit v1.2.3 From 1ad253d137c45839c40ba896506ccaa7c42643e7 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Mon, 16 Mar 2015 13:11:29 -0700 Subject: expose the server's cq through the generic service object --- include/grpc++/async_generic_service.h | 6 +++++- include/grpc++/server.h | 2 -- src/cpp/server/async_generic_service.cc | 4 ++++ src/cpp/server/server.cc | 4 ++-- test/cpp/end2end/generic_end2end_test.cc | 6 +++--- 5 files changed, 14 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/include/grpc++/async_generic_service.h b/include/grpc++/async_generic_service.h index 05fa76149e..d10a56c7f7 100644 --- a/include/grpc++/async_generic_service.h +++ b/include/grpc++/async_generic_service.h @@ -59,12 +59,16 @@ class AsyncGenericService GRPC_FINAL { public: // TODO(yangg) Once we can add multiple completion queues to the server // in c core, add a CompletionQueue* argument to the ctor here. - AsyncGenericService() : server_(nullptr) {} + // TODO(yangg) support methods list. + AsyncGenericService(const grpc::string& methods) : server_(nullptr) {} void RequestCall(GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, CompletionQueue* cq, void* tag); + // The new rpc event should be obtained from this completion queue. + CompletionQueue* completion_queue(); + private: friend class Server; Server* server_; diff --git a/include/grpc++/server.h b/include/grpc++/server.h index e05bde7349..8cd0a4f668 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -70,8 +70,6 @@ class Server GRPC_FINAL : private CallHook, // function to ever return) void Wait(); - CompletionQueue* cq() { return &cq_; } - private: friend class AsyncGenericService; friend class ServerBuilder; diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc index 67241fee7e..2009af7cbd 100644 --- a/src/cpp/server/async_generic_service.cc +++ b/src/cpp/server/async_generic_service.cc @@ -43,5 +43,9 @@ void AsyncGenericService::RequestCall( server_->RequestAsyncGenericCall(ctx, reader_writer, cq, tag); } +CompletionQueue* AsyncGenericService::completion_queue() { + return &server_->cq_; +} + } // namespace grpc diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index ac350df62d..4d5e77e633 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -211,7 +211,7 @@ bool Server::RegisterService(RpcService* service) { bool Server::RegisterAsyncService(AsynchronousService* service) { GPR_ASSERT(service->dispatch_impl_ == nullptr && - "Can only register one asynchronous service against one server."); + "Can only register an asynchronous service against one server."); service->dispatch_impl_ = this; service->request_args_ = new void* [service->method_count_]; for (size_t i = 0; i < service->method_count_; ++i) { @@ -230,7 +230,7 @@ bool Server::RegisterAsyncService(AsynchronousService* service) { void Server::RegisterAsyncGenericService(AsyncGenericService* service) { GPR_ASSERT(service->server_ == nullptr && - "Can only register one generic service against one server."); + "Can only register an async generic service against one server."); service->server_ = this; } diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 102f1c758b..4a0d2c5c01 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -91,7 +91,7 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) { class GenericEnd2endTest : public ::testing::Test { protected: - GenericEnd2endTest() {} + GenericEnd2endTest() : generic_service_("*") {} void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); @@ -145,7 +145,7 @@ class GenericEnd2endTest : public ::testing::Test { generic_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2)); - verify_ok(server_->cq(), 2, true); + verify_ok(generic_service_.completion_queue(), 2, true); EXPECT_EQ(server_address_.str(), srv_ctx.host()); EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method()); ByteBuffer recv_buffer; @@ -212,7 +212,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { generic_service_.RequestCall(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); - verify_ok(server_->cq(), 2, true); + verify_ok(generic_service_.completion_queue(), 2, true); EXPECT_EQ(server_address_.str(), srv_ctx.host()); EXPECT_EQ("/grpc.cpp.test.util.TestService/BidiStream", srv_ctx.method()); -- cgit v1.2.3 From 7aadf46fdb05b5f595440c41998023e69e1700e5 Mon Sep 17 00:00:00 2001 From: vjpai Date: Mon, 16 Mar 2015 23:58:44 -0700 Subject: Change to std::chrono and add a test. --- include/grpc++/completion_queue.h | 9 ++++-- src/cpp/common/completion_queue.cc | 9 ++++-- test/cpp/end2end/async_end2end_test.cc | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 4181911b58..d742d85ef7 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_COMPLETION_QUEUE_H #define GRPCXX_COMPLETION_QUEUE_H -#include +#include #include struct grpc_completion_queue; @@ -81,12 +81,15 @@ class CompletionQueue { // Nonblocking (until deadline) read from queue. // Cannot rely on result of tag or ok if return is TIMEOUT - NextStatus AsyncNext(void **tag, bool *ok, gpr_timespec deadline); + NextStatus AsyncNext(void **tag, bool *ok, + std::chrono::system_clock::time_point deadline); // Blocking (until deadline) read from queue. // Returns false if the queue is ready for destruction, true if event bool Next(void **tag, bool *ok) { - return (AsyncNext(tag,ok,gpr_inf_future) != SHUTDOWN); + return (AsyncNext(tag,ok, + std::chrono::system_clock::time_point::max()) != + SHUTDOWN); } // Shutdown has to be called, and the CompletionQueue can only be diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc index 2913298afe..fede2da016 100644 --- a/src/cpp/common/completion_queue.cc +++ b/src/cpp/common/completion_queue.cc @@ -57,12 +57,15 @@ class EventDeleter { } }; -CompletionQueue::NextStatus CompletionQueue::AsyncNext(void** tag, bool* ok, - gpr_timespec deadline) { +CompletionQueue::NextStatus +CompletionQueue::AsyncNext(void** tag, bool* ok, + std::chrono::system_clock::time_point deadline) { std::unique_ptr ev; + gpr_timespec gpr_deadline; + Timepoint2Timespec(deadline, &gpr_deadline); for (;;) { - ev.reset(grpc_completion_queue_next(cq_, deadline)); + ev.reset(grpc_completion_queue_next(cq_, gpr_deadline)); if (!ev) { /* got a NULL back because deadline passed */ return TIMEOUT; } diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 70df9e14b2..e011b788ff 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -76,6 +76,20 @@ void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { EXPECT_EQ(tag(i), got_tag); } +void verify_timed_ok(CompletionQueue* cq, int i, bool expect_ok, + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::time_point::max(), + CompletionQueue::NextStatus expected_outcome = + CompletionQueue::GOT_EVENT) { + bool ok; + void* got_tag; + EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome); + if (expected_outcome == CompletionQueue::GOT_EVENT) { + EXPECT_EQ(expect_ok, ok); + EXPECT_EQ(tag(i), got_tag); + } +} + class AsyncEnd2endTest : public ::testing::Test { protected: AsyncEnd2endTest() : service_(&srv_cq_) {} @@ -166,6 +180,50 @@ TEST_F(AsyncEnd2endTest, SequentialRpcs) { SendRpc(10); } +// Test a simple RPC using the async version of Next +TEST_F(AsyncEnd2endTest, AsyncNextRpc) { + ResetStub(); + + EchoRequest send_request; + EchoRequest recv_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + + ClientContext cli_ctx; + ServerContext srv_ctx; + grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); + + send_request.set_message("Hello"); + std::unique_ptr > + response_reader(stub_->AsyncEcho(&cli_ctx, send_request, + &cli_cq_, tag(1))); + + std::chrono::system_clock::time_point + time_now(std::chrono::system_clock::now()), + time_limit(std::chrono::system_clock::now()+std::chrono::seconds(5)); + verify_timed_ok(&srv_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); + verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); + + service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, + tag(2)); + + verify_timed_ok(&srv_cq_, 2, true, time_limit); + EXPECT_EQ(send_request.message(), recv_request.message()); + verify_timed_ok(&cli_cq_, 1, true, time_limit); + + send_response.set_message(recv_request.message()); + response_writer.Finish(send_response, Status::OK, tag(3)); + verify_timed_ok(&srv_cq_, 3, true); + + response_reader->Finish(&recv_response, &recv_status, tag(4)); + verify_timed_ok(&cli_cq_, 4, true); + + EXPECT_EQ(send_response.message(), recv_response.message()); + EXPECT_TRUE(recv_status.IsOk()); + +} + // Two pings and a final pong. TEST_F(AsyncEnd2endTest, SimpleClientStreaming) { ResetStub(); -- cgit v1.2.3 From 6baa9b67ada4f0abadd27a830778463f3e8aabd3 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Tue, 17 Mar 2015 10:49:39 -0700 Subject: clang-format c++ code --- include/grpc++/async_generic_service.h | 5 +- include/grpc++/async_unary_call.h | 7 ++- include/grpc++/byte_buffer.h | 4 +- include/grpc++/channel_interface.h | 4 +- include/grpc++/client_context.h | 30 +++++------ include/grpc++/completion_queue.h | 24 ++++----- include/grpc++/config.h | 7 +-- include/grpc++/credentials.h | 4 +- include/grpc++/generic_stub.h | 2 +- include/grpc++/impl/call.h | 72 +++++++++++++-------------- include/grpc++/impl/client_unary_call.h | 8 +-- src/cpp/client/channel.h | 10 ++-- src/cpp/client/channel_arguments.cc | 18 +++---- src/cpp/client/client_context.cc | 8 +-- src/cpp/client/client_unary_call.cc | 8 +-- src/cpp/client/create_channel.cc | 9 ++-- src/cpp/client/secure_credentials.cc | 5 +- src/cpp/proto/proto_utils.cc | 22 ++++---- src/cpp/proto/proto_utils.h | 6 +-- src/cpp/server/async_generic_service.cc | 3 +- src/cpp/server/async_server_context.cc | 16 +++--- src/cpp/server/insecure_server_credentials.cc | 3 +- src/cpp/server/secure_server_credentials.cc | 12 +++-- src/cpp/server/server.cc | 5 +- src/cpp/server/server_builder.cc | 3 +- src/cpp/server/thread_pool.cc | 4 +- src/cpp/server/thread_pool.h | 2 +- src/cpp/util/slice.cc | 4 +- src/cpp/util/status.cc | 4 +- src/cpp/util/time.cc | 4 +- src/cpp/util/time.h | 4 +- test/cpp/client/credentials_test.cc | 2 +- test/cpp/end2end/async_end2end_test.cc | 2 +- test/cpp/end2end/generic_end2end_test.cc | 9 ++-- test/cpp/interop/client.cc | 3 +- test/cpp/interop/interop_test.cc | 16 +++--- test/cpp/qps/client_async.cc | 52 +++++++++---------- test/cpp/qps/qps_driver.cc | 2 +- test/cpp/qps/server.cc | 4 +- test/cpp/qps/server_async.cc | 44 ++++++++-------- test/cpp/util/create_test_channel.cc | 3 +- test/cpp/util/status_test.cc | 2 +- 42 files changed, 224 insertions(+), 232 deletions(-) (limited to 'test') diff --git a/include/grpc++/async_generic_service.h b/include/grpc++/async_generic_service.h index d10a56c7f7..911d31cb1f 100644 --- a/include/grpc++/async_generic_service.h +++ b/include/grpc++/async_generic_service.h @@ -41,7 +41,8 @@ struct grpc_server; namespace grpc { -typedef ServerAsyncReaderWriter GenericServerAsyncReaderWriter; +typedef ServerAsyncReaderWriter + GenericServerAsyncReaderWriter; class GenericServerContext GRPC_FINAL : public ServerContext { public: @@ -74,6 +75,6 @@ class AsyncGenericService GRPC_FINAL { Server* server_; }; -} // namespace grpc +} // namespace grpc #endif // GRPCXX_ASYNC_GENERIC_SERVICE_H diff --git a/include/grpc++/async_unary_call.h b/include/grpc++/async_unary_call.h index 658941bb6d..d1d5be5b50 100644 --- a/include/grpc++/async_unary_call.h +++ b/include/grpc++/async_unary_call.h @@ -48,10 +48,9 @@ template class ClientAsyncResponseReader GRPC_FINAL { public: ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - const grpc::protobuf::Message& request, void* tag) - : context_(context), - call_(channel->CreateCall(method, context, cq)) { + const RpcMethod& method, ClientContext* context, + const grpc::protobuf::Message& request, void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { init_buf_.Reset(tag); init_buf_.AddSendInitialMetadata(&context->send_initial_metadata_); init_buf_.AddSendMessage(request); diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h index e864ca3bba..ceb62622fd 100644 --- a/include/grpc++/byte_buffer.h +++ b/include/grpc++/byte_buffer.h @@ -72,9 +72,7 @@ class ByteBuffer GRPC_FINAL { buffer_ = buf; } - grpc_byte_buffer* buffer() const { - return buffer_; - } + grpc_byte_buffer* buffer() const { return buffer_; } grpc_byte_buffer* buffer_; }; diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel_interface.h index 51260aed3d..7d50b45280 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel_interface.h @@ -51,8 +51,8 @@ class ChannelInterface : public CallHook { public: virtual ~ChannelInterface() {} - virtual Call CreateCall(const RpcMethod &method, ClientContext *context, - CompletionQueue *cq) = 0; + virtual Call CreateCall(const RpcMethod& method, ClientContext* context, + CompletionQueue* cq) = 0; }; } // namespace grpc diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index c55d7c2d58..4e7f5a7be0 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -74,8 +74,8 @@ class ClientContext { ClientContext(); ~ClientContext(); - void AddMetadata(const grpc::string &meta_key, - const grpc::string &meta_value); + void AddMetadata(const grpc::string& meta_key, + const grpc::string& meta_value); const std::multimap& GetServerInitialMetadata() { GPR_ASSERT(initial_metadata_received_); @@ -87,19 +87,17 @@ class ClientContext { return trailing_metadata_; } - void set_absolute_deadline(const system_clock::time_point &deadline); + void set_absolute_deadline(const system_clock::time_point& deadline); system_clock::time_point absolute_deadline(); - void set_authority(const grpc::string& authority) { - authority_ = authority; - } + void set_authority(const grpc::string& authority) { authority_ = authority; } void TryCancel(); private: // Disallow copy and assign. - ClientContext(const ClientContext &); - ClientContext &operator=(const ClientContext &); + ClientContext(const ClientContext&); + ClientContext& operator=(const ClientContext&); friend class CallOpBuffer; friend class Channel; @@ -118,24 +116,22 @@ class ClientContext { template friend class ::grpc::ClientAsyncResponseReader; - grpc_call *call() { return call_; } - void set_call(grpc_call *call) { + grpc_call* call() { return call_; } + void set_call(grpc_call* call) { GPR_ASSERT(call_ == nullptr); call_ = call; } - grpc_completion_queue *cq() { return cq_; } - void set_cq(grpc_completion_queue *cq) { cq_ = cq; } + grpc_completion_queue* cq() { return cq_; } + void set_cq(grpc_completion_queue* cq) { cq_ = cq; } gpr_timespec RawDeadline() { return absolute_deadline_; } - grpc::string authority() { - return authority_; - } + grpc::string authority() { return authority_; } bool initial_metadata_received_; - grpc_call *call_; - grpc_completion_queue *cq_; + grpc_call* call_; + grpc_completion_queue* cq_; gpr_timespec absolute_deadline_; grpc::string authority_; std::multimap send_initial_metadata_; diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index f741e3c36b..1caaa8d6cf 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -65,26 +65,26 @@ class CompletionQueueTag { // to do) // If this function returns false, the tag is dropped and not returned // from the completion queue - virtual bool FinalizeResult(void **tag, bool *status) = 0; + virtual bool FinalizeResult(void** tag, bool* status) = 0; }; // grpc_completion_queue wrapper class class CompletionQueue { public: CompletionQueue(); - explicit CompletionQueue(grpc_completion_queue *take); + explicit CompletionQueue(grpc_completion_queue* take); ~CompletionQueue(); // Blocking read from queue. // Returns true if an event was received, false if the queue is ready // for destruction. - bool Next(void **tag, bool *ok); + bool Next(void** tag, bool* ok); // Shutdown has to be called, and the CompletionQueue can only be // destructed when false is returned from Next(). void Shutdown(); - grpc_completion_queue *cq() { return cq_; } + grpc_completion_queue* cq() { return cq_; } private: // Friend synchronous wrappers so that they can access Pluck(), which is @@ -103,20 +103,20 @@ class CompletionQueue { friend class ::grpc::ServerReaderWriter; friend class ::grpc::Server; friend class ::grpc::ServerContext; - friend Status BlockingUnaryCall(ChannelInterface *channel, - const RpcMethod &method, - ClientContext *context, - const grpc::protobuf::Message &request, - grpc::protobuf::Message *result); + friend Status BlockingUnaryCall(ChannelInterface* channel, + const RpcMethod& method, + ClientContext* context, + const grpc::protobuf::Message& request, + grpc::protobuf::Message* result); // Wraps grpc_completion_queue_pluck. // Cannot be mixed with calls to Next(). - bool Pluck(CompletionQueueTag *tag); + bool Pluck(CompletionQueueTag* tag); // Does a single polling pluck on tag - void TryPluck(CompletionQueueTag *tag); + void TryPluck(CompletionQueueTag* tag); - grpc_completion_queue *cq_; // owned + grpc_completion_queue* cq_; // owned }; } // namespace grpc diff --git a/include/grpc++/config.h b/include/grpc++/config.h index 0267b85215..35bf507364 100644 --- a/include/grpc++/config.h +++ b/include/grpc++/config.h @@ -59,11 +59,12 @@ #ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM #include -#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ::google::protobuf::io::ZeroCopyOutputStream -#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ::google::protobuf::io::ZeroCopyInputStream +#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ + ::google::protobuf::io::ZeroCopyOutputStream +#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ + ::google::protobuf::io::ZeroCopyInputStream #endif - namespace grpc { typedef GRPC_CUSTOM_STRING string; diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index 59ad638f47..c3f48592cc 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -50,8 +50,8 @@ class Credentials { protected: friend std::unique_ptr CompositeCredentials( - const std::unique_ptr& creds1, - const std::unique_ptr& creds2); + const std::unique_ptr& creds1, + const std::unique_ptr& creds2); virtual SecureCredentials* AsSecureCredentials() = 0; diff --git a/include/grpc++/generic_stub.h b/include/grpc++/generic_stub.h index 6038d7c66c..d4c8380ad4 100644 --- a/include/grpc++/generic_stub.h +++ b/include/grpc++/generic_stub.h @@ -57,6 +57,6 @@ class GenericStub GRPC_FINAL { std::shared_ptr channel_; }; -} // namespace grpc +} // namespace grpc #endif // GRPCXX_GENERIC_STUB_H diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index a8551ad459..e117ac6313 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -55,89 +55,89 @@ class CallOpBuffer : public CompletionQueueTag { CallOpBuffer(); ~CallOpBuffer(); - void Reset(void *next_return_tag); + void Reset(void* next_return_tag); // Does not take ownership. void AddSendInitialMetadata( - std::multimap *metadata); - void AddSendInitialMetadata(ClientContext *ctx); - void AddRecvInitialMetadata(ClientContext *ctx); - void AddSendMessage(const grpc::protobuf::Message &message); + std::multimap* metadata); + void AddSendInitialMetadata(ClientContext* ctx); + void AddRecvInitialMetadata(ClientContext* ctx); + void AddSendMessage(const grpc::protobuf::Message& message); void AddSendMessage(const ByteBuffer& message); - void AddRecvMessage(grpc::protobuf::Message *message); - void AddRecvMessage(ByteBuffer *message); + void AddRecvMessage(grpc::protobuf::Message* message); + void AddRecvMessage(ByteBuffer* message); void AddClientSendClose(); - void AddClientRecvStatus(ClientContext *ctx, Status *status); - void AddServerSendStatus(std::multimap *metadata, - const Status &status); - void AddServerRecvClose(bool *cancelled); + void AddClientRecvStatus(ClientContext* ctx, Status* status); + void AddServerSendStatus(std::multimap* metadata, + const Status& status); + void AddServerRecvClose(bool* cancelled); // INTERNAL API: // Convert to an array of grpc_op elements - void FillOps(grpc_op *ops, size_t *nops); + void FillOps(grpc_op* ops, size_t* nops); // Called by completion queue just prior to returning from Next() or Pluck() - bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE; + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool got_message; private: - void *return_tag_; + void* return_tag_; // Send initial metadata bool send_initial_metadata_; size_t initial_metadata_count_; - grpc_metadata *initial_metadata_; + grpc_metadata* initial_metadata_; // Recv initial metadta - std::multimap *recv_initial_metadata_; + std::multimap* recv_initial_metadata_; grpc_metadata_array recv_initial_metadata_arr_; // Send message - const grpc::protobuf::Message *send_message_; - const ByteBuffer *send_message_buffer_; - grpc_byte_buffer *send_buf_; + const grpc::protobuf::Message* send_message_; + const ByteBuffer* send_message_buffer_; + grpc_byte_buffer* send_buf_; // Recv message - grpc::protobuf::Message *recv_message_; - ByteBuffer *recv_message_buffer_; - grpc_byte_buffer *recv_buf_; + grpc::protobuf::Message* recv_message_; + ByteBuffer* recv_message_buffer_; + grpc_byte_buffer* recv_buf_; // Client send close bool client_send_close_; // Client recv status - std::multimap *recv_trailing_metadata_; - Status *recv_status_; + std::multimap* recv_trailing_metadata_; + Status* recv_status_; grpc_metadata_array recv_trailing_metadata_arr_; grpc_status_code status_code_; - char *status_details_; + char* status_details_; size_t status_details_capacity_; // Server send status - const Status *send_status_; + const Status* send_status_; size_t trailing_metadata_count_; - grpc_metadata *trailing_metadata_; + grpc_metadata* trailing_metadata_; int cancelled_buf_; - bool *recv_closed_; + bool* recv_closed_; }; // Channel and Server implement this to allow them to hook performing ops class CallHook { public: virtual ~CallHook() {} - virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) = 0; + virtual void PerformOpsOnCall(CallOpBuffer* ops, Call* call) = 0; }; // Straightforward wrapping of the C call object class Call GRPC_FINAL { public: /* call is owned by the caller */ - Call(grpc_call *call, CallHook *call_hook_, CompletionQueue *cq); + Call(grpc_call* call, CallHook* call_hook_, CompletionQueue* cq); - void PerformOps(CallOpBuffer *buffer); + void PerformOps(CallOpBuffer* buffer); - grpc_call *call() { return call_; } - CompletionQueue *cq() { return cq_; } + grpc_call* call() { return call_; } + CompletionQueue* cq() { return cq_; } private: - CallHook *call_hook_; - CompletionQueue *cq_; - grpc_call *call_; + CallHook* call_hook_; + CompletionQueue* cq_; + grpc_call* call_; }; } // namespace grpc diff --git a/include/grpc++/impl/client_unary_call.h b/include/grpc++/impl/client_unary_call.h index fd9715da50..0e8aeed781 100644 --- a/include/grpc++/impl/client_unary_call.h +++ b/include/grpc++/impl/client_unary_call.h @@ -45,10 +45,10 @@ class RpcMethod; class Status; // Wrapper that performs a blocking unary call -Status BlockingUnaryCall(ChannelInterface *channel, const RpcMethod &method, - ClientContext *context, - const grpc::protobuf::Message &request, - grpc::protobuf::Message *result); +Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, + ClientContext* context, + const grpc::protobuf::Message& request, + grpc::protobuf::Message* result); } // namespace grpc diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h index a1de3817e6..3980eba237 100644 --- a/src/cpp/client/channel.h +++ b/src/cpp/client/channel.h @@ -51,16 +51,16 @@ class StreamContextInterface; class Channel GRPC_FINAL : public ChannelInterface { public: - Channel(const grpc::string &target, grpc_channel *c_channel); + Channel(const grpc::string& target, grpc_channel* c_channel); ~Channel() GRPC_OVERRIDE; - virtual Call CreateCall(const RpcMethod &method, ClientContext *context, - CompletionQueue *cq) GRPC_OVERRIDE; - virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) GRPC_OVERRIDE; + virtual Call CreateCall(const RpcMethod& method, ClientContext* context, + CompletionQueue* cq) GRPC_OVERRIDE; + virtual void PerformOpsOnCall(CallOpBuffer* ops, Call* call) GRPC_OVERRIDE; private: const grpc::string target_; - grpc_channel *const c_channel_; // owned + grpc_channel* const c_channel_; // owned }; } // namespace grpc diff --git a/src/cpp/client/channel_arguments.cc b/src/cpp/client/channel_arguments.cc index abf0fc1c0a..87f8349eef 100644 --- a/src/cpp/client/channel_arguments.cc +++ b/src/cpp/client/channel_arguments.cc @@ -37,7 +37,7 @@ namespace grpc { -void ChannelArguments::SetSslTargetNameOverride(const grpc::string &name) { +void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) { SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name); } @@ -50,32 +50,32 @@ grpc::string ChannelArguments::GetSslTargetNameOverride() const { return ""; } -void ChannelArguments::SetInt(const grpc::string &key, int value) { +void ChannelArguments::SetInt(const grpc::string& key, int value) { grpc_arg arg; arg.type = GRPC_ARG_INTEGER; strings_.push_back(key); - arg.key = const_cast(strings_.back().c_str()); + arg.key = const_cast(strings_.back().c_str()); arg.value.integer = value; args_.push_back(arg); } -void ChannelArguments::SetString(const grpc::string &key, - const grpc::string &value) { +void ChannelArguments::SetString(const grpc::string& key, + const grpc::string& value) { grpc_arg arg; arg.type = GRPC_ARG_STRING; strings_.push_back(key); - arg.key = const_cast(strings_.back().c_str()); + arg.key = const_cast(strings_.back().c_str()); strings_.push_back(value); - arg.value.string = const_cast(strings_.back().c_str()); + arg.value.string = const_cast(strings_.back().c_str()); args_.push_back(arg); } -void ChannelArguments::SetChannelArgs(grpc_channel_args *channel_args) const { +void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { channel_args->num_args = args_.size(); if (channel_args->num_args > 0) { - channel_args->args = const_cast(&args_[0]); + channel_args->args = const_cast(&args_[0]); } } diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 9f99f7bcd5..de9f8c7201 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -53,7 +53,7 @@ ClientContext::~ClientContext() { if (cq_) { grpc_completion_queue_shutdown(cq_); // Drain cq_. - grpc_event *ev; + grpc_event* ev; grpc_completion_type t; do { ev = grpc_completion_queue_next(cq_, gpr_inf_future); @@ -65,7 +65,7 @@ ClientContext::~ClientContext() { } void ClientContext::set_absolute_deadline( - const system_clock::time_point &deadline) { + const system_clock::time_point& deadline) { Timepoint2Timespec(deadline, &absolute_deadline_); } @@ -73,8 +73,8 @@ system_clock::time_point ClientContext::absolute_deadline() { return Timespec2Timepoint(absolute_deadline_); } -void ClientContext::AddMetadata(const grpc::string &meta_key, - const grpc::string &meta_value) { +void ClientContext::AddMetadata(const grpc::string& meta_key, + const grpc::string& meta_value) { send_initial_metadata_.insert(std::make_pair(meta_key, meta_value)); } diff --git a/src/cpp/client/client_unary_call.cc b/src/cpp/client/client_unary_call.cc index 5c179de9d8..7e7ea78bcd 100644 --- a/src/cpp/client/client_unary_call.cc +++ b/src/cpp/client/client_unary_call.cc @@ -42,10 +42,10 @@ namespace grpc { // Wrapper that performs a blocking unary call -Status BlockingUnaryCall(ChannelInterface *channel, const RpcMethod &method, - ClientContext *context, - const grpc::protobuf::Message &request, - grpc::protobuf::Message *result) { +Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, + ClientContext* context, + const grpc::protobuf::Message& request, + grpc::protobuf::Message* result) { CompletionQueue cq; Call call(channel->CreateCall(method, context, &cq)); CallOpBuffer buf; diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index 57d215d0f3..301430572a 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -41,9 +41,10 @@ namespace grpc { class ChannelArguments; std::shared_ptr CreateChannel( - const grpc::string &target, const std::unique_ptr &creds, - const ChannelArguments &args) { - return creds ? creds->CreateChannel(target, args) : - std::shared_ptr(new Channel(target, grpc_lame_client_channel_create())); + const grpc::string& target, const std::unique_ptr& creds, + const ChannelArguments& args) { + return creds ? creds->CreateChannel(target, args) + : std::shared_ptr( + new Channel(target, grpc_lame_client_channel_create())); } } // namespace grpc diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index a2f6a69858..412dc0764f 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -55,7 +55,8 @@ class SecureCredentials GRPC_FINAL : public Credentials { args.SetChannelArgs(&channel_args); return std::shared_ptr(new Channel( args.GetSslTargetNameOverride().empty() - ? target : args.GetSslTargetNameOverride(), + ? target + : args.GetSslTargetNameOverride(), grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args))); } @@ -111,7 +112,7 @@ std::unique_ptr ServiceAccountCredentials( // Builds JWT credentials. std::unique_ptr JWTCredentials( - const grpc::string &json_key, std::chrono::seconds token_lifetime) { + const grpc::string& json_key, std::chrono::seconds token_lifetime) { if (token_lifetime.count() <= 0) { gpr_log(GPR_ERROR, "Trying to create JWTCredentials with non-positive lifetime"); diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index 9254e5879f..b8de2ea173 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -45,7 +45,7 @@ const int kMaxBufferLength = 8192; class GrpcBufferWriter GRPC_FINAL : public ::grpc::protobuf::io::ZeroCopyOutputStream { public: - explicit GrpcBufferWriter(grpc_byte_buffer **bp, + explicit GrpcBufferWriter(grpc_byte_buffer** bp, int block_size = kMaxBufferLength) : block_size_(block_size), byte_count_(0), have_backup_(false) { *bp = grpc_byte_buffer_create(NULL, 0); @@ -58,7 +58,7 @@ class GrpcBufferWriter GRPC_FINAL } } - bool Next(void **data, int *size) GRPC_OVERRIDE { + bool Next(void** data, int* size) GRPC_OVERRIDE { if (have_backup_) { slice_ = backup_slice_; have_backup_ = false; @@ -89,7 +89,7 @@ class GrpcBufferWriter GRPC_FINAL private: const int block_size_; gpr_int64 byte_count_; - gpr_slice_buffer *slice_buffer_; + gpr_slice_buffer* slice_buffer_; bool have_backup_; gpr_slice backup_slice_; gpr_slice slice_; @@ -98,7 +98,7 @@ class GrpcBufferWriter GRPC_FINAL class GrpcBufferReader GRPC_FINAL : public ::grpc::protobuf::io::ZeroCopyInputStream { public: - explicit GrpcBufferReader(grpc_byte_buffer *buffer) + explicit GrpcBufferReader(grpc_byte_buffer* buffer) : byte_count_(0), backup_count_(0) { reader_ = grpc_byte_buffer_reader_create(buffer); } @@ -106,7 +106,7 @@ class GrpcBufferReader GRPC_FINAL grpc_byte_buffer_reader_destroy(reader_); } - bool Next(const void **data, int *size) GRPC_OVERRIDE { + bool Next(const void** data, int* size) GRPC_OVERRIDE { if (backup_count_ > 0) { *data = GPR_SLICE_START_PTR(slice_) + GPR_SLICE_LENGTH(slice_) - backup_count_; @@ -123,12 +123,10 @@ class GrpcBufferReader GRPC_FINAL return true; } - void BackUp(int count) GRPC_OVERRIDE { - backup_count_ = count; - } + void BackUp(int count) GRPC_OVERRIDE { backup_count_ = count; } bool Skip(int count) GRPC_OVERRIDE { - const void *data; + const void* data; int size; while (Next(&data, &size)) { if (size >= count) { @@ -149,18 +147,18 @@ class GrpcBufferReader GRPC_FINAL private: gpr_int64 byte_count_; gpr_int64 backup_count_; - grpc_byte_buffer_reader *reader_; + grpc_byte_buffer_reader* reader_; gpr_slice slice_; }; namespace grpc { -bool SerializeProto(const grpc::protobuf::Message &msg, grpc_byte_buffer **bp) { +bool SerializeProto(const grpc::protobuf::Message& msg, grpc_byte_buffer** bp) { GrpcBufferWriter writer(bp); return msg.SerializeToZeroCopyStream(&writer); } -bool DeserializeProto(grpc_byte_buffer *buffer, grpc::protobuf::Message *msg) { +bool DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg) { GrpcBufferReader reader(buffer); return msg->ParseFromZeroCopyStream(&reader); } diff --git a/src/cpp/proto/proto_utils.h b/src/cpp/proto/proto_utils.h index 7a1b1f8b7c..bc60dc9929 100644 --- a/src/cpp/proto/proto_utils.h +++ b/src/cpp/proto/proto_utils.h @@ -43,11 +43,11 @@ namespace grpc { // Serialize the msg into a buffer created inside the function. The caller // should destroy the returned buffer when done with it. If serialization fails, // false is returned and buffer is left unchanged. -bool SerializeProto(const grpc::protobuf::Message &msg, - grpc_byte_buffer **buffer); +bool SerializeProto(const grpc::protobuf::Message& msg, + grpc_byte_buffer** buffer); // The caller keeps ownership of buffer and msg. -bool DeserializeProto(grpc_byte_buffer *buffer, grpc::protobuf::Message *msg); +bool DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg); } // namespace grpc diff --git a/src/cpp/server/async_generic_service.cc b/src/cpp/server/async_generic_service.cc index 2009af7cbd..07cb933715 100644 --- a/src/cpp/server/async_generic_service.cc +++ b/src/cpp/server/async_generic_service.cc @@ -47,5 +47,4 @@ CompletionQueue* AsyncGenericService::completion_queue() { return &server_->cq_; } -} // namespace grpc - +} // namespace grpc diff --git a/src/cpp/server/async_server_context.cc b/src/cpp/server/async_server_context.cc index f21efcfb19..628822a338 100644 --- a/src/cpp/server/async_server_context.cc +++ b/src/cpp/server/async_server_context.cc @@ -42,7 +42,7 @@ namespace grpc { AsyncServerContext::AsyncServerContext( - grpc_call *call, const grpc::string &method, const grpc::string &host, + grpc_call* call, const grpc::string& method, const grpc::string& host, system_clock::time_point absolute_deadline) : method_(method), host_(host), @@ -52,22 +52,22 @@ AsyncServerContext::AsyncServerContext( AsyncServerContext::~AsyncServerContext() { grpc_call_destroy(call_); } -void AsyncServerContext::Accept(grpc_completion_queue *cq) { +void AsyncServerContext::Accept(grpc_completion_queue* cq) { GPR_ASSERT(grpc_call_server_accept_old(call_, cq, this) == GRPC_CALL_OK); GPR_ASSERT(grpc_call_server_end_initial_metadata_old( call_, GRPC_WRITE_BUFFER_HINT) == GRPC_CALL_OK); } -bool AsyncServerContext::StartRead(grpc::protobuf::Message *request) { +bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) { GPR_ASSERT(request); request_ = request; grpc_call_error err = grpc_call_start_read_old(call_, this); return err == GRPC_CALL_OK; } -bool AsyncServerContext::StartWrite(const grpc::protobuf::Message &response, +bool AsyncServerContext::StartWrite(const grpc::protobuf::Message& response, int flags) { - grpc_byte_buffer *buffer = nullptr; + grpc_byte_buffer* buffer = nullptr; if (!SerializeProto(response, &buffer)) { return false; } @@ -76,16 +76,16 @@ bool AsyncServerContext::StartWrite(const grpc::protobuf::Message &response, return err == GRPC_CALL_OK; } -bool AsyncServerContext::StartWriteStatus(const Status &status) { +bool AsyncServerContext::StartWriteStatus(const Status& status) { grpc_call_error err = grpc_call_start_write_status_old( call_, static_cast(status.code()), status.details().empty() ? nullptr - : const_cast(status.details().c_str()), + : const_cast(status.details().c_str()), this); return err == GRPC_CALL_OK; } -bool AsyncServerContext::ParseRead(grpc_byte_buffer *read_buffer) { +bool AsyncServerContext::ParseRead(grpc_byte_buffer* read_buffer) { GPR_ASSERT(request_); bool success = DeserializeProto(read_buffer, request_); request_ = nullptr; diff --git a/src/cpp/server/insecure_server_credentials.cc b/src/cpp/server/insecure_server_credentials.cc index f5e4732f73..55dd90d7a7 100644 --- a/src/cpp/server/insecure_server_credentials.cc +++ b/src/cpp/server/insecure_server_credentials.cc @@ -46,7 +46,8 @@ class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials { } // namespace std::shared_ptr InsecureServerCredentials() { - return std::shared_ptr(new InsecureServerCredentialsImpl()); + return std::shared_ptr( + new InsecureServerCredentialsImpl()); } } // namespace grpc diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc index ff35638503..88f7a9b1a9 100644 --- a/src/cpp/server/secure_server_credentials.cc +++ b/src/cpp/server/secure_server_credentials.cc @@ -40,7 +40,8 @@ namespace grpc { namespace { class SecureServerCredentials GRPC_FINAL : public ServerCredentials { public: - explicit SecureServerCredentials(grpc_server_credentials* creds) : creds_(creds) {} + explicit SecureServerCredentials(grpc_server_credentials* creds) + : creds_(creds) {} ~SecureServerCredentials() GRPC_OVERRIDE { grpc_server_credentials_release(creds_); } @@ -56,16 +57,17 @@ class SecureServerCredentials GRPC_FINAL : public ServerCredentials { } // namespace std::shared_ptr SslServerCredentials( - const SslServerCredentialsOptions &options) { + const SslServerCredentialsOptions& options) { std::vector pem_key_cert_pairs; - for (const auto &key_cert_pair : options.pem_key_cert_pairs) { + for (const auto& key_cert_pair : options.pem_key_cert_pairs) { pem_key_cert_pairs.push_back( {key_cert_pair.private_key.c_str(), key_cert_pair.cert_chain.c_str()}); } - grpc_server_credentials *c_creds = grpc_ssl_server_credentials_create( + grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create( options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(), &pem_key_cert_pairs[0], pem_key_cert_pairs.size()); - return std::shared_ptr(new SecureServerCredentials(c_creds)); + return std::shared_ptr( + new SecureServerCredentials(c_creds)); } } // namespace grpc diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 4d5e77e633..4ed4c45507 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -322,11 +322,10 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { payload_(nullptr) { memset(&array_, 0, sizeof(array_)); grpc_call_details_init(&call_details_); - grpc_server_request_call( - server->server_, &call_, &call_details_, &array_, cq->cq(), this); + grpc_server_request_call(server->server_, &call_, &call_details_, &array_, + cq->cq(), this); } - ~AsyncRequest() { if (payload_) { grpc_byte_buffer_destroy(payload_); diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 835596d393..2f5a0dc6c8 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -56,7 +56,8 @@ void ServerBuilder::RegisterAsyncGenericService(AsyncGenericService* service) { if (generic_service_) { gpr_log(GPR_ERROR, "Adding multiple AsyncGenericService is unsupported for now. " - "Dropping the service %p", service); + "Dropping the service %p", + service); return; } generic_service_ = service; diff --git a/src/cpp/server/thread_pool.cc b/src/cpp/server/thread_pool.cc index 5dc9bcf916..d3013b806c 100644 --- a/src/cpp/server/thread_pool.cc +++ b/src/cpp/server/thread_pool.cc @@ -66,12 +66,12 @@ ThreadPool::~ThreadPool() { shutdown_ = true; cv_.notify_all(); } - for (auto &t : threads_) { + for (auto& t : threads_) { t.join(); } } -void ThreadPool::ScheduleCallback(const std::function &callback) { +void ThreadPool::ScheduleCallback(const std::function& callback) { std::lock_guard lock(mu_); callbacks_.push(callback); cv_.notify_one(); diff --git a/src/cpp/server/thread_pool.h b/src/cpp/server/thread_pool.h index 6157e403e9..6225d82a0b 100644 --- a/src/cpp/server/thread_pool.h +++ b/src/cpp/server/thread_pool.h @@ -50,7 +50,7 @@ class ThreadPool GRPC_FINAL : public ThreadPoolInterface { explicit ThreadPool(int num_threads); ~ThreadPool(); - void ScheduleCallback(const std::function &callback) GRPC_OVERRIDE; + void ScheduleCallback(const std::function& callback) GRPC_OVERRIDE; private: std::mutex mu_; diff --git a/src/cpp/util/slice.cc b/src/cpp/util/slice.cc index a549c5008d..57370dabc6 100644 --- a/src/cpp/util/slice.cc +++ b/src/cpp/util/slice.cc @@ -37,9 +37,7 @@ namespace grpc { Slice::Slice() : slice_(gpr_empty_slice()) {} -Slice::~Slice() { - gpr_slice_unref(slice_); -} +Slice::~Slice() { gpr_slice_unref(slice_); } Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {} diff --git a/src/cpp/util/status.cc b/src/cpp/util/status.cc index bbf8030668..b694a513e7 100644 --- a/src/cpp/util/status.cc +++ b/src/cpp/util/status.cc @@ -35,7 +35,7 @@ namespace grpc { -const Status &Status::OK = Status(); -const Status &Status::Cancelled = Status(StatusCode::CANCELLED); +const Status& Status::OK = Status(); +const Status& Status::Cancelled = Status(StatusCode::CANCELLED); } // namespace grpc diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc index 919e5623fa..44d2283e76 100644 --- a/src/cpp/util/time.cc +++ b/src/cpp/util/time.cc @@ -43,8 +43,8 @@ using std::chrono::system_clock; namespace grpc { // TODO(yangg) prevent potential overflow. -void Timepoint2Timespec(const system_clock::time_point &from, - gpr_timespec *to) { +void Timepoint2Timespec(const system_clock::time_point& from, + gpr_timespec* to) { system_clock::duration deadline = from.time_since_epoch(); seconds secs = duration_cast(deadline); nanoseconds nsecs = duration_cast(deadline - secs); diff --git a/src/cpp/util/time.h b/src/cpp/util/time.h index 1994848eb2..8b7fcf55f7 100644 --- a/src/cpp/util/time.h +++ b/src/cpp/util/time.h @@ -41,8 +41,8 @@ namespace grpc { // from and to should be absolute time. -void Timepoint2Timespec(const std::chrono::system_clock::time_point &from, - gpr_timespec *to); +void Timepoint2Timespec(const std::chrono::system_clock::time_point& from, + gpr_timespec* to); std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 59ca33cc29..24251f297b 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -54,7 +54,7 @@ TEST_F(CredentialsTest, InvalidServiceAccountCreds) { } // namespace testing } // namespace grpc -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); grpc_init(); int ret = RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 70df9e14b2..e3471203a0 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -66,7 +66,7 @@ namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr)i; } +void* tag(int i) { return (void*)(gpr_intptr) i; } void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { bool ok; diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 4a0d2c5c01..a2faa62865 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -68,7 +68,7 @@ namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr)i; } +void* tag(int i) { return (void*)(gpr_intptr) i; } void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { bool ok; @@ -91,7 +91,7 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) { class GenericEnd2endTest : public ::testing::Test { protected: - GenericEnd2endTest() : generic_service_("*") {} + GenericEnd2endTest() : generic_service_("*") {} void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); @@ -116,8 +116,8 @@ class GenericEnd2endTest : public ::testing::Test { } void ResetStub() { - std::shared_ptr channel = - CreateChannel(server_address_.str(), InsecureCredentials(), ChannelArguments()); + std::shared_ptr channel = CreateChannel( + server_address_.str(), InsecureCredentials(), ChannelArguments()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); } @@ -238,7 +238,6 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { client_ok(6); EXPECT_EQ(send_response.message(), recv_response.message()); - cli_stream->WritesDone(tag(7)); client_ok(7); diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index e5645e568e..ef410671ce 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -237,8 +237,7 @@ void DoServiceAccountCreds() { } void DoJwtTokenCreds() { - gpr_log(GPR_INFO, - "Sending a large unary rpc with JWT token credentials ..."); + gpr_log(GPR_INFO, "Sending a large unary rpc with JWT token credentials ..."); std::shared_ptr channel = CreateChannelForTestCase("jwt_token_creds"); SimpleRequest request; diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index 811e0eb009..a7a5cc0b2c 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -54,13 +54,13 @@ extern "C" { #include #include "test/core/util/port.h" -int test_client(const char *root, const char *host, int port) { +int test_client(const char* root, const char* host, int port) { int status; pid_t cli; cli = fork(); if (cli == 0) { - char *binary_path; - char *port_arg; + char* binary_path; + char* port_arg; gpr_asprintf(&binary_path, "%s/interop_client", root); gpr_asprintf(&port_arg, "--server_port=%d", port); @@ -78,9 +78,9 @@ int test_client(const char *root, const char *host, int port) { return 0; } -int main(int argc, char **argv) { - char *me = argv[0]; - char *lslash = strrchr(me, '/'); +int main(int argc, char** argv) { + char* me = argv[0]; + char* lslash = strrchr(me, '/'); char root[1024]; int port = grpc_pick_unused_port_or_die(); int status; @@ -104,8 +104,8 @@ int main(int argc, char **argv) { /* start the server */ svr = fork(); if (svr == 0) { - char *binary_path; - char *port_arg; + char* binary_path; + char* port_arg; gpr_asprintf(&binary_path, "%s/interop_server", root); gpr_asprintf(&port_arg, "--port=%d", port); diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index c6535bebf8..526f37a1fd 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -61,23 +61,23 @@ class ClientRpcContext { virtual ~ClientRpcContext() {} virtual bool RunNextState() = 0; // do next state, return false if steps done virtual void StartNewClone() = 0; - static void *tag(ClientRpcContext *c) { return reinterpret_cast(c); } - static ClientRpcContext *detag(void *t) { - return reinterpret_cast(t); + static void* tag(ClientRpcContext* c) { return reinterpret_cast(c); } + static ClientRpcContext* detag(void* t) { + return reinterpret_cast(t); } - virtual void report_stats(Histogram *hist) = 0; + virtual void report_stats(Histogram* hist) = 0; }; template class ClientRpcContextUnaryImpl : public ClientRpcContext { public: ClientRpcContextUnaryImpl( - TestService::Stub *stub, const RequestType &req, + TestService::Stub* stub, const RequestType& req, std::function< std::unique_ptr>( - TestService::Stub *, grpc::ClientContext *, const RequestType &, - void *)> start_req, - std::function on_done) + TestService::Stub*, grpc::ClientContext*, const RequestType&, + void*)> start_req, + std::function on_done) : context_(), stub_(stub), req_(req), @@ -90,7 +90,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { start_req(stub_, &context_, req_, ClientRpcContext::tag(this))) {} ~ClientRpcContextUnaryImpl() GRPC_OVERRIDE {} bool RunNextState() GRPC_OVERRIDE { return (this->*next_state_)(); } - void report_stats(Histogram *hist) GRPC_OVERRIDE { + void report_stats(Histogram* hist) GRPC_OVERRIDE { hist->Add((Timer::Now() - start_) * 1e9); } @@ -113,13 +113,13 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { return false; } grpc::ClientContext context_; - TestService::Stub *stub_; + TestService::Stub* stub_; RequestType req_; ResponseType response_; bool (ClientRpcContextUnaryImpl::*next_state_)(); - std::function callback_; + std::function callback_; std::function>( - TestService::Stub *, grpc::ClientContext *, const RequestType &, void *)> + TestService::Stub*, grpc::ClientContext*, const RequestType&, void*)> start_req_; grpc::Status status_; double start_; @@ -129,13 +129,13 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { class AsyncClient GRPC_FINAL : public Client { public: - explicit AsyncClient(const ClientConfig &config) : Client(config) { + explicit AsyncClient(const ClientConfig& config) : Client(config) { for (int i = 0; i < config.async_client_threads(); i++) { cli_cqs_.emplace_back(new CompletionQueue); } auto payload_size = config.payload_size(); - auto check_done = [payload_size](grpc::Status s, SimpleResponse *response) { + auto check_done = [payload_size](grpc::Status s, SimpleResponse* response) { GPR_ASSERT(s.IsOk() && (response->payload().type() == grpc::testing::PayloadType::COMPRESSABLE) && (response->payload().body().length() == @@ -144,16 +144,16 @@ class AsyncClient GRPC_FINAL : public Client { int t = 0; for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) { - for (auto &channel : channels_) { - auto *cq = cli_cqs_[t].get(); + for (auto& channel : channels_) { + auto* cq = cli_cqs_[t].get(); t = (t + 1) % cli_cqs_.size(); - auto start_req = [cq](TestService::Stub *stub, grpc::ClientContext *ctx, - const SimpleRequest &request, void *tag) { + auto start_req = [cq](TestService::Stub* stub, grpc::ClientContext* ctx, + const SimpleRequest& request, void* tag) { return stub->AsyncUnaryCall(ctx, request, cq, tag); }; - TestService::Stub *stub = channel.get_stub(); - const SimpleRequest &request = request_; + TestService::Stub* stub = channel.get_stub(); + const SimpleRequest& request = request_; new ClientRpcContextUnaryImpl( stub, request, start_req, check_done); } @@ -165,9 +165,9 @@ class AsyncClient GRPC_FINAL : public Client { ~AsyncClient() GRPC_OVERRIDE { EndThreads(); - for (auto &cq : cli_cqs_) { + for (auto& cq : cli_cqs_) { cq->Shutdown(); - void *got_tag; + void* got_tag; bool ok; while (cq->Next(&got_tag, &ok)) { delete ClientRpcContext::detag(got_tag); @@ -175,12 +175,12 @@ class AsyncClient GRPC_FINAL : public Client { } } - void ThreadFunc(Histogram *histogram, size_t thread_idx) GRPC_OVERRIDE { - void *got_tag; + void ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE { + void* got_tag; bool ok; cli_cqs_[thread_idx]->Next(&got_tag, &ok); - ClientRpcContext *ctx = ClientRpcContext::detag(got_tag); + ClientRpcContext* ctx = ClientRpcContext::detag(got_tag); if (ctx->RunNextState() == false) { // call the callback and then delete it ctx->report_stats(histogram); @@ -193,7 +193,7 @@ class AsyncClient GRPC_FINAL : public Client { std::vector> cli_cqs_; }; -std::unique_ptr CreateAsyncClient(const ClientConfig &args) { +std::unique_ptr CreateAsyncClient(const ClientConfig& args) { return std::unique_ptr(new AsyncClient(args)); } diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index bf51e7408e..5e9a577f8e 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -69,7 +69,7 @@ namespace gflags {} using namespace google; using namespace gflags; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_init(); ParseCommandLineFlags(&argc, &argv, true); diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc index 005f0f9c5e..6a207d8730 100644 --- a/test/cpp/qps/server.cc +++ b/test/cpp/qps/server.cc @@ -73,8 +73,8 @@ using grpc::Status; // In some distros, gflags is in the namespace google, and in some others, // in gflags. This hack is enabling us to find both. -namespace google { } -namespace gflags { } +namespace google {} +namespace gflags {} using namespace google; using namespace gflags; diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 19778e5a7c..fcb5ac6d2f 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -62,9 +62,9 @@ namespace testing { class AsyncQpsServerTest : public Server { public: - AsyncQpsServerTest(const ServerConfig &config, int port) + AsyncQpsServerTest(const ServerConfig& config, int port) : srv_cq_(), async_service_(&srv_cq_), server_(nullptr) { - char *server_address = NULL; + char* server_address = NULL; gpr_join_host_port(&server_address, "::", port); ServerBuilder builder; @@ -87,10 +87,10 @@ class AsyncQpsServerTest : public Server { threads_.push_back(std::thread([=]() { // Wait until work is available or we are shutting down bool ok; - void *got_tag; + void* got_tag; while (srv_cq_.Next(&got_tag, &ok)) { if (ok) { - ServerRpcContext *ctx = detag(got_tag); + ServerRpcContext* ctx = detag(got_tag); // The tag is a pointer to an RPC context to invoke if (ctx->RunNextState() == false) { // this RPC context is done, so refresh it @@ -105,7 +105,7 @@ class AsyncQpsServerTest : public Server { ~AsyncQpsServerTest() { server_->Shutdown(); srv_cq_.Shutdown(); - for (auto &thr : threads_) { + for (auto& thr : threads_) { thr.join(); } while (!contexts_.empty()) { @@ -122,21 +122,21 @@ class AsyncQpsServerTest : public Server { virtual bool RunNextState() = 0; // do next state, return false if all done virtual void Reset() = 0; // start this back at a clean state }; - static void *tag(ServerRpcContext *func) { - return reinterpret_cast(func); + static void* tag(ServerRpcContext* func) { + return reinterpret_cast(func); } - static ServerRpcContext *detag(void *tag) { - return reinterpret_cast(tag); + static ServerRpcContext* detag(void* tag) { + return reinterpret_cast(tag); } template class ServerRpcContextUnaryImpl : public ServerRpcContext { public: ServerRpcContextUnaryImpl( - std::function *, - void *)> request_method, - std::function + std::function*, + void*)> request_method, + std::function invoke_method) : next_state_(&ServerRpcContextUnaryImpl::invoker), request_method_(request_method), @@ -175,16 +175,16 @@ class AsyncQpsServerTest : public Server { ServerContext srv_ctx_; RequestType req_; bool (ServerRpcContextUnaryImpl::*next_state_)(); - std::function *, void *)> + std::function*, void*)> request_method_; - std::function + std::function invoke_method_; grpc::ServerAsyncResponseWriter response_writer_; }; - static Status UnaryCall(const SimpleRequest *request, - SimpleResponse *response) { + static Status UnaryCall(const SimpleRequest* request, + SimpleResponse* response) { if (request->has_response_size() && request->response_size() > 0) { if (!SetPayload(request->response_type(), request->response_size(), response->mutable_payload())) { @@ -197,13 +197,13 @@ class AsyncQpsServerTest : public Server { TestService::AsyncService async_service_; std::vector threads_; std::unique_ptr server_; - std::function *, void *)> + std::function*, void*)> request_unary_; - std::forward_list contexts_; + std::forward_list contexts_; }; -std::unique_ptr CreateAsyncServer(const ServerConfig &config, +std::unique_ptr CreateAsyncServer(const ServerConfig& config, int port) { return std::unique_ptr(new AsyncQpsServerTest(config, port)); } diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index d3b84b2965..f040acc4b1 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -72,8 +72,7 @@ std::shared_ptr CreateTestChannel( const grpc::string& connect_to = server.empty() ? override_hostname : server; if (creds.get()) { - channel_creds = - CompositeCredentials(creds, channel_creds); + channel_creds = CompositeCredentials(creds, channel_creds); } return CreateChannel(connect_to, channel_creds, channel_args); } else { diff --git a/test/cpp/util/status_test.cc b/test/cpp/util/status_test.cc index 8c6a3354fe..17b92ab06a 100644 --- a/test/cpp/util/status_test.cc +++ b/test/cpp/util/status_test.cc @@ -36,7 +36,7 @@ #include // Make sure the existing grpc_status_code match with grpc::Code. -int main(int argc, char **argv) { +int main(int argc, char** argv) { GPR_ASSERT(grpc::StatusCode::OK == static_cast(GRPC_STATUS_OK)); GPR_ASSERT(grpc::StatusCode::CANCELLED == -- cgit v1.2.3 From 3c220dfc32c0af5cf8d634f5827d798855b69d07 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Tue, 17 Mar 2015 11:47:54 -0700 Subject: Print out status when it is not ok in interop tests --- test/cpp/interop/client.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index e5645e568e..3bf299b1b5 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -161,6 +161,15 @@ std::shared_ptr CreateChannelForTestCase( } } +void AssertOkOrPrintErrorStatus(const grpc::Status& s) { + if (s.IsOk()) { + return; + } + gpr_log(GPR_INFO, "Error status code: %d, message: %s", + s.code(), s.details().c_str()); + GPR_ASSERT(0); +} + void DoEmpty() { gpr_log(GPR_INFO, "Sending an empty rpc..."); std::shared_ptr channel = @@ -172,8 +181,8 @@ void DoEmpty() { ClientContext context; grpc::Status s = stub->EmptyCall(&context, request, &response); + AssertOkOrPrintErrorStatus(s); - GPR_ASSERT(s.IsOk()); gpr_log(GPR_INFO, "Empty rpc done."); } @@ -190,7 +199,7 @@ void PerformLargeUnary(std::shared_ptr channel, grpc::Status s = stub->UnaryCall(&context, *request, response); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); GPR_ASSERT(response->payload().type() == grpc::testing::PayloadType::COMPRESSABLE); GPR_ASSERT(response->payload().body() == @@ -285,7 +294,7 @@ void DoRequestStreaming() { grpc::Status s = stream->Finish(); GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Request streaming done."); } @@ -314,7 +323,7 @@ void DoResponseStreaming() { GPR_ASSERT(response_stream_sizes.size() == i); grpc::Status s = stream->Finish(); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Response streaming done."); } @@ -346,7 +355,7 @@ void DoResponseStreamingWithSlowConsumer() { GPR_ASSERT(kNumResponseMessages == i); grpc::Status s = stream->Finish(); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Response streaming done."); } @@ -379,7 +388,7 @@ void DoHalfDuplex() { } GPR_ASSERT(response_stream_sizes.size() == i); grpc::Status s = stream->Finish(); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Half-duplex streaming rpc done."); } @@ -412,7 +421,7 @@ void DoPingPong() { stream->WritesDone(); GPR_ASSERT(!stream->Read(&response)); grpc::Status s = stream->Finish(); - GPR_ASSERT(s.IsOk()); + AssertOkOrPrintErrorStatus(s); gpr_log(GPR_INFO, "Ping pong streaming done."); } -- cgit v1.2.3 From 757afaeb3072a3f3d30d2054ce1a53af168c48ce Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Tue, 17 Mar 2015 15:49:26 -0700 Subject: clang-format new changes --- include/grpc++/completion_queue.h | 13 ++++++------- test/cpp/end2end/async_end2end_test.cc | 26 ++++++++++++-------------- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 8a36b09a7f..d98a8bbd5f 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -77,19 +77,18 @@ class CompletionQueue { ~CompletionQueue(); // Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT - enum NextStatus {SHUTDOWN, GOT_EVENT, TIMEOUT}; + enum NextStatus { SHUTDOWN, GOT_EVENT, TIMEOUT }; // Nonblocking (until deadline) read from queue. // Cannot rely on result of tag or ok if return is TIMEOUT - NextStatus AsyncNext(void **tag, bool *ok, - std::chrono::system_clock::time_point deadline); + NextStatus AsyncNext(void** tag, bool* ok, + std::chrono::system_clock::time_point deadline); // Blocking (until deadline) read from queue. // Returns false if the queue is ready for destruction, true if event - bool Next(void **tag, bool *ok) { - return (AsyncNext(tag,ok, - std::chrono::system_clock::time_point::max()) != - SHUTDOWN); + bool Next(void** tag, bool* ok) { + return (AsyncNext(tag, ok, std::chrono::system_clock::time_point::max()) != + SHUTDOWN); } // Shutdown has to be called, and the CompletionQueue can only be diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 44b8899bf7..4a71a84eeb 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -76,11 +76,11 @@ void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { EXPECT_EQ(tag(i), got_tag); } -void verify_timed_ok(CompletionQueue* cq, int i, bool expect_ok, - std::chrono::system_clock::time_point deadline = - std::chrono::system_clock::time_point::max(), - CompletionQueue::NextStatus expected_outcome = - CompletionQueue::GOT_EVENT) { +void verify_timed_ok( + CompletionQueue* cq, int i, bool expect_ok, + std::chrono::system_clock::time_point deadline = + std::chrono::system_clock::time_point::max(), + CompletionQueue::NextStatus expected_outcome = CompletionQueue::GOT_EVENT) { bool ok; void* got_tag; EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome); @@ -195,18 +195,17 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) { grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); send_request.set_message("Hello"); - std::unique_ptr > - response_reader(stub_->AsyncEcho(&cli_ctx, send_request, - &cli_cq_, tag(1))); + std::unique_ptr > response_reader( + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - std::chrono::system_clock::time_point - time_now(std::chrono::system_clock::now()), - time_limit(std::chrono::system_clock::now()+std::chrono::seconds(5)); + std::chrono::system_clock::time_point time_now( + std::chrono::system_clock::now()), + time_limit(std::chrono::system_clock::now() + std::chrono::seconds(5)); verify_timed_ok(&srv_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, - tag(2)); + tag(2)); verify_timed_ok(&srv_cq_, 2, true, time_limit); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -221,9 +220,8 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) { EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_TRUE(recv_status.IsOk()); - } - + // Two pings and a final pong. TEST_F(AsyncEnd2endTest, SimpleClientStreaming) { ResetStub(); -- cgit v1.2.3 From 89905ac55d986878b338406a298ee513c15b68be Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Tue, 17 Mar 2015 18:26:48 -0700 Subject: Factor out interface-specific early_adopter code Refactors early_adopter such that interface-specific code is located in the framework module as a submodule `alpha`. --- src/compiler/python_generator.cc | 2 +- src/python/interop/interop/methods.py | 2 +- .../src/grpc/early_adopter/_face_utilities.py | 183 ---------- src/python/src/grpc/early_adopter/_reexport.py | 203 ----------- src/python/src/grpc/early_adopter/exceptions.py | 48 --- .../src/grpc/early_adopter/implementations.py | 6 +- .../src/grpc/early_adopter/implementations_test.py | 2 +- src/python/src/grpc/early_adopter/interfaces.py | 388 --------------------- src/python/src/grpc/early_adopter/utilities.py | 269 -------------- src/python/src/grpc/framework/alpha/__init__.py | 28 ++ .../src/grpc/framework/alpha/_face_utilities.py | 183 ++++++++++ src/python/src/grpc/framework/alpha/_reexport.py | 203 +++++++++++ src/python/src/grpc/framework/alpha/exceptions.py | 48 +++ src/python/src/grpc/framework/alpha/interfaces.py | 388 +++++++++++++++++++++ src/python/src/grpc/framework/alpha/utilities.py | 269 ++++++++++++++ src/python/src/setup.py | 1 + test/compiler/python_plugin_test.py | 2 +- 17 files changed, 1127 insertions(+), 1098 deletions(-) delete mode 100644 src/python/src/grpc/early_adopter/_face_utilities.py delete mode 100644 src/python/src/grpc/early_adopter/_reexport.py delete mode 100644 src/python/src/grpc/early_adopter/exceptions.py delete mode 100644 src/python/src/grpc/early_adopter/interfaces.py delete mode 100644 src/python/src/grpc/early_adopter/utilities.py create mode 100644 src/python/src/grpc/framework/alpha/__init__.py create mode 100644 src/python/src/grpc/framework/alpha/_face_utilities.py create mode 100644 src/python/src/grpc/framework/alpha/_reexport.py create mode 100644 src/python/src/grpc/framework/alpha/exceptions.py create mode 100644 src/python/src/grpc/framework/alpha/interfaces.py create mode 100644 src/python/src/grpc/framework/alpha/utilities.py (limited to 'test') diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 8136602ae5..e4f85450f5 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -381,7 +381,7 @@ bool PrintStubFactory(const std::string& package_qualified_service_name, bool PrintPreamble(const FileDescriptor* file, Printer* out) { out->Print("import abc\n"); out->Print("from grpc.early_adopter import implementations\n"); - out->Print("from grpc.early_adopter import utilities\n"); + out->Print("from grpc.framework.alpha import utilities\n"); return true; } diff --git a/src/python/interop/interop/methods.py b/src/python/interop/interop/methods.py index 4f83ccc085..79550a3789 100644 --- a/src/python/interop/interop/methods.py +++ b/src/python/interop/interop/methods.py @@ -32,7 +32,7 @@ import enum import threading -from grpc.early_adopter import utilities +from grpc.framework.alpha import utilities from interop import empty_pb2 from interop import messages_pb2 diff --git a/src/python/src/grpc/early_adopter/_face_utilities.py b/src/python/src/grpc/early_adopter/_face_utilities.py deleted file mode 100644 index ce099fc22f..0000000000 --- a/src/python/src/grpc/early_adopter/_face_utilities.py +++ /dev/null @@ -1,183 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import abc -import collections - -# face_interfaces is referenced from specification in this module. -from grpc.framework.common import cardinality -from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import -from grpc.framework.face import utilities as face_utilities -from grpc.early_adopter import _reexport -from grpc.early_adopter import interfaces - - -def _qualified_name(service_name, method_name): - return '/%s/%s' % (service_name, method_name) - - -# TODO(nathaniel): This structure is getting bloated; it could be shrunk if -# implementations._Stub used a generic rather than a dynamic underlying -# face-layer stub. -class InvocationBreakdown(object): - """An intermediate representation of invocation-side views of RPC methods. - - Attributes: - cardinalities: A dictionary from RPC method name to interfaces.Cardinality - value. - qualified_names: A dictionary from unqualified RPC method name to - service-qualified RPC method name. - face_cardinalities: A dictionary from service-qualified RPC method name to - to cardinality.Cardinality value. - request_serializers: A dictionary from service-qualified RPC method name to - callable behavior to be used serializing request values for the RPC. - response_deserializers: A dictionary from service-qualified RPC method name - to callable behavior to be used deserializing response values for the - RPC. - """ - __metaclass__ = abc.ABCMeta - - -class _EasyInvocationBreakdown( - InvocationBreakdown, - collections.namedtuple( - '_EasyInvocationBreakdown', - ('cardinalities', 'qualified_names', 'face_cardinalities', - 'request_serializers', 'response_deserializers'))): - pass - - -class ServiceBreakdown(object): - """An intermediate representation of service-side views of RPC methods. - - Attributes: - implementations: A dictionary from service-qualified RPC method name to - face_interfaces.MethodImplementation implementing the RPC method. - request_deserializers: A dictionary from service-qualified RPC method name - to callable behavior to be used deserializing request values for the RPC. - response_serializers: A dictionary from service-qualified RPC method name - to callable behavior to be used serializing response values for the RPC. - """ - __metaclass__ = abc.ABCMeta - - -class _EasyServiceBreakdown( - ServiceBreakdown, - collections.namedtuple( - '_EasyServiceBreakdown', - ('implementations', 'request_deserializers', 'response_serializers'))): - pass - - -def break_down_invocation(service_name, method_descriptions): - """Derives an InvocationBreakdown from several RPC method descriptions. - - Args: - service_name: The package-qualified full name of the service. - method_descriptions: A dictionary from RPC method name to - interfaces.RpcMethodInvocationDescription describing the RPCs. - - Returns: - An InvocationBreakdown corresponding to the given method descriptions. - """ - cardinalities = {} - qualified_names = {} - face_cardinalities = {} - request_serializers = {} - response_deserializers = {} - for name, method_description in method_descriptions.iteritems(): - qualified_name = _qualified_name(service_name, name) - method_cardinality = method_description.cardinality() - cardinalities[name] = method_description.cardinality() - qualified_names[name] = qualified_name - face_cardinalities[qualified_name] = _reexport.common_cardinality( - method_cardinality) - request_serializers[qualified_name] = method_description.serialize_request - response_deserializers[qualified_name] = ( - method_description.deserialize_response) - return _EasyInvocationBreakdown( - cardinalities, qualified_names, face_cardinalities, request_serializers, - response_deserializers) - - -def break_down_service(service_name, method_descriptions): - """Derives a ServiceBreakdown from several RPC method descriptions. - - Args: - method_descriptions: A dictionary from RPC method name to - interfaces.RpcMethodServiceDescription describing the RPCs. - - Returns: - A ServiceBreakdown corresponding to the given method descriptions. - """ - implementations = {} - request_deserializers = {} - response_serializers = {} - for name, method_description in method_descriptions.iteritems(): - qualified_name = _qualified_name(service_name, name) - method_cardinality = method_description.cardinality() - if method_cardinality is interfaces.Cardinality.UNARY_UNARY: - def service( - request, face_rpc_context, - service_behavior=method_description.service_unary_unary): - return service_behavior( - request, _reexport.rpc_context(face_rpc_context)) - implementations[qualified_name] = face_utilities.unary_unary_inline( - service) - elif method_cardinality is interfaces.Cardinality.UNARY_STREAM: - def service( - request, face_rpc_context, - service_behavior=method_description.service_unary_stream): - return service_behavior( - request, _reexport.rpc_context(face_rpc_context)) - implementations[qualified_name] = face_utilities.unary_stream_inline( - service) - elif method_cardinality is interfaces.Cardinality.STREAM_UNARY: - def service( - request_iterator, face_rpc_context, - service_behavior=method_description.service_stream_unary): - return service_behavior( - request_iterator, _reexport.rpc_context(face_rpc_context)) - implementations[qualified_name] = face_utilities.stream_unary_inline( - service) - elif method_cardinality is interfaces.Cardinality.STREAM_STREAM: - def service( - request_iterator, face_rpc_context, - service_behavior=method_description.service_stream_stream): - return service_behavior( - request_iterator, _reexport.rpc_context(face_rpc_context)) - implementations[qualified_name] = face_utilities.stream_stream_inline( - service) - request_deserializers[qualified_name] = ( - method_description.deserialize_request) - response_serializers[qualified_name] = ( - method_description.serialize_response) - - return _EasyServiceBreakdown( - implementations, request_deserializers, response_serializers) diff --git a/src/python/src/grpc/early_adopter/_reexport.py b/src/python/src/grpc/early_adopter/_reexport.py deleted file mode 100644 index 49bc38e203..0000000000 --- a/src/python/src/grpc/early_adopter/_reexport.py +++ /dev/null @@ -1,203 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -from grpc.framework.common import cardinality -from grpc.framework.face import exceptions as face_exceptions -from grpc.framework.face import interfaces as face_interfaces -from grpc.framework.foundation import future -from grpc.early_adopter import exceptions -from grpc.early_adopter import interfaces - -_EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY = { - interfaces.Cardinality.UNARY_UNARY: cardinality.Cardinality.UNARY_UNARY, - interfaces.Cardinality.UNARY_STREAM: cardinality.Cardinality.UNARY_STREAM, - interfaces.Cardinality.STREAM_UNARY: cardinality.Cardinality.STREAM_UNARY, - interfaces.Cardinality.STREAM_STREAM: cardinality.Cardinality.STREAM_STREAM, -} - -_ABORTION_REEXPORT = { - face_interfaces.Abortion.CANCELLED: interfaces.Abortion.CANCELLED, - face_interfaces.Abortion.EXPIRED: interfaces.Abortion.EXPIRED, - face_interfaces.Abortion.NETWORK_FAILURE: - interfaces.Abortion.NETWORK_FAILURE, - face_interfaces.Abortion.SERVICED_FAILURE: - interfaces.Abortion.SERVICED_FAILURE, - face_interfaces.Abortion.SERVICER_FAILURE: - interfaces.Abortion.SERVICER_FAILURE, -} - - -class _RpcError(exceptions.RpcError): - pass - - -def _reexport_error(face_rpc_error): - if isinstance(face_rpc_error, face_exceptions.CancellationError): - return exceptions.CancellationError() - elif isinstance(face_rpc_error, face_exceptions.ExpirationError): - return exceptions.ExpirationError() - else: - return _RpcError() - - -def _as_face_abortion_callback(abortion_callback): - def face_abortion_callback(face_abortion): - abortion_callback(_ABORTION_REEXPORT[face_abortion]) - return face_abortion_callback - - -class _ReexportedFuture(future.Future): - - def __init__(self, face_future): - self._face_future = face_future - - def cancel(self): - return self._face_future.cancel() - - def cancelled(self): - return self._face_future.cancelled() - - def running(self): - return self._face_future.running() - - def done(self): - return self._face_future.done() - - def result(self, timeout=None): - try: - return self._face_future.result(timeout=timeout) - except face_exceptions.RpcError as e: - raise _reexport_error(e) - - def exception(self, timeout=None): - face_error = self._face_future.exception(timeout=timeout) - return None if face_error is None else _reexport_error(face_error) - - def traceback(self, timeout=None): - return self._face_future.traceback(timeout=timeout) - - def add_done_callback(self, fn): - self._face_future.add_done_callback(lambda unused_face_future: fn(self)) - - -def _call_reexporting_errors(behavior, *args, **kwargs): - try: - return behavior(*args, **kwargs) - except face_exceptions.RpcError as e: - raise _reexport_error(e) - - -def _reexported_future(face_future): - return _ReexportedFuture(face_future) - - -class _CancellableIterator(interfaces.CancellableIterator): - - def __init__(self, face_cancellable_iterator): - self._face_cancellable_iterator = face_cancellable_iterator - - def __iter__(self): - return self - - def next(self): - return _call_reexporting_errors(self._face_cancellable_iterator.next) - - def cancel(self): - self._face_cancellable_iterator.cancel() - - -class _RpcContext(interfaces.RpcContext): - - def __init__(self, face_rpc_context): - self._face_rpc_context = face_rpc_context - - def is_active(self): - return self._face_rpc_context.is_active() - - def time_remaining(self): - return self._face_rpc_context.time_remaining() - - def add_abortion_callback(self, abortion_callback): - self._face_rpc_context.add_abortion_callback( - _as_face_abortion_callback(abortion_callback)) - - -class _UnaryUnarySyncAsync(interfaces.UnaryUnarySyncAsync): - - def __init__(self, face_unary_unary_multi_callable): - self._underlying = face_unary_unary_multi_callable - - def __call__(self, request, timeout): - return _call_reexporting_errors( - self._underlying, request, timeout) - - def async(self, request, timeout): - return _ReexportedFuture(self._underlying.future(request, timeout)) - - -class _StreamUnarySyncAsync(interfaces.StreamUnarySyncAsync): - - def __init__(self, face_stream_unary_multi_callable): - self._underlying = face_stream_unary_multi_callable - - def __call__(self, request_iterator, timeout): - return _call_reexporting_errors( - self._underlying, request_iterator, timeout) - - def async(self, request_iterator, timeout): - return _ReexportedFuture(self._underlying.future(request_iterator, timeout)) - - -def common_cardinality(early_adopter_cardinality): - return _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[ - early_adopter_cardinality] - - -def common_cardinalities(early_adopter_cardinalities): - common_cardinalities = {} - for name, early_adopter_cardinality in early_adopter_cardinalities.iteritems(): - common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[ - early_adopter_cardinality] - return common_cardinalities - - -def rpc_context(face_rpc_context): - return _RpcContext(face_rpc_context) - - -def cancellable_iterator(face_cancellable_iterator): - return _CancellableIterator(face_cancellable_iterator) - - -def unary_unary_sync_async(face_unary_unary_multi_callable): - return _UnaryUnarySyncAsync(face_unary_unary_multi_callable) - - -def stream_unary_sync_async(face_stream_unary_multi_callable): - return _StreamUnarySyncAsync(face_stream_unary_multi_callable) diff --git a/src/python/src/grpc/early_adopter/exceptions.py b/src/python/src/grpc/early_adopter/exceptions.py deleted file mode 100644 index 5234d3b91c..0000000000 --- a/src/python/src/grpc/early_adopter/exceptions.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Exceptions raised by GRPC. - -Only GRPC should instantiate and raise these exceptions. -""" - -import abc - - -class RpcError(Exception): - """Common super type for all exceptions raised by GRPC.""" - __metaclass__ = abc.ABCMeta - - -class CancellationError(RpcError): - """Indicates that an RPC has been cancelled.""" - - -class ExpirationError(RpcError): - """Indicates that an RPC has expired ("timed out").""" diff --git a/src/python/src/grpc/early_adopter/implementations.py b/src/python/src/grpc/early_adopter/implementations.py index 9cadb58d0f..cc0b8ec9e8 100644 --- a/src/python/src/grpc/early_adopter/implementations.py +++ b/src/python/src/grpc/early_adopter/implementations.py @@ -33,9 +33,9 @@ import threading from grpc._adapter import fore as _fore from grpc._adapter import rear as _rear -from grpc.early_adopter import _face_utilities -from grpc.early_adopter import _reexport -from grpc.early_adopter import interfaces +from grpc.framework.alpha import _face_utilities +from grpc.framework.alpha import _reexport +from grpc.framework.alpha import interfaces from grpc.framework.base import implementations as _base_implementations from grpc.framework.base import util as _base_utilities from grpc.framework.face import implementations as _face_implementations diff --git a/src/python/src/grpc/early_adopter/implementations_test.py b/src/python/src/grpc/early_adopter/implementations_test.py index 949d3def3d..ae4adad90f 100644 --- a/src/python/src/grpc/early_adopter/implementations_test.py +++ b/src/python/src/grpc/early_adopter/implementations_test.py @@ -34,7 +34,7 @@ import unittest from grpc.early_adopter import implementations -from grpc.early_adopter import utilities +from grpc.framework.alpha import utilities from grpc._junkdrawer import math_pb2 SERVICE_NAME = 'math.Math' diff --git a/src/python/src/grpc/early_adopter/interfaces.py b/src/python/src/grpc/early_adopter/interfaces.py deleted file mode 100644 index b733873c1c..0000000000 --- a/src/python/src/grpc/early_adopter/interfaces.py +++ /dev/null @@ -1,388 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Interfaces of GRPC.""" - -import abc -import enum - -# exceptions is referenced from specification in this module. -from grpc.early_adopter import exceptions # pylint: disable=unused-import -from grpc.framework.foundation import activated -from grpc.framework.foundation import future - - -@enum.unique -class Cardinality(enum.Enum): - """Constants for the four cardinalities of RPC.""" - - UNARY_UNARY = 'request-unary/response-unary' - UNARY_STREAM = 'request-unary/response-streaming' - STREAM_UNARY = 'request-streaming/response-unary' - STREAM_STREAM = 'request-streaming/response-streaming' - - -@enum.unique -class Abortion(enum.Enum): - """Categories of RPC abortion.""" - - CANCELLED = 'cancelled' - EXPIRED = 'expired' - NETWORK_FAILURE = 'network failure' - SERVICED_FAILURE = 'serviced failure' - SERVICER_FAILURE = 'servicer failure' - - -class CancellableIterator(object): - """Implements the Iterator protocol and affords a cancel method.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def __iter__(self): - """Returns the self object in accordance with the Iterator protocol.""" - raise NotImplementedError() - - @abc.abstractmethod - def next(self): - """Returns a value or raises StopIteration per the Iterator protocol.""" - raise NotImplementedError() - - @abc.abstractmethod - def cancel(self): - """Requests cancellation of whatever computation underlies this iterator.""" - raise NotImplementedError() - - -class RpcContext(object): - """Provides RPC-related information and action.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def is_active(self): - """Describes whether the RPC is active or has terminated.""" - raise NotImplementedError() - - @abc.abstractmethod - def time_remaining(self): - """Describes the length of allowed time remaining for the RPC. - Returns: - A nonnegative float indicating the length of allowed time in seconds - remaining for the RPC to complete before it is considered to have timed - out. - """ - raise NotImplementedError() - - @abc.abstractmethod - def add_abortion_callback(self, abortion_callback): - """Registers a callback to be called if the RPC is aborted. - Args: - abortion_callback: A callable to be called and passed an Abortion value - in the event of RPC abortion. - """ - raise NotImplementedError() - - -class UnaryUnarySyncAsync(object): - """Affords invoking a unary-unary RPC synchronously or asynchronously. - Values implementing this interface are directly callable and present an - "async" method. Both calls take a request value and a numeric timeout. - Direct invocation of a value of this type invokes its associated RPC and - blocks until the RPC's response is available. Calling the "async" method - of a value of this type invokes its associated RPC and immediately returns a - future.Future bound to the asynchronous execution of the RPC. - """ - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def __call__(self, request, timeout): - """Synchronously invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: A duration of time in seconds to allow for the RPC. - Returns: - The response value for the RPC. - Raises: - exceptions.RpcError: Indicating that the RPC was aborted. - """ - raise NotImplementedError() - - @abc.abstractmethod - def async(self, request, timeout): - """Asynchronously invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: A duration of time in seconds to allow for the RPC. - Returns: - A future.Future representing the RPC. In the event of RPC completion, the - returned Future's result value will be the response value of the RPC. - In the event of RPC abortion, the returned Future's exception value - will be an exceptions.RpcError. - """ - raise NotImplementedError() - - -class StreamUnarySyncAsync(object): - """Affords invoking a stream-unary RPC synchronously or asynchronously. - Values implementing this interface are directly callable and present an - "async" method. Both calls take an iterator of request values and a numeric - timeout. Direct invocation of a value of this type invokes its associated RPC - and blocks until the RPC's response is available. Calling the "async" method - of a value of this type invokes its associated RPC and immediately returns a - future.Future bound to the asynchronous execution of the RPC. - """ - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def __call__(self, request_iterator, timeout): - """Synchronously invokes the underlying RPC. - - Args: - request_iterator: An iterator that yields request values for the RPC. - timeout: A duration of time in seconds to allow for the RPC. - - Returns: - The response value for the RPC. - - Raises: - exceptions.RpcError: Indicating that the RPC was aborted. - """ - raise NotImplementedError() - - @abc.abstractmethod - def async(self, request_iterator, timeout): - """Asynchronously invokes the underlying RPC. - - Args: - request_iterator: An iterator that yields request values for the RPC. - timeout: A duration of time in seconds to allow for the RPC. - - Returns: - A future.Future representing the RPC. In the event of RPC completion, the - returned Future's result value will be the response value of the RPC. - In the event of RPC abortion, the returned Future's exception value - will be an exceptions.RpcError. - """ - raise NotImplementedError() - - -class RpcMethodDescription(object): - """A type for the common aspects of RPC method descriptions.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def cardinality(self): - """Identifies the cardinality of this RpcMethodDescription. - - Returns: - A Cardinality value identifying whether or not this - RpcMethodDescription is request-unary or request-streaming and - whether or not it is response-unary or response-streaming. - """ - raise NotImplementedError() - - -class RpcMethodInvocationDescription(RpcMethodDescription): - """Invocation-side description of an RPC method.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def serialize_request(self, request): - """Serializes a request value. - - Args: - request: A request value appropriate for the RPC method described by this - RpcMethodInvocationDescription. - - Returns: - The serialization of the given request value as a - bytestring. - """ - raise NotImplementedError() - - @abc.abstractmethod - def deserialize_response(self, serialized_response): - """Deserializes a response value. - - Args: - serialized_response: A bytestring that is the serialization of a response - value appropriate for the RPC method described by this - RpcMethodInvocationDescription. - - Returns: - A response value corresponding to the given bytestring. - """ - raise NotImplementedError() - - -class RpcMethodServiceDescription(RpcMethodDescription): - """Service-side description of an RPC method.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def deserialize_request(self, serialized_request): - """Deserializes a request value. - - Args: - serialized_request: A bytestring that is the serialization of a request - value appropriate for the RPC method described by this - RpcMethodServiceDescription. - - Returns: - A request value corresponding to the given bytestring. - """ - raise NotImplementedError() - - @abc.abstractmethod - def serialize_response(self, response): - """Serializes a response value. - - Args: - response: A response value appropriate for the RPC method described by - this RpcMethodServiceDescription. - - Returns: - The serialization of the given response value as a - bytestring. - """ - raise NotImplementedError() - - @abc.abstractmethod - def service_unary_unary(self, request, context): - """Carries out this RPC. - - This method may only be called if the cardinality of this - RpcMethodServiceDescription is Cardinality.UNARY_UNARY. - - Args: - request: A request value appropriate for the RPC method described by this - RpcMethodServiceDescription. - context: An RpcContext object for the RPC. - - Returns: - A response value appropriate for the RPC method described by this - RpcMethodServiceDescription. - """ - raise NotImplementedError() - - @abc.abstractmethod - def service_unary_stream(self, request, context): - """Carries out this RPC. - - This method may only be called if the cardinality of this - RpcMethodServiceDescription is Cardinality.UNARY_STREAM. - - Args: - request: A request value appropriate for the RPC method described by this - RpcMethodServiceDescription. - context: An RpcContext object for the RPC. - - Yields: - Zero or more response values appropriate for the RPC method described by - this RpcMethodServiceDescription. - """ - raise NotImplementedError() - - @abc.abstractmethod - def service_stream_unary(self, request_iterator, context): - """Carries out this RPC. - - This method may only be called if the cardinality of this - RpcMethodServiceDescription is Cardinality.STREAM_UNARY. - - Args: - request_iterator: An iterator of request values appropriate for the RPC - method described by this RpcMethodServiceDescription. - context: An RpcContext object for the RPC. - - Returns: - A response value appropriate for the RPC method described by this - RpcMethodServiceDescription. - """ - raise NotImplementedError() - - @abc.abstractmethod - def service_stream_stream(self, request_iterator, context): - """Carries out this RPC. - - This method may only be called if the cardinality of this - RpcMethodServiceDescription is Cardinality.STREAM_STREAM. - - Args: - request_iterator: An iterator of request values appropriate for the RPC - method described by this RpcMethodServiceDescription. - context: An RpcContext object for the RPC. - - Yields: - Zero or more response values appropriate for the RPC method described by - this RpcMethodServiceDescription. - """ - raise NotImplementedError() - - -class Stub(object): - """A stub with callable RPC method names for attributes. - - Instances of this type are context managers and only afford RPC invocation - when used in context. - - Instances of this type, when used in context, respond to attribute access - as follows: if the requested attribute is the name of a unary-unary RPC - method, the value of the attribute will be a UnaryUnarySyncAsync with which - to invoke the RPC method. If the requested attribute is the name of a - unary-stream RPC method, the value of the attribute will be a callable taking - a request object and a timeout parameter and returning a CancellableIterator - that yields the response values of the RPC. If the requested attribute is the - name of a stream-unary RPC method, the value of the attribute will be a - StreamUnarySyncAsync with which to invoke the RPC method. If the requested - attribute is the name of a stream-stream RPC method, the value of the - attribute will be a callable taking an iterator of request objects and a - timeout and returning a CancellableIterator that yields the response values - of the RPC. - - In all cases indication of abortion is indicated by raising of - exceptions.RpcError, exceptions.CancellationError, - and exceptions.ExpirationError. - """ - __metaclass__ = abc.ABCMeta - - -class Server(activated.Activated): - """A GRPC Server.""" - __metaclass__ = abc.ABCMeta - - @abc.abstractmethod - def port(self): - """Reports the port on which the server is serving. - - This method may only be called while the server is activated. - - Returns: - The port on which the server is serving. - """ - raise NotImplementedError() diff --git a/src/python/src/grpc/early_adopter/utilities.py b/src/python/src/grpc/early_adopter/utilities.py deleted file mode 100644 index da8ef825aa..0000000000 --- a/src/python/src/grpc/early_adopter/utilities.py +++ /dev/null @@ -1,269 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Utilities for use with GRPC.""" - -from grpc.early_adopter import interfaces - - -class _RpcMethodDescription( - interfaces.RpcMethodInvocationDescription, - interfaces.RpcMethodServiceDescription): - - def __init__( - self, cardinality, unary_unary, unary_stream, stream_unary, - stream_stream, request_serializer, request_deserializer, - response_serializer, response_deserializer): - self._cardinality = cardinality - self._unary_unary = unary_unary - self._unary_stream = unary_stream - self._stream_unary = stream_unary - self._stream_stream = stream_stream - self._request_serializer = request_serializer - self._request_deserializer = request_deserializer - self._response_serializer = response_serializer - self._response_deserializer = response_deserializer - - def cardinality(self): - """See interfaces.RpcMethodDescription.cardinality for specification.""" - return self._cardinality - - def serialize_request(self, request): - """See interfaces.RpcMethodInvocationDescription.serialize_request.""" - return self._request_serializer(request) - - def deserialize_request(self, serialized_request): - """See interfaces.RpcMethodServiceDescription.deserialize_request.""" - return self._request_deserializer(serialized_request) - - def serialize_response(self, response): - """See interfaces.RpcMethodServiceDescription.serialize_response.""" - return self._response_serializer(response) - - def deserialize_response(self, serialized_response): - """See interfaces.RpcMethodInvocationDescription.deserialize_response.""" - return self._response_deserializer(serialized_response) - - def service_unary_unary(self, request, context): - """See interfaces.RpcMethodServiceDescription.service_unary_unary.""" - return self._unary_unary(request, context) - - def service_unary_stream(self, request, context): - """See interfaces.RpcMethodServiceDescription.service_unary_stream.""" - return self._unary_stream(request, context) - - def service_stream_unary(self, request_iterator, context): - """See interfaces.RpcMethodServiceDescription.service_stream_unary.""" - return self._stream_unary(request_iterator, context) - - def service_stream_stream(self, request_iterator, context): - """See interfaces.RpcMethodServiceDescription.service_stream_stream.""" - return self._stream_stream(request_iterator, context) - - -def unary_unary_invocation_description( - request_serializer, response_deserializer): - """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. - - Args: - request_serializer: A callable that when called on a request - value returns a bytestring corresponding to that value. - response_deserializer: A callable that when called on a - bytestring returns the response value corresponding to - that bytestring. - - Returns: - An interfaces.RpcMethodInvocationDescription constructed from the given - arguments representing a unary-request/unary-response RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.UNARY_UNARY, None, None, None, None, - request_serializer, None, None, response_deserializer) - - -def unary_stream_invocation_description( - request_serializer, response_deserializer): - """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. - - Args: - request_serializer: A callable that when called on a request - value returns a bytestring corresponding to that value. - response_deserializer: A callable that when called on a - bytestring returns the response value corresponding to - that bytestring. - - Returns: - An interfaces.RpcMethodInvocationDescription constructed from the given - arguments representing a unary-request/streaming-response RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.UNARY_STREAM, None, None, None, None, - request_serializer, None, None, response_deserializer) - - -def stream_unary_invocation_description( - request_serializer, response_deserializer): - """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. - - Args: - request_serializer: A callable that when called on a request - value returns a bytestring corresponding to that value. - response_deserializer: A callable that when called on a - bytestring returns the response value corresponding to - that bytestring. - - Returns: - An interfaces.RpcMethodInvocationDescription constructed from the given - arguments representing a streaming-request/unary-response RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.STREAM_UNARY, None, None, None, None, - request_serializer, None, None, response_deserializer) - - -def stream_stream_invocation_description( - request_serializer, response_deserializer): - """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. - - Args: - request_serializer: A callable that when called on a request - value returns a bytestring corresponding to that value. - response_deserializer: A callable that when called on a - bytestring returns the response value corresponding to - that bytestring. - - Returns: - An interfaces.RpcMethodInvocationDescription constructed from the given - arguments representing a streaming-request/streaming-response RPC - method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.STREAM_STREAM, None, None, None, None, - request_serializer, None, None, response_deserializer) - - -def unary_unary_service_description( - behavior, request_deserializer, response_serializer): - """Creates an interfaces.RpcMethodServiceDescription for the given behavior. - - Args: - behavior: A callable that implements a unary-unary RPC - method that accepts a single request and an interfaces.RpcContext and - returns a single response. - request_deserializer: A callable that when called on a - bytestring returns the request value corresponding to that - bytestring. - response_serializer: A callable that when called on a - response value returns the bytestring corresponding to - that value. - - Returns: - An interfaces.RpcMethodServiceDescription constructed from the given - arguments representing a unary-request/unary-response RPC - method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.UNARY_UNARY, behavior, None, None, None, - None, request_deserializer, response_serializer, None) - - -def unary_stream_service_description( - behavior, request_deserializer, response_serializer): - """Creates an interfaces.RpcMethodServiceDescription for the given behavior. - - Args: - behavior: A callable that implements a unary-stream RPC - method that accepts a single request and an interfaces.RpcContext - and returns an iterator of zero or more responses. - request_deserializer: A callable that when called on a - bytestring returns the request value corresponding to that - bytestring. - response_serializer: A callable that when called on a - response value returns the bytestring corresponding to - that value. - - Returns: - An interfaces.RpcMethodServiceDescription constructed from the given - arguments representing a unary-request/streaming-response - RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.UNARY_STREAM, None, behavior, None, None, - None, request_deserializer, response_serializer, None) - - -def stream_unary_service_description( - behavior, request_deserializer, response_serializer): - """Creates an interfaces.RpcMethodServiceDescription for the given behavior. - - Args: - behavior: A callable that implements a stream-unary RPC - method that accepts an iterator of zero or more requests - and an interfaces.RpcContext and returns a single response. - request_deserializer: A callable that when called on a - bytestring returns the request value corresponding to that - bytestring. - response_serializer: A callable that when called on a - response value returns the bytestring corresponding to - that value. - - Returns: - An interfaces.RpcMethodServiceDescription constructed from the given - arguments representing a streaming-request/unary-response - RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.STREAM_UNARY, None, None, behavior, None, - None, request_deserializer, response_serializer, None) - - -def stream_stream_service_description( - behavior, request_deserializer, response_serializer): - """Creates an interfaces.RpcMethodServiceDescription for the given behavior. - - Args: - behavior: A callable that implements a stream-stream RPC - method that accepts an iterator of zero or more requests - and an interfaces.RpcContext and returns an iterator of - zero or more responses. - request_deserializer: A callable that when called on a - bytestring returns the request value corresponding to that - bytestring. - response_serializer: A callable that when called on a - response value returns the bytestring corresponding to - that value. - - Returns: - An interfaces.RpcMethodServiceDescription constructed from the given - arguments representing a - streaming-request/streaming-response RPC method. - """ - return _RpcMethodDescription( - interfaces.Cardinality.STREAM_STREAM, None, None, None, behavior, - None, request_deserializer, response_serializer, None) diff --git a/src/python/src/grpc/framework/alpha/__init__.py b/src/python/src/grpc/framework/alpha/__init__.py new file mode 100644 index 0000000000..b89398809f --- /dev/null +++ b/src/python/src/grpc/framework/alpha/__init__.py @@ -0,0 +1,28 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/python/src/grpc/framework/alpha/_face_utilities.py b/src/python/src/grpc/framework/alpha/_face_utilities.py new file mode 100644 index 0000000000..fb0cfe426d --- /dev/null +++ b/src/python/src/grpc/framework/alpha/_face_utilities.py @@ -0,0 +1,183 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import abc +import collections + +# face_interfaces is referenced from specification in this module. +from grpc.framework.common import cardinality +from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import +from grpc.framework.face import utilities as face_utilities +from grpc.framework.alpha import _reexport +from grpc.framework.alpha import interfaces + + +def _qualified_name(service_name, method_name): + return '/%s/%s' % (service_name, method_name) + + +# TODO(nathaniel): This structure is getting bloated; it could be shrunk if +# implementations._Stub used a generic rather than a dynamic underlying +# face-layer stub. +class InvocationBreakdown(object): + """An intermediate representation of invocation-side views of RPC methods. + + Attributes: + cardinalities: A dictionary from RPC method name to interfaces.Cardinality + value. + qualified_names: A dictionary from unqualified RPC method name to + service-qualified RPC method name. + face_cardinalities: A dictionary from service-qualified RPC method name to + to cardinality.Cardinality value. + request_serializers: A dictionary from service-qualified RPC method name to + callable behavior to be used serializing request values for the RPC. + response_deserializers: A dictionary from service-qualified RPC method name + to callable behavior to be used deserializing response values for the + RPC. + """ + __metaclass__ = abc.ABCMeta + + +class _EasyInvocationBreakdown( + InvocationBreakdown, + collections.namedtuple( + '_EasyInvocationBreakdown', + ('cardinalities', 'qualified_names', 'face_cardinalities', + 'request_serializers', 'response_deserializers'))): + pass + + +class ServiceBreakdown(object): + """An intermediate representation of service-side views of RPC methods. + + Attributes: + implementations: A dictionary from service-qualified RPC method name to + face_interfaces.MethodImplementation implementing the RPC method. + request_deserializers: A dictionary from service-qualified RPC method name + to callable behavior to be used deserializing request values for the RPC. + response_serializers: A dictionary from service-qualified RPC method name + to callable behavior to be used serializing response values for the RPC. + """ + __metaclass__ = abc.ABCMeta + + +class _EasyServiceBreakdown( + ServiceBreakdown, + collections.namedtuple( + '_EasyServiceBreakdown', + ('implementations', 'request_deserializers', 'response_serializers'))): + pass + + +def break_down_invocation(service_name, method_descriptions): + """Derives an InvocationBreakdown from several RPC method descriptions. + + Args: + service_name: The package-qualified full name of the service. + method_descriptions: A dictionary from RPC method name to + interfaces.RpcMethodInvocationDescription describing the RPCs. + + Returns: + An InvocationBreakdown corresponding to the given method descriptions. + """ + cardinalities = {} + qualified_names = {} + face_cardinalities = {} + request_serializers = {} + response_deserializers = {} + for name, method_description in method_descriptions.iteritems(): + qualified_name = _qualified_name(service_name, name) + method_cardinality = method_description.cardinality() + cardinalities[name] = method_description.cardinality() + qualified_names[name] = qualified_name + face_cardinalities[qualified_name] = _reexport.common_cardinality( + method_cardinality) + request_serializers[qualified_name] = method_description.serialize_request + response_deserializers[qualified_name] = ( + method_description.deserialize_response) + return _EasyInvocationBreakdown( + cardinalities, qualified_names, face_cardinalities, request_serializers, + response_deserializers) + + +def break_down_service(service_name, method_descriptions): + """Derives a ServiceBreakdown from several RPC method descriptions. + + Args: + method_descriptions: A dictionary from RPC method name to + interfaces.RpcMethodServiceDescription describing the RPCs. + + Returns: + A ServiceBreakdown corresponding to the given method descriptions. + """ + implementations = {} + request_deserializers = {} + response_serializers = {} + for name, method_description in method_descriptions.iteritems(): + qualified_name = _qualified_name(service_name, name) + method_cardinality = method_description.cardinality() + if method_cardinality is interfaces.Cardinality.UNARY_UNARY: + def service( + request, face_rpc_context, + service_behavior=method_description.service_unary_unary): + return service_behavior( + request, _reexport.rpc_context(face_rpc_context)) + implementations[qualified_name] = face_utilities.unary_unary_inline( + service) + elif method_cardinality is interfaces.Cardinality.UNARY_STREAM: + def service( + request, face_rpc_context, + service_behavior=method_description.service_unary_stream): + return service_behavior( + request, _reexport.rpc_context(face_rpc_context)) + implementations[qualified_name] = face_utilities.unary_stream_inline( + service) + elif method_cardinality is interfaces.Cardinality.STREAM_UNARY: + def service( + request_iterator, face_rpc_context, + service_behavior=method_description.service_stream_unary): + return service_behavior( + request_iterator, _reexport.rpc_context(face_rpc_context)) + implementations[qualified_name] = face_utilities.stream_unary_inline( + service) + elif method_cardinality is interfaces.Cardinality.STREAM_STREAM: + def service( + request_iterator, face_rpc_context, + service_behavior=method_description.service_stream_stream): + return service_behavior( + request_iterator, _reexport.rpc_context(face_rpc_context)) + implementations[qualified_name] = face_utilities.stream_stream_inline( + service) + request_deserializers[qualified_name] = ( + method_description.deserialize_request) + response_serializers[qualified_name] = ( + method_description.serialize_response) + + return _EasyServiceBreakdown( + implementations, request_deserializers, response_serializers) diff --git a/src/python/src/grpc/framework/alpha/_reexport.py b/src/python/src/grpc/framework/alpha/_reexport.py new file mode 100644 index 0000000000..198cb95ad5 --- /dev/null +++ b/src/python/src/grpc/framework/alpha/_reexport.py @@ -0,0 +1,203 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from grpc.framework.common import cardinality +from grpc.framework.face import exceptions as face_exceptions +from grpc.framework.face import interfaces as face_interfaces +from grpc.framework.foundation import future +from grpc.framework.alpha import exceptions +from grpc.framework.alpha import interfaces + +_EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY = { + interfaces.Cardinality.UNARY_UNARY: cardinality.Cardinality.UNARY_UNARY, + interfaces.Cardinality.UNARY_STREAM: cardinality.Cardinality.UNARY_STREAM, + interfaces.Cardinality.STREAM_UNARY: cardinality.Cardinality.STREAM_UNARY, + interfaces.Cardinality.STREAM_STREAM: cardinality.Cardinality.STREAM_STREAM, +} + +_ABORTION_REEXPORT = { + face_interfaces.Abortion.CANCELLED: interfaces.Abortion.CANCELLED, + face_interfaces.Abortion.EXPIRED: interfaces.Abortion.EXPIRED, + face_interfaces.Abortion.NETWORK_FAILURE: + interfaces.Abortion.NETWORK_FAILURE, + face_interfaces.Abortion.SERVICED_FAILURE: + interfaces.Abortion.SERVICED_FAILURE, + face_interfaces.Abortion.SERVICER_FAILURE: + interfaces.Abortion.SERVICER_FAILURE, +} + + +class _RpcError(exceptions.RpcError): + pass + + +def _reexport_error(face_rpc_error): + if isinstance(face_rpc_error, face_exceptions.CancellationError): + return exceptions.CancellationError() + elif isinstance(face_rpc_error, face_exceptions.ExpirationError): + return exceptions.ExpirationError() + else: + return _RpcError() + + +def _as_face_abortion_callback(abortion_callback): + def face_abortion_callback(face_abortion): + abortion_callback(_ABORTION_REEXPORT[face_abortion]) + return face_abortion_callback + + +class _ReexportedFuture(future.Future): + + def __init__(self, face_future): + self._face_future = face_future + + def cancel(self): + return self._face_future.cancel() + + def cancelled(self): + return self._face_future.cancelled() + + def running(self): + return self._face_future.running() + + def done(self): + return self._face_future.done() + + def result(self, timeout=None): + try: + return self._face_future.result(timeout=timeout) + except face_exceptions.RpcError as e: + raise _reexport_error(e) + + def exception(self, timeout=None): + face_error = self._face_future.exception(timeout=timeout) + return None if face_error is None else _reexport_error(face_error) + + def traceback(self, timeout=None): + return self._face_future.traceback(timeout=timeout) + + def add_done_callback(self, fn): + self._face_future.add_done_callback(lambda unused_face_future: fn(self)) + + +def _call_reexporting_errors(behavior, *args, **kwargs): + try: + return behavior(*args, **kwargs) + except face_exceptions.RpcError as e: + raise _reexport_error(e) + + +def _reexported_future(face_future): + return _ReexportedFuture(face_future) + + +class _CancellableIterator(interfaces.CancellableIterator): + + def __init__(self, face_cancellable_iterator): + self._face_cancellable_iterator = face_cancellable_iterator + + def __iter__(self): + return self + + def next(self): + return _call_reexporting_errors(self._face_cancellable_iterator.next) + + def cancel(self): + self._face_cancellable_iterator.cancel() + + +class _RpcContext(interfaces.RpcContext): + + def __init__(self, face_rpc_context): + self._face_rpc_context = face_rpc_context + + def is_active(self): + return self._face_rpc_context.is_active() + + def time_remaining(self): + return self._face_rpc_context.time_remaining() + + def add_abortion_callback(self, abortion_callback): + self._face_rpc_context.add_abortion_callback( + _as_face_abortion_callback(abortion_callback)) + + +class _UnaryUnarySyncAsync(interfaces.UnaryUnarySyncAsync): + + def __init__(self, face_unary_unary_multi_callable): + self._underlying = face_unary_unary_multi_callable + + def __call__(self, request, timeout): + return _call_reexporting_errors( + self._underlying, request, timeout) + + def async(self, request, timeout): + return _ReexportedFuture(self._underlying.future(request, timeout)) + + +class _StreamUnarySyncAsync(interfaces.StreamUnarySyncAsync): + + def __init__(self, face_stream_unary_multi_callable): + self._underlying = face_stream_unary_multi_callable + + def __call__(self, request_iterator, timeout): + return _call_reexporting_errors( + self._underlying, request_iterator, timeout) + + def async(self, request_iterator, timeout): + return _ReexportedFuture(self._underlying.future(request_iterator, timeout)) + + +def common_cardinality(early_adopter_cardinality): + return _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[ + early_adopter_cardinality] + + +def common_cardinalities(early_adopter_cardinalities): + common_cardinalities = {} + for name, early_adopter_cardinality in early_adopter_cardinalities.iteritems(): + common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[ + early_adopter_cardinality] + return common_cardinalities + + +def rpc_context(face_rpc_context): + return _RpcContext(face_rpc_context) + + +def cancellable_iterator(face_cancellable_iterator): + return _CancellableIterator(face_cancellable_iterator) + + +def unary_unary_sync_async(face_unary_unary_multi_callable): + return _UnaryUnarySyncAsync(face_unary_unary_multi_callable) + + +def stream_unary_sync_async(face_stream_unary_multi_callable): + return _StreamUnarySyncAsync(face_stream_unary_multi_callable) diff --git a/src/python/src/grpc/framework/alpha/exceptions.py b/src/python/src/grpc/framework/alpha/exceptions.py new file mode 100644 index 0000000000..5234d3b91c --- /dev/null +++ b/src/python/src/grpc/framework/alpha/exceptions.py @@ -0,0 +1,48 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Exceptions raised by GRPC. + +Only GRPC should instantiate and raise these exceptions. +""" + +import abc + + +class RpcError(Exception): + """Common super type for all exceptions raised by GRPC.""" + __metaclass__ = abc.ABCMeta + + +class CancellationError(RpcError): + """Indicates that an RPC has been cancelled.""" + + +class ExpirationError(RpcError): + """Indicates that an RPC has expired ("timed out").""" diff --git a/src/python/src/grpc/framework/alpha/interfaces.py b/src/python/src/grpc/framework/alpha/interfaces.py new file mode 100644 index 0000000000..8380567c97 --- /dev/null +++ b/src/python/src/grpc/framework/alpha/interfaces.py @@ -0,0 +1,388 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Interfaces of GRPC.""" + +import abc +import enum + +# exceptions is referenced from specification in this module. +from grpc.framework.alpha import exceptions # pylint: disable=unused-import +from grpc.framework.foundation import activated +from grpc.framework.foundation import future + + +@enum.unique +class Cardinality(enum.Enum): + """Constants for the four cardinalities of RPC.""" + + UNARY_UNARY = 'request-unary/response-unary' + UNARY_STREAM = 'request-unary/response-streaming' + STREAM_UNARY = 'request-streaming/response-unary' + STREAM_STREAM = 'request-streaming/response-streaming' + + +@enum.unique +class Abortion(enum.Enum): + """Categories of RPC abortion.""" + + CANCELLED = 'cancelled' + EXPIRED = 'expired' + NETWORK_FAILURE = 'network failure' + SERVICED_FAILURE = 'serviced failure' + SERVICER_FAILURE = 'servicer failure' + + +class CancellableIterator(object): + """Implements the Iterator protocol and affords a cancel method.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __iter__(self): + """Returns the self object in accordance with the Iterator protocol.""" + raise NotImplementedError() + + @abc.abstractmethod + def next(self): + """Returns a value or raises StopIteration per the Iterator protocol.""" + raise NotImplementedError() + + @abc.abstractmethod + def cancel(self): + """Requests cancellation of whatever computation underlies this iterator.""" + raise NotImplementedError() + + +class RpcContext(object): + """Provides RPC-related information and action.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def is_active(self): + """Describes whether the RPC is active or has terminated.""" + raise NotImplementedError() + + @abc.abstractmethod + def time_remaining(self): + """Describes the length of allowed time remaining for the RPC. + Returns: + A nonnegative float indicating the length of allowed time in seconds + remaining for the RPC to complete before it is considered to have timed + out. + """ + raise NotImplementedError() + + @abc.abstractmethod + def add_abortion_callback(self, abortion_callback): + """Registers a callback to be called if the RPC is aborted. + Args: + abortion_callback: A callable to be called and passed an Abortion value + in the event of RPC abortion. + """ + raise NotImplementedError() + + +class UnaryUnarySyncAsync(object): + """Affords invoking a unary-unary RPC synchronously or asynchronously. + Values implementing this interface are directly callable and present an + "async" method. Both calls take a request value and a numeric timeout. + Direct invocation of a value of this type invokes its associated RPC and + blocks until the RPC's response is available. Calling the "async" method + of a value of this type invokes its associated RPC and immediately returns a + future.Future bound to the asynchronous execution of the RPC. + """ + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __call__(self, request, timeout): + """Synchronously invokes the underlying RPC. + Args: + request: The request value for the RPC. + timeout: A duration of time in seconds to allow for the RPC. + Returns: + The response value for the RPC. + Raises: + exceptions.RpcError: Indicating that the RPC was aborted. + """ + raise NotImplementedError() + + @abc.abstractmethod + def async(self, request, timeout): + """Asynchronously invokes the underlying RPC. + Args: + request: The request value for the RPC. + timeout: A duration of time in seconds to allow for the RPC. + Returns: + A future.Future representing the RPC. In the event of RPC completion, the + returned Future's result value will be the response value of the RPC. + In the event of RPC abortion, the returned Future's exception value + will be an exceptions.RpcError. + """ + raise NotImplementedError() + + +class StreamUnarySyncAsync(object): + """Affords invoking a stream-unary RPC synchronously or asynchronously. + Values implementing this interface are directly callable and present an + "async" method. Both calls take an iterator of request values and a numeric + timeout. Direct invocation of a value of this type invokes its associated RPC + and blocks until the RPC's response is available. Calling the "async" method + of a value of this type invokes its associated RPC and immediately returns a + future.Future bound to the asynchronous execution of the RPC. + """ + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __call__(self, request_iterator, timeout): + """Synchronously invokes the underlying RPC. + + Args: + request_iterator: An iterator that yields request values for the RPC. + timeout: A duration of time in seconds to allow for the RPC. + + Returns: + The response value for the RPC. + + Raises: + exceptions.RpcError: Indicating that the RPC was aborted. + """ + raise NotImplementedError() + + @abc.abstractmethod + def async(self, request_iterator, timeout): + """Asynchronously invokes the underlying RPC. + + Args: + request_iterator: An iterator that yields request values for the RPC. + timeout: A duration of time in seconds to allow for the RPC. + + Returns: + A future.Future representing the RPC. In the event of RPC completion, the + returned Future's result value will be the response value of the RPC. + In the event of RPC abortion, the returned Future's exception value + will be an exceptions.RpcError. + """ + raise NotImplementedError() + + +class RpcMethodDescription(object): + """A type for the common aspects of RPC method descriptions.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def cardinality(self): + """Identifies the cardinality of this RpcMethodDescription. + + Returns: + A Cardinality value identifying whether or not this + RpcMethodDescription is request-unary or request-streaming and + whether or not it is response-unary or response-streaming. + """ + raise NotImplementedError() + + +class RpcMethodInvocationDescription(RpcMethodDescription): + """Invocation-side description of an RPC method.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def serialize_request(self, request): + """Serializes a request value. + + Args: + request: A request value appropriate for the RPC method described by this + RpcMethodInvocationDescription. + + Returns: + The serialization of the given request value as a + bytestring. + """ + raise NotImplementedError() + + @abc.abstractmethod + def deserialize_response(self, serialized_response): + """Deserializes a response value. + + Args: + serialized_response: A bytestring that is the serialization of a response + value appropriate for the RPC method described by this + RpcMethodInvocationDescription. + + Returns: + A response value corresponding to the given bytestring. + """ + raise NotImplementedError() + + +class RpcMethodServiceDescription(RpcMethodDescription): + """Service-side description of an RPC method.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def deserialize_request(self, serialized_request): + """Deserializes a request value. + + Args: + serialized_request: A bytestring that is the serialization of a request + value appropriate for the RPC method described by this + RpcMethodServiceDescription. + + Returns: + A request value corresponding to the given bytestring. + """ + raise NotImplementedError() + + @abc.abstractmethod + def serialize_response(self, response): + """Serializes a response value. + + Args: + response: A response value appropriate for the RPC method described by + this RpcMethodServiceDescription. + + Returns: + The serialization of the given response value as a + bytestring. + """ + raise NotImplementedError() + + @abc.abstractmethod + def service_unary_unary(self, request, context): + """Carries out this RPC. + + This method may only be called if the cardinality of this + RpcMethodServiceDescription is Cardinality.UNARY_UNARY. + + Args: + request: A request value appropriate for the RPC method described by this + RpcMethodServiceDescription. + context: An RpcContext object for the RPC. + + Returns: + A response value appropriate for the RPC method described by this + RpcMethodServiceDescription. + """ + raise NotImplementedError() + + @abc.abstractmethod + def service_unary_stream(self, request, context): + """Carries out this RPC. + + This method may only be called if the cardinality of this + RpcMethodServiceDescription is Cardinality.UNARY_STREAM. + + Args: + request: A request value appropriate for the RPC method described by this + RpcMethodServiceDescription. + context: An RpcContext object for the RPC. + + Yields: + Zero or more response values appropriate for the RPC method described by + this RpcMethodServiceDescription. + """ + raise NotImplementedError() + + @abc.abstractmethod + def service_stream_unary(self, request_iterator, context): + """Carries out this RPC. + + This method may only be called if the cardinality of this + RpcMethodServiceDescription is Cardinality.STREAM_UNARY. + + Args: + request_iterator: An iterator of request values appropriate for the RPC + method described by this RpcMethodServiceDescription. + context: An RpcContext object for the RPC. + + Returns: + A response value appropriate for the RPC method described by this + RpcMethodServiceDescription. + """ + raise NotImplementedError() + + @abc.abstractmethod + def service_stream_stream(self, request_iterator, context): + """Carries out this RPC. + + This method may only be called if the cardinality of this + RpcMethodServiceDescription is Cardinality.STREAM_STREAM. + + Args: + request_iterator: An iterator of request values appropriate for the RPC + method described by this RpcMethodServiceDescription. + context: An RpcContext object for the RPC. + + Yields: + Zero or more response values appropriate for the RPC method described by + this RpcMethodServiceDescription. + """ + raise NotImplementedError() + + +class Stub(object): + """A stub with callable RPC method names for attributes. + + Instances of this type are context managers and only afford RPC invocation + when used in context. + + Instances of this type, when used in context, respond to attribute access + as follows: if the requested attribute is the name of a unary-unary RPC + method, the value of the attribute will be a UnaryUnarySyncAsync with which + to invoke the RPC method. If the requested attribute is the name of a + unary-stream RPC method, the value of the attribute will be a callable taking + a request object and a timeout parameter and returning a CancellableIterator + that yields the response values of the RPC. If the requested attribute is the + name of a stream-unary RPC method, the value of the attribute will be a + StreamUnarySyncAsync with which to invoke the RPC method. If the requested + attribute is the name of a stream-stream RPC method, the value of the + attribute will be a callable taking an iterator of request objects and a + timeout and returning a CancellableIterator that yields the response values + of the RPC. + + In all cases indication of abortion is indicated by raising of + exceptions.RpcError, exceptions.CancellationError, + and exceptions.ExpirationError. + """ + __metaclass__ = abc.ABCMeta + + +class Server(activated.Activated): + """A GRPC Server.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def port(self): + """Reports the port on which the server is serving. + + This method may only be called while the server is activated. + + Returns: + The port on which the server is serving. + """ + raise NotImplementedError() diff --git a/src/python/src/grpc/framework/alpha/utilities.py b/src/python/src/grpc/framework/alpha/utilities.py new file mode 100644 index 0000000000..7d7f78f5e4 --- /dev/null +++ b/src/python/src/grpc/framework/alpha/utilities.py @@ -0,0 +1,269 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Utilities for use with GRPC.""" + +from grpc.framework.alpha import interfaces + + +class _RpcMethodDescription( + interfaces.RpcMethodInvocationDescription, + interfaces.RpcMethodServiceDescription): + + def __init__( + self, cardinality, unary_unary, unary_stream, stream_unary, + stream_stream, request_serializer, request_deserializer, + response_serializer, response_deserializer): + self._cardinality = cardinality + self._unary_unary = unary_unary + self._unary_stream = unary_stream + self._stream_unary = stream_unary + self._stream_stream = stream_stream + self._request_serializer = request_serializer + self._request_deserializer = request_deserializer + self._response_serializer = response_serializer + self._response_deserializer = response_deserializer + + def cardinality(self): + """See interfaces.RpcMethodDescription.cardinality for specification.""" + return self._cardinality + + def serialize_request(self, request): + """See interfaces.RpcMethodInvocationDescription.serialize_request.""" + return self._request_serializer(request) + + def deserialize_request(self, serialized_request): + """See interfaces.RpcMethodServiceDescription.deserialize_request.""" + return self._request_deserializer(serialized_request) + + def serialize_response(self, response): + """See interfaces.RpcMethodServiceDescription.serialize_response.""" + return self._response_serializer(response) + + def deserialize_response(self, serialized_response): + """See interfaces.RpcMethodInvocationDescription.deserialize_response.""" + return self._response_deserializer(serialized_response) + + def service_unary_unary(self, request, context): + """See interfaces.RpcMethodServiceDescription.service_unary_unary.""" + return self._unary_unary(request, context) + + def service_unary_stream(self, request, context): + """See interfaces.RpcMethodServiceDescription.service_unary_stream.""" + return self._unary_stream(request, context) + + def service_stream_unary(self, request_iterator, context): + """See interfaces.RpcMethodServiceDescription.service_stream_unary.""" + return self._stream_unary(request_iterator, context) + + def service_stream_stream(self, request_iterator, context): + """See interfaces.RpcMethodServiceDescription.service_stream_stream.""" + return self._stream_stream(request_iterator, context) + + +def unary_unary_invocation_description( + request_serializer, response_deserializer): + """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. + + Args: + request_serializer: A callable that when called on a request + value returns a bytestring corresponding to that value. + response_deserializer: A callable that when called on a + bytestring returns the response value corresponding to + that bytestring. + + Returns: + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a unary-request/unary-response RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.UNARY_UNARY, None, None, None, None, + request_serializer, None, None, response_deserializer) + + +def unary_stream_invocation_description( + request_serializer, response_deserializer): + """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. + + Args: + request_serializer: A callable that when called on a request + value returns a bytestring corresponding to that value. + response_deserializer: A callable that when called on a + bytestring returns the response value corresponding to + that bytestring. + + Returns: + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a unary-request/streaming-response RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.UNARY_STREAM, None, None, None, None, + request_serializer, None, None, response_deserializer) + + +def stream_unary_invocation_description( + request_serializer, response_deserializer): + """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. + + Args: + request_serializer: A callable that when called on a request + value returns a bytestring corresponding to that value. + response_deserializer: A callable that when called on a + bytestring returns the response value corresponding to + that bytestring. + + Returns: + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a streaming-request/unary-response RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.STREAM_UNARY, None, None, None, None, + request_serializer, None, None, response_deserializer) + + +def stream_stream_invocation_description( + request_serializer, response_deserializer): + """Creates an interfaces.RpcMethodInvocationDescription for an RPC method. + + Args: + request_serializer: A callable that when called on a request + value returns a bytestring corresponding to that value. + response_deserializer: A callable that when called on a + bytestring returns the response value corresponding to + that bytestring. + + Returns: + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a streaming-request/streaming-response RPC + method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.STREAM_STREAM, None, None, None, None, + request_serializer, None, None, response_deserializer) + + +def unary_unary_service_description( + behavior, request_deserializer, response_serializer): + """Creates an interfaces.RpcMethodServiceDescription for the given behavior. + + Args: + behavior: A callable that implements a unary-unary RPC + method that accepts a single request and an interfaces.RpcContext and + returns a single response. + request_deserializer: A callable that when called on a + bytestring returns the request value corresponding to that + bytestring. + response_serializer: A callable that when called on a + response value returns the bytestring corresponding to + that value. + + Returns: + An interfaces.RpcMethodServiceDescription constructed from the given + arguments representing a unary-request/unary-response RPC + method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.UNARY_UNARY, behavior, None, None, None, + None, request_deserializer, response_serializer, None) + + +def unary_stream_service_description( + behavior, request_deserializer, response_serializer): + """Creates an interfaces.RpcMethodServiceDescription for the given behavior. + + Args: + behavior: A callable that implements a unary-stream RPC + method that accepts a single request and an interfaces.RpcContext + and returns an iterator of zero or more responses. + request_deserializer: A callable that when called on a + bytestring returns the request value corresponding to that + bytestring. + response_serializer: A callable that when called on a + response value returns the bytestring corresponding to + that value. + + Returns: + An interfaces.RpcMethodServiceDescription constructed from the given + arguments representing a unary-request/streaming-response + RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.UNARY_STREAM, None, behavior, None, None, + None, request_deserializer, response_serializer, None) + + +def stream_unary_service_description( + behavior, request_deserializer, response_serializer): + """Creates an interfaces.RpcMethodServiceDescription for the given behavior. + + Args: + behavior: A callable that implements a stream-unary RPC + method that accepts an iterator of zero or more requests + and an interfaces.RpcContext and returns a single response. + request_deserializer: A callable that when called on a + bytestring returns the request value corresponding to that + bytestring. + response_serializer: A callable that when called on a + response value returns the bytestring corresponding to + that value. + + Returns: + An interfaces.RpcMethodServiceDescription constructed from the given + arguments representing a streaming-request/unary-response + RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.STREAM_UNARY, None, None, behavior, None, + None, request_deserializer, response_serializer, None) + + +def stream_stream_service_description( + behavior, request_deserializer, response_serializer): + """Creates an interfaces.RpcMethodServiceDescription for the given behavior. + + Args: + behavior: A callable that implements a stream-stream RPC + method that accepts an iterator of zero or more requests + and an interfaces.RpcContext and returns an iterator of + zero or more responses. + request_deserializer: A callable that when called on a + bytestring returns the request value corresponding to that + bytestring. + response_serializer: A callable that when called on a + response value returns the bytestring corresponding to + that value. + + Returns: + An interfaces.RpcMethodServiceDescription constructed from the given + arguments representing a + streaming-request/streaming-response RPC method. + """ + return _RpcMethodDescription( + interfaces.Cardinality.STREAM_STREAM, None, None, None, behavior, + None, request_deserializer, response_serializer, None) diff --git a/src/python/src/setup.py b/src/python/src/setup.py index 63731212c7..bd70634b8f 100644 --- a/src/python/src/setup.py +++ b/src/python/src/setup.py @@ -64,6 +64,7 @@ _PACKAGES = ( 'grpc._junkdrawer', 'grpc.early_adopter', 'grpc.framework', + 'grpc.framework.alpha', 'grpc.framework.base', 'grpc.framework.common', 'grpc.framework.face', diff --git a/test/compiler/python_plugin_test.py b/test/compiler/python_plugin_test.py index 9cf3c624c0..3d2f117b0d 100644 --- a/test/compiler/python_plugin_test.py +++ b/test/compiler/python_plugin_test.py @@ -39,7 +39,7 @@ import tempfile import time import unittest -from grpc.early_adopter import exceptions +from grpc.framework.alpha import exceptions from grpc.framework.foundation import future # Identifiers of entities we expect to find in the generated module. -- cgit v1.2.3 From a4ac78c8ce23df5143487aa38c1bda2cd98228e6 Mon Sep 17 00:00:00 2001 From: David Klempner Date: Wed, 18 Mar 2015 14:20:53 -0700 Subject: Make metadata_test test_things_stick_around use fewer strings This test is quadratic in nstr and times out under tsan. --- test/core/transport/metadata_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index f345cebdb6..66b5407d3c 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -178,7 +178,7 @@ static void test_things_stick_around(void) { grpc_mdctx *ctx; int i, j; char *buffer; - int nstrs = 10000; + int nstrs = 1000; grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs); int *shuf = gpr_malloc(sizeof(int) * nstrs); grpc_mdstr *test; -- cgit v1.2.3 From cfd6073a66fda3db150998ef40dbbc76c198c02e Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Wed, 18 Mar 2015 16:27:43 -0700 Subject: Various Windows fixes. -) using dupenv_s instead of getenv_s and calling strdup ourselves. -) few impossible-to-obtain if checks. -) various signed/unsigned casting. -) using time_t instead of time32_t -) checking output of FormatMessage for failures. -) don't redefine _WIN32_WINNT without undefining it first. -) fixed msvc's interlocked casting. -) renamed AddPort to AddListeningPort. -) added protobuf's third_party includes to search path. -) added a missing definition for inet_ntop in mingw32. -) removed useless declarations. --- examples/pubsub/publisher_test.cc | 2 +- examples/pubsub/subscriber_test.cc | 2 +- include/grpc++/server.h | 2 +- include/grpc++/server_builder.h | 6 ++--- include/grpc/support/atm_win32.h | 26 +++++++++++++++------- src/core/iomgr/sockaddr_win32.h | 5 +++++ src/core/iomgr/tcp_server_windows.c | 3 --- src/core/iomgr/tcp_windows.c | 4 ++-- src/core/support/env_win32.c | 15 ++++++++----- src/core/support/file_win32.c | 2 +- src/core/support/log_win32.c | 8 ++++--- src/core/support/string_win32.c | 6 +++-- src/core/support/sync_win32.c | 1 + src/core/support/time_win32.c | 4 ++-- src/cpp/common/call.cc | 9 +++++--- src/cpp/server/server.cc | 3 ++- src/cpp/server/server_builder.cc | 8 +++---- src/csharp/Grpc.Core.Tests/ClientServerTest.cs | 6 ++--- src/csharp/Grpc.Core.Tests/ServerTest.cs | 2 +- src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs | 4 ++-- src/csharp/Grpc.Core/Server.cs | 8 +++---- .../Grpc.Examples.Tests/MathClientServerTests.cs | 2 +- .../InteropClientServerTest.cs | 2 +- .../Grpc.IntegrationTesting/InteropServer.cs | 4 ++-- test/cpp/end2end/async_end2end_test.cc | 2 +- test/cpp/end2end/end2end_test.cc | 2 +- test/cpp/end2end/generic_end2end_test.cc | 2 +- test/cpp/interop/server.cc | 2 +- test/cpp/qps/server.cc | 2 +- test/cpp/qps/server_async.cc | 2 +- test/cpp/qps/server_sync.cc | 2 +- test/cpp/qps/worker.cc | 2 +- vsprojects/vs2013/global.props | 2 +- 33 files changed, 88 insertions(+), 64 deletions(-) (limited to 'test') diff --git a/examples/pubsub/publisher_test.cc b/examples/pubsub/publisher_test.cc index f9b6bb3418..62442c7384 100644 --- a/examples/pubsub/publisher_test.cc +++ b/examples/pubsub/publisher_test.cc @@ -107,7 +107,7 @@ class PublisherTest : public ::testing::Test { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; ServerBuilder builder; - builder.AddPort(server_address_.str(), grpc::InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), grpc::InsecureServerCredentials()); builder.RegisterService(&service_); server_ = builder.BuildAndStart(); diff --git a/examples/pubsub/subscriber_test.cc b/examples/pubsub/subscriber_test.cc index 2d606336ad..b8dd1f9486 100644 --- a/examples/pubsub/subscriber_test.cc +++ b/examples/pubsub/subscriber_test.cc @@ -105,7 +105,7 @@ class SubscriberTest : public ::testing::Test { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; ServerBuilder builder; - builder.AddPort(server_address_.str(), grpc::InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), grpc::InsecureServerCredentials()); builder.RegisterService(&service_); server_ = builder.BuildAndStart(); diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 8cd0a4f668..bddb4f62aa 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -86,7 +86,7 @@ class Server GRPC_FINAL : private CallHook, bool RegisterAsyncService(AsynchronousService* service); void RegisterAsyncGenericService(AsyncGenericService* service); // Add a listening port. Can be called multiple times. - int AddPort(const grpc::string& addr, ServerCredentials* creds); + int AddListeningPort(const grpc::string& addr, ServerCredentials* creds); // Start the server. bool Start(); diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index c09c8fee52..9a9932ebe0 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -69,9 +69,9 @@ class ServerBuilder { void RegisterAsyncGenericService(AsyncGenericService* service); // Add a listening port. Can be called multiple times. - void AddPort(const grpc::string& addr, - std::shared_ptr creds, - int* selected_port = nullptr); + void AddListeningPort(const grpc::string& addr, + std::shared_ptr creds, + int* selected_port = nullptr); // Set the thread pool used for running appliation rpc handlers. // Does not take ownership. diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h index 8b5322488e..4a21b5b547 100644 --- a/include/grpc/support/atm_win32.h +++ b/include/grpc/support/atm_win32.h @@ -63,25 +63,31 @@ static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { /* InterlockedCompareExchangePointerNoFence() not available on vista or windows7 */ #ifdef GPR_ARCH_64 - return o == (gpr_atm)InterlockedCompareExchangeAcquire64(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeAcquire64((volatile LONGLONG *) p, + (LONGLONG) n, (LONGLONG) o); #else - return o == (gpr_atm)InterlockedCompareExchangeAcquire(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *) p, + (LONG) n, (LONG) o); #endif } static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { #ifdef GPR_ARCH_64 - return o == (gpr_atm)InterlockedCompareExchangeAcquire64(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeAcquire64((volatile LONGLONG) p, + (LONGLONG) n, (LONGLONG) o); #else - return o == (gpr_atm)InterlockedCompareExchangeAcquire(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *) p, + (LONG) n, (LONG) o); #endif } static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { #ifdef GPR_ARCH_64 - return o == (gpr_atm)InterlockedCompareExchangeRelease64(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeRelease64((volatile LONGLONG *) p, + (LONGLONG) n, (LONGLONG) o); #else - return o == (gpr_atm)InterlockedCompareExchangeRelease(p, n, o); + return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG *) p, + (LONG) n, (LONG) o); #endif } @@ -101,11 +107,15 @@ static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm *p, gpr_atm delta) { #ifdef GPR_ARCH_64 do { old = *p; - } while (old != (gpr_atm)InterlockedCompareExchange64(p, old + delta, old)); + } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *) p, + (LONGLONG) old + delta, + (LONGLONG) old)); #else do { old = *p; - } while (old != (gpr_atm)InterlockedCompareExchange(p, old + delta, old)); + } while (old != (gpr_atm)InterlockedCompareExchange((volatile LONG *) p, + (LONG) old + delta, + (LONG) old)); #endif return old; } diff --git a/src/core/iomgr/sockaddr_win32.h b/src/core/iomgr/sockaddr_win32.h index 3a5f27bb34..c0385ea614 100644 --- a/src/core/iomgr/sockaddr_win32.h +++ b/src/core/iomgr/sockaddr_win32.h @@ -38,4 +38,9 @@ #include #include +#ifdef __MINGW32__ +/* mingw seems to be missing that definition. */ +const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); +#endif + #endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H */ diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c index 59319da26d..0c3ab1dc91 100644 --- a/src/core/iomgr/tcp_server_windows.c +++ b/src/core/iomgr/tcp_server_windows.c @@ -53,9 +53,6 @@ #define INIT_PORT_CAP 2 #define MIN_SAFE_ACCEPT_QUEUE_SIZE 100 -static gpr_once s_init_max_accept_queue_size; -static int s_max_accept_queue_size; - /* one listening port */ typedef struct server_port { gpr_uint8 addresses[sizeof(struct sockaddr_in6) * 2 + 32]; diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c index 3efd69a71b..ec5496e7ee 100644 --- a/src/core/iomgr/tcp_windows.c +++ b/src/core/iomgr/tcp_windows.c @@ -172,7 +172,7 @@ static void win_notify_on_read(grpc_endpoint *ep, tcp->read_slice = gpr_slice_malloc(8192); buffer.len = GPR_SLICE_LENGTH(tcp->read_slice); - buffer.buf = GPR_SLICE_START_PTR(tcp->read_slice); + buffer.buf = (char *)GPR_SLICE_START_PTR(tcp->read_slice); gpr_log(GPR_DEBUG, "win_notify_on_read: calling WSARecv without overlap"); status = WSARecv(tcp->socket->socket, &buffer, 1, &bytes_read, &flags, @@ -284,7 +284,7 @@ static grpc_endpoint_write_status win_write(grpc_endpoint *ep, for (i = 0; i < tcp->write_slices.count; i++) { buffers[i].len = GPR_SLICE_LENGTH(tcp->write_slices.slices[i]); - buffers[i].buf = GPR_SLICE_START_PTR(tcp->write_slices.slices[i]); + buffers[i].buf = (char *)GPR_SLICE_START_PTR(tcp->write_slices.slices[i]); } gpr_log(GPR_DEBUG, "win_write: calling WSASend without overlap"); diff --git a/src/core/support/env_win32.c b/src/core/support/env_win32.c index 177cc36a30..9b4cd698ad 100644 --- a/src/core/support/env_win32.c +++ b/src/core/support/env_win32.c @@ -36,6 +36,7 @@ #ifdef GPR_WIN32 #include "src/core/support/env.h" +#include "src/core/support/string.h" #include @@ -43,14 +44,16 @@ #include char *gpr_getenv(const char *name) { - size_t required_size; + size_t size; char *result = NULL; + char *duplicated; + errno_t err; - getenv_s(&required_size, NULL, 0, name); - if (required_size == 0) return NULL; - result = gpr_malloc(required_size); - getenv_s(&required_size, result, required_size, name); - return result; + err = _dupenv_s(&result, &size, name); + if (err) return NULL; + duplicated = gpr_strdup(result); + free(result); + return duplicated; } void gpr_setenv(const char *name, const char *value) { diff --git a/src/core/support/file_win32.c b/src/core/support/file_win32.c index fe209af9b2..f59d3af397 100644 --- a/src/core/support/file_win32.c +++ b/src/core/support/file_win32.c @@ -72,7 +72,7 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename_out) { if (_tfopen_s(&result, tmp_filename, TEXT("wb+")) != 0) goto end; end: - if (result && tmp_filename) { + if (result && tmp_filename_out) { *tmp_filename_out = gpr_tchar_to_char(tmp_filename); } diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c index 720dc141f5..159c7e052c 100644 --- a/src/core/support/log_win32.c +++ b/src/core/support/log_win32.c @@ -43,6 +43,7 @@ #include #include +#include "src/core/support/string.h" #include "src/core/support/string_win32.h" void gpr_log(const char *file, int line, gpr_log_severity severity, @@ -55,7 +56,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, va_start(args, format); ret = _vscprintf(format, args); va_end(args); - if (!(0 <= ret && ret < ~(size_t)0)) { + if (ret < 0) { message = NULL; } else { /* Allocate a new buffer, with space for the NUL terminator. */ @@ -66,7 +67,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, va_start(args, format); ret = vsnprintf_s(message, strp_buflen, _TRUNCATE, format, args); va_end(args); - if (ret != strp_buflen - 1) { + if ((size_t)ret != strp_buflen - 1) { /* This should never happen. */ gpr_free(message); message = NULL; @@ -90,7 +91,7 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09u %5u %s:%d] %s\n", + fprintf(stderr, "%s%s.%09u %5lu %s:%d] %s\n", gpr_log_severity_string(args->severity), time_buffer, (int)(now.tv_nsec), GetCurrentThreadId(), args->file, args->line, args->message); @@ -105,6 +106,7 @@ char *gpr_format_message(DWORD messageid) { NULL, messageid, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)(&tmessage), 0, NULL); + if (status == 0) return gpr_strdup("Unable to retreive error string"); message = gpr_tchar_to_char(tmessage); LocalFree(tmessage); return message; diff --git a/src/core/support/string_win32.c b/src/core/support/string_win32.c index 583abd27d8..6d1d6337a9 100644 --- a/src/core/support/string_win32.c +++ b/src/core/support/string_win32.c @@ -44,6 +44,8 @@ #include +#include "src/core/support/string.h" + int gpr_asprintf(char **strp, const char *format, ...) { va_list args; int ret; @@ -53,7 +55,7 @@ int gpr_asprintf(char **strp, const char *format, ...) { va_start(args, format); ret = _vscprintf(format, args); va_end(args); - if (!(0 <= ret && ret < ~(size_t)0)) { + if (ret < 0) { *strp = NULL; return -1; } @@ -69,7 +71,7 @@ int gpr_asprintf(char **strp, const char *format, ...) { va_start(args, format); ret = vsnprintf_s(*strp, strp_buflen, _TRUNCATE, format, args); va_end(args); - if (ret == strp_buflen - 1) { + if ((size_t)ret == strp_buflen - 1) { return ret; } diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c index c9a977cc80..cc31d9b052 100644 --- a/src/core/support/sync_win32.c +++ b/src/core/support/sync_win32.c @@ -37,6 +37,7 @@ #ifdef GPR_WIN32 +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #include #include diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c index 8256849655..f221cb5790 100644 --- a/src/core/support/time_win32.c +++ b/src/core/support/time_win32.c @@ -42,8 +42,8 @@ gpr_timespec gpr_now(void) { gpr_timespec now_tv; - struct __timeb32 now_tb; - _ftime32_s(&now_tb); + struct _timeb now_tb; + _ftime_s(&now_tb); now_tv.tv_sec = now_tb.time; now_tv.tv_nsec = now_tb.millitm * 1000000; return now_tv; diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index ebe7deec70..5c26a1ad7c 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -48,7 +48,6 @@ CallOpBuffer::CallOpBuffer() initial_metadata_count_(0), initial_metadata_(nullptr), recv_initial_metadata_(nullptr), - recv_initial_metadata_arr_{0, 0, nullptr}, send_message_(nullptr), send_message_buffer_(nullptr), send_buf_(nullptr), @@ -58,7 +57,6 @@ CallOpBuffer::CallOpBuffer() client_send_close_(false), recv_trailing_metadata_(nullptr), recv_status_(nullptr), - recv_trailing_metadata_arr_{0, 0, nullptr}, status_code_(GRPC_STATUS_OK), status_details_(nullptr), status_details_capacity_(0), @@ -66,7 +64,12 @@ CallOpBuffer::CallOpBuffer() trailing_metadata_count_(0), trailing_metadata_(nullptr), cancelled_buf_(0), - recv_closed_(nullptr) {} + recv_closed_(nullptr) { + memset(&recv_trailing_metadata_arr_, 0, sizeof(recv_trailing_metadata_arr_)); + memset(&recv_initial_metadata_arr_, 0, sizeof(recv_initial_metadata_arr_)); + recv_trailing_metadata_arr_.metadata = nullptr; + recv_initial_metadata_arr_.metadata = nullptr; +} void CallOpBuffer::Reset(void* next_return_tag) { return_tag_ = next_return_tag; diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 4d5e77e633..09a541c5a5 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -234,7 +234,8 @@ void Server::RegisterAsyncGenericService(AsyncGenericService* service) { service->server_ = this; } -int Server::AddPort(const grpc::string& addr, ServerCredentials* creds) { +int Server::AddListeningPort(const grpc::string& addr, + ServerCredentials* creds) { GPR_ASSERT(!started_); return creds->AddPortToServer(addr, server_); } diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 835596d393..960734756e 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -62,9 +62,9 @@ void ServerBuilder::RegisterAsyncGenericService(AsyncGenericService* service) { generic_service_ = service; } -void ServerBuilder::AddPort(const grpc::string& addr, - std::shared_ptr creds, - int* selected_port) { +void ServerBuilder::AddListeningPort(const grpc::string& addr, + std::shared_ptr creds, + int* selected_port) { ports_.push_back(Port{addr, creds, selected_port}); } @@ -99,7 +99,7 @@ std::unique_ptr ServerBuilder::BuildAndStart() { server->RegisterAsyncGenericService(generic_service_); } for (auto& port : ports_) { - int r = server->AddPort(port.addr, port.creds.get()); + int r = server->AddListeningPort(port.addr, port.creds.get()); if (!r) return nullptr; if (port.selected_port != nullptr) { *port.selected_port = r; diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs index 807f5a6ded..3da9e33e53 100644 --- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs @@ -74,7 +74,7 @@ namespace Grpc.Core.Tests ServerServiceDefinition.CreateBuilder(serviceName) .AddMethod(unaryEchoStringMethod, HandleUnaryEchoString).Build()); - int port = server.AddPort(host + ":0"); + int port = server.AddListeningPort(host + ":0"); server.Start(); using (Channel channel = new Channel(host + ":" + port)) @@ -97,7 +97,7 @@ namespace Grpc.Core.Tests ServerServiceDefinition.CreateBuilder(serviceName) .AddMethod(unaryEchoStringMethod, HandleUnaryEchoString).Build()); - int port = server.AddPort(host + ":0"); + int port = server.AddListeningPort(host + ":0"); server.Start(); using (Channel channel = new Channel(host + ":" + port)) @@ -117,7 +117,7 @@ namespace Grpc.Core.Tests server.AddServiceDefinition( ServerServiceDefinition.CreateBuilder(serviceName).Build()); - int port = server.AddPort(host + ":0"); + int port = server.AddListeningPort(host + ":0"); server.Start(); using (Channel channel = new Channel(host + ":" + port)) diff --git a/src/csharp/Grpc.Core.Tests/ServerTest.cs b/src/csharp/Grpc.Core.Tests/ServerTest.cs index 12f914bfad..2a1855da67 100644 --- a/src/csharp/Grpc.Core.Tests/ServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ServerTest.cs @@ -47,7 +47,7 @@ namespace Grpc.Core.Tests GrpcEnvironment.Initialize(); Server server = new Server(); - server.AddPort("localhost:0"); + server.AddListeningPort("localhost:0"); server.Start(); server.ShutdownAsync().Wait(); diff --git a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs index dc4781e796..a59da09822 100644 --- a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs @@ -80,12 +80,12 @@ namespace Grpc.Core.Internal return grpcsharp_server_create(cq, args); } - public int AddPort(string addr) + public int AddListeningPort(string addr) { return grpcsharp_server_add_http2_port(this, addr); } - public int AddPort(string addr, ServerCredentialsSafeHandle credentials) + public int AddListeningPort(string addr, ServerCredentialsSafeHandle credentials) { return grpcsharp_server_add_secure_http2_port(this, addr, credentials); } diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index 2439cdb6dc..f086fa8beb 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -76,17 +76,17 @@ namespace Grpc.Core } // only call before Start() - public int AddPort(string addr) + public int AddListeningPort(string addr) { - return handle.AddPort(addr); + return handle.AddListeningPort(addr); } // only call before Start() - public int AddPort(string addr, ServerCredentials credentials) + public int AddListeningPort(string addr, ServerCredentials credentials) { using (var nativeCredentials = credentials.ToNativeCredentials()) { - return handle.AddPort(addr, nativeCredentials); + return handle.AddListeningPort(addr, nativeCredentials); } } diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs index 32a523f213..85f213cb39 100644 --- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs +++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs @@ -58,7 +58,7 @@ namespace math.Tests server = new Server(); server.AddServiceDefinition(MathGrpc.BindService(new MathServiceImpl())); - int port = server.AddPort(host + ":0"); + int port = server.AddListeningPort(host + ":0"); server.Start(); channel = new Channel(host + ":" + port); diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs index 814f6311f2..1e76d3df21 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs @@ -59,7 +59,7 @@ namespace Grpc.IntegrationTesting server = new Server(); server.AddServiceDefinition(TestServiceGrpc.BindService(new TestServiceImpl())); - int port = server.AddPort(host + ":0", TestCredentials.CreateTestServerCredentials()); + int port = server.AddListeningPort(host + ":0", TestCredentials.CreateTestServerCredentials()); server.Start(); var channelArgs = ChannelArgs.CreateBuilder() diff --git a/src/csharp/Grpc.IntegrationTesting/InteropServer.cs b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs index 5e580280b6..ad5200774f 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropServer.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs @@ -96,11 +96,11 @@ namespace Grpc.IntegrationTesting string addr = "0.0.0.0:" + options.port; if (options.useTls) { - server.AddPort(addr, TestCredentials.CreateTestServerCredentials()); + server.AddListeningPort(addr, TestCredentials.CreateTestServerCredentials()); } else { - server.AddPort(addr); + server.AddListeningPort(addr); } Console.WriteLine("Running server on " + addr); server.Start(); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index e011b788ff..c6b53c60a5 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -99,7 +99,7 @@ class AsyncEnd2endTest : public ::testing::Test { server_address_ << "localhost:" << port; // Setup server ServerBuilder builder; - builder.AddPort(server_address_.str(), grpc::InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), grpc::InsecureServerCredentials()); builder.RegisterAsyncService(&service_); server_ = builder.BuildAndStart(); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c586849349..41c2669533 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -151,7 +151,7 @@ class End2endTest : public ::testing::Test { server_address_ << "localhost:" << port; // Setup server ServerBuilder builder; - builder.AddPort(server_address_.str(), InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), InsecureServerCredentials()); builder.RegisterService(&service_); builder.RegisterService(&dup_pkg_service_); builder.SetThreadPool(&thread_pool_); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 4a0d2c5c01..5377d05a4e 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -98,7 +98,7 @@ class GenericEnd2endTest : public ::testing::Test { server_address_ << "localhost:" << port; // Setup server ServerBuilder builder; - builder.AddPort(server_address_.str(), InsecureServerCredentials()); + builder.AddListeningPort(server_address_.str(), InsecureServerCredentials()); builder.RegisterAsyncGenericService(&generic_service_); server_ = builder.BuildAndStart(); } diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 743482e967..eceb600d4c 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -217,7 +217,7 @@ void RunServer() { "", {{test_server1_key, test_server1_cert}}}; creds = grpc::SslServerCredentials(ssl_opts); } - builder.AddPort(server_address.str(), creds); + builder.AddListeningPort(server_address.str(), creds); std::unique_ptr server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); while (!got_sigint) { diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc index 005f0f9c5e..4ebedf83c1 100644 --- a/test/cpp/qps/server.cc +++ b/test/cpp/qps/server.cc @@ -137,7 +137,7 @@ static void RunServer() { SimpleResponse response; ServerBuilder builder; - builder.AddPort(server_address, grpc::InsecureServerCredentials()); + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); builder.RegisterService(&service); std::unique_ptr pool(new ThreadPool(FLAGS_server_threads)); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 19778e5a7c..121ac73c52 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -68,7 +68,7 @@ class AsyncQpsServerTest : public Server { gpr_join_host_port(&server_address, "::", port); ServerBuilder builder; - builder.AddPort(server_address, InsecureServerCredentials()); + builder.AddListeningPort(server_address, InsecureServerCredentials()); gpr_free(server_address); builder.RegisterAsyncService(&async_service_); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 5c6541989c..3e15fb61c0 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -84,7 +84,7 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server { char* server_address = NULL; gpr_join_host_port(&server_address, "::", port); - builder.AddPort(server_address, InsecureServerCredentials()); + builder.AddListeningPort(server_address, InsecureServerCredentials()); gpr_free(server_address); builder.RegisterService(&service_); diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index faabfd1147..fdcd9d5069 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -210,7 +210,7 @@ static void RunServer() { WorkerImpl service; ServerBuilder builder; - builder.AddPort(server_address, InsecureServerCredentials()); + builder.AddListeningPort(server_address, InsecureServerCredentials()); builder.RegisterService(&service); gpr_free(server_address); diff --git a/vsprojects/vs2013/global.props b/vsprojects/vs2013/global.props index 27efc13b24..ae44e18d4e 100644 --- a/vsprojects/vs2013/global.props +++ b/vsprojects/vs2013/global.props @@ -5,7 +5,7 @@ - $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\third_party\zlib;$(SolutionDir)\..\third_party;$(SolutionDir)\..\..\third_party\openssl\inc32 + $(SolutionDir)\..\..;$(SolutionDir)\..\..\include;$(SolutionDir)\..\..\third_party\zlib;$(SolutionDir)\..\third_party;$(SolutionDir)\..\..\third_party\openssl\inc32;$(SolutionDir)\..\..\third_party\protobuf\src _CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) EnableAllWarnings -- cgit v1.2.3