diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..b51d2c0d821 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: cpp +before_install: + - sudo add-apt-repository ppa:yjwong/gflags -y + - sudo add-apt-repository ppa:h-rayflood/llvm -y + - sudo apt-get update -qq + - sudo apt-get install -qq libgtest-dev libgflags-dev python-virtualenv clang-3.5 +env: + global: + - RUBY_VERSION=2.1 + matrix: + - CONFIG=dbg TEST=c + - CONFIG=dbg TEST=c++ + - CONFIG=opt TEST=c + - CONFIG=opt TEST=c++ + - CONFIG=opt TEST=node + - CONFIG=opt TEST=ruby +script: + - rvm use $RUBY_VERSION + - gem install bundler + - ./tools/run_tests/run_tests.py -l $TEST -t -j 16 -c $CONFIG -s 4.0 +notifications: + email: false \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 57d176f6637..b58c3568fcd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,27 +24,27 @@ properly run all the tests. If you are planning to work on any of the languages other than C and C++, you will also need their appropriate development environments. -If you want to work under Windows, we recommend you to use Visual Studio 2013. +If you want to work under Windows, we recommend the use of Visual Studio 2013. The [Community or Express editions](http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) are free and suitable for developing with grpc. Note however that our test environment and tools are available for Unix environments only at the moment. ## Testing your changes -We provide a tool to help you run our suite of tests in various environments. +We provide a tool to help run the suite of tests in various environments. In order to run most of the available tests, one would need to run: `./tools/run_tests/run_tests.py` -If you want to run all the possible tests for all possible languages, do this: +If you want to run all the possible tests for any of the languages {c, c++, node, php, python}, do this: -`./tools/run_tests/run_tests.py -lall -call` +`./tools/run_tests/run_tests.py -l -c all` ## Adding or removing source code Each language uses its own build system to work. Currently, the root's Makefile -and the Visual Studio project files are building the C and C++ source code only -at the moment. In order to ease the maintenance of these files, we have a +and the Visual Studio project files are building only the C and C++ source code. +In order to ease the maintenance of these files, we have a template system. Please do not contribute manual changes to any of the generated files. Instead, modify the template files, or the build.json file, and re-generate the project files using the following command: diff --git a/INSTALL b/INSTALL index 2f5f29c788f..50040d7d21c 100644 --- a/INSTALL +++ b/INSTALL @@ -9,15 +9,16 @@ wiki pages: * If you are in a hurry * ************************* -A typical unix installation won't require any more steps than running: - - $ make - # make install + $ git clone https://github.com/grpc/grpc.git + $ cd grpc + $ git submodule update --init + $ make + $ sudo make install You don't need anything else than GNU Make, gcc and autotools. Under a Debian or Ubuntu system, this should boil down to the following packages: - # apt-get install build-essential autoconf libtool + $ apt-get install build-essential autoconf libtool Building the python wrapper requires the following: diff --git a/Makefile b/Makefile index 277e8caebc2..e390a3efe63 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ LDXX_valgrind = g++ CPPFLAGS_valgrind = -O0 OPENSSL_CFLAGS_valgrind = -DPURIFY LDFLAGS_valgrind = -DEFINES_valgrind = _DEBUG DEBUG +DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1 @@ -87,7 +87,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer LDFLAGS_tsan = -fsanitize=thread -DEFINES_tsan = NDEBUG +DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_asan = 1 REQUIRE_CUSTOM_LIBRARIES_asan = 1 @@ -97,7 +97,7 @@ LD_asan = clang LDXX_asan = clang++ CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer LDFLAGS_asan = -fsanitize=address -DEFINES_asan = NDEBUG +DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -108,7 +108,7 @@ LDXX_msan = clang++-libc++ CPPFLAGS_msan = -O1 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 OPENSSL_CFLAGS_msan = -DPURIFY LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -DEFINES_msan = NDEBUG +DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 @@ -119,7 +119,7 @@ LDXX_ubsan = clang++ CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer OPENSSL_CFLAGS_ubsan = -DPURIFY LDFLAGS_ubsan = -fsanitize=undefined -DEFINES_ubsan = NDEBUG +DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_gcov = 1 CC_gcov = gcc @@ -143,7 +143,15 @@ CXX = $(CXX_$(CONFIG)) LD = $(LD_$(CONFIG)) LDXX = $(LDXX_$(CONFIG)) AR = ar +ifeq ($(SYSTEM),Linux) STRIP = strip --strip-unneeded +else +ifeq ($(SYSTEM),Darwin) +STRIP = strip -x +else +STRIP = strip +endif +endif INSTALL = install RM = rm -f @@ -152,6 +160,10 @@ $(error Invalid CONFIG value '$(CONFIG)') endif +# Detect if we can use C++11 +CXX11_CHECK_CMD = $(CXX) -std=c++11 -o /dev/null -c test/build/c++11.cc +HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) + # The HOST compiler settings are used to compile the protoc plugins. # In most cases, you won't have to change anything, but if you are # cross-compiling, you can override these variables from GNU make's @@ -166,8 +178,17 @@ CPPFLAGS += $(CPPFLAGS_$(CONFIG)) DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" LDFLAGS += $(LDFLAGS_$(CONFIG)) +ifdef EXTRA_DEFINES +DEFINES += $(EXTRA_DEFINES) +endif + CFLAGS += -std=c89 -pedantic +ifeq ($(HAS_CXX11),true) CXXFLAGS += -std=c++11 +else +CXXFLAGS += -std=c++0x +DEFINES += GRPC_OLD_CXX +endif CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter LDFLAGS += -g -fPIC @@ -195,7 +216,7 @@ E = @echo Q = @ endif -VERSION = 0.8.0.0 +VERSION = 0.5.0.0 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -524,7 +545,9 @@ pubsub_client: $(BINDIR)/$(CONFIG)/pubsub_client pubsub_publisher_test: $(BINDIR)/$(CONFIG)/pubsub_publisher_test pubsub_subscriber_test: $(BINDIR)/$(CONFIG)/pubsub_subscriber_test qps_client: $(BINDIR)/$(CONFIG)/qps_client +qps_client_async: $(BINDIR)/$(CONFIG)/qps_client_async qps_server: $(BINDIR)/$(CONFIG)/qps_server +qps_server_async: $(BINDIR)/$(CONFIG)/qps_server_async status_test: $(BINDIR)/$(CONFIG)/status_test thread_pool_test: $(BINDIR)/$(CONFIG)/thread_pool_test chttp2_fake_security_cancel_after_accept_test: $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test @@ -897,7 +920,11 @@ third_party/protobuf/configure: $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure $(E) "[MAKE] Building protobuf" +ifeq ($(HAVE_CXX11),true) $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-DLANG_CXX11 -std=c++11" CPPFLAGS="-fPIC $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static) +else + $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-std=c++0x" CPPFLAGS="-fPIC $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static) +endif $(Q)$(MAKE) -C third_party/protobuf clean $(Q)$(MAKE) -C third_party/protobuf $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf @@ -933,7 +960,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_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_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_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_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_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_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_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_client $(BINDIR)/$(CONFIG)/qps_server $(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)/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_client $(BINDIR)/$(CONFIG)/qps_client_async $(BINDIR)/$(CONFIG)/qps_server $(BINDIR)/$(CONFIG)/qps_server_async $(BINDIR)/$(CONFIG)/status_test $(BINDIR)/$(CONFIG)/thread_pool_test test: test_c test_cxx @@ -7476,13 +7503,24 @@ $(BINDIR)/$(CONFIG)/async_end2end_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/async_end2end_test: $(ASYNC_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 + +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)/async_end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/async_end2end_test: $(PROTOBUF_DEP) $(ASYNC_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) $(ASYNC_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)/async_end2end_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/end2end/async_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_async_end2end_test: $(ASYNC_END2END_TEST_OBJS:.o=.dep) @@ -7507,13 +7545,24 @@ $(BINDIR)/$(CONFIG)/channel_arguments_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/channel_arguments_test: $(CHANNEL_ARGUMENTS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +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)/channel_arguments_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/channel_arguments_test: $(PROTOBUF_DEP) $(CHANNEL_ARGUMENTS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` $(Q) $(LDXX) $(LDFLAGS) $(CHANNEL_ARGUMENTS_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/channel_arguments_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/client/channel_arguments_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_channel_arguments_test: $(CHANNEL_ARGUMENTS_TEST_OBJS:.o=.dep) @@ -7538,13 +7587,24 @@ $(BINDIR)/$(CONFIG)/credentials_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/credentials_test: $(CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a + +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)/credentials_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/credentials_test: $(PROTOBUF_DEP) $(CREDENTIALS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` $(Q) $(LDXX) $(LDFLAGS) $(CREDENTIALS_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/credentials_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/client/credentials_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_credentials_test: $(CREDENTIALS_TEST_OBJS:.o=.dep) @@ -7569,13 +7629,24 @@ $(BINDIR)/$(CONFIG)/end2end_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/end2end_test: $(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 + +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)/end2end_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/end2end_test: $(PROTOBUF_DEP) $(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) $(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)/end2end_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/end2end/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_end2end_test: $(END2END_TEST_OBJS:.o=.dep) @@ -7596,7 +7667,7 @@ GRPC_CPP_PLUGIN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basen ifeq ($(NO_PROTOBUF),true) -# You can't build the protoc plugins if you don't have protobuf 3.0.0+. +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. $(BINDIR)/$(CONFIG)/grpc_cpp_plugin: protobuf_dep_error @@ -7628,7 +7699,7 @@ GRPC_PYTHON_PLUGIN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(ba ifeq ($(NO_PROTOBUF),true) -# You can't build the protoc plugins if you don't have protobuf 3.0.0+. +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. $(BINDIR)/$(CONFIG)/grpc_python_plugin: protobuf_dep_error @@ -7660,7 +7731,7 @@ GRPC_RUBY_PLUGIN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(base ifeq ($(NO_PROTOBUF),true) -# You can't build the protoc plugins if you don't have protobuf 3.0.0+. +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. $(BINDIR)/$(CONFIG)/grpc_ruby_plugin: protobuf_dep_error @@ -7699,13 +7770,24 @@ $(BINDIR)/$(CONFIG)/interop_client: openssl_dep_error else -$(BINDIR)/$(CONFIG)/interop_client: $(INTEROP_CLIENT_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 + +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)/interop_client: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/interop_client: $(PROTOBUF_DEP) $(INTEROP_CLIENT_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) $(INTEROP_CLIENT_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)/interop_client endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/interop/empty.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 $(OBJDIR)/$(CONFIG)/test/cpp/interop/messages.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 $(OBJDIR)/$(CONFIG)/test/cpp/interop/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 @@ -7736,13 +7818,24 @@ $(BINDIR)/$(CONFIG)/interop_server: openssl_dep_error else -$(BINDIR)/$(CONFIG)/interop_server: $(INTEROP_SERVER_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 + +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)/interop_server: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/interop_server: $(PROTOBUF_DEP) $(INTEROP_SERVER_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) $(INTEROP_SERVER_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)/interop_server endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/interop/empty.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 $(OBJDIR)/$(CONFIG)/test/cpp/interop/messages.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 $(OBJDIR)/$(CONFIG)/test/cpp/interop/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 @@ -7770,13 +7863,24 @@ $(BINDIR)/$(CONFIG)/interop_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/interop_test: $(INTEROP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +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)/interop_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/interop_test: $(PROTOBUF_DEP) $(INTEROP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.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) $(INTEROP_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/interop_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/interop/interop_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_interop_test: $(INTEROP_TEST_OBJS:.o=.dep) @@ -7801,13 +7905,24 @@ $(BINDIR)/$(CONFIG)/pubsub_client: openssl_dep_error else -$(BINDIR)/$(CONFIG)/pubsub_client: $(PUBSUB_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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 + +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)/pubsub_client: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/pubsub_client: $(PROTOBUF_DEP) $(PUBSUB_CLIENT_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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) $(PUBSUB_CLIENT_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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)/pubsub_client endif +endif + $(OBJDIR)/$(CONFIG)/examples/pubsub/main.o: $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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_pubsub_client: $(PUBSUB_CLIENT_OBJS:.o=.dep) @@ -7832,13 +7947,24 @@ $(BINDIR)/$(CONFIG)/pubsub_publisher_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/pubsub_publisher_test: $(PUBSUB_PUBLISHER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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 + +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)/pubsub_publisher_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/pubsub_publisher_test: $(PROTOBUF_DEP) $(PUBSUB_PUBLISHER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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) $(PUBSUB_PUBLISHER_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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)/pubsub_publisher_test endif +endif + $(OBJDIR)/$(CONFIG)/examples/pubsub/publisher_test.o: $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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_pubsub_publisher_test: $(PUBSUB_PUBLISHER_TEST_OBJS:.o=.dep) @@ -7863,13 +7989,24 @@ $(BINDIR)/$(CONFIG)/pubsub_subscriber_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/pubsub_subscriber_test: $(PUBSUB_SUBSCRIBER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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 + +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)/pubsub_subscriber_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/pubsub_subscriber_test: $(PROTOBUF_DEP) $(PUBSUB_SUBSCRIBER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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) $(PUBSUB_SUBSCRIBER_TEST_OBJS) $(GTEST_LIB) $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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)/pubsub_subscriber_test endif +endif + $(OBJDIR)/$(CONFIG)/examples/pubsub/subscriber_test.o: $(LIBDIR)/$(CONFIG)/libpubsub_client_lib.a $(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_pubsub_subscriber_test: $(PUBSUB_SUBSCRIBER_TEST_OBJS:.o=.dep) @@ -7895,13 +8032,24 @@ $(BINDIR)/$(CONFIG)/qps_client: openssl_dep_error else -$(BINDIR)/$(CONFIG)/qps_client: $(QPS_CLIENT_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 + +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)/qps_client: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/qps_client: $(PROTOBUF_DEP) $(QPS_CLIENT_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) $(QPS_CLIENT_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)/qps_client endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/qps/qpstest.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 $(OBJDIR)/$(CONFIG)/test/cpp/qps/client.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 @@ -7914,6 +8062,39 @@ endif endif +QPS_CLIENT_ASYNC_SRC = \ + $(GENDIR)/test/cpp/qps/qpstest.pb.cc \ + test/cpp/qps/client_async.cc \ + +QPS_CLIENT_ASYNC_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(QPS_CLIENT_ASYNC_SRC)))) + +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL with ALPN. + +$(BINDIR)/$(CONFIG)/qps_client_async: openssl_dep_error + +else + +$(BINDIR)/$(CONFIG)/qps_client_async: $(QPS_CLIENT_ASYNC_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) $(QPS_CLIENT_ASYNC_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)/qps_client_async + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qpstest.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 +$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.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_qps_client_async: $(QPS_CLIENT_ASYNC_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(QPS_CLIENT_ASYNC_OBJS:.o=.dep) +endif +endif + + QPS_SERVER_SRC = \ $(GENDIR)/test/cpp/qps/qpstest.pb.cc \ test/cpp/qps/server.cc \ @@ -7928,13 +8109,24 @@ $(BINDIR)/$(CONFIG)/qps_server: openssl_dep_error else -$(BINDIR)/$(CONFIG)/qps_server: $(QPS_SERVER_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 + +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)/qps_server: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/qps_server: $(PROTOBUF_DEP) $(QPS_SERVER_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) $(QPS_SERVER_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)/qps_server endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/qps/qpstest.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 $(OBJDIR)/$(CONFIG)/test/cpp/qps/server.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 @@ -7947,6 +8139,39 @@ endif endif +QPS_SERVER_ASYNC_SRC = \ + $(GENDIR)/test/cpp/qps/qpstest.pb.cc \ + test/cpp/qps/server_async.cc \ + +QPS_SERVER_ASYNC_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(QPS_SERVER_ASYNC_SRC)))) + +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL with ALPN. + +$(BINDIR)/$(CONFIG)/qps_server_async: openssl_dep_error + +else + +$(BINDIR)/$(CONFIG)/qps_server_async: $(QPS_SERVER_ASYNC_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) $(QPS_SERVER_ASYNC_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)/qps_server_async + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qpstest.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 +$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.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_qps_server_async: $(QPS_SERVER_ASYNC_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(QPS_SERVER_ASYNC_OBJS:.o=.dep) +endif +endif + + STATUS_TEST_SRC = \ test/cpp/util/status_test.cc \ @@ -7960,13 +8185,24 @@ $(BINDIR)/$(CONFIG)/status_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/status_test: $(STATUS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +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)/status_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/status_test: $(PROTOBUF_DEP) $(STATUS_TEST_OBJS) $(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) $(STATUS_TEST_OBJS) $(GTEST_LIB) $(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)/status_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/util/status_test.o: $(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_status_test: $(STATUS_TEST_OBJS:.o=.dep) @@ -7991,13 +8227,24 @@ $(BINDIR)/$(CONFIG)/thread_pool_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/thread_pool_test: $(THREAD_POOL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +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)/thread_pool_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/thread_pool_test: $(PROTOBUF_DEP) $(THREAD_POOL_TEST_OBJS) $(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) $(THREAD_POOL_TEST_OBJS) $(GTEST_LIB) $(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)/thread_pool_test endif +endif + $(OBJDIR)/$(CONFIG)/test/cpp/server/thread_pool_test.o: $(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_thread_pool_test: $(THREAD_POOL_TEST_OBJS:.o=.dep) diff --git a/PATENTS b/PATENTS new file mode 100644 index 00000000000..619f9dbfe63 --- /dev/null +++ b/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the GRPC project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of GRPC, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of GRPC. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of GRPC or any code incorporated within this +implementation of GRPC constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of GRPC +shall terminate as of the date such litigation is filed. diff --git a/README.md b/README.md index fc35934f2df..8fa9fa4956e 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ See grpc/INSTALL for installation instructions for various platforms. #Repository Structure -This repository contains source code for gRPC libraries for multiple lanugages written on top +This repository contains source code for gRPC libraries for multiple languages written on top of shared C core library [src/core] (src/core). * C++ source code: [src/cpp] (src/cpp) - * Python source code: [src/python] (src/python) * Ruby source code: [src/ruby] (src/ruby) * NodeJS source code: [src/node] (src/node) + * Python source code: [src/python] (src/python) * PHP source code: [src/php] (src/php) * C# source code: [src/csharp] (src/csharp) * Objective-C source code: [src/objective-c] (src/objective-c) @@ -33,9 +33,9 @@ Libraries in different languages are in different state of development. We are s * shared C core library [src/core] (src/core) : Early adopter ready - Alpha. * C++ Library: [src/cpp] (src/cpp) : Early adopter ready - Alpha. - * Python Library: [src/python] (src/python) : Early adopter ready - Alpha. * Ruby Library: [src/ruby] (src/ruby) : Early adopter ready - Alpha. * NodeJS Library: [src/node] (src/node) : Early adopter ready - Alpha. + * Python Library: [src/python] (src/python) : Usable with limitations - Pre-Alpha. * PHP Library: [src/php] (src/php) : Pre-Alpha. * C# Library: [src/csharp] (src/csharp) : Pre-Alpha. * Objective-C Library: [src/objective-c] (src/objective-c): Pre-Alpha. diff --git a/build.json b/build.json index 7a030ea888a..6be1d537ffa 100644 --- a/build.json +++ b/build.json @@ -3,7 +3,7 @@ "#": "The public version number of the library.", "version": { "major": 0, - "minor": 8, + "minor": 5, "micro": 0, "build": 0 } @@ -582,7 +582,8 @@ "grpc", "gpr_test_util", "gpr" - ] + ], + "flaky": true }, { "name": "census_statistics_multiple_writers_test", @@ -638,7 +639,8 @@ "grpc", "gpr_test_util", "gpr" - ] + ], + "flaky": true }, { "name": "census_stats_store_test", @@ -866,7 +868,8 @@ "grpc", "gpr_test_util", "gpr" - ] + ], + "flaky": true }, { "name": "fling_test", @@ -880,7 +883,8 @@ "grpc", "gpr_test_util", "gpr" - ] + ], + "flaky": true }, { "name": "gen_hpack_tables", @@ -1815,6 +1819,24 @@ "gpr" ] }, + { + "name": "qps_client_async", + "build": "test", + "run": false, + "language": "c++", + "src": [ + "test/cpp/qps/qpstest.proto", + "test/cpp/qps/client_async.cc" + ], + "deps": [ + "grpc++_test_util", + "grpc_test_util", + "grpc++", + "grpc", + "gpr_test_util", + "gpr" + ] + }, { "name": "qps_server", "build": "test", @@ -1833,6 +1855,24 @@ "gpr" ] }, + { + "name": "qps_server_async", + "build": "test", + "run": false, + "language": "c++", + "src": [ + "test/cpp/qps/qpstest.proto", + "test/cpp/qps/server_async.cc" + ], + "deps": [ + "grpc++_test_util", + "grpc_test_util", + "grpc++", + "grpc", + "gpr_test_util", + "gpr" + ] + }, { "name": "status_test", "build": "test", diff --git a/examples/pubsub/README b/examples/pubsub/README index b55083afc56..faeb622153f 100644 --- a/examples/pubsub/README +++ b/examples/pubsub/README @@ -1,3 +1,6 @@ +Experimental example code, likely to change. +Users should not attempt to run this code till this warning is removed. + C++ Client implementation for Cloud Pub/Sub service (https://developers.google.com/apis-explorer/#p/pubsub/v1beta1/). @@ -12,19 +15,7 @@ be created with scope "https://www.googleapis.com/auth/cloud-platform" as below: gcloud compute instances create instance-name --image debian-7 --scopes https://www.googleapis.com/auth/cloud-platform -Google TLS cert is required to run the client, which can be downloaded from -Chrome browser. - -To run the client from GCE: -make pubsub_client -GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="Google TLS cert" bins/opt/pubsub_client - --project_id="your project id" - -A service account credential is required to run the client from other -environments, which can be generated as a JSON key file from -https://console.developers.google.com/project/. To run the client with a service -account credential: -GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="Google TLS cert" bins/opt/pubsub_client - --project_id="your project id" - --service_account_key_file="absolute path to the JSON key file" +To run the client: +make pubsub_client +bins/opt/pubsub_client --project_id="your project id" diff --git a/examples/pubsub/publisher.h b/examples/pubsub/publisher.h index 2d64a2abfa3..c90406ffef8 100644 --- a/examples/pubsub/publisher.h +++ b/examples/pubsub/publisher.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_ -#define __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_ +#ifndef GRPC_EXAMPLES_PUBSUB_PUBLISHER_H +#define GRPC_EXAMPLES_PUBSUB_PUBLISHER_H #include #include @@ -64,4 +64,4 @@ class Publisher { } // namespace examples } // namespace grpc -#endif // __GRPCPP_EXAMPLES_PUBSUB_PUBLISHER_H_ +#endif // GRPC_EXAMPLES_PUBSUB_PUBLISHER_H diff --git a/examples/pubsub/publisher_test.cc b/examples/pubsub/publisher_test.cc index 4539557a35b..c988b4802eb 100644 --- a/examples/pubsub/publisher_test.cc +++ b/examples/pubsub/publisher_test.cc @@ -61,28 +61,28 @@ class PublisherServiceImpl : public tech::pubsub::PublisherService::Service { public: Status CreateTopic(::grpc::ServerContext* context, const ::tech::pubsub::Topic* request, - ::tech::pubsub::Topic* response) override { + ::tech::pubsub::Topic* response) GRPC_OVERRIDE { EXPECT_EQ(request->name(), kTopic); return Status::OK; } Status Publish(ServerContext* context, const ::tech::pubsub::PublishRequest* request, - ::proto2::Empty* response) override { + ::proto2::Empty* response) GRPC_OVERRIDE { EXPECT_EQ(request->message().data(), kMessageData); return Status::OK; } Status GetTopic(ServerContext* context, const ::tech::pubsub::GetTopicRequest* request, - ::tech::pubsub::Topic* response) override { + ::tech::pubsub::Topic* response) GRPC_OVERRIDE { EXPECT_EQ(request->topic(), kTopic); return Status::OK; } - Status ListTopics(ServerContext* context, - const ::tech::pubsub::ListTopicsRequest* request, - ::tech::pubsub::ListTopicsResponse* response) override { + Status ListTopics( + ServerContext* context, const ::tech::pubsub::ListTopicsRequest* request, + ::tech::pubsub::ListTopicsResponse* response) GRPC_OVERRIDE { std::ostringstream ss; ss << "cloud.googleapis.com/project in (/projects/" << kProjectId << ")"; EXPECT_EQ(request->query(), ss.str()); @@ -92,7 +92,7 @@ class PublisherServiceImpl : public tech::pubsub::PublisherService::Service { Status DeleteTopic(ServerContext* context, const ::tech::pubsub::DeleteTopicRequest* request, - ::proto2::Empty* response) override { + ::proto2::Empty* response) GRPC_OVERRIDE { EXPECT_EQ(request->topic(), kTopic); return Status::OK; } @@ -102,7 +102,7 @@ class PublisherServiceImpl : public tech::pubsub::PublisherService::Service { class PublisherTest : public ::testing::Test { protected: // Setup a server and a client for PublisherService. - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; ServerBuilder builder; @@ -116,7 +116,7 @@ class PublisherTest : public ::testing::Test { publisher_.reset(new grpc::examples::pubsub::Publisher(channel_)); } - void TearDown() override { + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); publisher_->Shutdown(); } diff --git a/examples/pubsub/subscriber.h b/examples/pubsub/subscriber.h index a973cd755c7..c587c01b825 100644 --- a/examples/pubsub/subscriber.h +++ b/examples/pubsub/subscriber.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_ -#define __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_ +#ifndef GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H +#define GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H #include #include @@ -65,4 +65,4 @@ class Subscriber { } // namespace examples } // namespace grpc -#endif // __GRPCPP_EXAMPLES_PUBSUB_SUBSCRIBER_H_ +#endif // GRPC_EXAMPLES_PUBSUB_SUBSCRIBER_H diff --git a/examples/pubsub/subscriber_test.cc b/examples/pubsub/subscriber_test.cc index c634aa4f823..4ff125f4b3a 100644 --- a/examples/pubsub/subscriber_test.cc +++ b/examples/pubsub/subscriber_test.cc @@ -57,9 +57,9 @@ const char kData[] = "Message data"; class SubscriberServiceImpl : public tech::pubsub::SubscriberService::Service { public: - Status CreateSubscription(ServerContext* context, - const tech::pubsub::Subscription* request, - tech::pubsub::Subscription* response) override { + Status CreateSubscription( + ServerContext* context, const tech::pubsub::Subscription* request, + tech::pubsub::Subscription* response) GRPC_OVERRIDE { EXPECT_EQ(request->topic(), kTopic); EXPECT_EQ(request->name(), kSubscriptionName); return Status::OK; @@ -67,7 +67,7 @@ class SubscriberServiceImpl : public tech::pubsub::SubscriberService::Service { Status GetSubscription(ServerContext* context, const tech::pubsub::GetSubscriptionRequest* request, - tech::pubsub::Subscription* response) override { + tech::pubsub::Subscription* response) GRPC_OVERRIDE { EXPECT_EQ(request->subscription(), kSubscriptionName); response->set_topic(kTopic); return Status::OK; @@ -76,14 +76,13 @@ class SubscriberServiceImpl : public tech::pubsub::SubscriberService::Service { Status DeleteSubscription( ServerContext* context, const tech::pubsub::DeleteSubscriptionRequest* request, - proto2::Empty* response) override { + proto2::Empty* response) GRPC_OVERRIDE { EXPECT_EQ(request->subscription(), kSubscriptionName); return Status::OK; } - Status Pull(ServerContext* context, - const tech::pubsub::PullRequest* request, - tech::pubsub::PullResponse* response) override { + Status Pull(ServerContext* context, const tech::pubsub::PullRequest* request, + tech::pubsub::PullResponse* response) GRPC_OVERRIDE { EXPECT_EQ(request->subscription(), kSubscriptionName); response->set_ack_id("1"); response->mutable_pubsub_event()->mutable_message()->set_data(kData); @@ -92,7 +91,7 @@ class SubscriberServiceImpl : public tech::pubsub::SubscriberService::Service { Status Acknowledge(ServerContext* context, const tech::pubsub::AcknowledgeRequest* request, - proto2::Empty* response) override { + proto2::Empty* response) GRPC_OVERRIDE { return Status::OK; } @@ -101,7 +100,7 @@ class SubscriberServiceImpl : public tech::pubsub::SubscriberService::Service { class SubscriberTest : public ::testing::Test { protected: // Setup a server and a client for SubscriberService. - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; ServerBuilder builder; @@ -115,7 +114,7 @@ class SubscriberTest : public ::testing::Test { subscriber_.reset(new grpc::examples::pubsub::Subscriber(channel_)); } - void TearDown() override { + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); subscriber_->Shutdown(); } diff --git a/include/grpc++/async_unary_call.h b/include/grpc++/async_unary_call.h index b4a654c4a98..71b7d3ff858 100644 --- a/include/grpc++/async_unary_call.h +++ b/include/grpc++/async_unary_call.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_ASYNC_UNARY_CALL_H__ -#define __GRPCPP_ASYNC_UNARY_CALL_H__ +#ifndef GRPCXX_ASYNC_UNARY_CALL_H +#define GRPCXX_ASYNC_UNARY_CALL_H #include #include @@ -45,7 +45,7 @@ namespace grpc { template -class ClientAsyncResponseReader final { +class ClientAsyncResponseReader GRPC_FINAL { public: ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, @@ -79,7 +79,7 @@ class ClientAsyncResponseReader final { private: - ClientContext* context_ = nullptr; + ClientContext* context_; Call call_; CallOpBuffer init_buf_; CallOpBuffer meta_buf_; @@ -87,7 +87,8 @@ class ClientAsyncResponseReader final { }; template -class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface { +class ServerAsyncResponseWriter GRPC_FINAL + : public ServerAsyncStreamingInterface { public: explicit ServerAsyncResponseWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} @@ -127,7 +128,7 @@ class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface { } private: - void BindCall(Call* call) override { call_ = *call; } + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } Call call_; ServerContext* ctx_; @@ -137,4 +138,4 @@ class ServerAsyncResponseWriter final : public ServerAsyncStreamingInterface { } // namespace grpc -#endif // __GRPCPP_ASYNC_UNARY_CALL_H__ +#endif // GRPCXX_ASYNC_UNARY_CALL_H diff --git a/include/grpc++/channel_arguments.h b/include/grpc++/channel_arguments.h index 75c3cf45b49..ad96ef14ae3 100644 --- a/include/grpc++/channel_arguments.h +++ b/include/grpc++/channel_arguments.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CHANNEL_ARGUMENTS_H_ -#define __GRPCPP_CHANNEL_ARGUMENTS_H_ +#ifndef GRPCXX_CHANNEL_ARGUMENTS_H +#define GRPCXX_CHANNEL_ARGUMENTS_H #include #include @@ -82,4 +82,4 @@ class ChannelArguments { } // namespace grpc -#endif // __GRPCPP_CHANNEL_ARGUMENTS_H_ +#endif // GRPCXX_CHANNEL_ARGUMENTS_H diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel_interface.h index 890fd04d824..77d13636184 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel_interface.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CHANNEL_INTERFACE_H__ -#define __GRPCPP_CHANNEL_INTERFACE_H__ +#ifndef GRPCXX_CHANNEL_INTERFACE_H +#define GRPCXX_CHANNEL_INTERFACE_H #include #include @@ -63,4 +63,4 @@ class ChannelInterface : public CallHook { } // namespace grpc -#endif // __GRPCPP_CHANNEL_INTERFACE_H__ +#endif // GRPCXX_CHANNEL_INTERFACE_H diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h index 1e7e6bfad7c..87e5e9ad6c4 100644 --- a/include/grpc++/client_context.h +++ b/include/grpc++/client_context.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CLIENT_CONTEXT_H__ -#define __GRPCPP_CLIENT_CONTEXT_H__ +#ifndef GRPCXX_CLIENT_CONTEXT_H +#define GRPCXX_CLIENT_CONTEXT_H #include #include @@ -139,7 +139,7 @@ class ClientContext { return authority_; } - bool initial_metadata_received_ = false; + bool initial_metadata_received_; grpc_call *call_; grpc_completion_queue *cq_; gpr_timespec absolute_deadline_; @@ -151,4 +151,4 @@ class ClientContext { } // namespace grpc -#endif // __GRPCPP_CLIENT_CONTEXT_H__ +#endif // GRPCXX_CLIENT_CONTEXT_H diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h index 0075482d717..0ca12604038 100644 --- a/include/grpc++/completion_queue.h +++ b/include/grpc++/completion_queue.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_COMPLETION_QUEUE_H__ -#define __GRPCPP_COMPLETION_QUEUE_H__ +#ifndef GRPCXX_COMPLETION_QUEUE_H +#define GRPCXX_COMPLETION_QUEUE_H #include @@ -121,4 +121,4 @@ class CompletionQueue { } // namespace grpc -#endif // __GRPCPP_COMPLETION_QUEUE_H__ +#endif // GRPCXX_COMPLETION_QUEUE_H diff --git a/include/grpc++/config.h b/include/grpc++/config.h index 2dced12e379..cfa8d3be9f1 100644 --- a/include/grpc++/config.h +++ b/include/grpc++/config.h @@ -31,15 +31,23 @@ * */ -#ifndef __GRPCPP_CONFIG_H__ -#define __GRPCPP_CONFIG_H__ +#ifndef GRPCXX_CONFIG_H +#define GRPCXX_CONFIG_H #include +#ifdef GRPC_OLD_CXX +#define GRPC_FINAL +#define GRPC_OVERRIDE +#else +#define GRPC_FINAL final +#define GRPC_OVERRIDE override +#endif + namespace grpc { typedef std::string string; } // namespace grpc -#endif // __GRPCPP_CONFIG_H__ +#endif // GRPCXX_CONFIG_H diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index 80ca0c4dc47..3f13188365c 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CREATE_CHANNEL_H__ -#define __GRPCPP_CREATE_CHANNEL_H__ +#ifndef GRPCXX_CREATE_CHANNEL_H +#define GRPCXX_CREATE_CHANNEL_H #include @@ -55,4 +55,4 @@ std::shared_ptr CreateChannel( } // namespace grpc -#endif // __GRPCPP_CREATE_CHANNEL_H__ +#endif // GRPCXX_CREATE_CHANNEL_H diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index 5cbcca3aa5e..12c1a2fc98a 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CREDENTIALS_H_ -#define __GRPCPP_CREDENTIALS_H_ +#ifndef GRPCXX_CREDENTIALS_H +#define GRPCXX_CREDENTIALS_H #include #include @@ -47,7 +47,7 @@ namespace grpc { // to creating an instance using CredentialsFactory, and passing it down // during channel construction. -class Credentials final { +class Credentials GRPC_FINAL { public: ~Credentials(); @@ -133,4 +133,4 @@ class CredentialsFactory { } // namespace grpc -#endif // __GRPCPP_CREDENTIALS_H_ +#endif // GRPCXX_CREDENTIALS_H diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index 341710f7a2e..3e199e3eaef 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -31,10 +31,11 @@ * */ -#ifndef __GRPCPP_CALL_H__ -#define __GRPCPP_CALL_H__ +#ifndef GRPCXX_IMPL_CALL_H +#define GRPCXX_IMPL_CALL_H #include +#include #include #include @@ -56,7 +57,7 @@ class Call; class CallOpBuffer : public CompletionQueueTag { public: - CallOpBuffer() : return_tag_(this) {} + CallOpBuffer(); ~CallOpBuffer(); void Reset(void *next_return_tag); @@ -80,40 +81,40 @@ class CallOpBuffer : public CompletionQueueTag { 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) override; + bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE; - bool got_message = false; + bool got_message; private: - void *return_tag_ = nullptr; + void *return_tag_; // Send initial metadata - bool send_initial_metadata_ = false; - size_t initial_metadata_count_ = 0; - grpc_metadata *initial_metadata_ = nullptr; + bool send_initial_metadata_; + size_t initial_metadata_count_; + grpc_metadata *initial_metadata_; // Recv initial metadta - std::multimap *recv_initial_metadata_ = nullptr; - grpc_metadata_array recv_initial_metadata_arr_ = {0, 0, nullptr}; + std::multimap *recv_initial_metadata_; + grpc_metadata_array recv_initial_metadata_arr_; // Send message - const google::protobuf::Message *send_message_ = nullptr; - grpc_byte_buffer *send_message_buf_ = nullptr; + const google::protobuf::Message *send_message_; + grpc_byte_buffer *send_message_buf_; // Recv message - google::protobuf::Message *recv_message_ = nullptr; - grpc_byte_buffer *recv_message_buf_ = nullptr; + google::protobuf::Message *recv_message_; + grpc_byte_buffer *recv_message_buf_; // Client send close - bool client_send_close_ = false; + bool client_send_close_; // Client recv status - std::multimap *recv_trailing_metadata_ = nullptr; - Status *recv_status_ = nullptr; - grpc_metadata_array recv_trailing_metadata_arr_ = {0, 0, nullptr}; - grpc_status_code status_code_ = GRPC_STATUS_OK; - char *status_details_ = nullptr; - size_t status_details_capacity_ = 0; + std::multimap *recv_trailing_metadata_; + Status *recv_status_; + grpc_metadata_array recv_trailing_metadata_arr_; + grpc_status_code status_code_; + char *status_details_; + size_t status_details_capacity_; // Server send status - const Status *send_status_ = nullptr; - size_t trailing_metadata_count_ = 0; - grpc_metadata *trailing_metadata_ = nullptr; + const Status *send_status_; + size_t trailing_metadata_count_; + grpc_metadata *trailing_metadata_; int cancelled_buf_; - bool *recv_closed_ = nullptr; + bool *recv_closed_; }; // Channel and Server implement this to allow them to hook performing ops @@ -124,7 +125,7 @@ class CallHook { }; // Straightforward wrapping of the C call object -class Call final { +class Call GRPC_FINAL { public: /* call is owned by the caller */ Call(grpc_call *call, CallHook *call_hook_, CompletionQueue *cq); @@ -142,4 +143,4 @@ class Call final { } // namespace grpc -#endif // __GRPCPP_CALL_INTERFACE_H__ +#endif // GRPCXX_IMPL_CALL_H diff --git a/include/grpc++/impl/client_unary_call.h b/include/grpc++/impl/client_unary_call.h index f25ded7a249..d8703264e60 100644 --- a/include/grpc++/impl/client_unary_call.h +++ b/include/grpc++/impl/client_unary_call.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_CLIENT_UNARY_CALL_H__ -#define __GRPCPP_CLIENT_UNARY_CALL_H__ +#ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H +#define GRPCXX_IMPL_CLIENT_UNARY_CALL_H namespace google { namespace protobuf { @@ -56,4 +56,4 @@ Status BlockingUnaryCall(ChannelInterface *channel, const RpcMethod &method, } // namespace grpc -#endif +#endif // GRPCXX_IMPL_CLIENT_UNARY_CALL_H diff --git a/include/grpc++/impl/internal_stub.h b/include/grpc++/impl/internal_stub.h index 25290121cdf..2cbf1d901b2 100644 --- a/include/grpc++/impl/internal_stub.h +++ b/include/grpc++/impl/internal_stub.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_IMPL_INTERNAL_STUB_H__ -#define __GRPCPP_IMPL_INTERNAL_STUB_H__ +#ifndef GRPCXX_IMPL_INTERNAL_STUB_H +#define GRPCXX_IMPL_INTERNAL_STUB_H #include @@ -57,4 +57,4 @@ class InternalStub { } // namespace grpc -#endif // __GRPCPP_IMPL_INTERNAL_STUB_H__ +#endif // GRPCXX_IMPL_INTERNAL_STUB_H diff --git a/include/grpc++/impl/rpc_method.h b/include/grpc++/impl/rpc_method.h index 0236b1182a0..ab407f5c468 100644 --- a/include/grpc++/impl/rpc_method.h +++ b/include/grpc++/impl/rpc_method.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_IMPL_RPC_METHOD_H__ -#define __GRPCPP_IMPL_RPC_METHOD_H__ +#ifndef GRPCXX_IMPL_RPC_METHOD_H +#define GRPCXX_IMPL_RPC_METHOD_H namespace google { namespace protobuf { @@ -66,4 +66,4 @@ class RpcMethod { } // namespace grpc -#endif // __GRPCPP_IMPL_RPC_METHOD_H__ +#endif // GRPCXX_IMPL_RPC_METHOD_H diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index ffd5c34ef6d..ff94c7e6c00 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ -#define __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ +#ifndef GRPCXX_IMPL_RPC_SERVICE_METHOD_H +#define GRPCXX_IMPL_RPC_SERVICE_METHOD_H #include #include @@ -77,7 +77,7 @@ class RpcMethodHandler : public MethodHandler { ServiceType* service) : func_(func), service_(service) {} - Status RunHandler(const HandlerParameter& param) final { + Status RunHandler(const HandlerParameter& param) GRPC_FINAL { // Invoke application function, cast proto messages to their actual types. return func_(service_, param.server_context, dynamic_cast(param.request), @@ -102,7 +102,7 @@ class ClientStreamingHandler : public MethodHandler { ServiceType* service) : func_(func), service_(service) {} - Status RunHandler(const HandlerParameter& param) final { + Status RunHandler(const HandlerParameter& param) GRPC_FINAL { ServerReader reader(param.call, param.server_context); return func_(service_, param.server_context, &reader, dynamic_cast(param.response)); @@ -124,7 +124,7 @@ class ServerStreamingHandler : public MethodHandler { ServiceType* service) : func_(func), service_(service) {} - Status RunHandler(const HandlerParameter& param) final { + Status RunHandler(const HandlerParameter& param) GRPC_FINAL { ServerWriter writer(param.call, param.server_context); return func_(service_, param.server_context, dynamic_cast(param.request), &writer); @@ -147,7 +147,7 @@ class BidiStreamingHandler : public MethodHandler { ServiceType* service) : func_(func), service_(service) {} - Status RunHandler(const HandlerParameter& param) final { + Status RunHandler(const HandlerParameter& param) GRPC_FINAL { ServerReaderWriter stream(param.call, param.server_context); return func_(service_, param.server_context, &stream); @@ -203,4 +203,4 @@ class RpcService { } // namespace grpc -#endif // __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ +#endif // GRPCXX_IMPL_RPC_SERVICE_METHOD_H diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h index cafa2696ab2..7481d64d6af 100644 --- a/include/grpc++/impl/service_type.h +++ b/include/grpc++/impl/service_type.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_IMPL_SERVICE_TYPE_H__ -#define __GRPCPP_IMPL_SERVICE_TYPE_H__ +#ifndef GRPCXX_IMPL_SERVICE_TYPE_H +#define GRPCXX_IMPL_SERVICE_TYPE_H namespace google { namespace protobuf { @@ -79,7 +79,11 @@ class AsynchronousService { AsynchronousService(CompletionQueue* cq, const char** method_names, size_t method_count) - : cq_(cq), method_names_(method_names), method_count_(method_count) {} + : cq_(cq), + dispatch_impl_(nullptr), + method_names_(method_names), + method_count_(method_count), + request_args_(nullptr) {} ~AsynchronousService() { delete[] request_args_; } @@ -116,12 +120,12 @@ class AsynchronousService { private: friend class Server; CompletionQueue* const cq_; - DispatchImpl* dispatch_impl_ = nullptr; + DispatchImpl* dispatch_impl_; const char** const method_names_; size_t method_count_; - void** request_args_ = nullptr; + void** request_args_; }; } // namespace grpc -#endif // __GRPCPP_IMPL_SERVICE_TYPE_H__ +#endif // GRPCXX_IMPL_SERVICE_TYPE_H diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 429c0ff3cf8..3282b82d04e 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_SERVER_H__ -#define __GRPCPP_SERVER_H__ +#ifndef GRPCXX_SERVER_H +#define GRPCXX_SERVER_H #include #include @@ -61,8 +61,8 @@ class ServerCredentials; class ThreadPoolInterface; // Currently it only supports handling rpcs in a single thread. -class Server final : private CallHook, - private AsynchronousService::DispatchImpl { +class Server GRPC_FINAL : private CallHook, + private AsynchronousService::DispatchImpl { public: ~Server(); @@ -97,7 +97,7 @@ class Server final : private CallHook, void RunRpc(); void ScheduleCallback(); - void PerformOpsOnCall(CallOpBuffer* ops, Call* call) override; + void PerformOpsOnCall(CallOpBuffer* ops, Call* call) GRPC_OVERRIDE; // DispatchImpl void RequestAsyncCall(void* registered_method, ServerContext* context, @@ -130,4 +130,4 @@ class Server final : private CallHook, } // namespace grpc -#endif // __GRPCPP_SERVER_H__ +#endif // GRPCXX_SERVER_H diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 4545c413d25..5566002dc22 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_SERVER_BUILDER_H__ -#define __GRPCPP_SERVER_BUILDER_H__ +#ifndef GRPCXX_SERVER_BUILDER_H +#define GRPCXX_SERVER_BUILDER_H #include #include @@ -83,9 +83,9 @@ class ServerBuilder { std::vector async_services_; std::vector ports_; std::shared_ptr creds_; - ThreadPoolInterface* thread_pool_ = nullptr; + ThreadPoolInterface* thread_pool_; }; } // namespace grpc -#endif // __GRPCPP_SERVER_BUILDER_H__ +#endif // GRPCXX_SERVER_BUILDER_H diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h index d327d8b41e5..9387f4a7e26 100644 --- a/include/grpc++/server_context.h +++ b/include/grpc++/server_context.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_SERVER_CONTEXT_H_ -#define __GRPCPP_SERVER_CONTEXT_H_ +#ifndef GRPCXX_SERVER_CONTEXT_H +#define GRPCXX_SERVER_CONTEXT_H #include #include @@ -66,7 +66,7 @@ class CompletionQueue; class Server; // Interface of server side rpc context. -class ServerContext final { +class ServerContext GRPC_FINAL { public: ServerContext(); // for async calls ~ServerContext(); @@ -108,12 +108,12 @@ class ServerContext final { ServerContext(gpr_timespec deadline, grpc_metadata* metadata, size_t metadata_count); - CompletionOp* completion_op_ = nullptr; + CompletionOp* completion_op_; std::chrono::system_clock::time_point deadline_; - grpc_call* call_ = nullptr; - CompletionQueue* cq_ = nullptr; - bool sent_initial_metadata_ = false; + grpc_call* call_; + CompletionQueue* cq_; + bool sent_initial_metadata_; std::multimap client_metadata_; std::multimap initial_metadata_; std::multimap trailing_metadata_; @@ -121,4 +121,4 @@ class ServerContext final { } // namespace grpc -#endif // __GRPCPP_SERVER_CONTEXT_H_ +#endif // GRPCXX_SERVER_CONTEXT_H diff --git a/include/grpc++/server_credentials.h b/include/grpc++/server_credentials.h index 5c6787a0770..45cd279e0b0 100644 --- a/include/grpc++/server_credentials.h +++ b/include/grpc++/server_credentials.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_SERVER_CREDENTIALS_H_ -#define __GRPCPP_SERVER_CREDENTIALS_H_ +#ifndef GRPCXX_SERVER_CREDENTIALS_H +#define GRPCXX_SERVER_CREDENTIALS_H #include #include @@ -44,7 +44,7 @@ struct grpc_server_credentials; namespace grpc { // grpc_server_credentials wrapper class. -class ServerCredentials final { +class ServerCredentials GRPC_FINAL { public: ~ServerCredentials(); @@ -79,4 +79,4 @@ class ServerCredentialsFactory { } // namespace grpc -#endif // __GRPCPP_SERVER_CREDENTIALS_H_ +#endif // GRPCXX_SERVER_CREDENTIALS_H diff --git a/include/grpc++/status.h b/include/grpc++/status.h index 1dfb0c997ca..8073319eab8 100644 --- a/include/grpc++/status.h +++ b/include/grpc++/status.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_STATUS_H__ -#define __GRPCPP_STATUS_H__ +#ifndef GRPCXX_STATUS_H +#define GRPCXX_STATUS_H #include #include @@ -62,4 +62,4 @@ class Status { } // namespace grpc -#endif // __GRPCPP_STATUS_H__ +#endif // GRPCXX_STATUS_H diff --git a/include/grpc++/status_code_enum.h b/include/grpc++/status_code_enum.h index 0ec0a976d22..2728fb0ec1f 100644 --- a/include/grpc++/status_code_enum.h +++ b/include/grpc++/status_code_enum.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_STATUS_CODE_ENUM_H__ -#define __GRPCPP_STATUS_CODE_ENUM_H__ +#ifndef GRPCXX_STATUS_CODE_ENUM_H +#define GRPCXX_STATUS_CODE_ENUM_H namespace grpc { @@ -195,4 +195,4 @@ enum StatusCode { } // namespace grpc -#endif // __GRPCPP_STATUS_CODE_ENUM_H_ +#endif // GRPCXX_STATUS_CODE_ENUM_H diff --git a/include/grpc++/stream.h b/include/grpc++/stream.h index cd95ff7c92f..d95a379757e 100644 --- a/include/grpc++/stream.h +++ b/include/grpc++/stream.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_STREAM_H__ -#define __GRPCPP_STREAM_H__ +#ifndef GRPCXX_STREAM_H +#define GRPCXX_STREAM_H #include #include @@ -83,8 +83,8 @@ class WriterInterface { }; template -class ClientReader final : public ClientStreamingInterface, - public ReaderInterface { +class ClientReader GRPC_FINAL : public ClientStreamingInterface, + public ReaderInterface { public: // Blocking create a stream and write the first request out. ClientReader(ChannelInterface* channel, const RpcMethod& method, @@ -111,7 +111,7 @@ class ClientReader final : public ClientStreamingInterface, GPR_ASSERT(cq_.Pluck(&buf)); } - virtual bool Read(R* msg) override { + virtual bool Read(R* msg) GRPC_OVERRIDE { CallOpBuffer buf; if (!context_->initial_metadata_received_) { buf.AddRecvInitialMetadata(context_); @@ -121,7 +121,7 @@ class ClientReader final : public ClientStreamingInterface, return cq_.Pluck(&buf) && buf.got_message; } - virtual Status Finish() override { + virtual Status Finish() GRPC_OVERRIDE { CallOpBuffer buf; Status status; buf.AddClientRecvStatus(context_, &status); @@ -137,8 +137,8 @@ class ClientReader final : public ClientStreamingInterface, }; template -class ClientWriter final : public ClientStreamingInterface, - public WriterInterface { +class ClientWriter GRPC_FINAL : public ClientStreamingInterface, + public WriterInterface { public: // Blocking create a stream. ClientWriter(ChannelInterface* channel, const RpcMethod& method, @@ -152,7 +152,7 @@ class ClientWriter final : public ClientStreamingInterface, cq_.Pluck(&buf); } - virtual bool Write(const W& msg) override { + virtual bool Write(const W& msg) GRPC_OVERRIDE { CallOpBuffer buf; buf.AddSendMessage(msg); call_.PerformOps(&buf); @@ -167,7 +167,7 @@ class ClientWriter final : public ClientStreamingInterface, } // Read the final response and wait for the final status. - virtual Status Finish() override { + virtual Status Finish() GRPC_OVERRIDE { CallOpBuffer buf; Status status; buf.AddRecvMessage(response_); @@ -186,9 +186,9 @@ class ClientWriter final : public ClientStreamingInterface, // Client-side interface for bi-directional streaming. template -class ClientReaderWriter final : public ClientStreamingInterface, - public WriterInterface, - public ReaderInterface { +class ClientReaderWriter GRPC_FINAL : public ClientStreamingInterface, + public WriterInterface, + public ReaderInterface { public: // Blocking create a stream. ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, @@ -213,7 +213,7 @@ class ClientReaderWriter final : public ClientStreamingInterface, GPR_ASSERT(cq_.Pluck(&buf)); } - virtual bool Read(R* msg) override { + virtual bool Read(R* msg) GRPC_OVERRIDE { CallOpBuffer buf; if (!context_->initial_metadata_received_) { buf.AddRecvInitialMetadata(context_); @@ -223,7 +223,7 @@ class ClientReaderWriter final : public ClientStreamingInterface, return cq_.Pluck(&buf) && buf.got_message; } - virtual bool Write(const W& msg) override { + virtual bool Write(const W& msg) GRPC_OVERRIDE { CallOpBuffer buf; buf.AddSendMessage(msg); call_.PerformOps(&buf); @@ -237,7 +237,7 @@ class ClientReaderWriter final : public ClientStreamingInterface, return cq_.Pluck(&buf); } - virtual Status Finish() override { + virtual Status Finish() GRPC_OVERRIDE { CallOpBuffer buf; Status status; buf.AddClientRecvStatus(context_, &status); @@ -253,7 +253,7 @@ class ClientReaderWriter final : public ClientStreamingInterface, }; template -class ServerReader final : public ReaderInterface { +class ServerReader GRPC_FINAL : public ReaderInterface { public: ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -267,7 +267,7 @@ class ServerReader final : public ReaderInterface { call_->cq()->Pluck(&buf); } - virtual bool Read(R* msg) override { + virtual bool Read(R* msg) GRPC_OVERRIDE { CallOpBuffer buf; buf.AddRecvMessage(msg); call_->PerformOps(&buf); @@ -280,7 +280,7 @@ class ServerReader final : public ReaderInterface { }; template -class ServerWriter final : public WriterInterface { +class ServerWriter GRPC_FINAL : public WriterInterface { public: ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -294,7 +294,7 @@ class ServerWriter final : public WriterInterface { call_->cq()->Pluck(&buf); } - virtual bool Write(const W& msg) override { + virtual bool Write(const W& msg) GRPC_OVERRIDE { CallOpBuffer buf; if (!ctx_->sent_initial_metadata_) { buf.AddSendInitialMetadata(&ctx_->initial_metadata_); @@ -312,8 +312,8 @@ class ServerWriter final : public WriterInterface { // Server-side interface for bi-directional streaming. template -class ServerReaderWriter final : public WriterInterface, - public ReaderInterface { +class ServerReaderWriter GRPC_FINAL : public WriterInterface, + public ReaderInterface { public: ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} @@ -327,14 +327,14 @@ class ServerReaderWriter final : public WriterInterface, call_->cq()->Pluck(&buf); } - virtual bool Read(R* msg) override { + virtual bool Read(R* msg) GRPC_OVERRIDE { CallOpBuffer buf; buf.AddRecvMessage(msg); call_->PerformOps(&buf); return call_->cq()->Pluck(&buf) && buf.got_message; } - virtual bool Write(const W& msg) override { + virtual bool Write(const W& msg) GRPC_OVERRIDE { CallOpBuffer buf; if (!ctx_->sent_initial_metadata_) { buf.AddSendInitialMetadata(&ctx_->initial_metadata_); @@ -380,8 +380,8 @@ class AsyncWriterInterface { }; template -class ClientAsyncReader final : public ClientAsyncStreamingInterface, - public AsyncReaderInterface { +class ClientAsyncReader GRPC_FINAL : public ClientAsyncStreamingInterface, + public AsyncReaderInterface { public: // Create a stream and write the first request out. ClientAsyncReader(ChannelInterface* channel, CompletionQueue* cq, @@ -395,7 +395,7 @@ class ClientAsyncReader final : public ClientAsyncStreamingInterface, call_.PerformOps(&init_buf_); } - void ReadInitialMetadata(void* tag) override { + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!context_->initial_metadata_received_); meta_buf_.Reset(tag); @@ -403,7 +403,7 @@ class ClientAsyncReader final : public ClientAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - void Read(R* msg, void* tag) override { + void Read(R* msg, void* tag) GRPC_OVERRIDE { read_buf_.Reset(tag); if (!context_->initial_metadata_received_) { read_buf_.AddRecvInitialMetadata(context_); @@ -412,7 +412,7 @@ class ClientAsyncReader final : public ClientAsyncStreamingInterface, call_.PerformOps(&read_buf_); } - void Finish(Status* status, void* tag) override { + void Finish(Status* status, void* tag) GRPC_OVERRIDE { finish_buf_.Reset(tag); if (!context_->initial_metadata_received_) { finish_buf_.AddRecvInitialMetadata(context_); @@ -422,7 +422,7 @@ class ClientAsyncReader final : public ClientAsyncStreamingInterface, } private: - ClientContext* context_ = nullptr; + ClientContext* context_; Call call_; CallOpBuffer init_buf_; CallOpBuffer meta_buf_; @@ -431,8 +431,8 @@ class ClientAsyncReader final : public ClientAsyncStreamingInterface, }; template -class ClientAsyncWriter final : public ClientAsyncStreamingInterface, - public AsyncWriterInterface { +class ClientAsyncWriter GRPC_FINAL : public ClientAsyncStreamingInterface, + public AsyncWriterInterface { public: ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, @@ -445,7 +445,7 @@ class ClientAsyncWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&init_buf_); } - void ReadInitialMetadata(void* tag) override { + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!context_->initial_metadata_received_); meta_buf_.Reset(tag); @@ -453,7 +453,7 @@ class ClientAsyncWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - void Write(const W& msg, void* tag) override { + void Write(const W& msg, void* tag) GRPC_OVERRIDE { write_buf_.Reset(tag); write_buf_.AddSendMessage(msg); call_.PerformOps(&write_buf_); @@ -465,7 +465,7 @@ class ClientAsyncWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&writes_done_buf_); } - void Finish(Status* status, void* tag) override { + void Finish(Status* status, void* tag) GRPC_OVERRIDE { finish_buf_.Reset(tag); if (!context_->initial_metadata_received_) { finish_buf_.AddRecvInitialMetadata(context_); @@ -476,7 +476,7 @@ class ClientAsyncWriter final : public ClientAsyncStreamingInterface, } private: - ClientContext* context_ = nullptr; + ClientContext* context_; google::protobuf::Message* const response_; Call call_; CallOpBuffer init_buf_; @@ -488,9 +488,9 @@ class ClientAsyncWriter final : public ClientAsyncStreamingInterface, // Client-side interface for bi-directional streaming. template -class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { +class ClientAsyncReaderWriter GRPC_FINAL : public ClientAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { public: ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, @@ -501,7 +501,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&init_buf_); } - void ReadInitialMetadata(void* tag) override { + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!context_->initial_metadata_received_); meta_buf_.Reset(tag); @@ -509,7 +509,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - void Read(R* msg, void* tag) override { + void Read(R* msg, void* tag) GRPC_OVERRIDE { read_buf_.Reset(tag); if (!context_->initial_metadata_received_) { read_buf_.AddRecvInitialMetadata(context_); @@ -518,7 +518,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&read_buf_); } - void Write(const W& msg, void* tag) override { + void Write(const W& msg, void* tag) GRPC_OVERRIDE { write_buf_.Reset(tag); write_buf_.AddSendMessage(msg); call_.PerformOps(&write_buf_); @@ -530,7 +530,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, call_.PerformOps(&writes_done_buf_); } - void Finish(Status* status, void* tag) override { + void Finish(Status* status, void* tag) GRPC_OVERRIDE { finish_buf_.Reset(tag); if (!context_->initial_metadata_received_) { finish_buf_.AddRecvInitialMetadata(context_); @@ -540,7 +540,7 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, } private: - ClientContext* context_ = nullptr; + ClientContext* context_; Call call_; CallOpBuffer init_buf_; CallOpBuffer meta_buf_; @@ -551,13 +551,13 @@ class ClientAsyncReaderWriter final : public ClientAsyncStreamingInterface, }; template -class ServerAsyncReader : public ServerAsyncStreamingInterface, - public AsyncReaderInterface { +class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncReaderInterface { public: explicit ServerAsyncReader(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - void SendInitialMetadata(void* tag) override { + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!ctx_->sent_initial_metadata_); meta_buf_.Reset(tag); @@ -566,7 +566,7 @@ class ServerAsyncReader : public ServerAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - void Read(R* msg, void* tag) override { + void Read(R* msg, void* tag) GRPC_OVERRIDE { read_buf_.Reset(tag); read_buf_.AddRecvMessage(msg); call_.PerformOps(&read_buf_); @@ -598,7 +598,7 @@ class ServerAsyncReader : public ServerAsyncStreamingInterface, } private: - void BindCall(Call* call) override { call_ = *call; } + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } Call call_; ServerContext* ctx_; @@ -608,13 +608,13 @@ class ServerAsyncReader : public ServerAsyncStreamingInterface, }; template -class ServerAsyncWriter : public ServerAsyncStreamingInterface, - public AsyncWriterInterface { +class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface { public: explicit ServerAsyncWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - void SendInitialMetadata(void* tag) override { + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!ctx_->sent_initial_metadata_); meta_buf_.Reset(tag); @@ -623,7 +623,7 @@ class ServerAsyncWriter : public ServerAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - void Write(const W& msg, void* tag) override { + void Write(const W& msg, void* tag) GRPC_OVERRIDE { write_buf_.Reset(tag); if (!ctx_->sent_initial_metadata_) { write_buf_.AddSendInitialMetadata(&ctx_->initial_metadata_); @@ -644,7 +644,7 @@ class ServerAsyncWriter : public ServerAsyncStreamingInterface, } private: - void BindCall(Call* call) override { call_ = *call; } + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } Call call_; ServerContext* ctx_; @@ -655,14 +655,14 @@ class ServerAsyncWriter : public ServerAsyncStreamingInterface, // Server-side interface for bi-directional streaming. template -class ServerAsyncReaderWriter : public ServerAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { +class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { public: explicit ServerAsyncReaderWriter(ServerContext* ctx) : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - void SendInitialMetadata(void* tag) override { + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { GPR_ASSERT(!ctx_->sent_initial_metadata_); meta_buf_.Reset(tag); @@ -671,13 +671,13 @@ class ServerAsyncReaderWriter : public ServerAsyncStreamingInterface, call_.PerformOps(&meta_buf_); } - virtual void Read(R* msg, void* tag) override { + virtual void Read(R* msg, void* tag) GRPC_OVERRIDE { read_buf_.Reset(tag); read_buf_.AddRecvMessage(msg); call_.PerformOps(&read_buf_); } - virtual void Write(const W& msg, void* tag) override { + virtual void Write(const W& msg, void* tag) GRPC_OVERRIDE { write_buf_.Reset(tag); if (!ctx_->sent_initial_metadata_) { write_buf_.AddSendInitialMetadata(&ctx_->initial_metadata_); @@ -698,7 +698,7 @@ class ServerAsyncReaderWriter : public ServerAsyncStreamingInterface, } private: - void BindCall(Call* call) override { call_ = *call; } + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } Call call_; ServerContext* ctx_; @@ -710,4 +710,4 @@ class ServerAsyncReaderWriter : public ServerAsyncStreamingInterface, } // namespace grpc -#endif // __GRPCPP_STREAM_H__ +#endif // GRPCXX_STREAM_H diff --git a/include/grpc++/thread_pool_interface.h b/include/grpc++/thread_pool_interface.h index c8392493241..ead307f6a2f 100644 --- a/include/grpc++/thread_pool_interface.h +++ b/include/grpc++/thread_pool_interface.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_THREAD_POOL_INTERFACE_H__ -#define __GRPCPP_THREAD_POOL_INTERFACE_H__ +#ifndef GRPCXX_THREAD_POOL_INTERFACE_H +#define GRPCXX_THREAD_POOL_INTERFACE_H #include @@ -49,4 +49,4 @@ class ThreadPoolInterface { } // namespace grpc -#endif // __GRPCPP_THREAD_POOL_INTERFACE_H__ +#endif // GRPCXX_THREAD_POOL_INTERFACE_H diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h index 89d8557edff..0ff494cdec9 100644 --- a/include/grpc/byte_buffer.h +++ b/include/grpc/byte_buffer.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_BYTE_BUFFER_H__ -#define __GRPC_BYTE_BUFFER_H__ +#ifndef GRPC_BYTE_BUFFER_H +#define GRPC_BYTE_BUFFER_H #include #include @@ -47,4 +47,4 @@ struct grpc_byte_buffer { } data; }; -#endif /* __GRPC_BYTE_BUFFER_H__ */ +#endif /* GRPC_BYTE_BUFFER_H */ diff --git a/include/grpc/byte_buffer_reader.h b/include/grpc/byte_buffer_reader.h index 4446e0c6b39..cb757cf6420 100644 --- a/include/grpc/byte_buffer_reader.h +++ b/include/grpc/byte_buffer_reader.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_BYTE_BUFFER_READER_H__ -#define __GRPC_BYTE_BUFFER_READER_H__ +#ifndef GRPC_BYTE_BUFFER_READER_H +#define GRPC_BYTE_BUFFER_READER_H #include #include @@ -46,4 +46,4 @@ struct grpc_byte_buffer_reader { } current; }; -#endif /* __GRPC_BYTE_BUFFER_READER_H__ */ +#endif /* GRPC_BYTE_BUFFER_READER_H */ diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 4a720d11f85..bb1653101f4 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_GRPC_H__ -#define __GRPC_GRPC_H__ +#ifndef GRPC_GRPC_H +#define GRPC_GRPC_H #include @@ -632,4 +632,4 @@ void grpc_server_destroy(grpc_server *server); } #endif -#endif /* __GRPC_GRPC_H__ */ +#endif /* GRPC_GRPC_H */ diff --git a/include/grpc/grpc_http.h b/include/grpc/grpc_http.h index 757f53f9df1..c41e87413f3 100644 --- a/include/grpc/grpc_http.h +++ b/include/grpc/grpc_http.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_GRPC_HTTP_H__ -#define __GRPC_GRPC_HTTP_H__ +#ifndef GRPC_GRPC_HTTP_H +#define GRPC_GRPC_HTTP_H #ifdef __cplusplus extern "C" { @@ -64,4 +64,4 @@ typedef struct { } #endif -#endif /* __GRPC_GRPC_HTTP_H__ */ +#endif /* GRPC_GRPC_HTTP_H */ diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 4ba4ffc1188..577f03e85fe 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPC_SECURITY_H_ -#define GRPC_SECURITY_H_ +#ifndef GRPC_GRPC_SECURITY_H +#define GRPC_GRPC_SECURITY_H #include "grpc.h" #include "status.h" @@ -185,4 +185,4 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr); } #endif -#endif /* GRPC_SECURITY_H_ */ +#endif /* GRPC_GRPC_SECURITY_H */ diff --git a/include/grpc/status.h b/include/grpc/status.h index 76a71ed26fc..a1a4d2ff0e2 100644 --- a/include/grpc/status.h +++ b/include/grpc/status.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_STATUS_H__ -#define __GRPC_STATUS_H__ +#ifndef GRPC_STATUS_H +#define GRPC_STATUS_H #ifdef __cplusplus extern "C" { @@ -199,4 +199,4 @@ typedef enum { } #endif -#endif /* __GRPC_STATUS_H__ */ +#endif /* GRPC_STATUS_H */ diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 09ea97565b2..509870f3e3d 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ALLOC_H__ -#define __GRPC_SUPPORT_ALLOC_H__ +#ifndef GRPC_SUPPORT_ALLOC_H +#define GRPC_SUPPORT_ALLOC_H #include @@ -55,4 +55,4 @@ void gpr_free_aligned(void *ptr); } #endif -#endif /* __GRPC_SUPPORT_ALLOC_H__ */ +#endif /* GRPC_SUPPORT_ALLOC_H */ diff --git a/include/grpc/support/atm.h b/include/grpc/support/atm.h index f1e30d31e80..feca6b30b23 100644 --- a/include/grpc/support/atm.h +++ b/include/grpc/support/atm.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ATM_H__ -#define __GRPC_SUPPORT_ATM_H__ +#ifndef GRPC_SUPPORT_ATM_H +#define GRPC_SUPPORT_ATM_H /* This interface provides atomic operations and barriers. It is internal to gpr support code and should not be used outside it. @@ -89,4 +89,4 @@ #error could not determine platform for atm #endif -#endif /* __GRPC_SUPPORT_ATM_H__ */ +#endif /* GRPC_SUPPORT_ATM_H */ diff --git a/include/grpc/support/atm_gcc_atomic.h b/include/grpc/support/atm_gcc_atomic.h index 2ae24aec06d..11d78b40973 100644 --- a/include/grpc/support/atm_gcc_atomic.h +++ b/include/grpc/support/atm_gcc_atomic.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ATM_GCC_ATOMIC_H__ -#define __GRPC_SUPPORT_ATM_GCC_ATOMIC_H__ +#ifndef GRPC_SUPPORT_ATM_GCC_ATOMIC_H +#define GRPC_SUPPORT_ATM_GCC_ATOMIC_H /* atm_platform.h for gcc and gcc-like compilers with the __atomic_* interface. */ @@ -66,4 +66,4 @@ static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { __ATOMIC_RELAXED); } -#endif /* __GRPC_SUPPORT_ATM_GCC_ATOMIC_H__ */ +#endif /* GRPC_SUPPORT_ATM_GCC_ATOMIC_H */ diff --git a/include/grpc/support/atm_gcc_sync.h b/include/grpc/support/atm_gcc_sync.h index cec62e1a20d..e863bfd4c1e 100644 --- a/include/grpc/support/atm_gcc_sync.h +++ b/include/grpc/support/atm_gcc_sync.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ATM_GCC_SYNC_H__ -#define __GRPC_SUPPORT_ATM_GCC_SYNC_H__ +#ifndef GRPC_SUPPORT_ATM_GCC_SYNC_H +#define GRPC_SUPPORT_ATM_GCC_SYNC_H /* variant of atm_platform.h for gcc and gcc-like compiers with __sync_* interface */ @@ -70,4 +70,4 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { #define gpr_atm_acq_cas(p, o, n) (__sync_bool_compare_and_swap((p), (o), (n))) #define gpr_atm_rel_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n)) -#endif /* __GRPC_SUPPORT_ATM_GCC_SYNC_H__ */ +#endif /* GRPC_SUPPORT_ATM_GCC_SYNC_H */ diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h index 9bb1cfec357..3b9113c28b0 100644 --- a/include/grpc/support/atm_win32.h +++ b/include/grpc/support/atm_win32.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ATM_WIN32_H__ -#define __GRPC_SUPPORT_ATM_WIN32_H__ +#ifndef GRPC_SUPPORT_ATM_WIN32_H +#define GRPC_SUPPORT_ATM_WIN32_H /* Win32 variant of atm_platform.h */ #include @@ -105,4 +105,4 @@ static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm *p, gpr_atm delta) { return old; } -#endif /* __GRPC_SUPPORT_ATM_WIN32_H__ */ +#endif /* GRPC_SUPPORT_ATM_WIN32_H */ diff --git a/include/grpc/support/cancellable_platform.h b/include/grpc/support/cancellable_platform.h index e77f9f15777..e8e4b84e2f1 100644 --- a/include/grpc/support/cancellable_platform.h +++ b/include/grpc/support/cancellable_platform.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_CANCELLABLE_PLATFORM_H__ -#define __GRPC_SUPPORT_CANCELLABLE_PLATFORM_H__ +#ifndef GRPC_SUPPORT_CANCELLABLE_PLATFORM_H +#define GRPC_SUPPORT_CANCELLABLE_PLATFORM_H #include #include @@ -53,4 +53,4 @@ typedef struct { struct gpr_cancellable_list_ waiters; } gpr_cancellable; -#endif /* __GRPC_SUPPORT_CANCELLABLE_PLATFORM_H__ */ +#endif /* GRPC_SUPPORT_CANCELLABLE_PLATFORM_H */ diff --git a/include/grpc/support/cmdline.h b/include/grpc/support/cmdline.h index 20de12242c7..c2350a07e8c 100644 --- a/include/grpc/support/cmdline.h +++ b/include/grpc/support/cmdline.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_CMDLINE_H__ -#define __GRPC_SUPPORT_CMDLINE_H__ +#ifndef GRPC_SUPPORT_CMDLINE_H +#define GRPC_SUPPORT_CMDLINE_H #ifdef __cplusplus extern "C" { @@ -92,4 +92,4 @@ void gpr_cmdline_destroy(gpr_cmdline *cl); } #endif -#endif /* __GRPC_SUPPORT_CMDLINE_H__ */ +#endif /* GRPC_SUPPORT_CMDLINE_H */ diff --git a/include/grpc/support/cpu.h b/include/grpc/support/cpu.h index 580f12dad72..005c3c721cc 100644 --- a/include/grpc/support/cpu.h +++ b/include/grpc/support/cpu.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SUPPORT_CPU_H__ -#define __GRPC_INTERNAL_SUPPORT_CPU_H__ +#ifndef GRPC_SUPPORT_CPU_H +#define GRPC_SUPPORT_CPU_H #ifdef __cplusplus extern "C" { @@ -54,4 +54,4 @@ unsigned gpr_cpu_current_cpu(void); } // extern "C" #endif -#endif /* __GRPC_INTERNAL_SUPPORT_CPU_H__ */ +#endif /* GRPC_SUPPORT_CPU_H */ diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h index fb9d3d1691e..31f7fedfd5d 100644 --- a/include/grpc/support/histogram.h +++ b/include/grpc/support/histogram.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_HISTOGRAM_H__ -#define __GRPC_SUPPORT_HISTOGRAM_H__ +#ifndef GRPC_SUPPORT_HISTOGRAM_H +#define GRPC_SUPPORT_HISTOGRAM_H #ifdef __cplusplus extern "C" { @@ -63,4 +63,4 @@ double gpr_histogram_sum_of_squares(gpr_histogram *histogram); } #endif -#endif /* __GRPC_SUPPORT_HISTOGRAM_H__ */ +#endif /* GRPC_SUPPORT_HISTOGRAM_H */ diff --git a/include/grpc/support/host_port.h b/include/grpc/support/host_port.h index 2dac38a157c..3cc2f498e8f 100644 --- a/include/grpc/support/host_port.h +++ b/include/grpc/support/host_port.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_HOST_PORT_H__ -#define __GRPC_SUPPORT_HOST_PORT_H__ +#ifndef GRPC_SUPPORT_HOST_PORT_H +#define GRPC_SUPPORT_HOST_PORT_H #ifdef __cplusplus extern "C" { @@ -59,4 +59,4 @@ void gpr_split_host_port(const char *name, char **host, char **port); } #endif -#endif /* __GRPC_SUPPORT_HOST_PORT_H__ */ +#endif /* GRPC_SUPPORT_HOST_PORT_H */ diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index c142949f770..aad4f235d22 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_LOG_H__ -#define __GRPC_SUPPORT_LOG_H__ +#ifndef GRPC_SUPPORT_LOG_H +#define GRPC_SUPPORT_LOG_H #include /* for abort() */ #include @@ -105,4 +105,4 @@ void gpr_set_log_function(gpr_log_func func); } #endif -#endif /* __GRPC_SUPPORT_LOG_H__ */ +#endif /* GRPC_SUPPORT_LOG_H */ diff --git a/include/grpc/support/log_win32.h b/include/grpc/support/log_win32.h index 52d6a703189..ad0edcdb89f 100644 --- a/include/grpc/support/log_win32.h +++ b/include/grpc/support/log_win32.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_LOG_WIN32_H__ -#define __GRPC_SUPPORT_LOG_WIN32_H__ +#ifndef GRPC_SUPPORT_LOG_WIN32_H +#define GRPC_SUPPORT_LOG_WIN32_H #include @@ -50,4 +50,4 @@ char *gpr_format_message(DWORD messageid); } #endif -#endif /* __GRPC_SUPPORT_LOG_H__ */ +#endif /* GRPC_SUPPORT_LOG_WIN32_H */ diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 0a651757bc0..f04c2e76afa 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_PORT_PLATFORM_H__ -#define __GRPC_SUPPORT_PORT_PLATFORM_H__ +#ifndef GRPC_SUPPORT_PORT_PLATFORM_H +#define GRPC_SUPPORT_PORT_PLATFORM_H /* Override this file with one for your platform if you need to redefine things. */ @@ -206,4 +206,4 @@ typedef uintptr_t gpr_uintptr; power of two */ #define GPR_MAX_ALIGNMENT 16 -#endif /* __GRPC_SUPPORT_PORT_PLATFORM_H__ */ +#endif /* GRPC_SUPPORT_PORT_PLATFORM_H */ diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h index 8a2129028fd..9026602f15f 100644 --- a/include/grpc/support/slice.h +++ b/include/grpc/support/slice.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SLICE_H__ -#define __GRPC_SUPPORT_SLICE_H__ +#ifndef GRPC_SUPPORT_SLICE_H +#define GRPC_SUPPORT_SLICE_H #include @@ -175,4 +175,4 @@ int gpr_slice_str_cmp(gpr_slice a, const char *b); } #endif -#endif /* __GRPC_SUPPORT_SLICE_H__ */ +#endif /* GRPC_SUPPORT_SLICE_H */ diff --git a/include/grpc/support/slice_buffer.h b/include/grpc/support/slice_buffer.h index 8b57f9f0b92..56f71ef2349 100644 --- a/include/grpc/support/slice_buffer.h +++ b/include/grpc/support/slice_buffer.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SLICE_BUFFER_H__ -#define __GRPC_SUPPORT_SLICE_BUFFER_H__ +#ifndef GRPC_SUPPORT_SLICE_BUFFER_H +#define GRPC_SUPPORT_SLICE_BUFFER_H #include @@ -81,4 +81,4 @@ void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb); } #endif -#endif /* __GRPC_SUPPORT_SLICE_BUFFER_H__ */ +#endif /* GRPC_SUPPORT_SLICE_BUFFER_H */ diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h index bc99317f3c9..35b2d12e774 100644 --- a/include/grpc/support/sync.h +++ b/include/grpc/support/sync.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SYNC_H__ -#define __GRPC_SUPPORT_SYNC_H__ +#ifndef GRPC_SUPPORT_SYNC_H +#define GRPC_SUPPORT_SYNC_H /* Synchronization primitives for GPR. The type gpr_mu provides a non-reentrant mutex (lock). @@ -345,4 +345,4 @@ gpr_intptr gpr_stats_read(const gpr_stats_counter *c); } #endif -#endif /* __GRPC_SUPPORT_SYNC_H__ */ +#endif /* GRPC_SUPPORT_SYNC_H */ diff --git a/include/grpc/support/sync_generic.h b/include/grpc/support/sync_generic.h index 3bae222cb00..bbd1b3ea2ec 100644 --- a/include/grpc/support/sync_generic.h +++ b/include/grpc/support/sync_generic.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SYNC_GENERIC_H__ -#define __GRPC_SUPPORT_SYNC_GENERIC_H__ +#ifndef GRPC_SUPPORT_SYNC_GENERIC_H +#define GRPC_SUPPORT_SYNC_GENERIC_H /* Generic type defintions for gpr_sync. */ #include @@ -58,4 +58,4 @@ typedef struct { #define GPR_STATS_INIT \ { 0 } -#endif /* __GRPC_SUPPORT_SYNC_GENERIC_H__ */ +#endif /* GRPC_SUPPORT_SYNC_GENERIC_H */ diff --git a/include/grpc/support/sync_posix.h b/include/grpc/support/sync_posix.h index 8ba2c5b8920..762d9ebe3cd 100644 --- a/include/grpc/support/sync_posix.h +++ b/include/grpc/support/sync_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SYNC_POSIX_H__ -#define __GRPC_SUPPORT_SYNC_POSIX_H__ +#ifndef GRPC_SUPPORT_SYNC_POSIX_H +#define GRPC_SUPPORT_SYNC_POSIX_H #include @@ -44,4 +44,4 @@ typedef pthread_once_t gpr_once; #define GPR_ONCE_INIT PTHREAD_ONCE_INIT -#endif /* __GRPC_SUPPORT_SYNC_POSIX_H__ */ +#endif /* GRPC_SUPPORT_SYNC_POSIX_H */ diff --git a/include/grpc/support/sync_win32.h b/include/grpc/support/sync_win32.h index 13823b8ee3d..cb2a8663a05 100644 --- a/include/grpc/support/sync_win32.h +++ b/include/grpc/support/sync_win32.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_SYNC_WIN32_H__ -#define __GRPC_SUPPORT_SYNC_WIN32_H__ +#ifndef GRPC_SUPPORT_SYNC_WIN32_H +#define GRPC_SUPPORT_SYNC_WIN32_H #include @@ -48,4 +48,4 @@ typedef CONDITION_VARIABLE gpr_cv; typedef INIT_ONCE gpr_once; #define GPR_ONCE_INIT INIT_ONCE_STATIC_INIT -#endif /* __GRPC_SUPPORT_SYNC_WIN32_H__ */ +#endif /* GRPC_SUPPORT_SYNC_WIN32_H */ diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index a81e6cd3ba9..64d5bed49a7 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_THD_H__ -#define __GRPC_SUPPORT_THD_H__ +#ifndef GRPC_SUPPORT_THD_H +#define GRPC_SUPPORT_THD_H /* Thread interface for GPR. Types @@ -73,4 +73,4 @@ gpr_thd_id gpr_thd_currentid(void); } #endif -#endif /* __GRPC_SUPPORT_THD_H__ */ +#endif /* GRPC_SUPPORT_THD_H */ diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h index 150b7ac8c53..1fd3181859f 100644 --- a/include/grpc/support/time.h +++ b/include/grpc/support/time.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_TIME_H__ -#define __GRPC_SUPPORT_TIME_H__ +#ifndef GRPC_SUPPORT_TIME_H +#define GRPC_SUPPORT_TIME_H /* Time support. We use gpr_timespec, which is analogous to struct timespec. On some machines, absolute times may be in local time. */ @@ -100,4 +100,4 @@ double gpr_timespec_to_micros(gpr_timespec t); } #endif -#endif /* __GRPC_SUPPORT_TIME_H__ */ +#endif /* GRPC_SUPPORT_TIME_H */ diff --git a/include/grpc/support/useful.h b/include/grpc/support/useful.h index 8d756c37c31..979f3d026b3 100644 --- a/include/grpc/support/useful.h +++ b/include/grpc/support/useful.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_USEFUL_H__ -#define __GRPC_SUPPORT_USEFUL_H__ +#ifndef GRPC_SUPPORT_USEFUL_H +#define GRPC_SUPPORT_USEFUL_H /* useful macros that don't belong anywhere else */ @@ -45,4 +45,4 @@ #define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array))) -#endif /* __GRPC_SUPPORT_USEFUL_H__ */ +#endif /* GRPC_SUPPORT_USEFUL_H */ diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 891032343b5..eade70d5332 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -186,7 +186,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer, printer->Print( *vars, "std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> " - "$Method$(::grpc::ClientContext* context, " + "Async$Method$(::grpc::ClientContext* context, " "const $Request$& request, " "::grpc::CompletionQueue* cq, void* tag);\n"); } else if (ClientOnlyStreaming(method)) { @@ -196,7 +196,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer, "::grpc::ClientContext* context, $Response$* response);\n"); printer->Print( *vars, - "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> $Method$(" + "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> Async$Method$(" "::grpc::ClientContext* context, $Response$* response, " "::grpc::CompletionQueue* cq, void* tag);\n"); } else if (ServerOnlyStreaming(method)) { @@ -206,7 +206,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer, "::grpc::ClientContext* context, const $Request$& request);\n"); printer->Print( *vars, - "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> $Method$(" + "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> Async$Method$(" "::grpc::ClientContext* context, const $Request$& request, " "::grpc::CompletionQueue* cq, void* tag);\n"); } else if (BidiStreaming(method)) { @@ -217,7 +217,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer, printer->Print(*vars, "std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " "$Request$, $Response$>> " - "$Method$(::grpc::ClientContext* context, " + "Async$Method$(::grpc::ClientContext* context, " "::grpc::CompletionQueue* cq, void* tag);\n"); } } @@ -300,13 +300,13 @@ void PrintHeaderService(google::protobuf::io::Printer *printer, (*vars)["Service"] = service->name(); printer->Print(*vars, - "class $Service$ final {\n" + "class $Service$ GRPC_FINAL {\n" " public:\n"); printer->Indent(); // Client side printer->Print( - "class Stub final : public ::grpc::InternalStub {\n" + "class Stub GRPC_FINAL : public ::grpc::InternalStub {\n" " public:\n"); printer->Indent(); for (int i = 0; i < service->method_count(); ++i) { @@ -331,7 +331,7 @@ void PrintHeaderService(google::protobuf::io::Printer *printer, for (int i = 0; i < service->method_count(); ++i) { PrintHeaderServerMethodSync(printer, service->method(i), vars); } - printer->Print("::grpc::RpcService* service() override final;\n"); + printer->Print("::grpc::RpcService* service() GRPC_OVERRIDE GRPC_FINAL;\n"); printer->Outdent(); printer->Print( " private:\n" @@ -340,7 +340,7 @@ void PrintHeaderService(google::protobuf::io::Printer *printer, // Server side - Asynchronous printer->Print( - "class AsyncService final : public ::grpc::AsynchronousService {\n" + "class AsyncService GRPC_FINAL : public ::grpc::AsynchronousService {\n" " public:\n"); printer->Indent(); (*vars)["MethodCount"] = as_string(service->method_count()); @@ -390,7 +390,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer, printer->Print( *vars, "std::unique_ptr< ::grpc::ClientAsyncResponseReader< $Response$>> " - "$Service$::Stub::$Method$(::grpc::ClientContext* context, " + "$Service$::Stub::Async$Method$(::grpc::ClientContext* context, " "const $Request$& request, " "::grpc::CompletionQueue* cq, void* tag) {\n"); printer->Print(*vars, @@ -416,7 +416,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer, "}\n\n"); printer->Print(*vars, "std::unique_ptr< ::grpc::ClientAsyncWriter< $Request$>> " - "$Service$::Stub::$Method$(" + "$Service$::Stub::Async$Method$(" "::grpc::ClientContext* context, $Response$* response, " "::grpc::CompletionQueue* cq, void* tag) {\n"); printer->Print(*vars, @@ -443,7 +443,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer, "}\n\n"); printer->Print(*vars, "std::unique_ptr< ::grpc::ClientAsyncReader< $Response$>> " - "$Service$::Stub::$Method$(" + "$Service$::Stub::Async$Method$(" "::grpc::ClientContext* context, const $Request$& request, " "::grpc::CompletionQueue* cq, void* tag) {\n"); printer->Print(*vars, @@ -471,7 +471,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer, printer->Print(*vars, "std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " "$Request$, $Response$>> " - "$Service$::Stub::$Method$(::grpc::ClientContext* context, " + "$Service$::Stub::Async$Method$(::grpc::ClientContext* context, " "::grpc::CompletionQueue* cq, void* tag) {\n"); printer->Print(*vars, " return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< " @@ -609,7 +609,7 @@ void PrintSourceService(google::protobuf::io::Printer *printer, " std::unique_ptr< $Service$::Stub> stub(new $Service$::Stub());\n" " stub->set_channel(channel);\n" " return stub;\n" - "};\n\n"); + "}\n\n"); for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); PrintSourceClientMethod(printer, service->method(i), vars); diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h index f5b1ad23eee..1bfe5a8819b 100644 --- a/src/compiler/cpp_generator.h +++ b/src/compiler/cpp_generator.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_COMPILER_CPP_GENERATOR_H_ -#define NET_GRPC_COMPILER_CPP_GENERATOR_H_ +#ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H +#define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H #include @@ -58,4 +58,4 @@ std::string GetSourceServices(const google::protobuf::FileDescriptor *file); } // namespace grpc_cpp_generator -#endif // NET_GRPC_COMPILER_CPP_GENERATOR_H_ +#endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H diff --git a/src/compiler/cpp_generator_helpers.h b/src/compiler/cpp_generator_helpers.h index e3c76e02912..16abbde8d47 100644 --- a/src/compiler/cpp_generator_helpers.h +++ b/src/compiler/cpp_generator_helpers.h @@ -31,57 +31,23 @@ * */ -#ifndef NET_GRPC_COMPILER_CPP_GENERATOR_HELPERS_H__ -#define NET_GRPC_COMPILER_CPP_GENERATOR_HELPERS_H__ +#ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H +#define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H #include #include #include #include +#include "src/compiler/generator_helpers.h" namespace grpc_cpp_generator { -inline bool StripSuffix(std::string *filename, const std::string &suffix) { - if (filename->length() >= suffix.length()) { - size_t suffix_pos = filename->length() - suffix.length(); - if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) { - filename->resize(filename->size() - suffix.size()); - return true; - } - } - - return false; -} - -inline std::string StripProto(std::string filename) { - if (!StripSuffix(&filename, ".protodevel")) { - StripSuffix(&filename, ".proto"); - } - return filename; -} - -inline std::string StringReplace(std::string str, const std::string &from, - const std::string &to) { - size_t pos = 0; - - for (;;) { - pos = str.find(from, pos); - if (pos == std::string::npos) { - break; - } - str.replace(pos, from.length(), to); - pos += to.length(); - } - - return str; -} - inline std::string DotsToColons(const std::string &name) { - return StringReplace(name, ".", "::"); + return grpc_generator::StringReplace(name, ".", "::"); } inline std::string DotsToUnderscores(const std::string &name) { - return StringReplace(name, ".", "_"); + return grpc_generator::StringReplace(name, ".", "_"); } inline std::string ClassName(const google::protobuf::Descriptor *descriptor, @@ -103,4 +69,4 @@ inline std::string ClassName(const google::protobuf::Descriptor *descriptor, } // namespace grpc_cpp_generator -#endif // NET_GRPC_COMPILER_CPP_GENERATOR_HELPERS_H__ +#endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc index a421e51b78d..feb158f89e6 100644 --- a/src/compiler/cpp_plugin.cc +++ b/src/compiler/cpp_plugin.cc @@ -63,7 +63,7 @@ class CppGrpcGenerator : public google::protobuf::compiler::CodeGenerator { return false; } - std::string file_name = grpc_cpp_generator::StripProto(file->name()); + std::string file_name = grpc_generator::StripProto(file->name()); // Generate .pb.h Insert(context, file_name + ".pb.h", "includes", diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h new file mode 100644 index 00000000000..2035820f0dc --- /dev/null +++ b/src/compiler/generator_helpers.h @@ -0,0 +1,79 @@ +/* + * + * 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 GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H +#define GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H + +#include +#include + +namespace grpc_generator { + +inline bool StripSuffix(std::string *filename, const std::string &suffix) { + if (filename->length() >= suffix.length()) { + size_t suffix_pos = filename->length() - suffix.length(); + if (filename->compare(suffix_pos, std::string::npos, suffix) == 0) { + filename->resize(filename->size() - suffix.size()); + return true; + } + } + + return false; +} + +inline std::string StripProto(std::string filename) { + if (!StripSuffix(&filename, ".protodevel")) { + StripSuffix(&filename, ".proto"); + } + return filename; +} + +inline std::string StringReplace(std::string str, const std::string &from, + const std::string &to) { + size_t pos = 0; + + for (;;) { + pos = str.find(from, pos); + if (pos == std::string::npos) { + break; + } + str.replace(pos, from.length(), to); + pos += to.length(); + } + + return str; +} + +} // namespace grpc_generator + +#endif // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index cdd3d8a98a5..b8d4aa509b4 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -31,26 +31,38 @@ * */ +#include #include #include +#include #include #include #include +#include +#include "src/compiler/generator_helpers.h" #include "src/compiler/python_generator.h" #include #include #include #include +using grpc_generator::StringReplace; +using grpc_generator::StripProto; +using google::protobuf::Descriptor; using google::protobuf::FileDescriptor; -using google::protobuf::ServiceDescriptor; using google::protobuf::MethodDescriptor; +using google::protobuf::ServiceDescriptor; using google::protobuf::io::Printer; using google::protobuf::io::StringOutputStream; using std::initializer_list; +using std::make_pair; using std::map; +using std::pair; +using std::replace; using std::string; +using std::strlen; +using std::vector; namespace grpc_python_generator { namespace { @@ -99,62 +111,81 @@ class IndentScope { // END FORMATTING BOILERPLATE // //////////////////////////////// -void PrintService(const ServiceDescriptor* service, - Printer* out) { +bool PrintServicer(const ServiceDescriptor* service, + Printer* out) { string doc = ""; map dict = ListToDict({ "Service", service->name(), "Documentation", doc, }); - out->Print(dict, "class $Service$Service(object):\n"); + out->Print(dict, "class EarlyAdopter$Service$Servicer(object):\n"); { IndentScope raii_class_indent(out); out->Print(dict, "\"\"\"$Documentation$\"\"\"\n"); - out->Print("def __init__(self):\n"); - { - IndentScope raii_method_indent(out); - out->Print("pass\n"); + out->Print("__metaclass__ = abc.ABCMeta\n"); + for (int i = 0; i < service->method_count(); ++i) { + auto meth = service->method(i); + string arg_name = meth->client_streaming() ? + "request_iterator" : "request"; + out->Print("@abc.abstractmethod\n"); + out->Print("def $Method$(self, $ArgName$, context):\n", + "Method", meth->name(), "ArgName", arg_name); + { + IndentScope raii_method_indent(out); + out->Print("raise NotImplementedError()\n"); + } } } + return true; } -void PrintServicer(const ServiceDescriptor* service, - Printer* out) { +bool PrintServer(const ServiceDescriptor* service, Printer* out) { string doc = ""; map dict = ListToDict({ "Service", service->name(), "Documentation", doc, }); - out->Print(dict, "class $Service$Servicer(object):\n"); + out->Print(dict, "class EarlyAdopter$Service$Server(object):\n"); { IndentScope raii_class_indent(out); out->Print(dict, "\"\"\"$Documentation$\"\"\"\n"); - for (int i = 0; i < service->method_count(); ++i) { - auto meth = service->method(i); - out->Print("def $Method$(self, arg):\n", "Method", meth->name()); - { - IndentScope raii_method_indent(out); - out->Print("raise NotImplementedError()\n"); - } + out->Print("__metaclass__ = abc.ABCMeta\n"); + out->Print("@abc.abstractmethod\n"); + out->Print("def start(self):\n"); + { + IndentScope raii_method_indent(out); + out->Print("raise NotImplementedError()\n"); + } + + out->Print("@abc.abstractmethod\n"); + out->Print("def stop(self):\n"); + { + IndentScope raii_method_indent(out); + out->Print("raise NotImplementedError()\n"); } } + return true; } -void PrintStub(const ServiceDescriptor* service, +bool PrintStub(const ServiceDescriptor* service, Printer* out) { string doc = ""; map dict = ListToDict({ "Service", service->name(), "Documentation", doc, }); - out->Print(dict, "class $Service$Stub(object):\n"); + out->Print(dict, "class EarlyAdopter$Service$Stub(object):\n"); { IndentScope raii_class_indent(out); out->Print(dict, "\"\"\"$Documentation$\"\"\"\n"); + out->Print("__metaclass__ = abc.ABCMeta\n"); for (int i = 0; i < service->method_count(); ++i) { const MethodDescriptor* meth = service->method(i); - auto methdict = ListToDict({"Method", meth->name()}); - out->Print(methdict, "def $Method$(self, arg):\n"); + string arg_name = meth->client_streaming() ? + "request_iterator" : "request"; + auto methdict = ListToDict({"Method", meth->name(), "ArgName", arg_name}); + out->Print("@abc.abstractmethod\n"); + out->Print(methdict, "def $Method$(self, $ArgName$):\n"); { IndentScope raii_method_indent(out); out->Print("raise NotImplementedError()\n"); @@ -162,169 +193,195 @@ void PrintStub(const ServiceDescriptor* service, out->Print(methdict, "$Method$.async = None\n"); } } + return true; } -void PrintStubImpl(const ServiceDescriptor* service, - Printer* out) { - map dict = ListToDict({ - "Service", service->name(), - }); - out->Print(dict, "class _$Service$Stub($Service$Stub):\n"); - { - IndentScope raii_class_indent(out); - out->Print("def __init__(self, face_stub, default_timeout):\n"); - { - IndentScope raii_method_indent(out); - out->Print("self._face_stub = face_stub\n" - "self._default_timeout = default_timeout\n" - "stub_self = self\n"); +// TODO(protobuf team): Export `ModuleName` from protobuf's +// `src/google/protobuf/compiler/python/python_generator.cc` file. +string ModuleName(const string& filename) { + string basename = StripProto(filename); + basename = StringReplace(basename, "-", "_"); + basename = StringReplace(basename, "/", "."); + return basename + "_pb2"; +} + +bool GetModuleAndMessagePath(const Descriptor* type, + pair* out) { + const Descriptor* path_elem_type = type; + vector message_path; + do { + message_path.push_back(path_elem_type); + path_elem_type = path_elem_type->containing_type(); + } while (path_elem_type != nullptr); + string file_name = type->file()->name(); + static const int proto_suffix_length = strlen(".proto"); + if (!(file_name.size() > static_cast(proto_suffix_length) && + file_name.find_last_of(".proto") == file_name.size() - 1)) { + return false; + } + string module = ModuleName(file_name); + string message_type; + for (auto path_iter = message_path.rbegin(); + path_iter != message_path.rend(); ++path_iter) { + message_type += (*path_iter)->name() + "."; + } + // no pop_back prior to C++11 + message_type.resize(message_type.size() - 1); + *out = make_pair(module, message_type); + return true; +} - for (int i = 0; i < service->method_count(); ++i) { - const MethodDescriptor* meth = service->method(i); - bool server_streaming = meth->server_streaming(); - bool client_streaming = meth->client_streaming(); - std::string blocking_call, future_call; - if (server_streaming) { - if (client_streaming) { - blocking_call = "stub_self._face_stub.inline_stream_in_stream_out"; - future_call = blocking_call; - } else { - blocking_call = "stub_self._face_stub.inline_value_in_stream_out"; - future_call = blocking_call; - } - } else { - if (client_streaming) { - blocking_call = "stub_self._face_stub.blocking_stream_in_value_out"; - future_call = "stub_self._face_stub.future_stream_in_value_out"; - } else { - blocking_call = "stub_self._face_stub.blocking_value_in_value_out"; - future_call = "stub_self._face_stub.future_value_in_value_out"; - } - } - // TODO(atash): use the solution described at - // http://stackoverflow.com/a/2982 to bind 'async' attribute - // functions to def'd functions instead of using callable attributes. - auto methdict = ListToDict({ - "Method", meth->name(), - "BlockingCall", blocking_call, - "FutureCall", future_call - }); - out->Print(methdict, "class $Method$(object):\n"); - { - IndentScope raii_callable_indent(out); - out->Print("def __call__(self, arg):\n"); - { - IndentScope raii_callable_call_indent(out); - out->Print(methdict, - "return $BlockingCall$(\"$Method$\", arg, " - "stub_self._default_timeout)\n"); - } - out->Print("def async(self, arg):\n"); - { - IndentScope raii_callable_async_indent(out); - out->Print(methdict, - "return $FutureCall$(\"$Method$\", arg, " - "stub_self._default_timeout)\n"); - } - } - out->Print(methdict, "self.$Method$ = $Method$()\n"); +bool PrintServerFactory(const ServiceDescriptor* service, Printer* out) { + out->Print("def early_adopter_create_$Service$_server(servicer, port, " + "root_certificates, key_chain_pairs):\n", + "Service", service->name()); + { + IndentScope raii_create_server_indent(out); + map> method_to_module_and_message; + out->Print("method_implementations = {\n"); + for (int i = 0; i < service->method_count(); ++i) { + IndentScope raii_implementations_indent(out); + const MethodDescriptor* meth = service->method(i); + string meth_type = + string(meth->client_streaming() ? "stream" : "unary") + + string(meth->server_streaming() ? "_stream" : "_unary") + "_inline"; + out->Print("\"$Method$\": utilities.$Type$(servicer.$Method$),\n", + "Method", meth->name(), + "Type", meth_type); + // Maintain information on the input type of the service method for later + // use in constructing the service assembly's activated fore link. + const Descriptor* input_type = meth->input_type(); + pair module_and_message; + if (!GetModuleAndMessagePath(input_type, &module_and_message)) { + return false; } + method_to_module_and_message.insert( + make_pair(meth->name(), module_and_message)); + } + out->Print("}\n"); + // Ensure that we've imported all of the relevant messages. + for (auto& meth_vals : method_to_module_and_message) { + out->Print("import $Module$\n", + "Module", meth_vals.second.first); + } + out->Print("request_deserializers = {\n"); + for (auto& meth_vals : method_to_module_and_message) { + IndentScope raii_serializers_indent(out); + string full_input_type_path = meth_vals.second.first + "." + + meth_vals.second.second; + out->Print("\"$Method$\": $Type$.FromString,\n", + "Method", meth_vals.first, + "Type", full_input_type_path); + } + out->Print("}\n"); + out->Print("response_serializers = {\n"); + for (auto& meth_vals : method_to_module_and_message) { + IndentScope raii_serializers_indent(out); + out->Print("\"$Method$\": lambda x: x.SerializeToString(),\n", + "Method", meth_vals.first); } + out->Print("}\n"); + out->Print("link = fore.activated_fore_link(port, request_deserializers, " + "response_serializers, root_certificates, key_chain_pairs)\n"); + out->Print("return implementations.assemble_service(" + "method_implementations, link)\n"); } + return true; } -void PrintStubGenerators(const ServiceDescriptor* service, Printer* out) { +bool PrintStubFactory(const ServiceDescriptor* service, Printer* out) { map dict = ListToDict({ "Service", service->name(), }); - // Write out a generator of linked pairs of Server/Stub - out->Print(dict, "def mock_$Service$(servicer, default_timeout):\n"); + out->Print(dict, "def early_adopter_create_$Service$_stub(host, port):\n"); { - IndentScope raii_mock_indent(out); - out->Print("value_in_value_out = {}\n" - "value_in_stream_out = {}\n" - "stream_in_value_out = {}\n" - "stream_in_stream_out = {}\n"); + IndentScope raii_create_server_indent(out); + map> method_to_module_and_message; + out->Print("method_implementations = {\n"); for (int i = 0; i < service->method_count(); ++i) { + IndentScope raii_implementations_indent(out); const MethodDescriptor* meth = service->method(i); - std::string super_interface, meth_dict; - bool server_streaming = meth->server_streaming(); - bool client_streaming = meth->client_streaming(); - if (server_streaming) { - if (client_streaming) { - super_interface = "InlineStreamInStreamOutMethod"; - meth_dict = "stream_in_stream_out"; - } else { - super_interface = "InlineValueInStreamOutMethod"; - meth_dict = "value_in_stream_out"; - } - } else { - if (client_streaming) { - super_interface = "InlineStreamInValueOutMethod"; - meth_dict = "stream_in_value_out"; - } else { - super_interface = "InlineValueInValueOutMethod"; - meth_dict = "value_in_value_out"; - } + string meth_type = + string(meth->client_streaming() ? "stream" : "unary") + + string(meth->server_streaming() ? "_stream" : "_unary") + "_inline"; + // TODO(atash): once the expected input to assemble_dynamic_inline_stub is + // cleaned up, change this to the expected argument's dictionary values. + out->Print("\"$Method$\": utilities.$Type$(None),\n", + "Method", meth->name(), + "Type", meth_type); + // Maintain information on the input type of the service method for later + // use in constructing the service assembly's activated fore link. + const Descriptor* output_type = meth->output_type(); + pair module_and_message; + if (!GetModuleAndMessagePath(output_type, &module_and_message)) { + return false; } - map methdict = ListToDict({ - "Method", meth->name(), - "SuperInterface", super_interface, - "MethodDict", meth_dict - }); - out->Print( - methdict, "class $Method$(_face_interfaces.$SuperInterface$):\n"); - { - IndentScope raii_inline_class_indent(out); - out->Print("def service(self, request, context):\n"); - { - IndentScope raii_inline_class_fn_indent(out); - out->Print(methdict, "return servicer.$Method$(request)\n"); - } - } - out->Print(methdict, "$MethodDict$['$Method$'] = $Method$()\n"); + method_to_module_and_message.insert( + make_pair(meth->name(), module_and_message)); } - out->Print( - "face_linked_pair = _face_testing.server_and_stub(default_timeout," - "inline_value_in_value_out_methods=value_in_value_out," - "inline_value_in_stream_out_methods=value_in_stream_out," - "inline_stream_in_value_out_methods=stream_in_value_out," - "inline_stream_in_stream_out_methods=stream_in_stream_out)\n"); - out->Print("class LinkedPair(object):\n"); - { - IndentScope raii_linked_pair(out); - out->Print("def __init__(self, server, stub):\n"); - { - IndentScope raii_linked_pair_init(out); - out->Print("self.server = server\n" - "self.stub = stub\n"); - } + out->Print("}\n"); + // Ensure that we've imported all of the relevant messages. + for (auto& meth_vals : method_to_module_and_message) { + out->Print("import $Module$\n", + "Module", meth_vals.second.first); + } + out->Print("response_deserializers = {\n"); + for (auto& meth_vals : method_to_module_and_message) { + IndentScope raii_serializers_indent(out); + string full_output_type_path = meth_vals.second.first + "." + + meth_vals.second.second; + out->Print("\"$Method$\": $Type$.FromString,\n", + "Method", meth_vals.first, + "Type", full_output_type_path); + } + out->Print("}\n"); + out->Print("request_serializers = {\n"); + for (auto& meth_vals : method_to_module_and_message) { + IndentScope raii_serializers_indent(out); + out->Print("\"$Method$\": lambda x: x.SerializeToString(),\n", + "Method", meth_vals.first); } - out->Print( - dict, - "stub = _$Service$Stub(face_linked_pair.stub, default_timeout)\n"); - out->Print("return LinkedPair(None, stub)\n"); + out->Print("}\n"); + out->Print("link = rear.activated_rear_link(" + "host, port, request_serializers, response_deserializers)\n"); + out->Print("return implementations.assemble_dynamic_inline_stub(" + "method_implementations, link)\n"); } + return true; +} + +bool PrintPreamble(const FileDescriptor* file, Printer* out) { + out->Print("import abc\n"); + out->Print("from grpc._adapter import fore\n"); + out->Print("from grpc._adapter import rear\n"); + out->Print("from grpc.framework.assembly import implementations\n"); + out->Print("from grpc.framework.assembly import utilities\n"); + return true; } } // namespace -string GetServices(const FileDescriptor* file) { +pair GetServices(const FileDescriptor* file) { string output; - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - out.Print("from grpc.framework.face import demonstration as _face_testing\n"); - out.Print("from grpc.framework.face import interfaces as _face_interfaces\n"); - - for (int i = 0; i < file->service_count(); ++i) { - auto service = file->service(i); - PrintService(service, &out); - PrintServicer(service, &out); - PrintStub(service, &out); - PrintStubImpl(service, &out); - PrintStubGenerators(service, &out); + { + // Scope the output stream so it closes and finalizes output to the string. + StringOutputStream output_stream(&output); + Printer out(&output_stream, '$'); + if (!PrintPreamble(file, &out)) { + return make_pair(false, ""); + } + for (int i = 0; i < file->service_count(); ++i) { + auto service = file->service(i); + if (!(PrintServicer(service, &out) && + PrintServer(service, &out) && + PrintStub(service, &out) && + PrintServerFactory(service, &out) && + PrintStubFactory(service, &out))) { + return make_pair(false, ""); + } + } } - return output; + return make_pair(true, std::move(output)); } } // namespace grpc_python_generator diff --git a/src/compiler/python_generator.h b/src/compiler/python_generator.h index 673ef7b23b3..df29ca17e3e 100644 --- a/src/compiler/python_generator.h +++ b/src/compiler/python_generator.h @@ -31,10 +31,11 @@ * */ -#ifndef __GRPC_COMPILER_PYTHON_GENERATOR_H__ -#define __GRPC_COMPILER_PYTHON_GENERATOR_H__ +#ifndef GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H +#define GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H #include +#include namespace google { namespace protobuf { @@ -44,8 +45,8 @@ class FileDescriptor; namespace grpc_python_generator { -std::string GetServices(const google::protobuf::FileDescriptor* file); +std::pair GetServices(const google::protobuf::FileDescriptor* file); } // namespace grpc_python_generator -#endif // __GRPC_COMPILER_PYTHON_GENERATOR_H__ +#endif // GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H diff --git a/src/compiler/python_plugin.cc b/src/compiler/python_plugin.cc index 05c6b095d8e..0dd2c5b8344 100644 --- a/src/compiler/python_plugin.cc +++ b/src/compiler/python_plugin.cc @@ -33,6 +33,7 @@ // Generates a Python gRPC service interface out of Protobuf IDL. +#include #include #include @@ -50,19 +51,18 @@ using google::protobuf::compiler::PluginMain; using google::protobuf::io::CodedOutputStream; using google::protobuf::io::ZeroCopyOutputStream; using std::string; +using std::strlen; class PythonGrpcGenerator : public CodeGenerator { public: PythonGrpcGenerator() {} - ~PythonGrpcGenerator() override {} + ~PythonGrpcGenerator() {} - bool Generate(const FileDescriptor* file, - const string& parameter, - GeneratorContext* context, - string* error) const override { + bool Generate(const FileDescriptor* file, const string& parameter, + GeneratorContext* context, string* error) const { // Get output file name. string file_name; - static const int proto_suffix_length = 6; // length of ".proto" + static const int proto_suffix_length = strlen(".proto"); if (file->name().size() > static_cast(proto_suffix_length) && file->name().find_last_of(".proto") == file->name().size() - 1) { file_name = file->name().substr( @@ -75,9 +75,15 @@ class PythonGrpcGenerator : public CodeGenerator { std::unique_ptr output( context->OpenForInsert(file_name, "module_scope")); CodedOutputStream coded_out(output.get()); - string code = grpc_python_generator::GetServices(file); - coded_out.WriteRaw(code.data(), code.size()); - return true; + bool success = false; + string code = ""; + tie(success, code) = grpc_python_generator::GetServices(file); + if (success) { + coded_out.WriteRaw(code.data(), code.size()); + return true; + } else { + return false; + } } }; diff --git a/src/compiler/ruby_generator.h b/src/compiler/ruby_generator.h index d0c568fad0f..4dd38e0c274 100644 --- a/src/compiler/ruby_generator.h +++ b/src/compiler/ruby_generator.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_COMPILER_RUBY_GENERATOR_H_ -#define NET_GRPC_COMPILER_RUBY_GENERATOR_H_ +#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H +#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H #include @@ -48,4 +48,4 @@ std::string GetServices(const google::protobuf::FileDescriptor *file); } // namespace grpc_ruby_generator -#endif // NET_GRPC_COMPILER_RUBY_GENERATOR_H_ +#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_H diff --git a/src/compiler/ruby_generator_helpers-inl.h b/src/compiler/ruby_generator_helpers-inl.h index 61d887b41cd..f3a087b3f8e 100644 --- a/src/compiler/ruby_generator_helpers-inl.h +++ b/src/compiler/ruby_generator_helpers-inl.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_COMPILER_RUBY_GENERATOR_HELPERS_INL_H_ -#define NET_GRPC_COMPILER_RUBY_GENERATOR_HELPERS_INL_H_ +#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H +#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H #include @@ -64,4 +64,4 @@ inline std::string MessagesRequireName( } // namespace grpc_ruby_generator -#endif // NET_GRPC_COMPILER_RUBY_GENERATOR_HELPERS_INL_H_ +#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_HELPERS_INL_H diff --git a/src/compiler/ruby_generator_map-inl.h b/src/compiler/ruby_generator_map-inl.h index a86342e8d55..f902b6d98f8 100644 --- a/src/compiler/ruby_generator_map-inl.h +++ b/src/compiler/ruby_generator_map-inl.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_COMPILER_RUBY_GENERATOR_MAP_INL_H_ -#define NET_GRPC_COMPILER_RUBY_GENERATOR_MAP_INL_H_ +#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H +#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H #include #include @@ -69,4 +69,4 @@ inline std::map ListToDict( } // namespace grpc_ruby_generator -#endif // NET_GRPC_COMPILER_RUBY_GENERATOR_MAP_INL_H_ +#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_MAP_INL_H diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h index 7c2e4e5d9d4..bdd314c16e5 100644 --- a/src/compiler/ruby_generator_string-inl.h +++ b/src/compiler/ruby_generator_string-inl.h @@ -31,8 +31,8 @@ * */ -#ifndef NET_GRPC_COMPILER_RUBY_GENERATOR_STRING_INL_H_ -#define NET_GRPC_COMPILER_RUBY_GENERATOR_STRING_INL_H_ +#ifndef GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H +#define GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H #include #include @@ -130,4 +130,4 @@ inline std::string RubyTypeOf(const std::string &a_type, } // namespace grpc_ruby_generator -#endif // NET_GRPC_COMPILER_RUBY_GENERATOR_STRING_INL_H_ +#endif // GRPC_INTERNAL_COMPILER_RUBY_GENERATOR_STRING_INL_H diff --git a/src/compiler/ruby_plugin.cc b/src/compiler/ruby_plugin.cc index 6580e5ab5be..4a6e9f7a5d3 100644 --- a/src/compiler/ruby_plugin.cc +++ b/src/compiler/ruby_plugin.cc @@ -50,12 +50,12 @@ class RubyGrpcGenerator : public google::protobuf::compiler::CodeGenerator { public: RubyGrpcGenerator() {} - ~RubyGrpcGenerator() override {} + ~RubyGrpcGenerator() {} bool Generate(const google::protobuf::FileDescriptor *file, const std::string ¶meter, google::protobuf::compiler::GeneratorContext *context, - std::string *error) const override { + std::string *error) const { std::string code = grpc_ruby_generator::GetServices(file); if (code.size() == 0) { return true; // don't generate a file if there are no services diff --git a/src/core/channel/census_filter.h b/src/core/channel/census_filter.h index 6acf9695f47..4f9759f0db2 100644 --- a/src/core/channel/census_filter.h +++ b/src/core/channel/census_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CENSUS_FILTER_H__ -#define __GRPC_INTERNAL_CHANNEL_CENSUS_FILTER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CENSUS_FILTER_H +#define GRPC_INTERNAL_CORE_CHANNEL_CENSUS_FILTER_H #include "src/core/channel/channel_stack.h" @@ -41,4 +41,4 @@ extern const grpc_channel_filter grpc_client_census_filter; extern const grpc_channel_filter grpc_server_census_filter; -#endif /* __GRPC_INTERNAL_CHANNEL_CENSUS_FILTER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CENSUS_FILTER_H */ diff --git a/src/core/channel/channel_args.h b/src/core/channel/channel_args.h index 640bbd85a5f..eb5bf63986a 100644 --- a/src/core/channel/channel_args.h +++ b/src/core/channel/channel_args.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CHANNEL_ARGS_H__ -#define __GRPC_INTERNAL_CHANNEL_CHANNEL_ARGS_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H +#define GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H #include @@ -51,4 +51,4 @@ void grpc_channel_args_destroy(grpc_channel_args *a); is specified in channel args, otherwise returns 0. */ int grpc_channel_args_is_census_enabled(const grpc_channel_args *a); -#endif /* __GRPC_INTERNAL_CHANNEL_CHANNEL_ARGS_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */ diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 1ca95e7f1a6..c136f5c17ca 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CHANNEL_STACK_H__ -#define __GRPC_INTERNAL_CHANNEL_CHANNEL_STACK_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H +#define GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H /* A channel filter defines how operations on a channel are implemented. Channel filters are chained together to create full channels, and if those @@ -301,4 +301,4 @@ void grpc_call_element_send_finish(grpc_call_element *cur_elem); #define GRPC_CALL_LOG_OP(sev, elem, op) \ if (grpc_trace_bits & GRPC_TRACE_CHANNEL) grpc_call_log_op(sev, elem, op) -#endif /* __GRPC_INTERNAL_CHANNEL_CHANNEL_STACK_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H */ diff --git a/src/core/channel/child_channel.h b/src/core/channel/child_channel.h index 84a11062cbe..38695402ab0 100644 --- a/src/core/channel/child_channel.h +++ b/src/core/channel/child_channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CHILD_CHANNEL_H_ -#define __GRPC_INTERNAL_CHANNEL_CHILD_CHANNEL_H_ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H +#define GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H #include "src/core/channel/channel_stack.h" @@ -61,4 +61,4 @@ grpc_child_call *grpc_child_channel_create_call(grpc_child_channel *channel, grpc_call_element *grpc_child_call_get_top_element(grpc_child_call *call); void grpc_child_call_destroy(grpc_child_call *call); -#endif /* __GRPC_INTERNAL_CHANNEL_CHILD_CHANNEL_H_ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHILD_CHANNEL_H */ diff --git a/src/core/channel/client_channel.h b/src/core/channel/client_channel.h index 7da4fc92580..7a67a9f21f0 100644 --- a/src/core/channel/client_channel.h +++ b/src/core/channel/client_channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CLIENT_CHANNEL_H__ -#define __GRPC_INTERNAL_CHANNEL_CLIENT_CHANNEL_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H +#define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H #include "src/core/channel/channel_stack.h" @@ -59,4 +59,4 @@ grpc_transport_setup_result grpc_client_channel_transport_setup_complete( grpc_channel_filter const **channel_filters, size_t num_channel_filters, grpc_mdctx *mdctx); -#endif /* __GRPC_INTERNAL_CHANNEL_CLIENT_CHANNEL_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/channel/client_setup.h b/src/core/channel/client_setup.h index f2b64265bc3..70137e1365a 100644 --- a/src/core/channel/client_setup.h +++ b/src/core/channel/client_setup.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CLIENT_SETUP_H__ -#define __GRPC_INTERNAL_CHANNEL_CLIENT_SETUP_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H +#define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H #include "src/core/channel/client_channel.h" #include "src/core/transport/metadata.h" @@ -70,4 +70,4 @@ gpr_timespec grpc_client_setup_request_deadline(grpc_client_setup_request *r); grpc_mdctx *grpc_client_setup_get_mdctx(grpc_client_setup_request *r); -#endif /* __GRPC_INTERNAL_CHANNEL_CLIENT_SETUP_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_SETUP_H */ diff --git a/src/core/channel/connected_channel.h b/src/core/channel/connected_channel.h index e19de62ca94..8b35f69b26f 100644 --- a/src/core/channel/connected_channel.h +++ b/src/core/channel/connected_channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_CONNECTED_CHANNEL_H__ -#define __GRPC_INTERNAL_CHANNEL_CONNECTED_CHANNEL_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H +#define GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H #include "src/core/channel/channel_stack.h" @@ -46,4 +46,4 @@ extern const grpc_channel_filter grpc_connected_channel_filter; grpc_transport_setup_result grpc_connected_channel_bind_transport( grpc_channel_stack *channel_stack, grpc_transport *transport); -#endif /* __GRPC_INTERNAL_CHANNEL_CONNECTED_CHANNEL_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/src/core/channel/http_client_filter.h b/src/core/channel/http_client_filter.h index 5882f8fe057..04eb839e006 100644 --- a/src/core/channel/http_client_filter.h +++ b/src/core/channel/http_client_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_HTTP_CLIENT_FILTER_H__ -#define __GRPC_INTERNAL_CHANNEL_HTTP_CLIENT_FILTER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H +#define GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H #include "src/core/channel/channel_stack.h" @@ -41,4 +41,4 @@ extern const grpc_channel_filter grpc_http_client_filter; #define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" -#endif /* __GRPC_INTERNAL_CHANNEL_HTTP_CLIENT_FILTER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H */ diff --git a/src/core/channel/http_filter.h b/src/core/channel/http_filter.h index b85cd3956eb..1b116ad61f4 100644 --- a/src/core/channel/http_filter.h +++ b/src/core/channel/http_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_HTTP_FILTER_H__ -#define __GRPC_INTERNAL_CHANNEL_HTTP_FILTER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_HTTP_FILTER_H +#define GRPC_INTERNAL_CORE_CHANNEL_HTTP_FILTER_H #include "src/core/channel/channel_stack.h" @@ -40,4 +40,4 @@ transports. */ extern const grpc_channel_filter grpc_http_filter; -#endif /* __GRPC_INTERNAL_CHANNEL_HTTP_FILTER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_HTTP_FILTER_H */ diff --git a/src/core/channel/http_server_filter.h b/src/core/channel/http_server_filter.h index 0643c7be83c..42f76ed17f2 100644 --- a/src/core/channel/http_server_filter.h +++ b/src/core/channel/http_server_filter.h @@ -31,12 +31,12 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_HTTP_SERVER_FILTER_H__ -#define __GRPC_INTERNAL_CHANNEL_HTTP_SERVER_FILTER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H +#define GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H #include "src/core/channel/channel_stack.h" /* Processes metadata on the client side for HTTP2 transports */ extern const grpc_channel_filter grpc_http_server_filter; -#endif /* __GRPC_INTERNAL_CHANNEL_HTTP_SERVER_FILTER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H */ diff --git a/src/core/channel/metadata_buffer.h b/src/core/channel/metadata_buffer.h index 701d69df7c5..b7cc5170d13 100644 --- a/src/core/channel/metadata_buffer.h +++ b/src/core/channel/metadata_buffer.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_METADATA_BUFFER_H__ -#define __GRPC_INTERNAL_CHANNEL_METADATA_BUFFER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_METADATA_BUFFER_H +#define GRPC_INTERNAL_CORE_CHANNEL_METADATA_BUFFER_H #include "src/core/channel/channel_stack.h" @@ -67,4 +67,4 @@ grpc_metadata *grpc_metadata_buffer_extract_elements( grpc_metadata_buffer *buffer); void grpc_metadata_buffer_cleanup_elements(void *elements, grpc_op_error error); -#endif /* __GRPC_INTERNAL_CHANNEL_METADATA_BUFFER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_METADATA_BUFFER_H */ diff --git a/src/core/channel/noop_filter.h b/src/core/channel/noop_filter.h index 93c2bff9b02..96463e53222 100644 --- a/src/core/channel/noop_filter.h +++ b/src/core/channel/noop_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_CHANNEL_NOOP_FILTER_H__ -#define __GRPC_INTERNAL_CHANNEL_NOOP_FILTER_H__ +#ifndef GRPC_INTERNAL_CORE_CHANNEL_NOOP_FILTER_H +#define GRPC_INTERNAL_CORE_CHANNEL_NOOP_FILTER_H #include "src/core/channel/channel_stack.h" @@ -41,4 +41,4 @@ customize for their own filters */ extern const grpc_channel_filter grpc_no_op_filter; -#endif /* __GRPC_INTERNAL_CHANNEL_NOOP_FILTER_H__ */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_NOOP_FILTER_H */ diff --git a/src/core/compression/algorithm.h b/src/core/compression/algorithm.h index e398ae34b4c..9dd9f57b568 100644 --- a/src/core/compression/algorithm.h +++ b/src/core/compression/algorithm.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_COMPRESSION_ALGORITHM_H__ -#define __GRPC_INTERNAL_COMPRESSION_ALGORITHM_H__ +#ifndef GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_H +#define GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_H /* The various compression algorithms supported by GRPC */ typedef enum { @@ -46,4 +46,4 @@ typedef enum { const char *grpc_compression_algorithm_name( grpc_compression_algorithm algorithm); -#endif /* __GRPC_INTERNAL_COMPRESSION_ALGORITHM_H__ */ +#endif /* GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_H */ diff --git a/src/core/compression/message_compress.h b/src/core/compression/message_compress.h index 666da2ed0d6..e8aef1a7139 100644 --- a/src/core/compression/message_compress.h +++ b/src/core/compression/message_compress.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_COMPRESSION_MESSAGE_COMPRESS_H__ -#define __GRPC_INTERNAL_COMPRESSION_MESSAGE_COMPRESS_H__ +#ifndef GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H +#define GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H #include "src/core/compression/algorithm.h" #include @@ -49,4 +49,4 @@ int grpc_msg_compress(grpc_compression_algorithm algorithm, int grpc_msg_decompress(grpc_compression_algorithm algorithm, gpr_slice_buffer *input, gpr_slice_buffer *output); -#endif /* __GRPC_INTERNAL_COMPRESSION_MESSAGE_COMPRESS_H__ */ +#endif /* GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H */ diff --git a/src/core/debug/trace.h b/src/core/debug/trace.h index a653fad2bbb..e11630f7e96 100644 --- a/src/core/debug/trace.h +++ b/src/core/debug/trace.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPC_CORE_DEBUG_TRACE_H -#define GRPC_CORE_DEBUG_TRACE_H +#ifndef GRPC_INTERNAL_CORE_DEBUG_TRACE_H +#define GRPC_INTERNAL_CORE_DEBUG_TRACE_H #include @@ -58,5 +58,4 @@ extern gpr_uint32 grpc_trace_bits; void grpc_init_trace_bits(); -#endif - +#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */ diff --git a/src/core/httpcli/format_request.h b/src/core/httpcli/format_request.h index e06b6329903..8bfb20bfd0c 100644 --- a/src/core/httpcli/format_request.h +++ b/src/core/httpcli/format_request.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_HTTPCLI_FORMAT_REQUEST_H__ -#define __GRPC_INTERNAL_HTTPCLI_FORMAT_REQUEST_H__ +#ifndef GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H +#define GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H #include "src/core/httpcli/httpcli.h" #include @@ -42,4 +42,4 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, const char *body_bytes, size_t body_size); -#endif /* __GRPC_INTERNAL_HTTPCLI_FORMAT_REQUEST_H__ */ +#endif /* GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H */ diff --git a/src/core/httpcli/httpcli.h b/src/core/httpcli/httpcli.h index f6209877680..255c5ed90f1 100644 --- a/src/core/httpcli/httpcli.h +++ b/src/core/httpcli/httpcli.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_HTTPCLI_HTTPCLI_H__ -#define __GRPC_INTERNAL_HTTPCLI_HTTPCLI_H__ +#ifndef GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H +#define GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H #include @@ -115,4 +115,4 @@ typedef int (*grpc_httpcli_post_override)(const grpc_httpcli_request *request, void grpc_httpcli_set_override(grpc_httpcli_get_override get, grpc_httpcli_post_override post); -#endif /* __GRPC_INTERNAL_HTTPCLI_HTTPCLI_H__ */ +#endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H */ diff --git a/src/core/httpcli/httpcli_security_context.h b/src/core/httpcli/httpcli_security_context.h index 5a1311e7a41..a776828a692 100644 --- a/src/core/httpcli/httpcli_security_context.h +++ b/src/core/httpcli/httpcli_security_context.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H__ -#define __GRPC_INTERNAL_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H__ +#ifndef GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H +#define GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H #include "src/core/security/security_context.h" @@ -40,4 +40,4 @@ grpc_security_status grpc_httpcli_ssl_channel_security_context_create( const unsigned char *pem_root_certs, size_t pem_root_certs_size, const char *secure_peer_name, grpc_channel_security_context **ctx); -#endif /* __GRPC_INTERNAL_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H__ */ +#endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H */ diff --git a/src/core/httpcli/parser.h b/src/core/httpcli/parser.h index db1fa0a33c8..71280e74794 100644 --- a/src/core/httpcli/parser.h +++ b/src/core/httpcli/parser.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_HTTPCLI_PARSER_H__ -#define __GRPC_INTERNAL_HTTPCLI_PARSER_H__ +#ifndef GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H +#define GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H #include "src/core/httpcli/httpcli.h" #include @@ -61,4 +61,4 @@ void grpc_httpcli_parser_destroy(grpc_httpcli_parser *parser); int grpc_httpcli_parser_parse(grpc_httpcli_parser *parser, gpr_slice slice); int grpc_httpcli_parser_eof(grpc_httpcli_parser *parser); -#endif /* __GRPC_INTERNAL_HTTPCLI_PARSER_H__ */ +#endif /* GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H */ diff --git a/src/core/iomgr/alarm.h b/src/core/iomgr/alarm.h index 6dcc63a6d58..e5262e21998 100644 --- a/src/core/iomgr/alarm.h +++ b/src/core/iomgr/alarm.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_ALARM_H__ -#define __GRPC_INTERNAL_IOMGR_ALARM_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_ALARM_H +#define GRPC_INTERNAL_CORE_IOMGR_ALARM_H #include "src/core/iomgr/iomgr.h" #include @@ -86,4 +86,4 @@ void grpc_alarm_init(grpc_alarm *alarm, gpr_timespec deadline, Requires: cancel() must happen after add() on a given alarm */ void grpc_alarm_cancel(grpc_alarm *alarm); -#endif /* __GRPC_INTERNAL_IOMGR_ALARM_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_ALARM_H */ diff --git a/src/core/iomgr/alarm_heap.h b/src/core/iomgr/alarm_heap.h index bb6e5e3a899..c5adfc6d31e 100644 --- a/src/core/iomgr/alarm_heap.h +++ b/src/core/iomgr/alarm_heap.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_ALARM_HEAP_H_ -#define __GRPC_INTERNAL_IOMGR_ALARM_HEAP_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_ALARM_HEAP_H +#define GRPC_INTERNAL_CORE_IOMGR_ALARM_HEAP_H #include "src/core/iomgr/alarm.h" @@ -54,4 +54,4 @@ void grpc_alarm_heap_pop(grpc_alarm_heap *heap); int grpc_alarm_heap_is_empty(grpc_alarm_heap *heap); -#endif /* __GRPC_INTERNAL_IOMGR_ALARM_HEAP_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_ALARM_HEAP_H */ diff --git a/src/core/iomgr/alarm_internal.h b/src/core/iomgr/alarm_internal.h index cbd8fa9421f..0268a01badf 100644 --- a/src/core/iomgr/alarm_internal.h +++ b/src/core/iomgr/alarm_internal.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_ALARM_INTERNAL_H_ -#define __GRPC_INTERNAL_IOMGR_ALARM_INTERNAL_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_ALARM_INTERNAL_H +#define GRPC_INTERNAL_CORE_IOMGR_ALARM_INTERNAL_H #include #include @@ -59,4 +59,4 @@ gpr_timespec grpc_alarm_list_next_timeout(void); void grpc_kick_poller(void); -#endif /* __GRPC_INTERNAL_IOMGR_ALARM_INTERNAL_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_ALARM_INTERNAL_H */ diff --git a/src/core/iomgr/endpoint.h b/src/core/iomgr/endpoint.h index e89cf6691c0..881e851800b 100644 --- a/src/core/iomgr/endpoint.h +++ b/src/core/iomgr/endpoint.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_ENDPOINT_H__ -#define __GRPC_INTERNAL_IOMGR_ENDPOINT_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H +#define GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H #include "src/core/iomgr/pollset.h" #include @@ -103,4 +103,4 @@ struct grpc_endpoint { const grpc_endpoint_vtable *vtable; }; -#endif /* __GRPC_INTERNAL_IOMGR_ENDPOINT_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H */ diff --git a/src/core/iomgr/endpoint_pair.h b/src/core/iomgr/endpoint_pair.h index 2e46aab2283..dffbd36d4c6 100644 --- a/src/core/iomgr/endpoint_pair.h +++ b/src/core/iomgr/endpoint_pair.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_ENDPOINT_PAIR_H_ -#define __GRPC_INTERNAL_IOMGR_ENDPOINT_PAIR_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H +#define GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H #include "src/core/iomgr/endpoint.h" @@ -43,4 +43,4 @@ typedef struct { grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(size_t read_slice_size); -#endif /* __GRPC_INTERNAL_IOMGR_ENDPOINT_PAIR_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H */ diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index 2a308c8ae20..be21f2b55f8 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_FD_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_FD_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset.h" @@ -143,4 +143,4 @@ void grpc_fd_unref(grpc_fd *fd); void grpc_fd_global_init(void); void grpc_fd_global_shutdown(void); -#endif /* __GRPC_INTERNAL_IOMGR_FD_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H */ diff --git a/src/core/iomgr/iocp_windows.h b/src/core/iomgr/iocp_windows.h index d0231702a16..33133193a10 100644 --- a/src/core/iomgr/iocp_windows.h +++ b/src/core/iomgr/iocp_windows.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_IOCP_WINDOWS_H_ -#define __GRPC_INTERNAL_IOMGR_IOCP_WINDOWS_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H +#define GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H #include #include @@ -49,4 +49,4 @@ void grpc_socket_notify_on_write(grpc_winsocket *, void(*cb)(void *, int success void grpc_socket_notify_on_read(grpc_winsocket *, void(*cb)(void *, int success), void *opaque); -#endif /* __GRPC_INTERNAL_IOMGR_IOCP_WINDOWS_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H */ diff --git a/src/core/iomgr/iomgr.h b/src/core/iomgr/iomgr.h index 18a7d151fc7..1f5d23fdda4 100644 --- a/src/core/iomgr/iomgr.h +++ b/src/core/iomgr/iomgr.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_IOMGR_H__ -#define __GRPC_INTERNAL_IOMGR_IOMGR_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_H +#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_H /* gRPC Callback definition */ typedef void (*grpc_iomgr_cb_func)(void *arg, int success); @@ -44,4 +44,4 @@ void grpc_iomgr_shutdown(void); and causes the invocation of a callback at some point in the future */ void grpc_iomgr_add_callback(grpc_iomgr_cb_func cb, void *cb_arg); -#endif /* __GRPC_INTERNAL_IOMGR_IOMGR_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_H */ diff --git a/src/core/iomgr/iomgr_internal.h b/src/core/iomgr/iomgr_internal.h index 7f29f44f7f9..07923258b9b 100644 --- a/src/core/iomgr/iomgr_internal.h +++ b/src/core/iomgr/iomgr_internal.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_IOMGR_INTERNAL_H_ -#define __GRPC_INTERNAL_IOMGR_IOMGR_INTERNAL_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H +#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/iomgr_internal.h" @@ -48,4 +48,4 @@ void grpc_iomgr_unref(void); void grpc_iomgr_platform_init(void); void grpc_iomgr_platform_shutdown(void); -#endif /* __GRPC_INTERNAL_IOMGR_IOMGR_INTERNAL_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H */ diff --git a/src/core/iomgr/iomgr_posix.h b/src/core/iomgr/iomgr_posix.h index f9e9b3d6ee4..a404f6433ec 100644 --- a/src/core/iomgr/iomgr_posix.h +++ b/src/core/iomgr/iomgr_posix.h @@ -31,12 +31,12 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_IOMGR_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_IOMGR_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H #include "src/core/iomgr/iomgr_internal.h" void grpc_pollset_global_init(void); void grpc_pollset_global_shutdown(void); -#endif /* __GRPC_INTERNAL_IOMGR_IOMGR_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H */ diff --git a/src/core/iomgr/pollset.h b/src/core/iomgr/pollset.h index c26947f37cb..067af87c931 100644 --- a/src/core/iomgr/pollset.h +++ b/src/core/iomgr/pollset.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_H #include #include @@ -71,4 +71,4 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline); Requires GRPC_POLLSET_MU(pollset) locked. */ void grpc_pollset_kick(grpc_pollset *pollset); -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */ diff --git a/src/core/iomgr/pollset_kick.h b/src/core/iomgr/pollset_kick.h index b224177d317..cc9357de1fc 100644 --- a/src/core/iomgr/pollset_kick.h +++ b/src/core/iomgr/pollset_kick.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_H #include @@ -71,4 +71,4 @@ void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state); void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state); -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_H */ diff --git a/src/core/iomgr/pollset_kick_posix.h b/src/core/iomgr/pollset_kick_posix.h index 162ae5bd8f1..427699198c3 100644 --- a/src/core/iomgr/pollset_kick_posix.h +++ b/src/core/iomgr/pollset_kick_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H #include "src/core/iomgr/wakeup_fd_posix.h" #include @@ -48,4 +48,4 @@ typedef struct grpc_pollset_kick_state { struct grpc_kick_fd_info *fd_info; } grpc_pollset_kick_state; -#endif /* __GRPC_INTERNALIOMGR_POLLSET_KICK_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H */ diff --git a/src/core/iomgr/pollset_kick_windows.h b/src/core/iomgr/pollset_kick_windows.h index 1053230a983..3836aa00820 100644 --- a/src/core/iomgr/pollset_kick_windows.h +++ b/src/core/iomgr/pollset_kick_windows.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_WINDOWS_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_WINDOWS_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_WINDOWS_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_WINDOWS_H #include @@ -42,4 +42,4 @@ typedef struct grpc_pollset_kick_state { int unused; } grpc_pollset_kick_state; -#endif /* __GRPC_INTERNALIOMGR_POLLSET_KICK_WINDOWS_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_WINDOWS_H */ diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h index 86b6c9f20e8..da843f7381c 100644 --- a/src/core/iomgr/pollset_posix.h +++ b/src/core/iomgr/pollset_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H #include @@ -104,4 +104,4 @@ grpc_pollset *grpc_backup_pollset(void); void grpc_platform_become_multipoller(grpc_pollset *pollset, struct grpc_fd **fds, size_t fd_count); -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */ diff --git a/src/core/iomgr/pollset_windows.h b/src/core/iomgr/pollset_windows.h index 41c193fcad0..266175abfb9 100644 --- a/src/core/iomgr/pollset_windows.h +++ b/src/core/iomgr/pollset_windows.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_POLLSET_WINDOWS_H_ -#define __GRPC_INTERNAL_IOMGR_POLLSET_WINDOWS_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H +#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H #include #include @@ -53,4 +53,4 @@ typedef struct grpc_pollset { #define GRPC_POLLSET_MU(pollset) (&(pollset)->mu) #define GRPC_POLLSET_CV(pollset) (&(pollset)->cv) -#endif /* __GRPC_INTERNAL_IOMGR_POLLSET_WINDOWS_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */ diff --git a/src/core/iomgr/resolve_address.h b/src/core/iomgr/resolve_address.h index 65432ec61aa..8f1d7a22bb1 100644 --- a/src/core/iomgr/resolve_address.h +++ b/src/core/iomgr/resolve_address.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_RESOLVE_ADDRESS_H__ -#define __GRPC_INTERNAL_IOMGR_RESOLVE_ADDRESS_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H +#define GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H #include @@ -66,4 +66,4 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addresses); grpc_resolved_addresses *grpc_blocking_resolve_address( const char *addr, const char *default_port); -#endif /* __GRPC_INTERNAL_IOMGR_RESOLVE_ADDRESS_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H */ diff --git a/src/core/iomgr/sockaddr.h b/src/core/iomgr/sockaddr.h index a5f7c546ecf..7528db73b81 100644 --- a/src/core/iomgr/sockaddr.h +++ b/src/core/iomgr/sockaddr.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_SOCKADDR_H_ -#define __GRPC_INTERNAL_IOMGR_SOCKADDR_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H #include @@ -44,4 +44,4 @@ #include "src/core/iomgr/sockaddr_posix.h" #endif -#endif /* __GRPC_INTERNAL_IOMGR_SOCKADDR_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H */ diff --git a/src/core/iomgr/sockaddr_posix.h b/src/core/iomgr/sockaddr_posix.h index 00115e25368..2a3d932f700 100644 --- a/src/core/iomgr/sockaddr_posix.h +++ b/src/core/iomgr/sockaddr_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_SOCKADDR_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_SOCKADDR_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H #include #include @@ -41,4 +41,4 @@ #include #include -#endif /* __GRPC_INTERNAL_IOMGR_SOCKADDR_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H */ diff --git a/src/core/iomgr/sockaddr_utils.h b/src/core/iomgr/sockaddr_utils.h index d3a25ad373b..bdfb83479b4 100644 --- a/src/core/iomgr/sockaddr_utils.h +++ b/src/core/iomgr/sockaddr_utils.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_SOCKADDR_UTILS_H__ -#define __GRPC_INTERNAL_IOMGR_SOCKADDR_UTILS_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H #include "src/core/iomgr/sockaddr.h" @@ -84,4 +84,4 @@ int grpc_sockaddr_set_port(const struct sockaddr *addr, int port); int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr, int normalize); -#endif /* __GRPC_INTERNAL_IOMGR_SOCKADDR_UTILS_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H */ diff --git a/src/core/iomgr/sockaddr_win32.h b/src/core/iomgr/sockaddr_win32.h index 6ed164ced1d..3a5f27bb345 100644 --- a/src/core/iomgr/sockaddr_win32.h +++ b/src/core/iomgr/sockaddr_win32.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_SOCKADDR_WIN32_H_ -#define __GRPC_INTERNAL_IOMGR_SOCKADDR_WIN32_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H #include #include #include -#endif /* __GRPC_INTERNAL_IOMGR_SOCKADDR_WIN32_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H */ diff --git a/src/core/iomgr/socket_utils_posix.h b/src/core/iomgr/socket_utils_posix.h index b35fe785f1a..c161082afc0 100644 --- a/src/core/iomgr/socket_utils_posix.h +++ b/src/core/iomgr/socket_utils_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_SOCKET_UTILS_POSIX_H__ -#define __GRPC_INTERNAL_IOMGR_SOCKET_UTILS_POSIX_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H #include #include @@ -105,4 +105,4 @@ extern int grpc_forbid_dualstack_sockets_for_testing; int grpc_create_dualstack_socket(const struct sockaddr *addr, int type, int protocol, grpc_dualstack_mode *dsmode); -#endif /* __GRPC_INTERNAL_IOMGR_SOCKET_UTILS_POSIX_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H */ diff --git a/src/core/iomgr/socket_windows.h b/src/core/iomgr/socket_windows.h index de80e97e7f6..d4776ab10f8 100644 --- a/src/core/iomgr/socket_windows.h +++ b/src/core/iomgr/socket_windows.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_HANDLE_WINDOWS_H__ -#define __GRPC_INTERNAL_IOMGR_HANDLE_WINDOWS_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H +#define GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H #include @@ -72,4 +72,4 @@ grpc_winsocket *grpc_winsocket_create(SOCKET socket); void grpc_winsocket_shutdown(grpc_winsocket *socket); void grpc_winsocket_orphan(grpc_winsocket *socket); -#endif /* __GRPC_INTERNAL_IOMGR_HANDLE_WINDOWS_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H */ diff --git a/src/core/iomgr/tcp_client.h b/src/core/iomgr/tcp_client.h index c919c02440f..2e91497fb7d 100644 --- a/src/core/iomgr/tcp_client.h +++ b/src/core/iomgr/tcp_client.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_TCP_CLIENT_H__ -#define __GRPC_INTERNAL_IOMGR_TCP_CLIENT_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H +#define GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H #include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/sockaddr.h" @@ -45,4 +45,4 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp), void *arg, const struct sockaddr *addr, int addr_len, gpr_timespec deadline); -#endif /* __GRPC_INTERNAL_IOMGR_TCP_CLIENT_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H */ diff --git a/src/core/iomgr/tcp_posix.h b/src/core/iomgr/tcp_posix.h index 6ff87704efb..7e8064bffc7 100644 --- a/src/core/iomgr/tcp_posix.h +++ b/src/core/iomgr/tcp_posix.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_TCP_POSIX_H__ -#define __GRPC_INTERNAL_IOMGR_TCP_POSIX_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H /* Low level TCP "bottom half" implementation, for use by transports built on top of a TCP connection. @@ -53,4 +53,4 @@ Takes ownership of fd. */ grpc_endpoint *grpc_tcp_create(grpc_fd *fd, size_t read_slice_size); -#endif /* __GRPC_INTERNAL_IOMGR_TCP_POSIX_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H */ diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h index c1e5f45208d..68ee85c5a7f 100644 --- a/src/core/iomgr/tcp_server.h +++ b/src/core/iomgr/tcp_server.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_TCP_SERVER_H__ -#define __GRPC_INTERNAL_IOMGR_TCP_SERVER_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H +#define GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H #include "src/core/iomgr/endpoint.h" @@ -73,4 +73,4 @@ int grpc_tcp_server_get_fd(grpc_tcp_server *s, unsigned index); void grpc_tcp_server_destroy(grpc_tcp_server *server); -#endif /* __GRPC_INTERNAL_IOMGR_TCP_SERVER_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H */ diff --git a/src/core/iomgr/tcp_windows.h b/src/core/iomgr/tcp_windows.h index 565d42e5b29..4cbc12c53aa 100644 --- a/src/core/iomgr/tcp_windows.h +++ b/src/core/iomgr/tcp_windows.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_TCP_WINDOWS_H__ -#define __GRPC_INTERNAL_IOMGR_TCP_WINDOWS_H__ +#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H +#define GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H /* Low level TCP "bottom half" implementation, for use by transports built on top of a TCP connection. @@ -54,4 +54,4 @@ grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket); int grpc_tcp_prepare_socket(SOCKET sock); -#endif /* __GRPC_INTERNAL_IOMGR_TCP_WINDOWS_H__ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H */ diff --git a/src/core/iomgr/time_averaged_stats.h b/src/core/iomgr/time_averaged_stats.h index e901f3c33b3..13894b26408 100644 --- a/src/core/iomgr/time_averaged_stats.h +++ b/src/core/iomgr/time_averaged_stats.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_TIME_AVERAGED_STATS_H_ -#define __GRPC_INTERNAL_IOMGR_TIME_AVERAGED_STATS_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H +#define GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H /* This tracks a time-decaying weighted average. It works by collecting batches of samples and then mixing their average into a time-decaying @@ -85,4 +85,4 @@ void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats *stats, value. */ double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats *stats); -#endif /* __GRPC_INTERNAL_IOMGR_TIME_AVERAGED_STATS_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H */ diff --git a/src/core/iomgr/wakeup_fd_pipe.h b/src/core/iomgr/wakeup_fd_pipe.h index a2fcde5b55f..aa8f977ddb8 100644 --- a/src/core/iomgr/wakeup_fd_pipe.h +++ b/src/core/iomgr/wakeup_fd_pipe.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ -#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H +#define GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H #include "src/core/iomgr/wakeup_fd_posix.h" extern grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable; -#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_PIPE_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H */ diff --git a/src/core/iomgr/wakeup_fd_posix.h b/src/core/iomgr/wakeup_fd_posix.h index 75bb9fc766c..1b0ff70c7f5 100644 --- a/src/core/iomgr/wakeup_fd_posix.h +++ b/src/core/iomgr/wakeup_fd_posix.h @@ -59,8 +59,8 @@ * 2. If the polling thread was awakened by a wakeup_fd event, call * grpc_wakeup_fd_consume_wakeup() on it. */ -#ifndef __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ -#define __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ +#ifndef GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H +#define GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H void grpc_wakeup_fd_global_init(void); void grpc_wakeup_fd_global_destroy(void); @@ -96,4 +96,4 @@ void grpc_wakeup_fd_destroy(grpc_wakeup_fd_info *fd_info); * wakeup_fd_nospecial.c if no such implementation exists. */ extern const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable; -#endif /* __GRPC_INTERNAL_IOMGR_WAKEUP_FD_POSIX_H_ */ +#endif /* GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H */ diff --git a/src/core/json/json.h b/src/core/json/json.h index dc519e9d5ec..69cbac17dc3 100644 --- a/src/core/json/json.h +++ b/src/core/json/json.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SRC_CORE_JSON_JSON_H__ -#define __GRPC_SRC_CORE_JSON_JSON_H__ +#ifndef GRPC_INTERNAL_CORE_JSON_JSON_H +#define GRPC_INTERNAL_CORE_JSON_JSON_H #include @@ -85,4 +85,4 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent); grpc_json* grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json* json); -#endif /* __GRPC_SRC_CORE_JSON_JSON_H__ */ +#endif /* GRPC_INTERNAL_CORE_JSON_JSON_H */ diff --git a/src/core/json/json_common.h b/src/core/json/json_common.h index 60763cc72ea..84bf3759169 100644 --- a/src/core/json/json_common.h +++ b/src/core/json/json_common.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SRC_CORE_JSON_JSON_COMMON_H__ -#define __GRPC_SRC_CORE_JSON_JSON_COMMON_H__ +#ifndef GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H +#define GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H /* The various json types. */ typedef enum { @@ -46,4 +46,4 @@ typedef enum { GRPC_JSON_TOP_LEVEL } grpc_json_type; -#endif /* __GRPC_SRC_CORE_JSON_JSON_COMMON_H__ */ +#endif /* GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H */ diff --git a/src/core/json/json_reader.h b/src/core/json/json_reader.h index f7f59127f93..b1a5ace8fb5 100644 --- a/src/core/json/json_reader.h +++ b/src/core/json/json_reader.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SRC_CORE_JSON_JSON_READER_H__ -#define __GRPC_SRC_CORE_JSON_JSON_READER_H__ +#ifndef GRPC_INTERNAL_CORE_JSON_JSON_READER_H +#define GRPC_INTERNAL_CORE_JSON_JSON_READER_H #include #include "src/core/json/json_common.h" @@ -157,4 +157,4 @@ void grpc_json_reader_init(grpc_json_reader* reader, */ int grpc_json_reader_is_complete(grpc_json_reader* reader); -#endif /* __GRPC_SRC_CORE_JSON_JSON_READER_H__ */ +#endif /* GRPC_INTERNAL_CORE_JSON_JSON_READER_H */ diff --git a/src/core/json/json_writer.h b/src/core/json/json_writer.h index 5d5d0891a3c..dfa61a5fefc 100644 --- a/src/core/json/json_writer.h +++ b/src/core/json/json_writer.h @@ -43,8 +43,8 @@ * a valid UTF-8 string overall. */ -#ifndef __GRPC_SRC_CORE_JSON_JSON_WRITER_H__ -#define __GRPC_SRC_CORE_JSON_JSON_WRITER_H__ +#ifndef GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H +#define GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H #include @@ -90,4 +90,4 @@ void grpc_json_writer_value_raw_with_len(grpc_json_writer* writer, const char* s /* Sets a string value. It'll be escaped, and utf-8 validated. */ void grpc_json_writer_value_string(grpc_json_writer* writer, const char* string); -#endif /* __GRPC_SRC_CORE_JSON_JSON_WRITER_H__ */ +#endif /* GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H */ diff --git a/src/core/security/auth.h b/src/core/security/auth.h index fee75c40e1c..08dc4152ba4 100644 --- a/src/core/security/auth.h +++ b/src/core/security/auth.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_AUTH_H__ -#define __GRPC_INTERNAL_SECURITY_AUTH_H__ +#ifndef GRPC_INTERNAL_CORE_SECURITY_AUTH_H +#define GRPC_INTERNAL_CORE_SECURITY_AUTH_H #include "src/core/channel/channel_stack.h" extern const grpc_channel_filter grpc_client_auth_filter; -#endif /* __GRPC_INTERNAL_SECURITY_AUTH_H__ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_AUTH_H */ diff --git a/src/core/security/base64.h b/src/core/security/base64.h index 0eb69d0ccb3..6a7cd8e96ce 100644 --- a/src/core/security/base64.h +++ b/src/core/security/base64.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_BASE64_H_ -#define __GRPC_INTERNAL_SECURITY_BASE64_H_ +#ifndef GRPC_INTERNAL_CORE_SECURITY_BASE64_H +#define GRPC_INTERNAL_CORE_SECURITY_BASE64_H #include @@ -45,4 +45,4 @@ char *grpc_base64_encode(const void *data, size_t data_size, int url_safe, slice in case of failure. */ gpr_slice grpc_base64_decode(const char *b64, int url_safe); -#endif /* __GRPC_INTERNAL_SECURITY_BASE64_H_ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_BASE64_H */ diff --git a/src/core/security/credentials.h b/src/core/security/credentials.h index 0a0074c1d53..454e66845d1 100644 --- a/src/core/security/credentials.h +++ b/src/core/security/credentials.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_CREDENTIALS_H__ -#define __GRPC_INTERNAL_SECURITY_CREDENTIALS_H__ +#ifndef GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H +#define GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H #include "src/core/transport/stream_op.h" #include @@ -160,4 +160,4 @@ typedef struct { const grpc_ssl_server_config *grpc_ssl_server_credentials_get_config( const grpc_server_credentials *ssl_creds); -#endif /* __GRPC_INTERNAL_SECURITY_CREDENTIALS_H__ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H */ diff --git a/src/core/security/json_token.h b/src/core/security/json_token.h index 1ef9682f528..029ede39558 100644 --- a/src/core/security/json_token.h +++ b/src/core/security/json_token.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_JSON_TOKEN_H_ -#define __GRPC_INTERNAL_SECURITY_JSON_TOKEN_H_ +#ifndef GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H +#define GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H #include #include @@ -79,4 +79,4 @@ typedef char *(*grpc_jwt_encode_and_sign_override)( void grpc_jwt_encode_and_sign_set_override( grpc_jwt_encode_and_sign_override func); -#endif /* __GRPC_INTERNAL_SECURITY_JSON_TOKEN_H_ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H */ diff --git a/src/core/security/secure_endpoint.h b/src/core/security/secure_endpoint.h index 82ba4082e32..808889bf047 100644 --- a/src/core/security/secure_endpoint.h +++ b/src/core/security/secure_endpoint.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_ENDPOINT_SECURE_ENDPOINT_H__ -#define __GRPC_INTERNAL_ENDPOINT_SECURE_ENDPOINT_H__ +#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H +#define GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H #include "src/core/iomgr/endpoint.h" #include @@ -44,4 +44,4 @@ grpc_endpoint *grpc_secure_endpoint_create( struct tsi_frame_protector *protector, grpc_endpoint *to_wrap, gpr_slice *leftover_slices, size_t leftover_nslices); -#endif /* __GRPC_INTERNAL_ENDPOINT_SECURE_ENDPOINT_H__ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H */ diff --git a/src/core/security/secure_transport_setup.h b/src/core/security/secure_transport_setup.h index 21f41fd6822..e1f8ed7830d 100644 --- a/src/core/security/secure_transport_setup.h +++ b/src/core/security/secure_transport_setup.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_SECURE_TRANSPORT_SETUP_H__ -#define __GRPC_INTERNAL_SECURITY_SECURE_TRANSPORT_SETUP_H__ +#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURE_TRANSPORT_SETUP_H +#define GRPC_INTERNAL_CORE_SECURITY_SECURE_TRANSPORT_SETUP_H #include "src/core/iomgr/endpoint.h" #include "src/core/security/security_context.h" @@ -50,4 +50,4 @@ void grpc_setup_secure_transport(grpc_security_context *ctx, grpc_secure_transport_setup_done_cb cb, void *user_data); -#endif /* __GRPC_INTERNAL_SECURITY_SECURE_TRANSPORT_SETUP_H__ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURE_TRANSPORT_SETUP_H */ diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c index 60064dc83dd..0dc37fa73c0 100644 --- a/src/core/security/security_context.c +++ b/src/core/security/security_context.c @@ -338,6 +338,24 @@ static grpc_security_status ssl_server_create_handshaker( return ssl_create_handshaker(c->handshaker_factory, 0, NULL, handshaker); } +static int ssl_host_matches_name(const tsi_peer *peer, + const char *peer_name) { + char *allocated_name = NULL; + int r; + + if (strchr(peer_name, ':') != NULL) { + char *ignored_port; + gpr_split_host_port(peer_name, &allocated_name, &ignored_port); + gpr_free(ignored_port); + peer_name = allocated_name; + if (!peer_name) return 0; + } + + r = tsi_ssl_peer_matches_name(peer, peer_name); + gpr_free(allocated_name); + return r; +} + static grpc_security_status ssl_check_peer(const char *peer_name, const tsi_peer *peer) { /* Check the ALPN. */ @@ -359,10 +377,11 @@ static grpc_security_status ssl_check_peer(const char *peer_name, /* Check the peer name if specified. */ if (peer_name != NULL && - !tsi_ssl_peer_matches_name(peer, peer_name)) { + !ssl_host_matches_name(peer, peer_name)) { gpr_log(GPR_ERROR, "Peer name %s is not in peer certificate", peer_name); return GRPC_SECURITY_ERROR; } + return GRPC_SECURITY_OK; } @@ -398,7 +417,7 @@ static grpc_security_status ssl_channel_check_call_host( grpc_ssl_channel_security_context *c = (grpc_ssl_channel_security_context *)ctx; - if (tsi_ssl_peer_matches_name(&c->peer, host)) return GRPC_SECURITY_OK; + if (ssl_host_matches_name(&c->peer, host)) return GRPC_SECURITY_OK; /* If the target name was overridden, then the original target_name was 'checked' transitively during the previous peer check at the end of the diff --git a/src/core/security/security_context.h b/src/core/security/security_context.h index 40e2daceb80..0b5821c3c08 100644 --- a/src/core/security/security_context.h +++ b/src/core/security/security_context.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SECURITY_SECURITY_CONTEXT_H__ -#define __GRPC_INTERNAL_SECURITY_SECURITY_CONTEXT_H__ +#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H +#define GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H #include #include "src/core/iomgr/endpoint.h" @@ -212,4 +212,4 @@ grpc_server *grpc_secure_server_create_internal(grpc_completion_queue *cq, const grpc_channel_args *args, grpc_security_context *ctx); -#endif /* __GRPC_INTERNAL_SECURITY_SECURITY_CONTEXT_H__ */ +#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */ diff --git a/src/core/statistics/census_interface.h b/src/core/statistics/census_interface.h index 0bb0a9f328d..eb4349c3115 100644 --- a/src/core/statistics/census_interface.h +++ b/src/core/statistics/census_interface.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_CENSUS_INTERFACE_H__ -#define __GRPC_INTERNAL_STATISTICS_CENSUS_INTERFACE_H__ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H +#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H #include @@ -73,4 +73,4 @@ census_op_id census_tracing_start_op(void); /* Ends tracing. Calling this function will invalidate the input op_id. */ void census_tracing_end_op(census_op_id op_id); -#endif /* __GRPC_INTERNAL_STATISTICS_CENSUS_INTERFACE_H__ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H */ diff --git a/src/core/statistics/census_log.h b/src/core/statistics/census_log.h index 01fd63aca39..06869b7a33a 100644 --- a/src/core/statistics/census_log.h +++ b/src/core/statistics/census_log.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_LOG_H__ -#define __GRPC_INTERNAL_STATISTICS_LOG_H__ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H +#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H #include @@ -88,4 +88,4 @@ size_t census_log_remaining_space(void); out-of-space. */ int census_log_out_of_space_count(void); -#endif /* __GRPC_INTERNAL_STATISTICS_LOG_H__ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H */ diff --git a/src/core/statistics/census_rpc_stats.h b/src/core/statistics/census_rpc_stats.h index 942de81b888..9336dce1f85 100644 --- a/src/core/statistics/census_rpc_stats.h +++ b/src/core/statistics/census_rpc_stats.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_CENSUS_RPC_STATS_H__ -#define __GRPC_INTERNAL_STATISTICS_CENSUS_RPC_STATS_H__ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H +#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H #include "src/core/statistics/census_interface.h" #include @@ -98,4 +98,4 @@ void census_stats_store_shutdown(void); } #endif -#endif /* __GRPC_INTERNAL_STATISTICS_CENSUS_RPC_STATS_H__ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H */ diff --git a/src/core/statistics/census_tracing.h b/src/core/statistics/census_tracing.h index 51aa578c0c1..a4494b510c2 100644 --- a/src/core/statistics/census_tracing.h +++ b/src/core/statistics/census_tracing.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_ -#define __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H +#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H #include #include "src/core/statistics/census_rpc_stats.h" @@ -93,4 +93,4 @@ census_trace_obj** census_get_active_ops(int* num_active_ops); } #endif -#endif /* __GRPC_INTERNAL_STATISTICS_CENSUS_TRACING_H_ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H */ diff --git a/src/core/statistics/hash_table.h b/src/core/statistics/hash_table.h index 2c2386d1ab1..7bcb4bcd9bd 100644 --- a/src/core/statistics/hash_table.h +++ b/src/core/statistics/hash_table.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_HASH_TABLE_H_ -#define __GRPC_INTERNAL_STATISTICS_HASH_TABLE_H_ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H +#define GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H #include @@ -128,4 +128,4 @@ typedef void (*census_ht_itr_cb)(census_ht_key key, const void* val_ptr, should not invalidate data entries. */ gpr_uint64 census_ht_for_all(const census_ht* ht, census_ht_itr_cb); -#endif /* __GRPC_INTERNAL_STATISTICS_HASH_TABLE_H_ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H */ diff --git a/src/core/statistics/window_stats.h b/src/core/statistics/window_stats.h index 98f8dac5595..d733d8d247a 100644 --- a/src/core/statistics/window_stats.h +++ b/src/core/statistics/window_stats.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_STATISTICS_WINDOW_STATS_H_ -#define __GRPC_INTERNAL_STATISTICS_WINDOW_STATS_H_ +#ifndef GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H +#define GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H #include @@ -170,4 +170,4 @@ void census_window_stats_get_sums(const struct census_window_stats* wstats, assertion failure). This function is thread-compatible. */ void census_window_stats_destroy(struct census_window_stats* wstats); -#endif /* __GRPC_INTERNAL_STATISTICS_WINDOW_STATS_H_ */ +#endif /* GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H */ diff --git a/src/core/support/env.h b/src/core/support/env.h index 0c6091b84b8..4f2e394d140 100644 --- a/src/core/support/env.h +++ b/src/core/support/env.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_ENV_H__ -#define __GRPC_SUPPORT_ENV_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_ENV_H +#define GRPC_INTERNAL_CORE_SUPPORT_ENV_H #include @@ -57,4 +57,4 @@ void gpr_setenv(const char *name, const char *value); } #endif -#endif /* __GRPC_SUPPORT_ENV_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_ENV_H */ diff --git a/src/core/support/file.h b/src/core/support/file.h index 600850e03d4..ee6ca7b2304 100644 --- a/src/core/support/file.h +++ b/src/core/support/file.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_FILE_H__ -#define __GRPC_SUPPORT_FILE_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_FILE_H +#define GRPC_INTERNAL_CORE_SUPPORT_FILE_H #include @@ -58,4 +58,4 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename); } #endif -#endif /* __GRPC_SUPPORT_FILE_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_FILE_H */ diff --git a/src/core/support/log_posix.c b/src/core/support/log_posix.c index 8f85791466d..afca792c404 100644 --- a/src/core/support/log_posix.c +++ b/src/core/support/log_posix.c @@ -64,7 +64,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, } else { message = allocated = gpr_malloc(ret + 1); va_start(args, format); - vsnprintf(message, ret, format, args); + vsnprintf(message, ret + 1, format, args); va_end(args); } gpr_log_message(file, line, severity, message); diff --git a/src/core/support/murmur_hash.h b/src/core/support/murmur_hash.h index 06c0c560797..85ab2fe4bfd 100644 --- a/src/core/support/murmur_hash.h +++ b/src/core/support/murmur_hash.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SUPPORT_MURMUR_HASH_H__ -#define __GRPC_INTERNAL_SUPPORT_MURMUR_HASH_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H +#define GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H #include @@ -41,4 +41,4 @@ /* compute the hash of key (length len) */ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed); -#endif /* __GRPC_INTERNAL_SUPPORT_MURMUR_HASH_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */ diff --git a/src/core/support/string.h b/src/core/support/string.h index eaa18264392..faf33427083 100644 --- a/src/core/support/string.h +++ b/src/core/support/string.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_STRING_H__ -#define __GRPC_SUPPORT_STRING_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_STRING_H +#define GRPC_INTERNAL_CORE_SUPPORT_STRING_H #include @@ -106,4 +106,4 @@ char *gpr_strvec_flatten(gpr_strvec *strs, size_t *total_length); } #endif -#endif /* __GRPC_SUPPORT_STRING_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_H */ diff --git a/src/core/support/string_win32.h b/src/core/support/string_win32.h index 5dbb40dbc3b..0bc3247d9da 100644 --- a/src/core/support/string_win32.h +++ b/src/core/support/string_win32.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_SUPPORT_STRING_WIN32_H__ -#define __GRPC_SUPPORT_STRING_WIN32_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H +#define GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H #include @@ -46,4 +46,4 @@ LPSTR gpr_tchar_to_char(LPCTSTR input); #endif /* GPR_WIN32 */ -#endif /* __GRPC_SUPPORT_STRING_WIN32_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H */ diff --git a/src/core/support/thd_internal.h b/src/core/support/thd_internal.h index 0fb1447e488..4683c37742e 100644 --- a/src/core/support/thd_internal.h +++ b/src/core/support/thd_internal.h @@ -31,9 +31,9 @@ * */ -#ifndef __GRPC_INTERNAL_SUPPORT_THD_INTERNAL_H__ -#define __GRPC_INTERNAL_SUPPORT_THD_INTERNAL_H__ +#ifndef GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H +#define GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H /* Internal interfaces between modules within the gpr support library. */ -#endif /* __GRPC_INTERNAL_SUPPORT_THD_INTERNAL_H__ */ +#endif /* GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H */ diff --git a/src/core/surface/byte_buffer_queue.h b/src/core/surface/byte_buffer_queue.h index 9d3b5257a7a..32c57f87563 100644 --- a/src/core/surface/byte_buffer_queue.h +++ b/src/core/surface/byte_buffer_queue.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_BYTE_BUFFER_QUEUE_H__ -#define __GRPC_INTERNAL_SURFACE_BYTE_BUFFER_QUEUE_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_BYTE_BUFFER_QUEUE_H +#define GRPC_INTERNAL_CORE_SURFACE_BYTE_BUFFER_QUEUE_H #include @@ -57,4 +57,4 @@ void grpc_bbq_flush(grpc_byte_buffer_queue *q); int grpc_bbq_empty(grpc_byte_buffer_queue *q); void grpc_bbq_push(grpc_byte_buffer_queue *q, grpc_byte_buffer *bb); -#endif /* __GRPC_INTERNAL_SURFACE_BYTE_BUFFER_QUEUE_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_BYTE_BUFFER_QUEUE_H */ diff --git a/src/core/surface/call.h b/src/core/surface/call.h index dd3ad124e6d..cb81cb52c25 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_CALL_H__ -#define __GRPC_INTERNAL_SURFACE_CALL_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_CALL_H +#define GRPC_INTERNAL_CORE_SURFACE_CALL_H #include "src/core/channel/channel_stack.h" #include "src/core/channel/metadata_buffer.h" @@ -119,4 +119,4 @@ grpc_call_stack *grpc_call_get_call_stack(grpc_call *call); /* Given the top call_element, get the call object. */ grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element); -#endif /* __GRPC_INTERNAL_SURFACE_CALL_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */ diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h index 6bdfd474d2e..d3e51185eec 100644 --- a/src/core/surface/channel.h +++ b/src/core/surface/channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_CHANNEL_H__ -#define __GRPC_INTERNAL_SURFACE_CHANNEL_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H +#define GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H #include "src/core/channel/channel_stack.h" @@ -50,4 +50,4 @@ void grpc_client_channel_closed(grpc_channel_element *elem); void grpc_channel_internal_ref(grpc_channel *channel); void grpc_channel_internal_unref(grpc_channel *channel); -#endif /* __GRPC_INTERNAL_SURFACE_CHANNEL_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H */ diff --git a/src/core/surface/client.h b/src/core/surface/client.h index 06ce8f66567..9db2ccf3d28 100644 --- a/src/core/surface/client.h +++ b/src/core/surface/client.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_CLIENT_H__ -#define __GRPC_INTERNAL_SURFACE_CLIENT_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_CLIENT_H +#define GRPC_INTERNAL_CORE_SURFACE_CLIENT_H #include "src/core/channel/channel_stack.h" extern const grpc_channel_filter grpc_client_surface_filter; -#endif /* __GRPC_INTERNAL_SURFACE_CLIENT_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_CLIENT_H */ diff --git a/src/core/surface/completion_queue.h b/src/core/surface/completion_queue.h index a7688b844c6..3054264cadf 100644 --- a/src/core/surface/completion_queue.h +++ b/src/core/surface/completion_queue.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_COMPLETION_QUEUE_H__ -#define __GRPC_INTERNAL_SURFACE_COMPLETION_QUEUE_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H +#define GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H /* Internal API for completion channels */ @@ -114,4 +114,4 @@ void grpc_cq_dump_pending_ops(grpc_completion_queue *cc); grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cc); -#endif /* __GRPC_INTERNAL_SURFACE_COMPLETION_QUEUE_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H */ diff --git a/src/core/surface/event_string.h b/src/core/surface/event_string.h index d9b1e4e0747..e8a8f935180 100644 --- a/src/core/surface/event_string.h +++ b/src/core/surface/event_string.h @@ -31,12 +31,12 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_EVENT_STRING_H__ -#define __GRPC_INTERNAL_SURFACE_EVENT_STRING_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H +#define GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H #include /* Returns a string describing an event. Must be later freed with gpr_free() */ char *grpc_event_string(grpc_event *ev); -#endif /* __GRPC_INTERNAL_SURFACE_EVENT_STRING_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H */ diff --git a/src/core/surface/lame_client.h b/src/core/surface/lame_client.h index 2bd97b95eb1..b13e8cb6efe 100644 --- a/src/core/surface/lame_client.h +++ b/src/core/surface/lame_client.h @@ -31,12 +31,12 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_LAME_CLIENT_H_ -#define __GRPC_INTERNAL_SURFACE_LAME_CLIENT_H_ +#ifndef GRPC_INTERNAL_CORE_SURFACE_LAME_CLIENT_H +#define GRPC_INTERNAL_CORE_SURFACE_LAME_CLIENT_H #include /* Create a lame client: this client fails every operation attempted on it. */ grpc_channel *grpc_lame_client_channel_create(void); -#endif /* __GRPC_INTERNAL_SURFACE_LAME_CLIENT_H_ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_LAME_CLIENT_H */ diff --git a/src/core/surface/server.h b/src/core/surface/server.h index 5ae59b22554..e33f69b8c75 100644 --- a/src/core/surface/server.h +++ b/src/core/surface/server.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_SERVER_H__ -#define __GRPC_INTERNAL_SURFACE_SERVER_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_SERVER_H +#define GRPC_INTERNAL_CORE_SURFACE_SERVER_H #include "src/core/channel/channel_stack.h" #include @@ -60,4 +60,4 @@ grpc_transport_setup_result grpc_server_setup_transport( const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server); -#endif /* __GRPC_INTERNAL_SURFACE_SERVER_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_SERVER_H */ diff --git a/src/core/surface/surface_trace.h b/src/core/surface/surface_trace.h index 4d478d6470e..50071ee317d 100644 --- a/src/core/surface/surface_trace.h +++ b/src/core/surface/surface_trace.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_SURFACE_SURFACE_TRACE_H__ -#define __GRPC_INTERNAL_SURFACE_SURFACE_TRACE_H__ +#ifndef GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H +#define GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H #include "src/core/debug/trace.h" #include @@ -44,4 +44,4 @@ gpr_free(_ev); \ } -#endif /* __GRPC_INTERNAL_SURFACE_SURFACE_TRACE_H__ */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H */ diff --git a/src/core/transport/chttp2/alpn.h b/src/core/transport/chttp2/alpn.h index 796f514f19e..fcbefc060f4 100644 --- a/src/core/transport/chttp2/alpn.h +++ b/src/core/transport/chttp2/alpn.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_ALPN_H_ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_ALPN_H_ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H #include @@ -46,4 +46,4 @@ size_t grpc_chttp2_num_alpn_versions(void); * grpc_chttp2_num_alpn_versions()) */ const char *grpc_chttp2_get_alpn_version_index(size_t i); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_ALPN_H_ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H */ diff --git a/src/core/transport/chttp2/bin_encoder.h b/src/core/transport/chttp2/bin_encoder.h index 2368fdd738c..9c88ac9725a 100644 --- a/src/core/transport/chttp2/bin_encoder.h +++ b/src/core/transport/chttp2/bin_encoder.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_BIN_ENCODER_H_ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_BIN_ENCODER_H_ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H #include @@ -53,4 +53,4 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input); int grpc_is_binary_header(const char *key, size_t length); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_BIN_ENCODER_H_ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H */ diff --git a/src/core/transport/chttp2/frame.h b/src/core/transport/chttp2/frame.h index 733dd5eec48..fbb941969e9 100644 --- a/src/core/transport/chttp2/frame.h +++ b/src/core/transport/chttp2/frame.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H #include #include @@ -77,4 +77,4 @@ typedef struct { #define GRPC_CHTTP2_DATA_FLAG_PADDED 8 #define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20 -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H */ diff --git a/src/core/transport/chttp2/frame_data.h b/src/core/transport/chttp2/frame_data.h index 4d05a5f4529..24e557accd1 100644 --- a/src/core/transport/chttp2/frame_data.h +++ b/src/core/transport/chttp2/frame_data.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_DATA_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_DATA_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H /* Parser for GRPC streams embedded in DATA frames */ @@ -77,4 +77,4 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse( /* create a slice with an empty data frame and is_last set */ gpr_slice grpc_chttp2_data_frame_create_empty_close(gpr_uint32 id); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_DATA_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H */ diff --git a/src/core/transport/chttp2/frame_goaway.h b/src/core/transport/chttp2/frame_goaway.h index 9ccef276346..76388915142 100644 --- a/src/core/transport/chttp2/frame_goaway.h +++ b/src/core/transport/chttp2/frame_goaway.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_GOAWAY_H_ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_GOAWAY_H_ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H #include "src/core/transport/chttp2/frame.h" #include @@ -71,4 +71,4 @@ void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code, gpr_slice debug_data, gpr_slice_buffer *slice_buffer); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_GOAWAY_H_ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H */ diff --git a/src/core/transport/chttp2/frame_ping.h b/src/core/transport/chttp2/frame_ping.h index d9d6f7ef15e..11d38b80ea5 100644 --- a/src/core/transport/chttp2/frame_ping.h +++ b/src/core/transport/chttp2/frame_ping.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_PING_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_PING_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H #include #include "src/core/transport/chttp2/frame.h" @@ -50,4 +50,4 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse( void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_PING_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H */ diff --git a/src/core/transport/chttp2/frame_rst_stream.h b/src/core/transport/chttp2/frame_rst_stream.h index 83fc3806eb2..2d3ee18637b 100644 --- a/src/core/transport/chttp2/frame_rst_stream.h +++ b/src/core/transport/chttp2/frame_rst_stream.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H #include gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 stream_id, gpr_uint32 code); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H */ diff --git a/src/core/transport/chttp2/frame_settings.h b/src/core/transport/chttp2/frame_settings.h index 6cde2c6e47e..18765631a68 100644 --- a/src/core/transport/chttp2/frame_settings.h +++ b/src/core/transport/chttp2/frame_settings.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_SETTINGS_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_SETTINGS_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H #include #include @@ -96,4 +96,4 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse( void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_SETTINGS_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */ diff --git a/src/core/transport/chttp2/frame_window_update.h b/src/core/transport/chttp2/frame_window_update.h index 093263db170..85475a8f9ef 100644 --- a/src/core/transport/chttp2/frame_window_update.h +++ b/src/core/transport/chttp2/frame_window_update.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H #include #include "src/core/transport/chttp2/frame.h" @@ -52,4 +52,4 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse( void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H */ diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h index 94acc8864f7..bb4c1a1f492 100644 --- a/src/core/transport/chttp2/hpack_parser.h +++ b/src/core/transport/chttp2/hpack_parser.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_PARSER_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_PARSER_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H #include @@ -108,4 +108,4 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse( void *hpack_parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_PARSER_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */ diff --git a/src/core/transport/chttp2/hpack_table.h b/src/core/transport/chttp2/hpack_table.h index ea0fc1d0302..d3bf41bbc5b 100644 --- a/src/core/transport/chttp2/hpack_table.h +++ b/src/core/transport/chttp2/hpack_table.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_TABLE_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_TABLE_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H #include "src/core/transport/metadata.h" #include @@ -94,4 +94,4 @@ typedef struct { grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( const grpc_chttp2_hptbl *tbl, grpc_mdelem *md); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_HPACK_TABLE_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H */ diff --git a/src/core/transport/chttp2/http2_errors.h b/src/core/transport/chttp2/http2_errors.h index 1eecd175401..4ab2ec02207 100644 --- a/src/core/transport/chttp2/http2_errors.h +++ b/src/core/transport/chttp2/http2_errors.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_HTTP2_ERRORS_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_HTTP2_ERRORS_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H /* error codes for RST_STREAM from http2 draft 14 section 7 */ typedef enum { @@ -53,4 +53,4 @@ typedef enum { GRPC_CHTTP2__ERROR_DO_NOT_USE = -1 } grpc_chttp2_error_code; -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_HTTP2_ERRORS_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H */ diff --git a/src/core/transport/chttp2/huffsyms.h b/src/core/transport/chttp2/huffsyms.h index 131c4acbebb..f9c14479669 100644 --- a/src/core/transport/chttp2/huffsyms.h +++ b/src/core/transport/chttp2/huffsyms.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_HUFFSYMS_H_ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_HUFFSYMS_H_ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H /* HPACK static huffman table */ @@ -45,4 +45,4 @@ typedef struct { extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS]; -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_HUFFSYMS_H_ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H */ diff --git a/src/core/transport/chttp2/status_conversion.h b/src/core/transport/chttp2/status_conversion.h index 8e2672008cf..cf06c3576e1 100644 --- a/src/core/transport/chttp2/status_conversion.h +++ b/src/core/transport/chttp2/status_conversion.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_STATUS_CONVERSION_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_STATUS_CONVERSION_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H #include #include "src/core/transport/chttp2/http2_errors.h" @@ -47,4 +47,4 @@ grpc_status_code grpc_chttp2_http2_error_to_grpc_status( grpc_status_code grpc_chttp2_http2_status_to_grpc_status(int status); int grpc_chttp2_grpc_status_to_http2_status(grpc_status_code status); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_STATUS_CONVERSION_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H */ diff --git a/src/core/transport/chttp2/stream_encoder.h b/src/core/transport/chttp2/stream_encoder.h index a99d61a553f..50c58ad5ca3 100644 --- a/src/core/transport/chttp2/stream_encoder.h +++ b/src/core/transport/chttp2/stream_encoder.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_ENCODER_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_ENCODER_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H #include "src/core/transport/chttp2/frame.h" #include "src/core/transport/metadata.h" @@ -90,4 +90,4 @@ void grpc_chttp2_encode(grpc_stream_op *ops, size_t ops_count, int eof, grpc_chttp2_hpack_compressor *compressor, gpr_slice_buffer *output); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_ENCODER_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_ENCODER_H */ diff --git a/src/core/transport/chttp2/stream_map.h b/src/core/transport/chttp2/stream_map.h index 3fb91fc88f7..d338d2f8921 100644 --- a/src/core/transport/chttp2/stream_map.h +++ b/src/core/transport/chttp2/stream_map.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_MAP_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_MAP_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H #include @@ -78,4 +78,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map, void *value), void *user_data); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_STREAM_MAP_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H */ diff --git a/src/core/transport/chttp2/timeout_encoding.h b/src/core/transport/chttp2/timeout_encoding.h index 2bef8ba67f5..e6664c62628 100644 --- a/src/core/transport/chttp2/timeout_encoding.h +++ b/src/core/transport/chttp2/timeout_encoding.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H_ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H_ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H #include "src/core/support/string.h" #include @@ -44,4 +44,4 @@ void grpc_chttp2_encode_timeout(gpr_timespec timeout, char *buffer); int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H_ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H */ diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h index 8c353c66a72..ee04ed7fb22 100644 --- a/src/core/transport/chttp2/varint.h +++ b/src/core/transport/chttp2/varint.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_VARINT_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_VARINT_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H #include @@ -71,4 +71,4 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value, } \ } while (0) -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_VARINT_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H */ diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index e9f1cd7842d..476cc4b226e 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -308,7 +308,7 @@ static void push_setting(transport *t, grpc_chttp2_setting_id id, gpr_uint32 value); static int prepare_callbacks(transport *t); -static void run_callbacks(transport *t); +static void run_callbacks(transport *t, const grpc_transport_callbacks *cb); static int prepare_write(transport *t); static void perform_write(transport *t, grpc_endpoint *ep); @@ -713,6 +713,7 @@ static void unlock(transport *t) { pending_goaway *goaways = NULL; grpc_endpoint *ep = t->ep; grpc_stream_op_buffer nuke_now; + const grpc_transport_callbacks *cb = t->cb; grpc_sopb_init(&nuke_now); if (t->nuke_later_sopb.nops) { @@ -732,7 +733,7 @@ static void unlock(transport *t) { } /* gather any callbacks that need to be made */ - if (!t->calling_back && t->cb) { + if (!t->calling_back && cb) { perform_callbacks = prepare_callbacks(t); if (perform_callbacks) { t->calling_back = 1; @@ -740,6 +741,7 @@ static void unlock(transport *t) { if (t->error_state == ERROR_STATE_SEEN) { call_closed = 1; t->calling_back = 1; + t->cb = NULL; /* no more callbacks */ t->error_state = ERROR_STATE_NOTIFIED; } if (t->num_pending_goaways) { @@ -761,16 +763,16 @@ static void unlock(transport *t) { /* perform some callbacks if necessary */ for (i = 0; i < num_goaways; i++) { - t->cb->goaway(t->cb_user_data, &t->base, goaways[i].status, - goaways[i].debug); + cb->goaway(t->cb_user_data, &t->base, goaways[i].status, + goaways[i].debug); } if (perform_callbacks) { - run_callbacks(t); + run_callbacks(t, cb); } if (call_closed) { - t->cb->closed(t->cb_user_data, &t->base); + cb->closed(t->cb_user_data, &t->base); } /* write some bytes if necessary */ @@ -1753,13 +1755,13 @@ static int prepare_callbacks(transport *t) { return n; } -static void run_callbacks(transport *t) { +static void run_callbacks(transport *t, const grpc_transport_callbacks *cb) { stream *s; while ((s = stream_list_remove_head(t, EXECUTING_CALLBACKS))) { size_t nops = s->callback_sopb.nops; s->callback_sopb.nops = 0; - t->cb->recv_batch(t->cb_user_data, &t->base, (grpc_stream *)s, - s->callback_sopb.ops, nops, s->callback_state); + cb->recv_batch(t->cb_user_data, &t->base, (grpc_stream *)s, + s->callback_sopb.ops, nops, s->callback_state); } } diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h index 6fbc5961a1d..c5b65bd4f75 100644 --- a/src/core/transport/chttp2_transport.h +++ b/src/core/transport/chttp2_transport.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_TRANSPORT_H__ -#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_TRANSPORT_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H +#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H #include "src/core/iomgr/endpoint.h" #include "src/core/transport/transport.h" @@ -44,4 +44,4 @@ void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, size_t nslices, grpc_mdctx *metadata_context, int is_client); -#endif /* __GRPC_INTERNAL_TRANSPORT_CHTTP2_TRANSPORT_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H */ diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h index 7a56e346901..b8afbeb1e34 100644 --- a/src/core/transport/metadata.h +++ b/src/core/transport/metadata.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_METADATA_H__ -#define __GRPC_INTERNAL_TRANSPORT_METADATA_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H +#define GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H #include #include @@ -137,4 +137,4 @@ const char *grpc_mdstr_as_c_string(grpc_mdstr *s); #define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash)) -#endif /* __GRPC_INTERNAL_TRANSPORT_METADATA_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H */ diff --git a/src/core/transport/stream_op.h b/src/core/transport/stream_op.h index 828a7f7226f..2ffbcce87b3 100644 --- a/src/core/transport/stream_op.h +++ b/src/core/transport/stream_op.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_STREAM_OP_H__ -#define __GRPC_INTERNAL_TRANSPORT_STREAM_OP_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H +#define GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H #include #include @@ -131,4 +131,4 @@ void grpc_sopb_add_flow_ctl_cb(grpc_stream_op_buffer *sopb, void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops, size_t nops); -#endif /* __GRPC_INTERNAL_TRANSPORT_STREAM_OP_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H */ diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h index 60193b1844c..ce8c17c3228 100644 --- a/src/core/transport/transport.h +++ b/src/core/transport/transport.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_TRANSPORT_H__ -#define __GRPC_INTERNAL_TRANSPORT_TRANSPORT_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H +#define GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H #include @@ -254,4 +254,4 @@ void grpc_transport_setup_initiate(grpc_transport_setup *setup); used as a destruction call by setup). */ void grpc_transport_setup_cancel(grpc_transport_setup *setup); -#endif /* __GRPC_INTERNAL_TRANSPORT_TRANSPORT_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H */ diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h index d1e0b1920ea..ac275c75606 100644 --- a/src/core/transport/transport_impl.h +++ b/src/core/transport/transport_impl.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_INTERNAL_TRANSPORT_TRANSPORT_IMPL_H__ -#define __GRPC_INTERNAL_TRANSPORT_TRANSPORT_IMPL_H__ +#ifndef GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H +#define GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H #include "src/core/transport/transport.h" @@ -84,4 +84,4 @@ struct grpc_transport { const grpc_transport_vtable *vtable; }; -#endif /* __GRPC_INTERNAL_TRANSPORT_TRANSPORT_IMPL_H__ */ +#endif /* GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H */ diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.c index e8af200284a..f58f04ea20b 100644 --- a/src/core/tsi/fake_transport_security.c +++ b/src/core/tsi/fake_transport_security.c @@ -392,8 +392,10 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer( if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX; } - gpr_log(GPR_INFO, "%s prepared %s.", impl->is_client ? "Client" : "Server", - tsi_fake_handshake_message_to_string(impl->next_message_to_send)); + if (tsi_tracing_enabled) { + gpr_log(GPR_INFO, "%s prepared %s.", impl->is_client ? "Client" : "Server", + tsi_fake_handshake_message_to_string(impl->next_message_to_send)); + } impl->next_message_to_send = next_message_to_send; } result = drain_frame_to_bytes(bytes, bytes_size, &impl->outgoing); @@ -401,7 +403,9 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer( if (!impl->is_client && impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { /* We're done. */ - gpr_log(GPR_INFO, "Server is done."); + if (tsi_tracing_enabled) { + gpr_log(GPR_INFO, "Server is done."); + } impl->result = TSI_OK; } else { impl->needs_incoming_message = 1; @@ -436,13 +440,17 @@ static tsi_result fake_handshaker_process_bytes_from_peer( tsi_fake_handshake_message_to_string(received_msg), tsi_fake_handshake_message_to_string(expected_msg)); } - gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server", - tsi_fake_handshake_message_to_string(received_msg)); + if (tsi_tracing_enabled) { + gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server", + tsi_fake_handshake_message_to_string(received_msg)); + } tsi_fake_frame_reset(&impl->incoming, 0 /* needs_draining */); impl->needs_incoming_message = 0; if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) { /* We're done. */ - gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server"); + if (tsi_tracing_enabled) { + gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server"); + } impl->result = TSI_OK; } return TSI_OK; diff --git a/src/core/tsi/fake_transport_security.h b/src/core/tsi/fake_transport_security.h index 36e62bce3da..af9730b90e1 100644 --- a/src/core/tsi/fake_transport_security.h +++ b/src/core/tsi/fake_transport_security.h @@ -31,8 +31,8 @@ * */ -#ifndef __FAKE_TRANSPORT_SECURITY_H_ -#define __FAKE_TRANSPORT_SECURITY_H_ +#ifndef GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H +#define GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H #include "src/core/tsi/transport_security_interface.h" @@ -58,4 +58,4 @@ tsi_frame_protector* tsi_create_fake_protector( } #endif -#endif /* __FAKE_TRANSPORT_SECURITY_H_ */ +#endif /* GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */ diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c index c13b2d5ea18..dc43f7e270c 100644 --- a/src/core/tsi/ssl_transport_security.c +++ b/src/core/tsi/ssl_transport_security.c @@ -39,7 +39,6 @@ #include #include #include -#include "src/core/debug/trace.h" #include "src/core/tsi/transport_security.h" #include @@ -163,7 +162,7 @@ static const char* ssl_error_string(int error) { /* TODO(jboeuf): Remove when we are past the debugging phase with this code. */ static void ssl_log_where_info(const SSL* ssl, int where, int flag, const char* msg) { - if ((where & flag) && (grpc_trace_bits & GRPC_TRACE_SSL)) { + if ((where & flag) && tsi_tracing_enabled) { gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg, SSL_state_string_long(ssl), SSL_state_string(ssl)); } @@ -1095,8 +1094,9 @@ static int does_entry_match_name(const char* entry, size_t entry_length, return 0; } name_subdomain = strchr(name, '.'); + if (name_subdomain == NULL) return 0; name_subdomain_length = strlen(name_subdomain); - if (name_subdomain == NULL || name_subdomain_length < 2) return 0; + if (name_subdomain_length < 2) return 0; name_subdomain++; /* Starts after the dot. */ name_subdomain_length--; entry += 2; /* Remove *. */ diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h index eecf2d7c2d6..192f7acf0e0 100644 --- a/src/core/tsi/ssl_transport_security.h +++ b/src/core/tsi/ssl_transport_security.h @@ -31,8 +31,8 @@ * */ -#ifndef __SSL_TRANSPORT_SECURITY_H_ -#define __SSL_TRANSPORT_SECURITY_H_ +#ifndef GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H +#define GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H #include "src/core/tsi/transport_security_interface.h" @@ -170,4 +170,4 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name); } #endif -#endif /* __SSL_TRANSPORT_SECURITY_H_ */ +#endif /* GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H */ diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.c index aeb9b3fc17d..04b30004fcd 100644 --- a/src/core/tsi/transport_security.c +++ b/src/core/tsi/transport_security.c @@ -36,6 +36,14 @@ #include #include +/* --- Tracing. --- */ + +int tsi_tracing_enabled = 0; + +void tsi_enable_tracing() { + tsi_tracing_enabled = 1; +} + /* --- Utils. --- */ char* tsi_strdup(const char* src) { diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h index 432da073463..59e5dcff9a2 100644 --- a/src/core/tsi/transport_security.h +++ b/src/core/tsi/transport_security.h @@ -31,8 +31,8 @@ * */ -#ifndef __TRANSPORT_SECURITY_H_ -#define __TRANSPORT_SECURITY_H_ +#ifndef GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H +#define GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H #include "src/core/tsi/transport_security_interface.h" @@ -40,6 +40,8 @@ extern "C" { #endif +extern int tsi_tracing_enabled; + /* Base for tsi_frame_protector implementations. See transport_security_interface.h for documentation. */ typedef struct { @@ -115,4 +117,4 @@ char* tsi_strdup(const char* src); /* Sadly, no strdup in C89. */ } #endif -#endif /* __TRANSPORT_SECURITY_H_ */ +#endif /* GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H */ diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h index 90e119ca8e4..33a19bef0de 100644 --- a/src/core/tsi/transport_security_interface.h +++ b/src/core/tsi/transport_security_interface.h @@ -31,8 +31,8 @@ * */ -#ifndef __TRANSPORT_SECURITY_INTERFACE_H_ -#define __TRANSPORT_SECURITY_INTERFACE_H_ +#ifndef GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H +#define GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H #include #include @@ -61,6 +61,11 @@ typedef enum { const char* tsi_result_to_string(tsi_result result); +/* --- tsi tracing --- */ + +/* Call this function before any other tsi function to avoid races. */ +void tsi_enable_tracing(void); + /* --- tsi_frame_protector object --- This object protects and unprotects buffers once the handshake is done. @@ -361,4 +366,4 @@ void tsi_handshaker_destroy(tsi_handshaker* self); } #endif -#endif /* __TRANSPORT_SECURITY_INTERFACE_H_ */ +#endif /* GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H */ diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h index 06f5a8ffdfe..63c6e2bde6d 100644 --- a/src/cpp/client/channel.h +++ b/src/cpp/client/channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_INTERNAL_CLIENT_CHANNEL_H__ -#define __GRPCPP_INTERNAL_CLIENT_CHANNEL_H__ +#ifndef GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H +#define GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H #include @@ -49,17 +49,17 @@ class CompletionQueue; class Credentials; class StreamContextInterface; -class Channel final : public ChannelInterface { +class Channel GRPC_FINAL : public ChannelInterface { public: Channel(const grpc::string &target, const ChannelArguments &args); Channel(const grpc::string &target, const std::unique_ptr &creds, const ChannelArguments &args); - ~Channel() override; + ~Channel() GRPC_OVERRIDE; virtual Call CreateCall(const RpcMethod &method, ClientContext *context, - CompletionQueue *cq) override; - virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) override; + CompletionQueue *cq) GRPC_OVERRIDE; + virtual void PerformOpsOnCall(CallOpBuffer *ops, Call *call) GRPC_OVERRIDE; private: const grpc::string target_; @@ -68,4 +68,4 @@ class Channel final : public ChannelInterface { } // namespace grpc -#endif // __GRPCPP_INTERNAL_CLIENT_CHANNEL_H__ +#endif // GRPC_INTERNAL_CPP_CLIENT_CHANNEL_H diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 80cbdd93acc..9f99f7bcd55 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -41,7 +41,10 @@ using std::chrono::system_clock; namespace grpc { ClientContext::ClientContext() - : call_(nullptr), cq_(nullptr), absolute_deadline_(gpr_inf_future) {} + : initial_metadata_received_(false), + call_(nullptr), + cq_(nullptr), + absolute_deadline_(gpr_inf_future) {} ClientContext::~ClientContext() { if (call_) { diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index e6a20a252db..f3a691114d2 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -41,6 +41,30 @@ namespace grpc { +CallOpBuffer::CallOpBuffer() + : return_tag_(this), + send_initial_metadata_(false), + initial_metadata_count_(0), + initial_metadata_(nullptr), + recv_initial_metadata_(nullptr), + recv_initial_metadata_arr_{0, 0, nullptr}, + send_message_(nullptr), + send_message_buf_(nullptr), + recv_message_(nullptr), + recv_message_buf_(nullptr), + 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), + send_status_(nullptr), + trailing_metadata_count_(0), + trailing_metadata_(nullptr), + cancelled_buf_(0), + recv_closed_(nullptr) {} + void CallOpBuffer::Reset(void* next_return_tag) { return_tag_ = next_return_tag; diff --git a/src/cpp/proto/proto_utils.h b/src/cpp/proto/proto_utils.h index 834884d5796..a0af4d6465d 100644 --- a/src/cpp/proto/proto_utils.h +++ b/src/cpp/proto/proto_utils.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_INTERNAL_PROTO_PROTO_UTILS_H__ -#define __GRPCPP_INTERNAL_PROTO_PROTO_UTILS_H__ +#ifndef GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H +#define GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H struct grpc_byte_buffer; namespace google { @@ -54,4 +54,4 @@ bool DeserializeProto(grpc_byte_buffer *buffer, google::protobuf::Message *msg); } // namespace grpc -#endif // __GRPCPP_INTERNAL_PROTO_PROTO_UTILS_H__ +#endif // GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 178fa1a7167..97bf0f1a6ea 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -49,11 +49,12 @@ namespace grpc { -class Server::SyncRequest final : public CompletionQueueTag { +class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { public: SyncRequest(RpcServiceMethod* method, void* tag) : method_(method), tag_(tag), + in_flight_(false), has_request_payload_(method->method_type() == RpcMethod::NORMAL_RPC || method->method_type() == RpcMethod::SERVER_STREAMING), @@ -85,14 +86,14 @@ class Server::SyncRequest final : public CompletionQueueTag { this)); } - bool FinalizeResult(void** tag, bool* status) override { + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { if (!*status) { grpc_completion_queue_destroy(cq_); } return true; } - class CallData final { + class CallData GRPC_FINAL { public: explicit CallData(Server* server, SyncRequest* mrd) : cq_(mrd->cq_), @@ -159,7 +160,7 @@ class Server::SyncRequest final : public CompletionQueueTag { private: RpcServiceMethod* const method_; void* const tag_; - bool in_flight_ = false; + bool in_flight_; const bool has_request_payload_; const bool has_response_payload_; grpc_call* call_; @@ -294,7 +295,7 @@ void Server::PerformOpsOnCall(CallOpBuffer* buf, Call* call) { grpc_call_start_batch(call->call(), ops, nops, buf)); } -class Server::AsyncRequest final : public CompletionQueueTag { +class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { public: AsyncRequest(Server* server, void* registered_method, ServerContext* ctx, ::google::protobuf::Message* request, @@ -305,7 +306,9 @@ class Server::AsyncRequest final : public CompletionQueueTag { stream_(stream), cq_(cq), ctx_(ctx), - server_(server) { + server_(server), + call_(nullptr), + payload_(nullptr) { memset(&array_, 0, sizeof(array_)); grpc_server_request_registered_call( server->server_, registered_method, &call_, &deadline_, &array_, @@ -319,7 +322,7 @@ class Server::AsyncRequest final : public CompletionQueueTag { grpc_metadata_array_destroy(&array_); } - bool FinalizeResult(void** tag, bool* status) override { + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { *tag = tag_; if (*status && request_) { if (payload_) { @@ -354,10 +357,10 @@ class Server::AsyncRequest final : public CompletionQueueTag { CompletionQueue* const cq_; ServerContext* const ctx_; Server* const server_; - grpc_call* call_ = nullptr; + grpc_call* call_; gpr_timespec deadline_; grpc_metadata_array array_; - grpc_byte_buffer* payload_ = nullptr; + grpc_byte_buffer* payload_; }; void Server::RequestAsyncCall(void* registered_method, ServerContext* context, diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 3c2093c3638..ae60f3d8b67 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -41,7 +41,7 @@ namespace grpc { -ServerBuilder::ServerBuilder() {} +ServerBuilder::ServerBuilder() : thread_pool_(nullptr) {} void ServerBuilder::RegisterService(SynchronousService* service) { services_.push_back(service->service()); diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 1aa18bcac57..bb3c2d1405f 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -44,10 +44,13 @@ namespace grpc { // CompletionOp -class ServerContext::CompletionOp final : public CallOpBuffer { +class ServerContext::CompletionOp GRPC_FINAL : public CallOpBuffer { public: - CompletionOp(); - bool FinalizeResult(void** tag, bool* status) override; + // initial refs: one in the server context, one in the cq + CompletionOp() : refs_(2), finalized_(false), cancelled_(false) { + AddServerRecvClose(&cancelled_); + } + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; bool CheckCancelled(CompletionQueue* cq); @@ -55,13 +58,11 @@ class ServerContext::CompletionOp final : public CallOpBuffer { private: std::mutex mu_; - int refs_ = 2; // initial refs: one in the server context, one in the cq - bool finalized_ = false; - bool cancelled_ = false; + int refs_; + bool finalized_; + bool cancelled_; }; -ServerContext::CompletionOp::CompletionOp() { AddServerRecvClose(&cancelled_); } - void ServerContext::CompletionOp::Unref() { std::unique_lock lock(mu_); if (--refs_ == 0) { @@ -90,11 +91,19 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { // ServerContext body -ServerContext::ServerContext() {} +ServerContext::ServerContext() + : completion_op_(nullptr), + call_(nullptr), + cq_(nullptr), + sent_initial_metadata_(false) {} ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata, size_t metadata_count) - : deadline_(Timespec2Timepoint(deadline)) { + : completion_op_(nullptr), + deadline_(Timespec2Timepoint(deadline)), + call_(nullptr), + cq_(nullptr), + sent_initial_metadata_(false) { for (size_t i = 0; i < metadata_count; i++) { client_metadata_.insert(std::make_pair( grpc::string(metadata[i].key), diff --git a/src/cpp/server/thread_pool.cc b/src/cpp/server/thread_pool.cc index fa11ddd04c7..5dc9bcf9165 100644 --- a/src/cpp/server/thread_pool.cc +++ b/src/cpp/server/thread_pool.cc @@ -35,7 +35,7 @@ namespace grpc { -ThreadPool::ThreadPool(int num_threads) { +ThreadPool::ThreadPool(int num_threads) : shutdown_(false) { for (int i = 0; i < num_threads; i++) { threads_.push_back(std::thread([this]() { for (;;) { diff --git a/src/cpp/server/thread_pool.h b/src/cpp/server/thread_pool.h index 283618f4b68..6157e403e95 100644 --- a/src/cpp/server/thread_pool.h +++ b/src/cpp/server/thread_pool.h @@ -31,9 +31,10 @@ * */ -#ifndef __GRPCPP_INTERNAL_SERVER_THREAD_POOL_H__ -#define __GRPCPP_INTERNAL_SERVER_THREAD_POOL_H__ +#ifndef GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H +#define GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H +#include #include #include @@ -44,21 +45,21 @@ namespace grpc { -class ThreadPool final : public ThreadPoolInterface { +class ThreadPool GRPC_FINAL : public ThreadPoolInterface { public: explicit ThreadPool(int num_threads); ~ThreadPool(); - void ScheduleCallback(const std::function &callback) override; + void ScheduleCallback(const std::function &callback) GRPC_OVERRIDE; private: std::mutex mu_; std::condition_variable cv_; - bool shutdown_ = false; + bool shutdown_; std::queue> callbacks_; std::vector threads_; }; } // namespace grpc -#endif // __GRPCPP_INTERNAL_SERVER_THREAD_POOL_H__ +#endif // GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H diff --git a/src/cpp/util/time.h b/src/cpp/util/time.h index 9f9e582d070..1994848eb21 100644 --- a/src/cpp/util/time.h +++ b/src/cpp/util/time.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_INTERNAL_UTIL_TIME_H__ -#define __GRPCPP_INTERNAL_UTIL_TIME_H__ +#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H +#define GRPC_INTERNAL_CPP_UTIL_TIME_H #include @@ -48,4 +48,4 @@ std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t); } // namespace grpc -#endif // __GRPCPP_INTERNAL_UTIL_TIME_H__ +#endif // GRPC_INTERNAL_CPP_UTIL_TIME_H diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs index 7e564a2fba5..39be35c2190 100644 --- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs @@ -101,15 +101,8 @@ namespace Grpc.Core.Tests using (Channel channel = new Channel(host + ":" + port)) { var call = new Call(unaryEchoStringMethod, channel); - - var stopwatch = new Stopwatch(); - stopwatch.Start(); - for (int i = 0; i < 1000; i++) - { - Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); - } - stopwatch.Stop(); - Console.WriteLine("Elapsed time: " + stopwatch.ElapsedMilliseconds + "ms"); + BenchmarkUtil.RunBenchmark(100, 1000, + () => { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); }); } server.ShutdownAsync().Wait(); diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj index 687be3c0cb6..a365320f052 100644 --- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj +++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj @@ -41,6 +41,7 @@ + diff --git a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs index 8d3aef946a6..596918c231c 100644 --- a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs +++ b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs @@ -41,14 +41,16 @@ namespace Grpc.Core.Tests public class GrpcEnvironmentTest { [Test] - public void InitializeAndShutdownGrpcEnvironment() { + public void InitializeAndShutdownGrpcEnvironment() + { GrpcEnvironment.Initialize(); Assert.IsNotNull(GrpcEnvironment.ThreadPool.CompletionQueue); GrpcEnvironment.Shutdown(); } [Test] - public void SubsequentInvocations() { + public void SubsequentInvocations() + { GrpcEnvironment.Initialize(); GrpcEnvironment.Initialize(); GrpcEnvironment.Shutdown(); @@ -56,7 +58,8 @@ namespace Grpc.Core.Tests } [Test] - public void InitializeAfterShutdown() { + public void InitializeAfterShutdown() + { GrpcEnvironment.Initialize(); var tp1 = GrpcEnvironment.ThreadPool; GrpcEnvironment.Shutdown(); diff --git a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs new file mode 100644 index 00000000000..282d521ba37 --- /dev/null +++ b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs @@ -0,0 +1,145 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Internal; +using Grpc.Core.Utils; +using NUnit.Framework; +using System.Runtime.InteropServices; + +namespace Grpc.Core.Tests +{ + public class PInvokeTest + { + int counter; + + [DllImport("grpc_csharp_ext.dll")] + static extern GRPCCallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] CompletionCallbackDelegate callback); + + [DllImport("grpc_csharp_ext.dll")] + static extern IntPtr grpcsharp_test_nop(IntPtr ptr); + + [TestFixtureSetUp] + public void Init() + { + GrpcEnvironment.Initialize(); + } + + [TestFixtureTearDown] + public void Cleanup() + { + GrpcEnvironment.Shutdown(); + } + + /// + /// (~1.26us .NET Windows) + /// + [Test] + public void CompletionQueueCreateDestroyBenchmark() + { + BenchmarkUtil.RunBenchmark( + 100000, 1000000, + () => { + CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); + cq.Dispose(); + } + ); + } + + + /// + /// Approximate results: + /// (~80ns Mono Linux) + /// (~110ns .NET Windows) + /// + [Test] + public void NativeCallbackBenchmark() + { + CompletionCallbackDelegate handler = Handler; + + counter = 0; + BenchmarkUtil.RunBenchmark( + 1000000, 10000000, + () => { + grpcsharp_test_callback(handler); + } + ); + Assert.AreNotEqual(0, counter); + } + + /// + /// Creating a new native-to-managed callback has significant overhead + /// compared to using an existing one. We need to be aware of this. + /// (~50us on Mono Linux!!!) + /// (~1.1us on .NET Windows) + /// + [Test] + public void NewNativeCallbackBenchmark() + { + counter = 0; + BenchmarkUtil.RunBenchmark( + 10000, 10000, + () => { + grpcsharp_test_callback(new CompletionCallbackDelegate(Handler)); + } + ); + Assert.AreNotEqual(0, counter); + } + + /// + /// Tests overhead of a simple PInvoke call. + /// (~46ns .NET Windows) + /// + [Test] + public void NopPInvokeBenchmark() + { + CompletionCallbackDelegate handler = Handler; + + BenchmarkUtil.RunBenchmark( + 1000000, 100000000, + () => { + grpcsharp_test_nop(IntPtr.Zero); + } + ); + } + + private void Handler(GRPCOpError op, IntPtr ptr) { + counter ++; + } + } +} + diff --git a/src/csharp/Grpc.Core/Calls.cs b/src/csharp/Grpc.Core/Calls.cs index b67332676ac..ee2208e5c25 100644 --- a/src/csharp/Grpc.Core/Calls.cs +++ b/src/csharp/Grpc.Core/Calls.cs @@ -47,19 +47,8 @@ namespace Grpc.Core { public static TResponse BlockingUnaryCall(Call call, TRequest req, CancellationToken token) { - //TODO: implement this in real synchronous style. - try { - return AsyncUnaryCall(call, req, token).Result; - } catch(AggregateException ae) { - foreach (var e in ae.InnerExceptions) - { - if (e is RpcException) - { - throw e; - } - } - throw; - } + var asyncCall = new AsyncCall(call.RequestSerializer, call.ResponseDeserializer); + return asyncCall.UnaryCall(call.Channel, call.MethodName, req); } public static async Task AsyncUnaryCall(Call call, TRequest req, CancellationToken token) diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 4ad32e10e43..05d40d45a6e 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -1,4 +1,4 @@ - + Debug @@ -33,6 +33,7 @@ + @@ -62,10 +63,20 @@ + + + + + + + + PreserveNewest + + + + + - - - - \ No newline at end of file diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index 0e3a0a581cd..d3a8da4729e 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -107,6 +107,7 @@ namespace Grpc.Core /// private GrpcEnvironment() { + GrpcLog.RedirectNativeLogs(Console.Error); grpcsharp_init(); threadPool = new GrpcThreadPool(THREAD_POOL_SIZE); threadPool.Start(); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 5e96092e270..6f37b059f75 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -38,6 +38,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Grpc.Core.Internal; +using Grpc.Core.Utils; namespace Grpc.Core.Internal { @@ -112,6 +113,36 @@ namespace Grpc.Core.Internal InitializeInternal(call, true); } + public TRead UnaryCall(Channel channel, String methodName, TWrite msg) + { + using(CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create()) + { + // TODO: handle serialization error... + byte[] payload = serializer(msg); + + unaryResponseTcs = new TaskCompletionSource(); + + lock (myLock) + { + Initialize(channel, cq, methodName); + started = true; + halfcloseRequested = true; + readingDone = true; + } + call.BlockingUnary(cq, payload, unaryResponseHandler); + + try + { + // Once the blocking call returns, the result should be available synchronously. + return unaryResponseTcs.Task.Result; + } + catch (AggregateException ae) + { + throw ExceptionHelper.UnwrapRpcException(ae); + } + } + } + public Task UnaryCallAsync(TWrite msg) { lock (myLock) @@ -150,6 +181,7 @@ namespace Grpc.Core.Internal { started = true; halfcloseRequested = true; + halfclosed = true; // halfclose not confirmed yet, but it will be once finishedHandler is called. this.readObserver = readObserver; @@ -513,6 +545,8 @@ namespace Grpc.Core.Internal } observer = readObserver; status = finishedStatus; + + ReleaseResourcesIfPossible(); } // TODO: wrap deserialization... diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 659a383b4bd..1c0bc98f062 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -62,6 +62,11 @@ namespace Grpc.Core.Internal [MarshalAs(UnmanagedType.FunctionPtr)] CompletionCallbackDelegate callback, byte[] send_buffer, UIntPtr send_buffer_len); + [DllImport("grpc_csharp_ext.dll")] + static extern void grpcsharp_call_blocking_unary(CallSafeHandle call, CompletionQueueSafeHandle dedicatedCq, + [MarshalAs(UnmanagedType.FunctionPtr)] CompletionCallbackDelegate callback, + byte[] send_buffer, UIntPtr send_buffer_len); + [DllImport("grpc_csharp_ext.dll")] static extern GRPCCallError grpcsharp_call_start_client_streaming(CallSafeHandle call, [MarshalAs(UnmanagedType.FunctionPtr)] CompletionCallbackDelegate callback); @@ -113,6 +118,11 @@ namespace Grpc.Core.Internal AssertCallOk(grpcsharp_call_start_unary(this, callback, payload, new UIntPtr((ulong) payload.Length))); } + public void BlockingUnary(CompletionQueueSafeHandle dedicatedCq, byte[] payload, CompletionCallbackDelegate callback) + { + grpcsharp_call_blocking_unary(this, dedicatedCq, callback, payload, new UIntPtr((ulong) payload.Length)); + } + public void StartClientStreaming(CompletionCallbackDelegate callback) { AssertCallOk(grpcsharp_call_start_client_streaming(this, callback)); diff --git a/src/csharp/Grpc.Core/Internal/GrpcLog.cs b/src/csharp/Grpc.Core/Internal/GrpcLog.cs new file mode 100644 index 00000000000..98768d05c6d --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/GrpcLog.cs @@ -0,0 +1,94 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Concurrent; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading; + +namespace Grpc.Core.Internal +{ + internal delegate void GprLogDelegate(IntPtr fileStringPtr, Int32 line, UInt64 threadId, IntPtr severityStringPtr, IntPtr msgPtr); + + /// + /// Logs from gRPC C core library can get lost if your application is not a console app. + /// This class allows redirection of logs to arbitrary destination. + /// + internal static class GrpcLog + { + static object staticLock = new object(); + static GprLogDelegate writeCallback; + static TextWriter dest; + + [DllImport("grpc_csharp_ext.dll")] + static extern void grpcsharp_redirect_log(GprLogDelegate callback); + + /// + /// Sets text writer as destination for logs from native gRPC C core library. + /// Only first invocation has effect. + /// + /// + public static void RedirectNativeLogs(TextWriter textWriter) + { + lock (staticLock) + { + if (writeCallback == null) + { + writeCallback = new GprLogDelegate(HandleWrite); + dest = textWriter; + grpcsharp_redirect_log(writeCallback); + } + } + } + + private static void HandleWrite(IntPtr fileStringPtr, Int32 line, UInt64 threadId, IntPtr severityStringPtr, IntPtr msgPtr) + { + try + { + // TODO: DateTime format used here is different than in C core. + dest.WriteLine(string.Format("{0}{1} {2} {3}:{4}: {5}", + Marshal.PtrToStringAnsi(severityStringPtr), DateTime.Now, + threadId, + Marshal.PtrToStringAnsi(fileStringPtr), + line, + Marshal.PtrToStringAnsi(msgPtr))); + } + catch (Exception e) + { + Console.WriteLine("Caught exception in native callback " + e); + } + } + } +} diff --git a/src/csharp/Grpc.Core/RpcException.cs b/src/csharp/Grpc.Core/RpcException.cs index 5a9d0039bc9..e1cf64ca56a 100644 --- a/src/csharp/Grpc.Core/RpcException.cs +++ b/src/csharp/Grpc.Core/RpcException.cs @@ -49,7 +49,8 @@ namespace Grpc.Core this.status = status; } - public Status Status { + public Status Status + { get { return status; diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index 002592a3d88..152cc2176c0 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -124,6 +124,17 @@ namespace Grpc.Core handle.Dispose(); } + /// + /// To allow awaiting termination of the server. + /// + public Task ShutdownTask + { + get + { + return shutdownTcs.Task; + } + } + public void Kill() { handle.Dispose(); } diff --git a/src/csharp/Grpc.Core/ServerCallHandler.cs b/src/csharp/Grpc.Core/ServerCallHandler.cs index 1296947f34d..289f97aecee 100644 --- a/src/csharp/Grpc.Core/ServerCallHandler.cs +++ b/src/csharp/Grpc.Core/ServerCallHandler.cs @@ -111,6 +111,8 @@ namespace Grpc.Core var finishedTask = asyncCall.ServerSideStreamingRequestCallAsync(new NullObserver()); + // TODO: this makes the call finish before all reads can be done which causes trouble + // in AsyncCall.HandleReadFinished callback. Revisit this. asyncCall.SendStatusFromServerAsync(new Status(StatusCode.Unimplemented, "No such method.")).Wait(); finishedTask.Wait(); diff --git a/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs b/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs new file mode 100644 index 00000000000..3f0dae84cf8 --- /dev/null +++ b/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs @@ -0,0 +1,68 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Collections.Concurrent; +using System.Diagnostics; + +namespace Grpc.Core.Utils +{ + public static class BenchmarkUtil + { + /// + /// Runs a simple benchmark preceded by warmup phase. + /// + public static void RunBenchmark(int warmupIterations, int benchmarkIterations, Action action) + { + Console.WriteLine("Warmup iterations: " + warmupIterations); + for (int i = 0; i < warmupIterations; i++) + { + action(); + } + + Console.WriteLine("Benchmark iterations: " + benchmarkIterations); + var stopwatch = new Stopwatch(); + stopwatch.Start(); + for (int i = 0; i < benchmarkIterations; i++) + { + action(); + } + stopwatch.Stop(); + Console.WriteLine("Elapsed time: " + stopwatch.ElapsedMilliseconds + "ms"); + Console.WriteLine("Ops per second: " + (int) ((double) benchmarkIterations * 1000 / stopwatch.ElapsedMilliseconds)); + } + } +} + diff --git a/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs b/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs new file mode 100644 index 00000000000..18702e1cc42 --- /dev/null +++ b/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs @@ -0,0 +1,57 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; + +namespace Grpc.Core.Utils +{ + public static class ExceptionHelper + { + /// + /// If inner exceptions contain RpcException, rethrows it. + /// Otherwise, rethrows the original aggregate exception. + /// Always throws, the exception return type is here only to make the. + /// + public static Exception UnwrapRpcException(AggregateException ae) { + foreach (var e in ae.InnerExceptions) + { + if (e is RpcException) + { + throw e; + } + } + throw ae; + } + } +} + diff --git a/src/csharp/Grpc.Examples/MathServiceImpl.cs b/src/csharp/Grpc.Examples/MathServiceImpl.cs index 462fab4454f..76a08ce5186 100644 --- a/src/csharp/Grpc.Examples/MathServiceImpl.cs +++ b/src/csharp/Grpc.Examples/MathServiceImpl.cs @@ -127,8 +127,7 @@ namespace math public void OnCompleted() { - Task.Factory.StartNew(() => - responseObserver.OnCompleted()); + responseObserver.OnCompleted(); } public void OnError(Exception error) @@ -138,13 +137,7 @@ namespace math public void OnNext(DivArgs value) { - // TODO: currently we need this indirection because - // responseObserver waits for write to finish, this - // callback is called from grpc threadpool which - // currently only has one thread. - // Same story for OnCompleted(). - Task.Factory.StartNew(() => - responseObserver.OnNext(DivInternal(value))); + responseObserver.OnNext(DivInternal(value)); } } } diff --git a/src/csharp/Grpc.IntegrationTesting.Client/.gitignore b/src/csharp/Grpc.IntegrationTesting.Client/.gitignore new file mode 100644 index 00000000000..a382af2294f --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Client/.gitignore @@ -0,0 +1,3 @@ +bin +obj + diff --git a/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj b/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj new file mode 100644 index 00000000000..b1a4a81916a --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Client/Grpc.IntegrationTesting.Client.csproj @@ -0,0 +1,49 @@ + + + + Debug + x86 + 10.0.0 + 2.0 + {3D166931-BA2D-416E-95A3-D36E8F6E90B9} + Exe + Grpc.IntegrationTesting.Client + Grpc.IntegrationTesting.Client + Grpc.IntegrationTesting.Client.Program + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + + + {C61154BA-DD4A-4838-8420-0162A28925E0} + Grpc.IntegrationTesting + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting.Client/Program.cs b/src/csharp/Grpc.IntegrationTesting.Client/Program.cs new file mode 100644 index 00000000000..2e1c9aaac25 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Client/Program.cs @@ -0,0 +1,46 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using Grpc.IntegrationTesting; + +namespace Grpc.IntegrationTesting.Client +{ + class Program + { + public static void Main(string[] args) + { + InteropClient.Run(args); + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..d1f9e8560dc --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("Grpc.IntegrationTesting.Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("0.1.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/src/csharp/Grpc.IntegrationTesting.Server/.gitignore b/src/csharp/Grpc.IntegrationTesting.Server/.gitignore new file mode 100644 index 00000000000..a382af2294f --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Server/.gitignore @@ -0,0 +1,3 @@ +bin +obj + diff --git a/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj b/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj new file mode 100644 index 00000000000..73c9f2d2077 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Server/Grpc.IntegrationTesting.Server.csproj @@ -0,0 +1,49 @@ + + + + Debug + x86 + 10.0.0 + 2.0 + {A654F3B8-E859-4E6A-B30D-227527DBEF0D} + Exe + Grpc.IntegrationTesting.Server + Grpc.IntegrationTesting.Server + Grpc.IntegrationTesting.Server.Program + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + + + {C61154BA-DD4A-4838-8420-0162A28925E0} + Grpc.IntegrationTesting + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting.Server/Program.cs b/src/csharp/Grpc.IntegrationTesting.Server/Program.cs new file mode 100644 index 00000000000..01bcc6e3081 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Server/Program.cs @@ -0,0 +1,45 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; + +namespace Grpc.IntegrationTesting.Server +{ + class Program + { + public static void Main(string[] args) + { + InteropServer.Run(args); + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..4ef93f328d2 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("Grpc.IntegrationTesting.Server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("0.1.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index 9b46a644bc1..6d6aaf57473 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -6,10 +6,9 @@ 10.0.0 2.0 {C61154BA-DD4A-4838-8420-0162A28925E0} - Exe + Library Grpc.IntegrationTesting Grpc.IntegrationTesting - Grpc.IntegrationTesting.Client v4.5 @@ -43,10 +42,13 @@ - + + + + diff --git a/src/csharp/Grpc.IntegrationTesting/Client.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs similarity index 89% rename from src/csharp/Grpc.IntegrationTesting/Client.cs rename to src/csharp/Grpc.IntegrationTesting/InteropClient.cs index bb650a112de..a7a3c63e032 100644 --- a/src/csharp/Grpc.IntegrationTesting/Client.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -33,7 +33,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text.RegularExpressions; +using System.Threading.Tasks; using Google.ProtocolBuffers; using Grpc.Core; using Grpc.Core.Utils; @@ -42,7 +44,7 @@ using grpc.testing; namespace Grpc.IntegrationTesting { - class Client + public class InteropClient { private class ClientOptions { @@ -57,12 +59,12 @@ namespace Grpc.IntegrationTesting ClientOptions options; - private Client(ClientOptions options) + private InteropClient(ClientOptions options) { this.options = options; } - public static void Main(string[] args) + public static void Run(string[] args) { Console.WriteLine("gRPC C# interop testing client"); ClientOptions options = ParseArguments(args); @@ -87,7 +89,7 @@ namespace Grpc.IntegrationTesting Environment.Exit(1); } - var interopClient = new Client(options); + var interopClient = new InteropClient(options); interopClient.Run(); } @@ -128,12 +130,15 @@ namespace Grpc.IntegrationTesting case "empty_stream": RunEmptyStream(client); break; + case "benchmark_empty_unary": + RunBenchmarkEmptyUnary(client); + break; default: throw new ArgumentException("Unknown test case " + testCase); } } - private void RunEmptyUnary(TestServiceGrpc.ITestServiceClient client) + public static void RunEmptyUnary(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running empty_unary"); var response = client.EmptyCall(Empty.DefaultInstance); @@ -141,7 +146,7 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } - private void RunLargeUnary(TestServiceGrpc.ITestServiceClient client) + public static void RunLargeUnary(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running large_unary"); var request = SimpleRequest.CreateBuilder() @@ -157,7 +162,7 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } - private void RunClientStreaming(TestServiceGrpc.ITestServiceClient client) + public static void RunClientStreaming(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running client_streaming"); @@ -176,7 +181,7 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } - private void RunServerStreaming(TestServiceGrpc.ITestServiceClient client) + public static void RunServerStreaming(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running server_streaming"); @@ -201,7 +206,7 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } - private void RunPingPong(TestServiceGrpc.ITestServiceClient client) + public static void RunPingPong(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running ping_pong"); @@ -230,7 +235,7 @@ namespace Grpc.IntegrationTesting inputs.OnNext(StreamingOutputCallRequest.CreateBuilder() .SetResponseType(PayloadType.COMPRESSABLE) - .AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(2635)) + .AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(2653)) .SetPayload(CreateZerosPayload(1828)).Build()); response = recorder.Queue.Take(); @@ -247,13 +252,15 @@ namespace Grpc.IntegrationTesting Assert.AreEqual(PayloadType.COMPRESSABLE, response.Payload.Type); Assert.AreEqual(58979, response.Payload.Body.Length); + inputs.OnCompleted(); + recorder.Finished.Wait(); Assert.AreEqual(0, recorder.Queue.Count); Console.WriteLine("Passed!"); } - private void RunEmptyStream(TestServiceGrpc.ITestServiceClient client) + public static void RunEmptyStream(TestServiceGrpc.ITestServiceClient client) { Console.WriteLine("running empty_stream"); @@ -267,8 +274,14 @@ namespace Grpc.IntegrationTesting Console.WriteLine("Passed!"); } + // This is not an official interop test, but it's useful. + public static void RunBenchmarkEmptyUnary(TestServiceGrpc.ITestServiceClient client) + { + BenchmarkUtil.RunBenchmark(10000, 10000, + () => { client.EmptyCall(Empty.DefaultInstance);}); + } - private Payload CreateZerosPayload(int size) { + private static Payload CreateZerosPayload(int size) { return Payload.CreateBuilder().SetBody(ByteString.CopyFrom(new byte[size])).Build(); } diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs new file mode 100644 index 00000000000..4bb0b9ee51f --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs @@ -0,0 +1,119 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Utils; +using NUnit.Framework; +using grpc.testing; + +namespace Grpc.IntegrationTesting +{ + /// + /// Runs interop tests in-process. + /// + public class InteropClientServerTest + { + string host = "localhost"; + Server server; + Channel channel; + TestServiceGrpc.ITestServiceClient client; + + [TestFixtureSetUp] + public void Init() + { + GrpcEnvironment.Initialize(); + + server = new Server(); + server.AddServiceDefinition(TestServiceGrpc.BindService(new TestServiceImpl())); + int port = server.AddPort(host + ":0"); + server.Start(); + channel = new Channel(host + ":" + port); + client = TestServiceGrpc.NewStub(channel); + } + + [TestFixtureTearDown] + public void Cleanup() + { + channel.Dispose(); + + server.ShutdownAsync().Wait(); + GrpcEnvironment.Shutdown(); + } + + [Test] + public void EmptyUnary() + { + InteropClient.RunEmptyUnary(client); + } + + [Test] + public void LargeUnary() + { + InteropClient.RunEmptyUnary(client); + } + + [Test] + public void ClientStreaming() + { + InteropClient.RunClientStreaming(client); + } + + [Test] + public void ServerStreaming() + { + InteropClient.RunServerStreaming(client); + } + + [Test] + public void PingPong() + { + InteropClient.RunPingPong(client); + } + + [Test] + public void EmptyStream() + { + InteropClient.RunEmptyStream(client); + } + + // TODO: add cancel_after_begin + + // TODO: add cancel_after_first_response + + } +} + diff --git a/src/csharp/Grpc.IntegrationTesting/InteropServer.cs b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs new file mode 100644 index 00000000000..a25d3b3530f --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs @@ -0,0 +1,140 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Google.ProtocolBuffers; +using Grpc.Core; +using Grpc.Core.Utils; +using NUnit.Framework; +using grpc.testing; + +namespace Grpc.IntegrationTesting +{ + public class InteropServer + { + private class ServerOptions + { + public bool help; + public int? port; + public bool useTls; + } + + ServerOptions options; + + private InteropServer(ServerOptions options) + { + this.options = options; + } + + public static void Run(string[] args) + { + Console.WriteLine("gRPC C# interop testing server"); + ServerOptions options = ParseArguments(args); + + if (!options.port.HasValue) + { + Console.WriteLine("Missing required argument."); + Console.WriteLine(); + options.help = true; + } + + if (options.help) + { + Console.WriteLine("Usage:"); + Console.WriteLine(" --port=PORT"); + Console.WriteLine(" --use_tls=BOOLEAN"); + Console.WriteLine(); + Environment.Exit(1); + } + + var interopServer = new InteropServer(options); + interopServer.Run(); + } + + private void Run() + { + GrpcEnvironment.Initialize(); + + var server = new Server(); + server.AddServiceDefinition(TestServiceGrpc.BindService(new TestServiceImpl())); + + string addr = "0.0.0.0:" + options.port; + server.AddPort(addr); + Console.WriteLine("Running server on " + addr); + server.Start(); + + server.ShutdownTask.Wait(); + + GrpcEnvironment.Shutdown(); + } + + private static ServerOptions ParseArguments(string[] args) + { + var options = new ServerOptions(); + foreach(string arg in args) + { + ParseArgument(arg, options); + if (options.help) + { + break; + } + } + return options; + } + + private static void ParseArgument(string arg, ServerOptions options) + { + Match match; + match = Regex.Match(arg, "--port=(.*)"); + if (match.Success) + { + options.port = int.Parse(match.Groups[1].Value.Trim()); + return; + } + + match = Regex.Match(arg, "--use_tls=(.*)"); + if (match.Success) + { + options.useTls = bool.Parse(match.Groups[1].Value.Trim()); + return; + } + + Console.WriteLine(string.Format("Unrecognized argument \"{0}\"", arg)); + options.help = true; + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs new file mode 100644 index 00000000000..176843b1305 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs @@ -0,0 +1,140 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Google.ProtocolBuffers; +using Grpc.Core.Utils; + +namespace grpc.testing +{ + /// + /// Implementation of TestService server + /// + public class TestServiceImpl : TestServiceGrpc.ITestService + { + public void EmptyCall(Empty request, IObserver responseObserver) + { + responseObserver.OnNext(Empty.DefaultInstance); + responseObserver.OnCompleted(); + } + + public void UnaryCall(SimpleRequest request, IObserver responseObserver) + { + var response = SimpleResponse.CreateBuilder() + .SetPayload(CreateZerosPayload(request.ResponseSize)).Build(); + //TODO: check we support ReponseType + responseObserver.OnNext(response); + responseObserver.OnCompleted(); + } + + public void StreamingOutputCall(StreamingOutputCallRequest request, IObserver responseObserver) + { + foreach(var responseParam in request.ResponseParametersList) + { + var response = StreamingOutputCallResponse.CreateBuilder() + .SetPayload(CreateZerosPayload(responseParam.Size)).Build(); + responseObserver.OnNext(response); + } + responseObserver.OnCompleted(); + } + + public IObserver StreamingInputCall(IObserver responseObserver) + { + var recorder = new RecordingObserver(); + Task.Run(() => { + int sum = 0; + foreach(var req in recorder.ToList().Result) + { + sum += req.Payload.Body.Length; + } + var response = StreamingInputCallResponse.CreateBuilder() + .SetAggregatedPayloadSize(sum).Build(); + responseObserver.OnNext(response); + responseObserver.OnCompleted(); + }); + return recorder; + } + + public IObserver FullDuplexCall(IObserver responseObserver) + { + return new FullDuplexObserver(responseObserver); + } + + public IObserver HalfDuplexCall(IObserver responseObserver) + { + throw new NotImplementedException(); + } + + private class FullDuplexObserver : IObserver { + + readonly IObserver responseObserver; + + public FullDuplexObserver(IObserver responseObserver) + { + this.responseObserver = responseObserver; + } + + public void OnCompleted() + { + responseObserver.OnCompleted(); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnNext(StreamingOutputCallRequest value) + { + // TODO: this is not in order!!! + //Task.Factory.StartNew(() => { + + foreach(var responseParam in value.ResponseParametersList) + { + var response = StreamingOutputCallResponse.CreateBuilder() + .SetPayload(CreateZerosPayload(responseParam.Size)).Build(); + responseObserver.OnNext(response); + } + //}); + } + } + + private static Payload CreateZerosPayload(int size) { + return Payload.CreateBuilder().SetBody(ByteString.CopyFrom(new byte[size])).Build(); + } + } +} + diff --git a/src/csharp/Grpc.sln b/src/csharp/Grpc.sln index a544eb1c338..2e6d2886993 100644 --- a/src/csharp/Grpc.sln +++ b/src/csharp/Grpc.sln @@ -13,6 +13,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.Examples.MathClient", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting", "Grpc.IntegrationTesting\Grpc.IntegrationTesting.csproj", "{C61154BA-DD4A-4838-8420-0162A28925E0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.Client", "Grpc.IntegrationTesting.Client\Grpc.IntegrationTesting.Client.csproj", "{3D166931-BA2D-416E-95A3-D36E8F6E90B9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.Server", "Grpc.IntegrationTesting.Server\Grpc.IntegrationTesting.Server.csproj", "{A654F3B8-E859-4E6A-B30D-227527DBEF0D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -23,6 +27,10 @@ Global {143B1C29-C442-4BE0-BF3F-A8F92288AC9F}.Debug|x86.Build.0 = Debug|Any CPU {143B1C29-C442-4BE0-BF3F-A8F92288AC9F}.Release|x86.ActiveCfg = Release|Any CPU {143B1C29-C442-4BE0-BF3F-A8F92288AC9F}.Release|x86.Build.0 = Release|Any CPU + {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Debug|x86.ActiveCfg = Debug|x86 + {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Debug|x86.Build.0 = Debug|x86 + {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Release|x86.ActiveCfg = Release|x86 + {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Release|x86.Build.0 = Release|x86 {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|x86.ActiveCfg = Debug|x86 {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|x86.Build.0 = Debug|x86 {61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Release|x86.ActiveCfg = Release|x86 @@ -35,6 +43,10 @@ Global {86EC5CB4-4EA2-40A2-8057-86542A0353BB}.Debug|x86.Build.0 = Debug|Any CPU {86EC5CB4-4EA2-40A2-8057-86542A0353BB}.Release|x86.ActiveCfg = Release|Any CPU {86EC5CB4-4EA2-40A2-8057-86542A0353BB}.Release|x86.Build.0 = Release|Any CPU + {A654F3B8-E859-4E6A-B30D-227527DBEF0D}.Debug|x86.ActiveCfg = Debug|x86 + {A654F3B8-E859-4E6A-B30D-227527DBEF0D}.Debug|x86.Build.0 = Debug|x86 + {A654F3B8-E859-4E6A-B30D-227527DBEF0D}.Release|x86.ActiveCfg = Release|x86 + {A654F3B8-E859-4E6A-B30D-227527DBEF0D}.Release|x86.Build.0 = Release|x86 {C61154BA-DD4A-4838-8420-0162A28925E0}.Debug|x86.ActiveCfg = Debug|x86 {C61154BA-DD4A-4838-8420-0162A28925E0}.Debug|x86.Build.0 = Debug|x86 {C61154BA-DD4A-4838-8420-0162A28925E0}.Release|x86.ActiveCfg = Release|x86 diff --git a/src/csharp/README.md b/src/csharp/README.md index 55739a1f83c..21aab521180 100755 --- a/src/csharp/README.md +++ b/src/csharp/README.md @@ -9,7 +9,7 @@ Status **This gRPC C# implementation is work-in-progress and is not expected to work yet.** - The implementation is a wrapper around gRPC C core library -- Code only runs under mono currently, building gGRPC C core library under Windows +- Code only runs under mono currently, building gRPC C core library under Windows is in progress. - It is very possible that some parts of the code will be heavily refactored or completely rewritten. diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 5f9f22cab10..8f5a4141872 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -35,9 +35,10 @@ #include #include -#include #include #include +#include +#include #include @@ -343,6 +344,23 @@ grpcsharp_call_start_unary(grpc_call *call, callback_funcptr callback, return grpc_call_start_batch(call, ops, sizeof(ops) / sizeof(ops[0]), ctx); } +/* Synchronous unary call */ +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_call_blocking_unary(grpc_call *call, + grpc_completion_queue *dedicated_cq, + callback_funcptr callback, + const char *send_buffer, size_t send_buffer_len) { + GPR_ASSERT(grpcsharp_call_start_unary(call, callback, send_buffer, + send_buffer_len) == GRPC_CALL_OK); + + /* TODO: we would like to use pluck, but we don't know the tag */ + GPR_ASSERT(grpcsharp_completion_queue_next_with_callback(dedicated_cq) == + GRPC_OP_COMPLETE); + grpc_completion_queue_shutdown(dedicated_cq); + GPR_ASSERT(grpcsharp_completion_queue_next_with_callback(dedicated_cq) == + GRPC_QUEUE_SHUTDOWN); +} + GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming(grpc_call *call, callback_funcptr callback) { @@ -566,3 +584,32 @@ grpcsharp_server_request_call(grpc_server *server, grpc_completion_queue *cq, server, &(ctx->server_rpc_new.call), &(ctx->server_rpc_new.call_details), &(ctx->server_rpc_new.request_metadata), cq, ctx); } + +/* Logging */ + +typedef void(GPR_CALLTYPE *grpcsharp_log_func)(const char *file, gpr_int32 line, + gpr_uint64 thd_id, + const char *severity_string, + const char *msg); +static grpcsharp_log_func log_func = NULL; + +/* Redirects gpr_log to log_func callback */ +static void grpcsharp_log_handler(gpr_log_func_args *args) { + log_func(args->file, args->line, gpr_thd_currentid(), + gpr_log_severity_string(args->severity), args->message); +} + +GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { + GPR_ASSERT(func); + log_func = func; + gpr_set_log_function(grpcsharp_log_handler); +} + +/* For testing */ +GPR_EXPORT void GPR_CALLTYPE +grpcsharp_test_callback(callback_funcptr callback) { + callback(GRPC_OP_OK, NULL); +} + +/* For testing */ +GPR_EXPORT void *GPR_CALLTYPE grpcsharp_test_nop(void *ptr) { return ptr; } diff --git a/src/node/LICENSE b/src/node/LICENSE new file mode 100644 index 00000000000..0209b570e10 --- /dev/null +++ b/src/node/LICENSE @@ -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/node/README.md b/src/node/README.md index 8880213e9a9..5b3de6b4f6e 100644 --- a/src/node/README.md +++ b/src/node/README.md @@ -4,6 +4,10 @@ Alpha : Ready for early adopters +## Prerequisites + +This requires `node` to be installed. If you instead have the `nodejs` executable on Debian, you should install the [`nodejs-legacy`](https://packages.debian.org/sid/nodejs-legacy) package. + ## Installation First, clone this repository (NPM package coming soon). Then follow the instructions in the `INSTALL` file in the root of the repository to install the C core library that this package depends on. diff --git a/src/node/binding.gyp b/src/node/binding.gyp index fb4c779f8eb..10afaf69627 100644 --- a/src/node/binding.gyp +++ b/src/node/binding.gyp @@ -7,10 +7,10 @@ "targets" : [ { 'include_dirs': [ - "IsUndefined()) { wrapped_channel = grpc_channel_create(**host, NULL); } else if (args[1]->IsObject()) { grpc_credentials *creds = NULL; Handle args_hash(args[1]->ToObject()->Clone()); + if (args_hash->HasOwnProperty(NanNew(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG))) { + host_override = new NanUtf8String(args_hash->Get(NanNew(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG))); + } if (args_hash->HasOwnProperty(NanNew("credentials"))) { Handle creds_value = args_hash->Get(NanNew("credentials")); if (!Credentials::HasInstance(creds_value)) { @@ -155,7 +159,12 @@ NAN_METHOD(Channel::New) { } else { return NanThrowTypeError("Channel expects a string and an object"); } - Channel *channel = new Channel(wrapped_channel, host); + Channel *channel; + if (host_override == NULL) { + channel = new Channel(wrapped_channel, host); + } else { + channel = new Channel(wrapped_channel, host_override); + } channel->Wrap(args.This()); NanReturnValue(args.This()); } else { diff --git a/src/node/package.json b/src/node/package.json index 1c44b106fb4..0ef1c990b1e 100644 --- a/src/node/package.json +++ b/src/node/package.json @@ -1,10 +1,27 @@ { "name": "grpc", - "version": "0.2.0", + "version": "0.5.1", + "author": "Google Inc.", "description": "gRPC Library for Node", + "homepage": "http://www.grpc.io/", + "repository": { + "type": "git", + "url": "https://github.com/grpc/grpc.git" + }, + "bugs": "https://github.com/grpc/grpc/issues", + "contributors": [ + { + "name": "Michael Lumish", + "email": "mlumish@google.com" + } + ], + "directories": { + "lib": "src", + "example": "examples" + }, "scripts": { - "lint": "nodejs ./node_modules/jshint/bin/jshint src test examples interop index.js", - "test": "nodejs ./node_modules/mocha/bin/mocha && npm run-script lint" + "lint": "node ./node_modules/jshint/bin/jshint src test examples interop index.js", + "test": "node ./node_modules/mocha/bin/mocha && npm run-script lint" }, "dependencies": { "bindings": "^1.2.1", @@ -22,6 +39,7 @@ "strftime": "^0.8.2" }, "files": [ + "LICENSE", "README.md", "index.js", "binding.gyp", @@ -31,5 +49,6 @@ "src", "test" ], - "main": "index.js" + "main": "index.js", + "license": "BSD-3-Clause" } diff --git a/src/php/ext/grpc/credentials.c b/src/php/ext/grpc/credentials.c index f25e042dd7f..6d8f59fa33d 100644 --- a/src/php/ext/grpc/credentials.c +++ b/src/php/ext/grpc/credentials.c @@ -94,7 +94,7 @@ zval *grpc_php_wrap_credentials(grpc_credentials *wrapped) { * @return Credentials The new default credentials object */ PHP_METHOD(Credentials, createDefault) { - grpc_credentials *creds = grpc_default_credentials_create(); + grpc_credentials *creds = grpc_google_default_credentials_create(); zval *creds_object = grpc_php_wrap_credentials(creds); RETURN_DESTROY_ZVAL(creds_object); } diff --git a/src/php/ext/grpc/event.c b/src/php/ext/grpc/event.c index 8d398450a4d..452c4b8bcba 100644 --- a/src/php/ext/grpc/event.c +++ b/src/php/ext/grpc/event.c @@ -90,10 +90,6 @@ zval *grpc_php_convert_event(grpc_event *event) { add_property_stringl(event_object, "data", read_string, read_len, true); } break; - case GRPC_INVOKE_ACCEPTED: - add_property_long(event_object, "data", - (long)event->data.invoke_accepted); - break; case GRPC_WRITE_ACCEPTED: add_property_long(event_object, "data", (long)event->data.write_accepted); break; diff --git a/src/python/README.md b/src/python/README.md index be2f2bedf9c..06ef1a0f836 100755 --- a/src/python/README.md +++ b/src/python/README.md @@ -1,9 +1,14 @@ -GRPC Python +gRPC Python ========= -The Python facility of GRPC. +The Python facility of gRPC. +Status +------- + +Usable with limitations, Pre-Alpha + Prerequisites ----------------------- @@ -13,8 +18,8 @@ Python 2.7, virtualenv, pip, libprotobuf-dev, and libprotoc-dev. Building from source ---------------------- -- Build the GRPC core -E.g, from the root of the grpc [git repo](https://github.com/google/grpc) +- Build the gRPC core from the root of the + [gRPC git repo](https://github.com/grpc/grpc) ``` $ make shared_c static_c ``` @@ -28,7 +33,23 @@ $ tools/run_tests/build_python.sh Testing ----------------------- -- Use run_python.sh to run GRPC as it was installed into the virtual environment +- Use run_python.sh to run gRPC as it was installed into the virtual environment ``` $ tools/run_tests/run_python.sh ``` + + +Installing +----------------------- + +- [Install the gRPC core](https://github.com/grpc/grpc/blob/master/INSTALL) + +- Install gRPC Python's dependencies +``` +$ pip install enum34==1.0.4 futures==2.2.0 protobuf==3.0.0-alpha-1 +``` + +- Install gRPC Python +``` +$ pip install src/python/src +``` diff --git a/src/python/interop/interop/client.py b/src/python/interop/interop/client.py new file mode 100644 index 00000000000..f4a449ef9e7 --- /dev/null +++ b/src/python/interop/interop/client.py @@ -0,0 +1,86 @@ +# 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. + +"""The Python implementation of the GRPC interoperability test client.""" + +import argparse + +from grpc.early_adopter import implementations + +from interop import methods +from interop import resources + +_ONE_DAY_IN_SECONDS = 60 * 60 * 24 + + +def _args(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--server_host', help='the host to which to connect', type=str) + parser.add_argument( + '--server_host_override', + help='the server host to which to claim to connect', type=str) + parser.add_argument( + '--server_port', help='the port to which to connect', type=int) + parser.add_argument( + '--test_case', help='the test case to execute', type=str) + parser.add_argument( + '--use_tls', help='require a secure connection', dest='use_tls', + action='store_true') + parser.add_argument( + '--use_test_ca', help='replace platform root CAs with ca.pem', + action='store_true') + return parser.parse_args() + + +def _stub(args): + if args.use_tls: + if args.use_test_ca: + root_certificates = resources.test_root_certificates() + else: + root_certificates = resources.prod_root_certificates() + # TODO(nathaniel): server host override. + + stub = implementations.secure_stub( + methods.CLIENT_METHODS, args.server_host, args.server_port, + root_certificates, None, None) + else: + stub = implementations.insecure_stub( + methods.CLIENT_METHODS, args.server_host, args.server_port) + return stub + + +def _test_interoperability(): + args = _args() + stub = _stub(args) + methods.test_interoperability(args.test_case, stub) + + +if __name__ == '__main__': + _test_interoperability() diff --git a/src/python/interop/interop/credentials/ca.pem b/src/python/interop/interop/credentials/ca.pem new file mode 100755 index 00000000000..6c8511a73c6 --- /dev/null +++ b/src/python/interop/interop/credentials/ca.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV +BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX +aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla +Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 +YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT +BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 ++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu +g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd +Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV +HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau +sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m +oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG +Dfcog5wrJytaQ6UA0wE= +-----END CERTIFICATE----- diff --git a/src/python/interop/interop/methods.py b/src/python/interop/interop/methods.py index 26c1869f93e..4da28ee7759 100644 --- a/src/python/interop/interop/methods.py +++ b/src/python/interop/interop/methods.py @@ -29,52 +29,57 @@ """Implementations of interoperability test methods.""" +import threading + from grpc.early_adopter import utilities from interop import empty_pb2 from interop import messages_pb2 -def _empty_call(request): +_TIMEOUT = 7 + + +def _empty_call(request, unused_context): return empty_pb2.Empty() -_CLIENT_EMPTY_CALL = utilities.unary_unary_client_rpc_method( +_CLIENT_EMPTY_CALL = utilities.unary_unary_invocation_description( empty_pb2.Empty.SerializeToString, empty_pb2.Empty.FromString) -_SERVER_EMPTY_CALL = utilities.unary_unary_server_rpc_method( +_SERVER_EMPTY_CALL = utilities.unary_unary_service_description( _empty_call, empty_pb2.Empty.FromString, empty_pb2.Empty.SerializeToString) -def _unary_call(request): +def _unary_call(request, unused_context): return messages_pb2.SimpleResponse( payload=messages_pb2.Payload( type=messages_pb2.COMPRESSABLE, body=b'\x00' * request.response_size)) -_CLIENT_UNARY_CALL = utilities.unary_unary_client_rpc_method( +_CLIENT_UNARY_CALL = utilities.unary_unary_invocation_description( messages_pb2.SimpleRequest.SerializeToString, messages_pb2.SimpleResponse.FromString) -_SERVER_UNARY_CALL = utilities.unary_unary_server_rpc_method( +_SERVER_UNARY_CALL = utilities.unary_unary_service_description( _unary_call, messages_pb2.SimpleRequest.FromString, messages_pb2.SimpleResponse.SerializeToString) -def _streaming_output_call(request): +def _streaming_output_call(request, unused_context): for response_parameters in request.response_parameters: yield messages_pb2.StreamingOutputCallResponse( payload=messages_pb2.Payload( type=request.response_type, body=b'\x00' * response_parameters.size)) -_CLIENT_STREAMING_OUTPUT_CALL = utilities.unary_stream_client_rpc_method( +_CLIENT_STREAMING_OUTPUT_CALL = utilities.unary_stream_invocation_description( messages_pb2.StreamingOutputCallRequest.SerializeToString, messages_pb2.StreamingOutputCallResponse.FromString) -_SERVER_STREAMING_OUTPUT_CALL = utilities.unary_stream_server_rpc_method( +_SERVER_STREAMING_OUTPUT_CALL = utilities.unary_stream_service_description( _streaming_output_call, messages_pb2.StreamingOutputCallRequest.FromString, messages_pb2.StreamingOutputCallResponse.SerializeToString) -def _streaming_input_call(request_iterator): +def _streaming_input_call(request_iterator, unused_context): aggregate_size = 0 for request in request_iterator: if request.payload and request.payload.body: @@ -82,35 +87,35 @@ def _streaming_input_call(request_iterator): return messages_pb2.StreamingInputCallResponse( aggregated_payload_size=aggregate_size) -_CLIENT_STREAMING_INPUT_CALL = utilities.stream_unary_client_rpc_method( +_CLIENT_STREAMING_INPUT_CALL = utilities.stream_unary_invocation_description( messages_pb2.StreamingInputCallRequest.SerializeToString, messages_pb2.StreamingInputCallResponse.FromString) -_SERVER_STREAMING_INPUT_CALL = utilities.stream_unary_server_rpc_method( +_SERVER_STREAMING_INPUT_CALL = utilities.stream_unary_service_description( _streaming_input_call, messages_pb2.StreamingInputCallRequest.FromString, messages_pb2.StreamingInputCallResponse.SerializeToString) -def _full_duplex_call(request_iterator): +def _full_duplex_call(request_iterator, unused_context): for request in request_iterator: yield messages_pb2.StreamingOutputCallResponse( payload=messages_pb2.Payload( type=request.payload.type, body=b'\x00' * request.response_parameters[0].size)) -_CLIENT_FULL_DUPLEX_CALL = utilities.stream_stream_client_rpc_method( +_CLIENT_FULL_DUPLEX_CALL = utilities.stream_stream_invocation_description( messages_pb2.StreamingOutputCallRequest.SerializeToString, messages_pb2.StreamingOutputCallResponse.FromString) -_SERVER_FULL_DUPLEX_CALL = utilities.stream_stream_server_rpc_method( +_SERVER_FULL_DUPLEX_CALL = utilities.stream_stream_service_description( _full_duplex_call, messages_pb2.StreamingOutputCallRequest.FromString, messages_pb2.StreamingOutputCallResponse.SerializeToString) # NOTE(nathaniel): Apparently this is the same as the full-duplex call? -_CLIENT_HALF_DUPLEX_CALL = utilities.stream_stream_client_rpc_method( +_CLIENT_HALF_DUPLEX_CALL = utilities.stream_stream_invocation_description( messages_pb2.StreamingOutputCallRequest.SerializeToString, messages_pb2.StreamingOutputCallResponse.FromString) -_SERVER_HALF_DUPLEX_CALL = utilities.stream_stream_server_rpc_method( +_SERVER_HALF_DUPLEX_CALL = utilities.stream_stream_service_description( _full_duplex_call, messages_pb2.StreamingOutputCallRequest.FromString, messages_pb2.StreamingOutputCallResponse.SerializeToString) @@ -142,3 +147,134 @@ SERVER_METHODS = { FULL_DUPLEX_CALL_METHOD_NAME: _SERVER_FULL_DUPLEX_CALL, HALF_DUPLEX_CALL_METHOD_NAME: _SERVER_HALF_DUPLEX_CALL, } + + +def _empty_unary(stub): + with stub: + response = stub.EmptyCall(empty_pb2.Empty(), _TIMEOUT) + if not isinstance(response, empty_pb2.Empty): + raise TypeError( + 'response is of type "%s", not empty_pb2.Empty!', type(response)) + + +def _large_unary(stub): + with stub: + request = messages_pb2.SimpleRequest( + response_type=messages_pb2.COMPRESSABLE, response_size=314159, + payload=messages_pb2.Payload(body=b'\x00' * 271828)) + response_future = stub.UnaryCall.async(request, _TIMEOUT) + response = response_future.result() + if response.payload.type is not messages_pb2.COMPRESSABLE: + raise ValueError( + 'response payload type is "%s"!' % type(response.payload.type)) + if len(response.payload.body) != 314159: + raise ValueError( + 'response body of incorrect size %d!' % len(response.payload.body)) + + +def _client_streaming(stub): + with stub: + payload_body_sizes = (27182, 8, 1828, 45904) + payloads = ( + messages_pb2.Payload(body=b'\x00' * size) + for size in payload_body_sizes) + requests = ( + messages_pb2.StreamingInputCallRequest(payload=payload) + for payload in payloads) + response = stub.StreamingInputCall(requests, _TIMEOUT) + if response.aggregated_payload_size != 74922: + raise ValueError( + 'incorrect size %d!' % response.aggregated_payload_size) + + +def _server_streaming(stub): + sizes = (31415, 9, 2653, 58979) + + with stub: + request = messages_pb2.StreamingOutputCallRequest( + response_type=messages_pb2.COMPRESSABLE, + response_parameters=( + messages_pb2.ResponseParameters(size=sizes[0]), + messages_pb2.ResponseParameters(size=sizes[1]), + messages_pb2.ResponseParameters(size=sizes[2]), + messages_pb2.ResponseParameters(size=sizes[3]), + )) + response_iterator = stub.StreamingOutputCall(request, _TIMEOUT) + for index, response in enumerate(response_iterator): + if response.payload.type != messages_pb2.COMPRESSABLE: + raise ValueError( + 'response body of invalid type %s!' % response.payload.type) + if len(response.payload.body) != sizes[index]: + raise ValueError( + 'response body of invalid size %d!' % len(response.payload.body)) + + +class _Pipe(object): + + def __init__(self): + self._condition = threading.Condition() + self._values = [] + self._open = True + + def __iter__(self): + return self + + def next(self): + with self._condition: + while not self._values and self._open: + self._condition.wait() + if self._values: + return self._values.pop(0) + else: + raise StopIteration() + + def add(self, value): + with self._condition: + self._values.append(value) + self._condition.notify() + + def close(self): + with self._condition: + self._open = False + self._condition.notify() + + +def _ping_pong(stub): + request_response_sizes = (31415, 9, 2653, 58979) + request_payload_sizes = (27182, 8, 1828, 45904) + + with stub: + pipe = _Pipe() + response_iterator = stub.FullDuplexCall(pipe, _TIMEOUT) + print 'Starting ping-pong with response iterator %s' % response_iterator + for response_size, payload_size in zip( + request_response_sizes, request_payload_sizes): + request = messages_pb2.StreamingOutputCallRequest( + response_type=messages_pb2.COMPRESSABLE, + response_parameters=(messages_pb2.ResponseParameters( + size=response_size),), + payload=messages_pb2.Payload(body=b'\x00' * payload_size)) + pipe.add(request) + response = next(response_iterator) + if response.payload.type != messages_pb2.COMPRESSABLE: + raise ValueError( + 'response body of invalid type %s!' % response.payload.type) + if len(response.payload.body) != response_size: + raise ValueError( + 'response body of invalid size %d!' % len(response.payload.body)) + pipe.close() + + +def test_interoperability(test_case, stub): + if test_case == 'empty_unary': + _empty_unary(stub) + elif test_case == 'large_unary': + _large_unary(stub) + elif test_case == 'server_streaming': + _server_streaming(stub) + elif test_case == 'client_streaming': + _client_streaming(stub) + elif test_case == 'ping_pong': + _ping_pong(stub) + else: + raise NotImplementedError('Test case "%s" not implemented!') diff --git a/src/ruby/lib/grpc/auth/signet.rb b/src/python/interop/interop/resources.py similarity index 54% rename from src/ruby/lib/grpc/auth/signet.rb rename to src/python/interop/interop/resources.py index a8bce1255c2..2c3045313d4 100644 --- a/src/ruby/lib/grpc/auth/signet.rb +++ b/src/python/interop/interop/resources.py @@ -27,41 +27,30 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'signet/oauth_2/client' +"""Constants and functions for data used in interoperability testing.""" -module Signet - # Signet::OAuth2 supports OAuth2 authentication. - module OAuth2 - AUTH_METADATA_KEY = :Authorization - # Signet::OAuth2::Client creates an OAuth2 client - # - # Here client is re-opened to add the #apply and #apply! methods which - # update a hash map with the fetched authentication token - # - # Eventually, this change may be merged into signet itself, or some other - # package that provides Google-specific auth via signet, and this extension - # will be unnecessary. - class Client - # Updates a_hash updated with the authentication token - def apply!(a_hash, opts = {}) - # fetch the access token there is currently not one, or if the client - # has expired - fetch_access_token!(opts) if access_token.nil? || expired? - a_hash[AUTH_METADATA_KEY] = "Bearer #{access_token}" - end +import os - # Returns a clone of a_hash updated with the authentication token - def apply(a_hash, opts = {}) - a_copy = a_hash.clone - apply!(a_copy, opts) - a_copy - end +import pkg_resources - # Returns a reference to the #apply method, suitable for passing as - # a closure - def updater_proc - lambda(&method(:apply)) - end - end - end -end +_ROOT_CERTIFICATES_RESOURCE_PATH = 'credentials/ca.pem' +_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' +_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' + + +def test_root_certificates(): + return pkg_resources.resource_string( + __name__, _ROOT_CERTIFICATES_RESOURCE_PATH) + + +def prod_root_certificates(): + return open(os.environ['SSL_CERT_FILE'], mode='rb').read() + + +def private_key(): + return pkg_resources.resource_string(__name__, _PRIVATE_KEY_RESOURCE_PATH) + + +def certificate_chain(): + return pkg_resources.resource_string( + __name__, _CERTIFICATE_CHAIN_RESOURCE_PATH) diff --git a/src/python/interop/interop/server.py b/src/python/interop/interop/server.py index 785d482fe59..4e4b127a9a7 100644 --- a/src/python/interop/interop/server.py +++ b/src/python/interop/interop/server.py @@ -31,18 +31,15 @@ import argparse import logging -import pkg_resources import time from grpc.early_adopter import implementations from interop import methods +from interop import resources _ONE_DAY_IN_SECONDS = 60 * 60 * 24 -_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' -_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' - def serve(): parser = argparse.ArgumentParser() @@ -54,10 +51,8 @@ def serve(): args = parser.parse_args() if args.use_tls: - private_key = pkg_resources.resource_string( - __name__, _PRIVATE_KEY_RESOURCE_PATH) - certificate_chain = pkg_resources.resource_string( - __name__, _CERTIFICATE_CHAIN_RESOURCE_PATH) + private_key = resources.private_key() + certificate_chain = resources.certificate_chain() server = implementations.secure_server( methods.SERVER_METHODS, args.port, private_key, certificate_chain) else: diff --git a/src/python/interop/setup.py b/src/python/interop/setup.py index 4b7709f2348..6db54350903 100644 --- a/src/python/interop/setup.py +++ b/src/python/interop/setup.py @@ -40,7 +40,9 @@ _PACKAGE_DIRECTORIES = { } _PACKAGE_DATA = { - 'interop': ['credentials/server1.key', 'credentials/server1.pem',] + 'interop': [ + 'credentials/ca.pem', 'credentials/server1.key', + 'credentials/server1.pem',] } _INSTALL_REQUIRES = ['grpc-2015>=0.0.1'] diff --git a/src/python/src/grpc/_adapter/_c.c b/src/python/src/grpc/_adapter/_c.c index 55b9d0512c9..f096a55b618 100644 --- a/src/python/src/grpc/_adapter/_c.c +++ b/src/python/src/grpc/_adapter/_c.c @@ -38,6 +38,7 @@ #include "grpc/_adapter/_channel.h" #include "grpc/_adapter/_call.h" #include "grpc/_adapter/_server.h" +#include "grpc/_adapter/_client_credentials.h" #include "grpc/_adapter/_server_credentials.h" static PyObject *init(PyObject *self) { @@ -76,6 +77,9 @@ PyMODINIT_FUNC init_c(void) { if (pygrpc_add_server(module) == -1) { return; } + if (pygrpc_add_client_credentials(module) == -1) { + return; + } if (pygrpc_add_server_credentials(module) == -1) { return; } diff --git a/src/python/src/grpc/_adapter/_c_test.py b/src/python/src/grpc/_adapter/_c_test.py index d421692ec9c..d81c63e3469 100644 --- a/src/python/src/grpc/_adapter/_c_test.py +++ b/src/python/src/grpc/_adapter/_c_test.py @@ -70,7 +70,7 @@ class _CTest(unittest.TestCase): def testChannel(self): _c.init() - channel = _c.Channel('test host:12345') + channel = _c.Channel('test host:12345', None) del channel _c.shut_down() @@ -81,7 +81,7 @@ class _CTest(unittest.TestCase): _c.init() - channel = _c.Channel('%s:%d' % (host, 12345)) + channel = _c.Channel('%s:%d' % (host, 12345), None) call = _c.Call(channel, method, host, time.time() + _TIMEOUT) del call del channel @@ -136,6 +136,29 @@ class _CTest(unittest.TestCase): _c.shut_down() + def test_client_credentials(self): + root_certificates = b'Trust starts here. Really.' + private_key = b'This is a really bad private key, yo.' + certificate_chain = b'Trust me! Do I not look trustworty?' + + _c.init() + + client_credentials = _c.ClientCredentials( + None, None, None) + self.assertIsNotNone(client_credentials) + client_credentials = _c.ClientCredentials( + root_certificates, None, None) + self.assertIsNotNone(client_credentials) + client_credentials = _c.ClientCredentials( + None, private_key, certificate_chain) + self.assertIsNotNone(client_credentials) + client_credentials = _c.ClientCredentials( + root_certificates, private_key, certificate_chain) + self.assertIsNotNone(client_credentials) + del client_credentials + + _c.shut_down() + def test_server_credentials(self): root_certificates = b'Trust starts here. Really.' first_private_key = b'This is a really bad private key, yo.' diff --git a/src/python/src/grpc/_adapter/_call.c b/src/python/src/grpc/_adapter/_call.c index 325d3d5bbd6..dca2e49373b 100644 --- a/src/python/src/grpc/_adapter/_call.c +++ b/src/python/src/grpc/_adapter/_call.c @@ -161,7 +161,7 @@ static const PyObject *pygrpc_call_accept(Call *self, PyObject *args) { } static const PyObject *pygrpc_call_premetadata(Call *self) { - /* TODO(b/18702680): Actually support metadata. */ + /* TODO(nathaniel): Metadata support. */ return pygrpc_translate_call_error( grpc_call_server_end_initial_metadata_old(self->c_call, 0)); } diff --git a/src/python/src/grpc/_adapter/_channel.c b/src/python/src/grpc/_adapter/_channel.c index 3ba943e4b2d..9cf580bcfb5 100644 --- a/src/python/src/grpc/_adapter/_channel.c +++ b/src/python/src/grpc/_adapter/_channel.c @@ -35,18 +35,28 @@ #include #include +#include + +#include "grpc/_adapter/_client_credentials.h" static int pygrpc_channel_init(Channel *self, PyObject *args, PyObject *kwds) { const char *hostport; - static char *kwlist[] = {"hostport", NULL}; + PyObject *client_credentials; + static char *kwlist[] = {"hostport", "client_credentials", NULL}; - if (!(PyArg_ParseTupleAndKeywords(args, kwds, "s:Channel", kwlist, - &hostport))) { + if (!(PyArg_ParseTupleAndKeywords(args, kwds, "sO:Channel", kwlist, + &hostport, &client_credentials))) { return -1; } - - self->c_channel = grpc_channel_create(hostport, NULL); - return 0; + if (client_credentials == Py_None) { + self->c_channel = grpc_channel_create(hostport, NULL); + return 0; + } else { + self->c_channel = grpc_secure_channel_create( + ((ClientCredentials *)client_credentials)->c_client_credentials, + hostport, NULL); + return 0; + } } static void pygrpc_channel_dealloc(Channel *self) { diff --git a/src/python/src/grpc/_adapter/_client_credentials.c b/src/python/src/grpc/_adapter/_client_credentials.c new file mode 100644 index 00000000000..e8ccff8d17d --- /dev/null +++ b/src/python/src/grpc/_adapter/_client_credentials.c @@ -0,0 +1,121 @@ +/* + * + * 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 "grpc/_adapter/_client_credentials.h" + +#include +#include +#include + +static int pygrpc_client_credentials_init(ClientCredentials *self, + PyObject *args, PyObject *kwds) { + char *root_certificates; + grpc_ssl_pem_key_cert_pair key_certificate_pair; + static char *kwlist[] = {"root_certificates", "private_key", + "certificate_chain", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "zzz:ClientCredentials", kwlist, + &root_certificates, + &key_certificate_pair.private_key, + &key_certificate_pair.cert_chain)) { + return -1; + } + + if (key_certificate_pair.private_key != NULL && key_certificate_pair.cert_chain != NULL) { + self->c_client_credentials = + grpc_ssl_credentials_create(root_certificates, &key_certificate_pair); + } else { + self->c_client_credentials = + grpc_ssl_credentials_create(root_certificates, NULL); + } + return 0; +} + +static void pygrpc_client_credentials_dealloc(ClientCredentials *self) { + if (self->c_client_credentials != NULL) { + grpc_credentials_release(self->c_client_credentials); + } + self->ob_type->tp_free((PyObject *)self); +} + +PyTypeObject pygrpc_ClientCredentialsType = { + PyVarObject_HEAD_INIT(NULL, 0) + "_grpc.ClientCredencials", /*tp_name*/ + sizeof(ClientCredentials), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)pygrpc_client_credentials_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Wrapping of grpc_credentials.", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)pygrpc_client_credentials_init, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +int pygrpc_add_client_credentials(PyObject *module) { + if (PyType_Ready(&pygrpc_ClientCredentialsType) < 0) { + return -1; + } + if (PyModule_AddObject(module, "ClientCredentials", + (PyObject *)&pygrpc_ClientCredentialsType) == -1) { + return -1; + } + return 0; +} diff --git a/src/python/src/grpc/_adapter/_client_credentials.h b/src/python/src/grpc/_adapter/_client_credentials.h new file mode 100644 index 00000000000..664dc80d751 --- /dev/null +++ b/src/python/src/grpc/_adapter/_client_credentials.h @@ -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. + * + */ + +#ifndef _ADAPTER__CLIENT_CREDENTIALS_H_ +#define _ADAPTER__CLIENT_CREDENTIALS_H_ + +#include +#include + +typedef struct { + PyObject_HEAD grpc_credentials *c_client_credentials; +} ClientCredentials; + +PyTypeObject pygrpc_ClientCredentialsType; + +int pygrpc_add_client_credentials(PyObject *module); + +#endif /* _ADAPTER__CLIENT_CREDENTIALS_H_ */ diff --git a/src/python/src/grpc/_adapter/_face_test_case.py b/src/python/src/grpc/_adapter/_face_test_case.py index 8cce322d300..475d780c950 100644 --- a/src/python/src/grpc/_adapter/_face_test_case.py +++ b/src/python/src/grpc/_adapter/_face_test_case.py @@ -85,7 +85,8 @@ class FaceTestCase(test_case.FaceTestCase, coverage.BlockingCoverage): port = fore_link.port() rear_link = rear.RearLink( 'localhost', port, pool, - serialization.request_serializers, serialization.response_deserializers) + serialization.request_serializers, + serialization.response_deserializers, False, None, None, None) rear_link.start() front = tickets_implementations.front(pool, pool, pool) back = tickets_implementations.back( diff --git a/src/python/src/grpc/_adapter/_links_test.py b/src/python/src/grpc/_adapter/_links_test.py index 6b3bcee9fa8..5d7e6772434 100644 --- a/src/python/src/grpc/_adapter/_links_test.py +++ b/src/python/src/grpc/_adapter/_links_test.py @@ -75,7 +75,7 @@ class RoundTripTest(unittest.TestCase): rear_link = rear.RearLink( 'localhost', port, self.rear_link_pool, {test_method: None}, - {test_method: None}) + {test_method: None}, False, None, None, None) rear_link.join_fore_link(test_fore_link) test_fore_link.join_rear_link(rear_link) rear_link.start() @@ -129,7 +129,7 @@ class RoundTripTest(unittest.TestCase): rear_link = rear.RearLink( 'localhost', port, self.rear_link_pool, {test_method: _IDENTITY}, - {test_method: _IDENTITY}) + {test_method: _IDENTITY}, False, None, None, None) rear_link.join_fore_link(test_fore_link) test_fore_link.join_rear_link(rear_link) rear_link.start() @@ -193,7 +193,7 @@ class RoundTripTest(unittest.TestCase): rear_link = rear.RearLink( 'localhost', port, self.rear_link_pool, {test_method: scenario.serialize_request}, - {test_method: scenario.deserialize_response}) + {test_method: scenario.deserialize_response}, False, None, None, None) rear_link.join_fore_link(test_fore_link) test_fore_link.join_rear_link(rear_link) rear_link.start() diff --git a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py b/src/python/src/grpc/_adapter/_lonely_rear_link_test.py index 9a13309a182..77821ba71a4 100644 --- a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py +++ b/src/python/src/grpc/_adapter/_lonely_rear_link_test.py @@ -50,7 +50,8 @@ class LonelyRearLinkTest(unittest.TestCase): self.pool.shutdown(wait=True) def testUpAndDown(self): - rear_link = rear.RearLink('nonexistent', 54321, self.pool, {}, {}) + rear_link = rear.RearLink( + 'nonexistent', 54321, self.pool, {}, {}, False, None, None, None) rear_link.start() rear_link.stop() @@ -63,7 +64,7 @@ class LonelyRearLinkTest(unittest.TestCase): rear_link = rear.RearLink( 'nonexistent', 54321, self.pool, {test_method: None}, - {test_method: None}) + {test_method: None}, False, None, None, None) rear_link.join_fore_link(fore_link) rear_link.start() diff --git a/src/python/src/grpc/_adapter/_low.py b/src/python/src/grpc/_adapter/_low.py index 2ef2eb879c1..a24baaeb3e7 100644 --- a/src/python/src/grpc/_adapter/_low.py +++ b/src/python/src/grpc/_adapter/_low.py @@ -52,5 +52,6 @@ Call = _c.Call Channel = _c.Channel CompletionQueue = _c.CompletionQueue Server = _c.Server +ClientCredentials = _c.ClientCredentials ServerCredentials = _c.ServerCredentials # pylint: enable=invalid-name diff --git a/src/python/src/grpc/_adapter/_low_test.py b/src/python/src/grpc/_adapter/_low_test.py index 898c62c0026..03e3f473a3e 100644 --- a/src/python/src/grpc/_adapter/_low_test.py +++ b/src/python/src/grpc/_adapter/_low_test.py @@ -56,7 +56,7 @@ class LonelyClientTest(unittest.TestCase): finish_tag = object() completion_queue = _low.CompletionQueue() - channel = _low.Channel('%s:%d' % (host, port)) + channel = _low.Channel('%s:%d' % (host, port), None) client_call = _low.Call(channel, method, host, deadline) client_call.invoke(completion_queue, metadata_tag, finish_tag) @@ -87,7 +87,7 @@ class EchoTest(unittest.TestCase): self.server.start() self.client_completion_queue = _low.CompletionQueue() - self.channel = _low.Channel('%s:%d' % (self.host, port)) + self.channel = _low.Channel('%s:%d' % (self.host, port), None) def tearDown(self): self.server.stop() @@ -265,7 +265,7 @@ class CancellationTest(unittest.TestCase): self.server.start() self.client_completion_queue = _low.CompletionQueue() - self.channel = _low.Channel('%s:%d' % (self.host, port)) + self.channel = _low.Channel('%s:%d' % (self.host, port), None) def tearDown(self): self.server.stop() diff --git a/src/python/src/grpc/_adapter/rear.py b/src/python/src/grpc/_adapter/rear.py index 94ff66ffdad..bfde5f5c577 100644 --- a/src/python/src/grpc/_adapter/rear.py +++ b/src/python/src/grpc/_adapter/rear.py @@ -92,7 +92,8 @@ class RearLink(ticket_interfaces.RearLink, activated.Activated): """An invocation-side bridge between RPC Framework and the C-ish _low code.""" def __init__( - self, host, port, pool, request_serializers, response_deserializers): + self, host, port, pool, request_serializers, response_deserializers, + secure, root_certificates, private_key, certificate_chain): """Constructor. Args: @@ -103,6 +104,13 @@ class RearLink(ticket_interfaces.RearLink, activated.Activated): serializer behaviors. response_deserializers: A dict from RPC method names to response object deserializer behaviors. + secure: A boolean indicating whether or not to use a secure connection. + root_certificates: The PEM-encoded root certificates or None to ask for + them to be retrieved from a default location. + private_key: The PEM-encoded private key to use or None if no private + key should be used. + certificate_chain: The PEM-encoded certificate chain to use or None if + no certificate chain should be used. """ self._condition = threading.Condition() self._host = host @@ -116,6 +124,14 @@ class RearLink(ticket_interfaces.RearLink, activated.Activated): self._channel = None self._rpc_states = {} self._spinning = False + if secure: + self._client_credentials = _low.ClientCredentials( + root_certificates, private_key, certificate_chain) + else: + self._client_credentials = None + self._root_certificates = root_certificates + self._private_key = private_key + self._certificate_chain = certificate_chain def _on_write_event(self, operation_id, event, rpc_state): if event.write_accepted: @@ -310,7 +326,8 @@ class RearLink(ticket_interfaces.RearLink, activated.Activated): """ with self._condition: self._completion_queue = _low.CompletionQueue() - self._channel = _low.Channel('%s:%d' % (self._host, self._port)) + self._channel = _low.Channel( + '%s:%d' % (self._host, self._port), self._client_credentials) return self def _stop(self): @@ -369,11 +386,17 @@ class RearLink(ticket_interfaces.RearLink, activated.Activated): class _ActivatedRearLink(ticket_interfaces.RearLink, activated.Activated): - def __init__(self, host, port, request_serializers, response_deserializers): + def __init__( + self, host, port, request_serializers, response_deserializers, secure, + root_certificates, private_key, certificate_chain): self._host = host self._port = port self._request_serializers = request_serializers self._response_deserializers = response_deserializers + self._secure = secure + self._root_certificates = root_certificates + self._private_key = private_key + self._certificate_chain = certificate_chain self._lock = threading.Lock() self._pool = None @@ -391,7 +414,8 @@ class _ActivatedRearLink(ticket_interfaces.RearLink, activated.Activated): self._pool = logging_pool.pool(_THREAD_POOL_SIZE) self._rear_link = RearLink( self._host, self._port, self._pool, self._request_serializers, - self._response_deserializers) + self._response_deserializers, self._secure, self._root_certificates, + self._private_key, self._certificate_chain) self._rear_link.join_fore_link(self._fore_link) self._rear_link.start() return self @@ -422,6 +446,7 @@ class _ActivatedRearLink(ticket_interfaces.RearLink, activated.Activated): self._rear_link.accept_front_to_back_ticket(ticket) +# TODO(issue 726): reconcile these two creation functions. def activated_rear_link( host, port, request_serializers, response_deserializers): """Creates a RearLink that is also an activated.Activated. @@ -436,6 +461,42 @@ def activated_rear_link( serializer behavior. response_deserializers: A dictionary from RPC method name to response object deserializer behavior. + secure: A boolean indicating whether or not to use a secure connection. + root_certificates: The PEM-encoded root certificates or None to ask for + them to be retrieved from a default location. + private_key: The PEM-encoded private key to use or None if no private key + should be used. + certificate_chain: The PEM-encoded certificate chain to use or None if no + certificate chain should be used. + """ + return _ActivatedRearLink( + host, port, request_serializers, response_deserializers, False, None, + None, None) + + + +def secure_activated_rear_link( + host, port, request_serializers, response_deserializers, root_certificates, + private_key, certificate_chain): + """Creates a RearLink that is also an activated.Activated. + + The returned object is only valid for use between calls to its start and stop + methods (or in context when used as a context manager). + + Args: + host: The host to which to connect for RPC service. + port: The port to which to connect for RPC service. + request_serializers: A dictionary from RPC method name to request object + serializer behavior. + response_deserializers: A dictionary from RPC method name to response + object deserializer behavior. + root_certificates: The PEM-encoded root certificates or None to ask for + them to be retrieved from a default location. + private_key: The PEM-encoded private key to use or None if no private key + should be used. + certificate_chain: The PEM-encoded certificate chain to use or None if no + certificate chain should be used. """ return _ActivatedRearLink( - host, port, request_serializers, response_deserializers) + host, port, request_serializers, response_deserializers, True, + root_certificates, private_key, certificate_chain) diff --git a/src/python/src/grpc/early_adopter/_assembly_utilities.py b/src/python/src/grpc/early_adopter/_assembly_utilities.py new file mode 100644 index 00000000000..facfc2bf0e6 --- /dev/null +++ b/src/python/src/grpc/early_adopter/_assembly_utilities.py @@ -0,0 +1,168 @@ +# 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 + +# assembly_interfaces is referenced from specification in this module. +from grpc.framework.assembly import interfaces as assembly_interfaces # pylint: disable=unused-import +from grpc.framework.assembly import utilities as assembly_utilities +from grpc.early_adopter import _reexport +from grpc.early_adopter import interfaces + + +# TODO(issue 726): Kill the "implementations" attribute of this in favor +# of the same-information-less-bogusly-represented "cardinalities". +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. + implementations: A dictionary from RPC method name to + assembly_interfaces.MethodImplementation describing the method. + request_serializers: A dictionary from RPC method name to callable + behavior to be used serializing request values for the RPC. + response_deserializers: A dictionary from 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', 'implementations', 'request_serializers', + 'response_deserializers'))): + pass + + +class ServiceBreakdown(object): + """An intermediate representation of service-side views of RPC methods. + + Attributes: + implementations: A dictionary from RPC method name + assembly_interfaces.MethodImplementation implementing the RPC method. + request_deserializers: A dictionary from RPC method name to callable + behavior to be used deserializing request values for the RPC. + response_serializers: A dictionary from 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(method_descriptions): + """Derives an InvocationBreakdown from several RPC method descriptions. + + Args: + method_descriptions: A dictionary from RPC method name to + interfaces.RpcMethodInvocationDescription describing the RPCs. + + Returns: + An InvocationBreakdown corresponding to the given method descriptions. + """ + cardinalities = {} + implementations = {} + request_serializers = {} + response_deserializers = {} + for name, method_description in method_descriptions.iteritems(): + cardinality = method_description.cardinality() + cardinalities[name] = cardinality + if cardinality is interfaces.Cardinality.UNARY_UNARY: + implementations[name] = assembly_utilities.unary_unary_inline(None) + elif cardinality is interfaces.Cardinality.UNARY_STREAM: + implementations[name] = assembly_utilities.unary_stream_inline(None) + elif cardinality is interfaces.Cardinality.STREAM_UNARY: + implementations[name] = assembly_utilities.stream_unary_inline(None) + elif cardinality is interfaces.Cardinality.STREAM_STREAM: + implementations[name] = assembly_utilities.stream_stream_inline(None) + request_serializers[name] = method_description.serialize_request + response_deserializers[name] = method_description.deserialize_response + return _EasyInvocationBreakdown( + cardinalities, implementations, request_serializers, + response_deserializers) + + +def break_down_service(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(): + cardinality = method_description.cardinality() + if 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[name] = assembly_utilities.unary_unary_inline(service) + elif 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[name] = assembly_utilities.unary_stream_inline(service) + elif 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[name] = assembly_utilities.stream_unary_inline(service) + elif 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[name] = assembly_utilities.stream_stream_inline(service) + request_deserializers[name] = method_description.deserialize_request + response_serializers[name] = method_description.serialize_response + + return _EasyServiceBreakdown( + implementations, request_deserializers, response_serializers) 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 3e37b08752b..00000000000 --- a/src/python/src/grpc/early_adopter/_face_utilities.py +++ /dev/null @@ -1,178 +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 - -from grpc.framework.face import interfaces as face_interfaces - -from grpc.early_adopter import interfaces - - -class _InlineUnaryUnaryMethod(face_interfaces.InlineValueInValueOutMethod): - - def __init__(self, unary_unary_server_rpc_method): - self._method = unary_unary_server_rpc_method - - def service(self, request, context): - """See face_interfaces.InlineValueInValueOutMethod.service for spec.""" - return self._method.service_unary_unary(request) - - -class _InlineUnaryStreamMethod(face_interfaces.InlineValueInStreamOutMethod): - - def __init__(self, unary_stream_server_rpc_method): - self._method = unary_stream_server_rpc_method - - def service(self, request, context): - """See face_interfaces.InlineValueInStreamOutMethod.service for spec.""" - return self._method.service_unary_stream(request) - - -class _InlineStreamUnaryMethod(face_interfaces.InlineStreamInValueOutMethod): - - def __init__(self, stream_unary_server_rpc_method): - self._method = stream_unary_server_rpc_method - - def service(self, request_iterator, context): - """See face_interfaces.InlineStreamInValueOutMethod.service for spec.""" - return self._method.service_stream_unary(request_iterator) - - -class _InlineStreamStreamMethod(face_interfaces.InlineStreamInStreamOutMethod): - - def __init__(self, stream_stream_server_rpc_method): - self._method = stream_stream_server_rpc_method - - def service(self, request_iterator, context): - """See face_interfaces.InlineStreamInStreamOutMethod.service for spec.""" - return self._method.service_stream_stream(request_iterator) - - -class ClientBreakdown(object): - """An intermediate representation of invocation-side views of RPC methods. - - Attributes: - request_serializers: A dictionary from RPC method name to callable - behavior to be used serializing request values for the RPC. - response_deserializers: A dictionary from RPC method name to callable - behavior to be used deserializing response values for the RPC. - """ - __metaclass__ = abc.ABCMeta - - -class _EasyClientBreakdown( - ClientBreakdown, - collections.namedtuple( - '_EasyClientBreakdown', - ('request_serializers', 'response_deserializers'))): - pass - - -class ServerBreakdown(object): - """An intermediate representation of implementations of RPC methods. - - Attributes: - unary_unary_methods: A dictionary from RPC method name to callable - behavior implementing the RPC method for unary-unary RPC methods. - unary_stream_methods: A dictionary from RPC method name to callable - behavior implementing the RPC method for unary-stream RPC methods. - stream_unary_methods: A dictionary from RPC method name to callable - behavior implementing the RPC method for stream-unary RPC methods. - stream_stream_methods: A dictionary from RPC method name to callable - behavior implementing the RPC method for stream-stream RPC methods. - request_deserializers: A dictionary from RPC method name to callable - behavior to be used deserializing request values for the RPC. - response_serializers: A dictionary from RPC method name to callable - behavior to be used serializing response values for the RPC. - """ - __metaclass__ = abc.ABCMeta - - - -class _EasyServerBreakdown( - ServerBreakdown, - collections.namedtuple( - '_EasyServerBreakdown', - ('unary_unary_methods', 'unary_stream_methods', 'stream_unary_methods', - 'stream_stream_methods', 'request_deserializers', - 'response_serializers'))): - pass - - -def client_break_down(methods): - """Derives a ClientBreakdown from several interfaces.ClientRpcMethods. - - Args: - methods: A dictionary from RPC mthod name to - interfaces.ClientRpcMethod object describing the RPCs. - - Returns: - A ClientBreakdown corresponding to the given methods. - """ - request_serializers = {} - response_deserializers = {} - for name, method in methods.iteritems(): - request_serializers[name] = method.serialize_request - response_deserializers[name] = method.deserialize_response - return _EasyClientBreakdown(request_serializers, response_deserializers) - - -def server_break_down(methods): - """Derives a ServerBreakdown from several interfaces.ServerRpcMethods. - - Args: - methods: A dictionary from RPC mthod name to - interfaces.ServerRpcMethod object describing the RPCs. - - Returns: - A ServerBreakdown corresponding to the given methods. - """ - unary_unary = {} - unary_stream = {} - stream_unary = {} - stream_stream = {} - request_deserializers = {} - response_serializers = {} - for name, method in methods.iteritems(): - cardinality = method.cardinality() - if cardinality is interfaces.Cardinality.UNARY_UNARY: - unary_unary[name] = _InlineUnaryUnaryMethod(method) - elif cardinality is interfaces.Cardinality.UNARY_STREAM: - unary_stream[name] = _InlineUnaryStreamMethod(method) - elif cardinality is interfaces.Cardinality.STREAM_UNARY: - stream_unary[name] = _InlineStreamUnaryMethod(method) - elif cardinality is interfaces.Cardinality.STREAM_STREAM: - stream_stream[name] = _InlineStreamStreamMethod(method) - request_deserializers[name] = method.deserialize_request - response_serializers[name] = method.serialize_response - - return _EasyServerBreakdown( - unary_unary, unary_stream, stream_unary, stream_stream, - request_deserializers, response_serializers) diff --git a/src/python/src/grpc/early_adopter/_reexport.py b/src/python/src/grpc/early_adopter/_reexport.py new file mode 100644 index 00000000000..35f4e85a728 --- /dev/null +++ b/src/python/src/grpc/early_adopter/_reexport.py @@ -0,0 +1,212 @@ +# 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.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 + +_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_sync_async): + self._underlying = face_unary_unary_sync_async + + def __call__(self, request, timeout): + return _call_reexporting_errors( + self._underlying, request, timeout) + + def async(self, request, timeout): + return _ReexportedFuture(self._underlying.async(request, timeout)) + + +class _StreamUnarySyncAsync(interfaces.StreamUnarySyncAsync): + + def __init__(self, face_stream_unary_sync_async): + self._underlying = face_stream_unary_sync_async + + 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.async(request_iterator, timeout)) + + +class _Stub(interfaces.Stub): + + def __init__(self, assembly_stub, cardinalities): + self._assembly_stub = assembly_stub + self._cardinalities = cardinalities + + def __enter__(self): + self._assembly_stub.__enter__() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self._assembly_stub.__exit__(exc_type, exc_val, exc_tb) + return False + + def __getattr__(self, attr): + underlying_attr = self._assembly_stub.__getattr__(attr) + cardinality = self._cardinalities.get(attr) + # TODO(nathaniel): unify this trick with its other occurrence in the code. + if cardinality is None: + for name, cardinality in self._cardinalities.iteritems(): + last_slash_index = name.rfind('/') + if 0 <= last_slash_index and name[last_slash_index + 1:] == attr: + break + else: + raise AttributeError(attr) + if cardinality is interfaces.Cardinality.UNARY_UNARY: + return _UnaryUnarySyncAsync(underlying_attr) + elif cardinality is interfaces.Cardinality.UNARY_STREAM: + return lambda request, timeout: _CancellableIterator( + underlying_attr(request, timeout)) + elif cardinality is interfaces.Cardinality.STREAM_UNARY: + return _StreamUnarySyncAsync(underlying_attr) + elif cardinality is interfaces.Cardinality.STREAM_STREAM: + return lambda request_iterator, timeout: _CancellableIterator( + underlying_attr(request_iterator, timeout)) + else: + raise AttributeError(attr) + +def rpc_context(face_rpc_context): + return _RpcContext(face_rpc_context) + + +def stub(assembly_stub, cardinalities): + return _Stub(assembly_stub, cardinalities) diff --git a/src/ruby/spec/auth/signet_spec.rb b/src/python/src/grpc/early_adopter/exceptions.py similarity index 53% rename from src/ruby/spec/auth/signet_spec.rb rename to src/python/src/grpc/early_adopter/exceptions.py index 1712edf2961..5234d3b91ce 100644 --- a/src/ruby/spec/auth/signet_spec.rb +++ b/src/python/src/grpc/early_adopter/exceptions.py @@ -27,44 +27,22 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) -$LOAD_PATH.unshift(spec_dir) -$LOAD_PATH.uniq! +"""Exceptions raised by GRPC. -require 'apply_auth_examples' -require 'grpc/auth/signet' -require 'jwt' -require 'openssl' -require 'spec_helper' +Only GRPC should instantiate and raise these exceptions. +""" -describe Signet::OAuth2::Client do - before(:example) do - @key = OpenSSL::PKey::RSA.new(2048) - @client = Signet::OAuth2::Client.new( - token_credential_uri: 'https://accounts.google.com/o/oauth2/token', - scope: 'https://www.googleapis.com/auth/userinfo.profile', - issuer: 'app@example.com', - audience: 'https://accounts.google.com/o/oauth2/token', - signing_key: @key - ) - end +import abc - def make_auth_stubs(with_access_token: '') - Faraday::Adapter::Test::Stubs.new do |stub| - stub.post('/o/oauth2/token') do |env| - params = Addressable::URI.form_unencode(env[:body]) - _claim, _header = JWT.decode(params.assoc('assertion').last, - @key.public_key) - want = ['grant_type', 'urn:ietf:params:oauth:grant-type:jwt-bearer'] - expect(params.assoc('grant_type')).to eq(want) - build_json_response( - 'access_token' => with_access_token, - 'token_type' => 'Bearer', - 'expires_in' => 3600 - ) - end - end - end - it_behaves_like 'apply/apply! are OK' -end +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 1d76d0f9e0d..61959586240 100644 --- a/src/python/src/grpc/early_adopter/implementations.py +++ b/src/python/src/grpc/early_adopter/implementations.py @@ -31,15 +31,12 @@ import threading -from grpc._adapter import fore -from grpc.framework.base.packets import implementations as _tickets_implementations -from grpc.framework.face import implementations as _face_implementations -from grpc.framework.foundation import logging_pool -from grpc.early_adopter import _face_utilities +from grpc._adapter import fore as _fore +from grpc._adapter import rear as _rear +from grpc.early_adopter import _assembly_utilities +from grpc.early_adopter import _reexport from grpc.early_adopter import interfaces - -_MEGA_TIMEOUT = 60 * 60 * 24 -_THREAD_POOL_SIZE = 80 +from grpc.framework.assembly import implementations as _assembly_implementations class _Server(interfaces.Server): @@ -48,63 +45,122 @@ class _Server(interfaces.Server): self._lock = threading.Lock() self._breakdown = breakdown self._port = port - self._private_key = private_key - self._certificate_chain = certificate_chain + if private_key is None or certificate_chain is None: + self._key_chain_pairs = () + else: + self._key_chain_pairs = ((private_key, certificate_chain),) - self._pool = None self._fore_link = None - self._back = None + self._server = None - def start(self): - """See interfaces.Server.start for specification.""" + def _start(self): with self._lock: - if self._pool is None: - self._pool = logging_pool.pool(_THREAD_POOL_SIZE) - servicer = _face_implementations.servicer( - self._pool, - inline_value_in_value_out_methods=self._breakdown.unary_unary_methods, - inline_value_in_stream_out_methods=self._breakdown.unary_stream_methods, - inline_stream_in_value_out_methods=self._breakdown.stream_unary_methods, - inline_stream_in_stream_out_methods=self._breakdown.stream_stream_methods) - self._fore_link = fore.ForeLink( - self._pool, self._breakdown.request_deserializers, - self._breakdown.response_serializers, None, - ((self._private_key, self._certificate_chain),), port=self._port) - self._fore_link.start() - port = self._fore_link.port() - self._back = _tickets_implementations.back( - servicer, self._pool, self._pool, self._pool, _MEGA_TIMEOUT, - _MEGA_TIMEOUT) - self._fore_link.join_rear_link(self._back) - self._back.join_fore_link(self._fore_link) - return port + if self._server is None: + self._fore_link = _fore.activated_fore_link( + self._port, self._breakdown.request_deserializers, + self._breakdown.response_serializers, None, self._key_chain_pairs) + + self._server = _assembly_implementations.assemble_service( + self._breakdown.implementations, self._fore_link) + self._server.start() else: raise ValueError('Server currently running!') - def stop(self): - """See interfaces.Server.stop for specification.""" + def _stop(self): with self._lock: - if self._pool is None: + if self._server is None: raise ValueError('Server not running!') else: - self._fore_link.stop() - self._pool.shutdown(wait=True) - self._pool = None + self._server.stop() + self._server = None + self._fore_link = None + + def __enter__(self): + self._start() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self._stop() + return False + + def start(self): + self._start() + + def stop(self): + self._stop() + + def port(self): + with self._lock: + return self._fore_link.port() + +def _build_stub(breakdown, activated_rear_link): + assembly_stub = _assembly_implementations.assemble_dynamic_inline_stub( + breakdown.implementations, activated_rear_link) + return _reexport.stub(assembly_stub, breakdown.cardinalities) def _build_server(methods, port, private_key, certificate_chain): - breakdown = _face_utilities.server_break_down(methods) + breakdown = _assembly_utilities.break_down_service(methods) return _Server(breakdown, port, private_key, certificate_chain) +def insecure_stub(methods, host, port): + """Constructs an insecure interfaces.Stub. + + Args: + methods: A dictionary from RPC method name to + interfaces.RpcMethodInvocationDescription describing the RPCs to be + supported by the created stub. + host: The host to which to connect for RPC service. + port: The port to which to connect for RPC service. + + Returns: + An interfaces.Stub affording RPC invocation. + """ + breakdown = _assembly_utilities.break_down_invocation(methods) + activated_rear_link = _rear.activated_rear_link( + host, port, breakdown.request_serializers, + breakdown.response_deserializers) + return _build_stub(breakdown, activated_rear_link) + + +def secure_stub( + methods, host, port, root_certificates, private_key, certificate_chain): + """Constructs an insecure interfaces.Stub. + + Args: + methods: A dictionary from RPC method name to + interfaces.RpcMethodInvocationDescription describing the RPCs to be + supported by the created stub. + host: The host to which to connect for RPC service. + port: The port to which to connect for RPC service. + root_certificates: The PEM-encoded root certificates or None to ask for + them to be retrieved from a default location. + private_key: The PEM-encoded private key to use or None if no private key + should be used. + certificate_chain: The PEM-encoded certificate chain to use or None if no + certificate chain should be used. + + Returns: + An interfaces.Stub affording RPC invocation. + """ + breakdown = _assembly_utilities.break_down_invocation(methods) + activated_rear_link = _rear.secure_activated_rear_link( + host, port, breakdown.request_serializers, + breakdown.response_deserializers, root_certificates, private_key, + certificate_chain) + return _build_stub(breakdown, activated_rear_link) + + def insecure_server(methods, port): """Constructs an insecure interfaces.Server. Args: methods: A dictionary from RPC method name to - interfaces.ServerRpcMethod object describing the RPCs to + interfaces.RpcMethodServiceDescription describing the RPCs to be serviced by the created server. - port: The port on which to serve. + port: The desired port on which to serve or zero to ask for a port to + be automatically selected. Returns: An interfaces.Server that will run with no security and @@ -118,9 +174,10 @@ def secure_server(methods, port, private_key, certificate_chain): Args: methods: A dictionary from RPC method name to - interfaces.ServerRpcMethod object describing the RPCs to + interfaces.RpcMethodServiceDescription describing the RPCs to be serviced by the created server. - port: The port on which to serve. + port: The port on which to serve or zero to ask for a port to be + automatically selected. private_key: A pem-encoded private key. certificate_chain: A pem-encoded certificate chain. diff --git a/src/python/src/grpc/early_adopter/implementations_test.py b/src/python/src/grpc/early_adopter/implementations_test.py new file mode 100644 index 00000000000..9ef06c32cbc --- /dev/null +++ b/src/python/src/grpc/early_adopter/implementations_test.py @@ -0,0 +1,176 @@ +# 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. + +# TODO(nathaniel): Expand this test coverage. + +"""Test of the GRPC-backed ForeLink and RearLink.""" + +import unittest + +from grpc.early_adopter import implementations +from grpc.early_adopter import utilities +from grpc._junkdrawer import math_pb2 + +DIV = 'Div' +DIV_MANY = 'DivMany' +FIB = 'Fib' +SUM = 'Sum' + +def _fibbonacci(limit): + left, right = 0, 1 + for _ in xrange(limit): + yield left + left, right = right, left + right + + +def _div(request, unused_context): + return math_pb2.DivReply( + quotient=request.dividend / request.divisor, + remainder=request.dividend % request.divisor) + + +def _div_many(request_iterator, unused_context): + for request in request_iterator: + yield math_pb2.DivReply( + quotient=request.dividend / request.divisor, + remainder=request.dividend % request.divisor) + + +def _fib(request, unused_context): + for number in _fibbonacci(request.limit): + yield math_pb2.Num(num=number) + + +def _sum(request_iterator, unused_context): + accumulation = 0 + for request in request_iterator: + accumulation += request.num + return math_pb2.Num(num=accumulation) + + +_INVOCATION_DESCRIPTIONS = { + DIV: utilities.unary_unary_invocation_description( + math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString), + DIV_MANY: utilities.stream_stream_invocation_description( + math_pb2.DivArgs.SerializeToString, math_pb2.DivReply.FromString), + FIB: utilities.unary_stream_invocation_description( + math_pb2.FibArgs.SerializeToString, math_pb2.Num.FromString), + SUM: utilities.stream_unary_invocation_description( + math_pb2.Num.SerializeToString, math_pb2.Num.FromString), +} + +_SERVICE_DESCRIPTIONS = { + DIV: utilities.unary_unary_service_description( + _div, math_pb2.DivArgs.FromString, + math_pb2.DivReply.SerializeToString), + DIV_MANY: utilities.stream_stream_service_description( + _div_many, math_pb2.DivArgs.FromString, + math_pb2.DivReply.SerializeToString), + FIB: utilities.unary_stream_service_description( + _fib, math_pb2.FibArgs.FromString, math_pb2.Num.SerializeToString), + SUM: utilities.stream_unary_service_description( + _sum, math_pb2.Num.FromString, math_pb2.Num.SerializeToString), +} + +_TIMEOUT = 3 + + +class EarlyAdopterImplementationsTest(unittest.TestCase): + + def setUp(self): + self.server = implementations.insecure_server(_SERVICE_DESCRIPTIONS, 0) + self.server.start() + port = self.server.port() + self.stub = implementations.insecure_stub(_INVOCATION_DESCRIPTIONS, 'localhost', port) + + def tearDown(self): + self.server.stop() + + def testUpAndDown(self): + with self.stub: + pass + + def testUnaryUnary(self): + divisor = 59 + dividend = 973 + expected_quotient = dividend / divisor + expected_remainder = dividend % divisor + + with self.stub: + response = self.stub.Div( + math_pb2.DivArgs(divisor=divisor, dividend=dividend), _TIMEOUT) + self.assertEqual(expected_quotient, response.quotient) + self.assertEqual(expected_remainder, response.remainder) + + def testUnaryStream(self): + stream_length = 43 + + with self.stub: + response_iterator = self.stub.Fib( + math_pb2.FibArgs(limit=stream_length), _TIMEOUT) + numbers = tuple(response.num for response in response_iterator) + for early, middle, later in zip(numbers, numbers[:1], numbers[:2]): + self.assertEqual(early + middle, later) + self.assertEqual(stream_length, len(numbers)) + + def testStreamUnary(self): + stream_length = 127 + + with self.stub: + response_future = self.stub.Sum.async( + (math_pb2.Num(num=index) for index in range(stream_length)), + _TIMEOUT) + self.assertEqual( + (stream_length * (stream_length - 1)) / 2, + response_future.result().num) + + def testStreamStream(self): + stream_length = 179 + divisor_offset = 71 + dividend_offset = 1763 + + with self.stub: + response_iterator = self.stub.DivMany( + (math_pb2.DivArgs( + divisor=divisor_offset + index, + dividend=dividend_offset + index) + for index in range(stream_length)), + _TIMEOUT) + for index, response in enumerate(response_iterator): + self.assertEqual( + (dividend_offset + index) / (divisor_offset + index), + response.quotient) + self.assertEqual( + (dividend_offset + index) % (divisor_offset + index), + response.remainder) + self.assertEqual(stream_length, index + 1) + + +if __name__ == '__main__': + unittest.main() diff --git a/src/python/src/grpc/early_adopter/interfaces.py b/src/python/src/grpc/early_adopter/interfaces.py index 0ec371f8e88..b733873c1c9 100644 --- a/src/python/src/grpc/early_adopter/interfaces.py +++ b/src/python/src/grpc/early_adopter/interfaces.py @@ -32,6 +32,11 @@ 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): @@ -43,24 +48,166 @@ class Cardinality(enum.Enum): STREAM_STREAM = 'request-streaming/response-streaming' -class RpcMethod(object): - """A type for the common aspects of RPC method specifications.""" +@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 RpcMethod. + """Identifies the cardinality of this RpcMethodDescription. Returns: A Cardinality value identifying whether or not this - RpcMethod is request-unary or request-streaming and - whether or not it is response-unary or - response-streaming. + RpcMethodDescription is request-unary or request-streaming and + whether or not it is response-unary or response-streaming. """ raise NotImplementedError() -class ClientRpcMethod(RpcMethod): +class RpcMethodInvocationDescription(RpcMethodDescription): """Invocation-side description of an RPC method.""" __metaclass__ = abc.ABCMeta @@ -69,7 +216,8 @@ class ClientRpcMethod(RpcMethod): """Serializes a request value. Args: - request: A request value appropriate for this RpcMethod. + request: A request value appropriate for the RPC method described by this + RpcMethodInvocationDescription. Returns: The serialization of the given request value as a @@ -82,9 +230,9 @@ class ClientRpcMethod(RpcMethod): """Deserializes a response value. Args: - serialized_response: A bytestring that is the - serialization of a response value appropriate for this - RpcMethod. + 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. @@ -92,7 +240,7 @@ class ClientRpcMethod(RpcMethod): raise NotImplementedError() -class ServerRpcMethod(RpcMethod): +class RpcMethodServiceDescription(RpcMethodDescription): """Service-side description of an RPC method.""" __metaclass__ = abc.ABCMeta @@ -101,9 +249,9 @@ class ServerRpcMethod(RpcMethod): """Deserializes a request value. Args: - serialized_request: A bytestring that is the - serialization of a request value appropriate for this - RpcMethod. + 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. @@ -115,7 +263,8 @@ class ServerRpcMethod(RpcMethod): """Serializes a response value. Args: - response: A response value appropriate for this RpcMethod. + response: A response value appropriate for the RPC method described by + this RpcMethodServiceDescription. Returns: The serialization of the given response value as a @@ -124,80 +273,116 @@ class ServerRpcMethod(RpcMethod): raise NotImplementedError() @abc.abstractmethod - def service_unary_unary(self, request): + def service_unary_unary(self, request, context): """Carries out this RPC. This method may only be called if the cardinality of this - RpcMethod is Cardinality.UNARY_UNARY. + RpcMethodServiceDescription is Cardinality.UNARY_UNARY. Args: - request: A request value appropriate for this RpcMethod. + 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 this RpcMethod. + A response value appropriate for the RPC method described by this + RpcMethodServiceDescription. """ raise NotImplementedError() @abc.abstractmethod - def service_unary_stream(self, request): + def service_unary_stream(self, request, context): """Carries out this RPC. This method may only be called if the cardinality of this - RpcMethod is Cardinality.UNARY_STREAM. + RpcMethodServiceDescription is Cardinality.UNARY_STREAM. Args: - request: A request value appropriate for this RpcMethod. + 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 this - RpcMethod. + 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): + def service_stream_unary(self, request_iterator, context): """Carries out this RPC. This method may only be called if the cardinality of this - RpcMethod is Cardinality.STREAM_UNARY. + RpcMethodServiceDescription is Cardinality.STREAM_UNARY. Args: - request_iterator: An iterator of request values - appropriate for this RpcMethod. + 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 this RpcMethod. + A response value appropriate for the RPC method described by this + RpcMethodServiceDescription. """ raise NotImplementedError() @abc.abstractmethod - def service_stream_stream(self, request_iterator): + def service_stream_stream(self, request_iterator, context): """Carries out this RPC. This method may only be called if the cardinality of this - RpcMethod is Cardinality.STREAM_STREAM. + RpcMethodServiceDescription is Cardinality.STREAM_STREAM. Args: - request_iterator: An iterator of request values - appropriate for this RpcMethod. + 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 appropraite for this - RpcMethod. + Zero or more response values appropriate for the RPC method described by + this RpcMethodServiceDescription. """ raise NotImplementedError() -class Server(object): +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 start(self): - """Instructs this server to commence service of RPCs.""" - raise NotImplementedError() + def port(self): + """Reports the port on which the server is serving. - @abc.abstractmethod - def stop(self): - """Instructs this server to halt service of RPCs.""" + 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 index 9277d3f6ad4..da8ef825aa5 100644 --- a/src/python/src/grpc/early_adopter/utilities.py +++ b/src/python/src/grpc/early_adopter/utilities.py @@ -32,7 +32,9 @@ from grpc.early_adopter import interfaces -class _RpcMethod(interfaces.ClientRpcMethod, interfaces.ServerRpcMethod): +class _RpcMethodDescription( + interfaces.RpcMethodInvocationDescription, + interfaces.RpcMethodServiceDescription): def __init__( self, cardinality, unary_unary, unary_stream, stream_unary, @@ -49,44 +51,45 @@ class _RpcMethod(interfaces.ClientRpcMethod, interfaces.ServerRpcMethod): self._response_deserializer = response_deserializer def cardinality(self): - """See interfaces.RpcMethod.cardinality for specification.""" + """See interfaces.RpcMethodDescription.cardinality for specification.""" return self._cardinality def serialize_request(self, request): - """See interfaces.RpcMethod.serialize_request for specification.""" + """See interfaces.RpcMethodInvocationDescription.serialize_request.""" return self._request_serializer(request) def deserialize_request(self, serialized_request): - """See interfaces.RpcMethod.deserialize_request for specification.""" + """See interfaces.RpcMethodServiceDescription.deserialize_request.""" return self._request_deserializer(serialized_request) def serialize_response(self, response): - """See interfaces.RpcMethod.serialize_response for specification.""" + """See interfaces.RpcMethodServiceDescription.serialize_response.""" return self._response_serializer(response) def deserialize_response(self, serialized_response): - """See interfaces.RpcMethod.deserialize_response for specification.""" + """See interfaces.RpcMethodInvocationDescription.deserialize_response.""" return self._response_deserializer(serialized_response) - def service_unary_unary(self, request): - """See interfaces.RpcMethod.service_unary_unary for specification.""" - return self._unary_unary(request) + 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): - """See interfaces.RpcMethod.service_unary_stream for specification.""" - return self._unary_stream(request) + 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): - """See interfaces.RpcMethod.service_stream_unary for specification.""" - return self._stream_unary(request_iterator) + 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): - """See interfaces.RpcMethod.service_stream_stream for specification.""" - return self._stream_stream(request_iterator) + def service_stream_stream(self, request_iterator, context): + """See interfaces.RpcMethodServiceDescription.service_stream_stream.""" + return self._stream_stream(request_iterator, context) -def unary_unary_client_rpc_method(request_serializer, response_deserializer): - """Constructs an interfaces.ClientRpcMethod for a unary-unary RPC method. +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 @@ -96,17 +99,17 @@ def unary_unary_client_rpc_method(request_serializer, response_deserializer): that bytestring. Returns: - An interfaces.ClientRpcMethod constructed from the given - arguments representing a unary-request/unary-response RPC - method. + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a unary-request/unary-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.UNARY_UNARY, None, None, None, None, request_serializer, None, None, response_deserializer) -def unary_stream_client_rpc_method(request_serializer, response_deserializer): - """Constructs an interfaces.ClientRpcMethod for a unary-stream RPC method. +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 @@ -116,17 +119,17 @@ def unary_stream_client_rpc_method(request_serializer, response_deserializer): that bytestring. Returns: - An interfaces.ClientRpcMethod constructed from the given - arguments representing a unary-request/streaming-response - RPC method. + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a unary-request/streaming-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.UNARY_STREAM, None, None, None, None, request_serializer, None, None, response_deserializer) -def stream_unary_client_rpc_method(request_serializer, response_deserializer): - """Constructs an interfaces.ClientRpcMethod for a stream-unary RPC method. +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 @@ -136,17 +139,17 @@ def stream_unary_client_rpc_method(request_serializer, response_deserializer): that bytestring. Returns: - An interfaces.ClientRpcMethod constructed from the given - arguments representing a streaming-request/unary-response - RPC method. + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a streaming-request/unary-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.STREAM_UNARY, None, None, None, None, request_serializer, None, None, response_deserializer) -def stream_stream_client_rpc_method(request_serializer, response_deserializer): - """Constructs an interfaces.ClientRpcMethod for a stream-stream RPC method. +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 @@ -156,23 +159,23 @@ def stream_stream_client_rpc_method(request_serializer, response_deserializer): that bytestring. Returns: - An interfaces.ClientRpcMethod constructed from the given - arguments representing a - streaming-request/streaming-response RPC method. + An interfaces.RpcMethodInvocationDescription constructed from the given + arguments representing a streaming-request/streaming-response RPC + method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.STREAM_STREAM, None, None, None, None, request_serializer, None, None, response_deserializer) -def unary_unary_server_rpc_method( +def unary_unary_service_description( behavior, request_deserializer, response_serializer): - """Constructs an interfaces.ServerRpcMethod for the given behavior. + """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 returns a single - response. + 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. @@ -181,23 +184,23 @@ def unary_unary_server_rpc_method( that value. Returns: - An interfaces.ServerRpcMethod constructed from the given + An interfaces.RpcMethodServiceDescription constructed from the given arguments representing a unary-request/unary-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.UNARY_UNARY, behavior, None, None, None, None, request_deserializer, response_serializer, None) -def unary_stream_server_rpc_method( +def unary_stream_service_description( behavior, request_deserializer, response_serializer): - """Constructs an interfaces.ServerRpcMethod for the given behavior. + """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 returns an - iterator of zero or more responses. + 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. @@ -206,23 +209,23 @@ def unary_stream_server_rpc_method( that value. Returns: - An interfaces.ServerRpcMethod constructed from the given + An interfaces.RpcMethodServiceDescription constructed from the given arguments representing a unary-request/streaming-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.UNARY_STREAM, None, behavior, None, None, None, request_deserializer, response_serializer, None) -def stream_unary_server_rpc_method( +def stream_unary_service_description( behavior, request_deserializer, response_serializer): - """Constructs an interfaces.ServerRpcMethod for the given behavior. + """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 returns a single response. + 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. @@ -231,23 +234,24 @@ def stream_unary_server_rpc_method( that value. Returns: - An interfaces.ServerRpcMethod constructed from the given + An interfaces.RpcMethodServiceDescription constructed from the given arguments representing a streaming-request/unary-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.STREAM_UNARY, None, None, behavior, None, None, request_deserializer, response_serializer, None) -def stream_stream_server_rpc_method( +def stream_stream_service_description( behavior, request_deserializer, response_serializer): - """Constructs an interfaces.ServerRpcMethod for the given behavior. + """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 returns an iterator of zero or more responses. + 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. @@ -256,10 +260,10 @@ def stream_stream_server_rpc_method( that value. Returns: - An interfaces.ServerRpcMethod constructed from the given + An interfaces.RpcMethodServiceDescription constructed from the given arguments representing a streaming-request/streaming-response RPC method. """ - return _RpcMethod( + return _RpcMethodDescription( interfaces.Cardinality.STREAM_STREAM, None, None, None, behavior, None, request_deserializer, response_serializer, None) diff --git a/src/python/src/grpc/framework/assembly/implementations.py b/src/python/src/grpc/framework/assembly/implementations.py index b9d314844c8..f7166ed99d1 100644 --- a/src/python/src/grpc/framework/assembly/implementations.py +++ b/src/python/src/grpc/framework/assembly/implementations.py @@ -31,16 +31,18 @@ import threading +# tickets_interfaces, face_interfaces, and activated are referenced from +# specification in this module. from grpc.framework.assembly import interfaces from grpc.framework.base import util as base_utilities from grpc.framework.base.packets import implementations as tickets_implementations -from grpc.framework.base.packets import interfaces as tickets_interfaces +from grpc.framework.base.packets import interfaces as tickets_interfaces # pylint: disable=unused-import from grpc.framework.common import cardinality from grpc.framework.common import style from grpc.framework.face import implementations as face_implementations -from grpc.framework.face import interfaces as face_interfaces +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.foundation import activated +from grpc.framework.foundation import activated # pylint: disable=unused-import from grpc.framework.foundation import logging_pool _ONE_DAY_IN_SECONDS = 60 * 60 * 24 @@ -138,7 +140,13 @@ class _DynamicInlineStub(object): with self._lock: behavior = self._behaviors.get(attr) if behavior is None: - raise AttributeError(attr) + for name, behavior in self._behaviors.iteritems(): + last_slash_index = name.rfind('/') + if 0 <= last_slash_index and name[last_slash_index + 1:] == attr: + return behavior + else: + raise AttributeError( + '_DynamicInlineStub instance has no attribute "%s"!' % attr) else: return behavior diff --git a/src/python/src/setup.py b/src/python/src/setup.py index e3f13fa5c8f..26121dcfab6 100644 --- a/src/python/src/setup.py +++ b/src/python/src/setup.py @@ -38,6 +38,7 @@ _EXTENSION_SOURCES = ( 'grpc/_adapter/_completion_queue.c', 'grpc/_adapter/_error.c', 'grpc/_adapter/_server.c', + 'grpc/_adapter/_client_credentials.c', 'grpc/_adapter/_server_credentials.c', ) @@ -80,6 +81,6 @@ _PACKAGE_DIRECTORIES = { } _core.setup( - name='grpc-2015', version='0.0.1', + name='grpc-2015', version='0.4.0', ext_modules=[_EXTENSION_MODULE], packages=_PACKAGES, package_dir=_PACKAGE_DIRECTORIES) diff --git a/src/ruby/bin/apis/pubsub_demo.rb b/src/ruby/bin/apis/pubsub_demo.rb index 6656a561309..9bb324ff646 100755 --- a/src/ruby/bin/apis/pubsub_demo.rb +++ b/src/ruby/bin/apis/pubsub_demo.rb @@ -31,10 +31,9 @@ # pubsub_demo demos accesses the Google PubSub API via its gRPC interface # -# TODO: update the Usage once the usable auth gem is available -# $ SSL_CERT_FILE= \ +# $ GOOGLE_APPLICATION_CREDENTIALS= \ +# SSL_CERT_FILE= \ # path/to/pubsub_demo.rb \ -# --service_account_key_file= \ # [--action= ] # # There are options related to the chosen action, see #parse_args below. @@ -49,6 +48,7 @@ $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) require 'optparse' require 'grpc' +require 'googleauth' require 'google/protobuf' require 'google/protobuf/empty' @@ -59,7 +59,9 @@ require 'tech/pubsub/proto/pubsub_services' def load_prod_cert fail 'could not find a production cert' if ENV['SSL_CERT_FILE'].nil? p "loading prod certs from #{ENV['SSL_CERT_FILE']}" - File.open(ENV['SSL_CERT_FILE']).read + File.open(ENV['SSL_CERT_FILE']) do |f| + return f.read + end end # creates a SSL Credentials from the production certificates. @@ -68,14 +70,9 @@ def ssl_creds end # Builds the metadata authentication update proc. -# -# TODO: replace this once the ruby usable auth repo is available. def auth_proc(opts) - if GRPC::Auth::GCECredentials.on_gce? - return GRPC::Auth::GCECredentials.new.updater_proc - end - fd = StringIO.new(File.read(opts.oauth_key_file)) - GRPC::Auth::ServiceAccountCredentials.new(opts.oauth_scope, fd).updater_proc + auth_creds = Google::Auth.get_application_default(opts.oauth_scope) + return auth_creds.updater_proc end # Creates a stub for accessing the publisher service. @@ -216,14 +213,14 @@ class NamedActions end # Args is used to hold the command line info. -Args = Struct.new(:host, :oauth_scope, :oauth_key_file, :port, :action, - :project_id, :topic_name, :sub_name) +Args = Struct.new(:host, :oauth_scope, :port, :action, :project_id, :topic_name, + :sub_name) # validates the the command line options, returning them as an Arg. def parse_args args = Args.new('pubsub-staging.googleapis.com', 'https://www.googleapis.com/auth/pubsub', - nil, 443, 'list_some_topics', 'stoked-keyword-656') + 443, 'list_some_topics', 'stoked-keyword-656') OptionParser.new do |opts| opts.on('--oauth_scope scope', 'Scope for OAuth tokens') { |v| args['oauth_scope'] = v } @@ -233,10 +230,6 @@ def parse_args opts.on('--server_port SERVER_PORT', 'server port') do |v| args.port = v end - opts.on('--service_account_key_file PATH', - 'Path to the service account json key file') do |v| - args.oauth_key_file = v - end # instance_methods(false) gives only the methods defined in that class. scenes = NamedActions.instance_methods(false).map { |t| t.to_s } @@ -257,15 +250,11 @@ def parse_args end def _check_args(args) - %w(host port action).each do |a| + %w(host port action oauth_scope).each do |a| if args[a].nil? raise OptionParser::MissingArgument.new("please specify --#{a}") end end - if args['oauth_key_file'].nil? || args['oauth_scope'].nil? - fail(OptionParser::MissingArgument, - 'please specify both of --service_account_key_file and --oauth_scope') - end args end diff --git a/src/ruby/bin/interop/interop_client.rb b/src/ruby/bin/interop/interop_client.rb index 380ceb11df0..b0b24b949f2 100755 --- a/src/ruby/bin/interop/interop_client.rb +++ b/src/ruby/bin/interop/interop_client.rb @@ -48,6 +48,7 @@ require 'minitest' require 'minitest/assertions' require 'grpc' +require 'googleauth' require 'google/protobuf' require 'test/cpp/interop/test_services' @@ -56,7 +57,7 @@ require 'test/cpp/interop/empty' require 'signet/ssl_config' -include GRPC::Auth +AUTH_ENV = Google::Auth::ServiceAccountCredentials::ENV_VAR # loads the certificates used to access the test server securely. def load_test_certs @@ -101,22 +102,14 @@ def create_stub(opts) } # Add service account creds if specified - if %w(all service_account_creds).include?(opts.test_case) + wants_creds = %w(all compute_engine_creds service_account_creds) + if wants_creds.include?(opts.test_case) unless opts.oauth_scope.nil? - fd = StringIO.new(File.read(opts.oauth_key_file)) - logger.info("loading oauth certs from #{opts.oauth_key_file}") - auth_creds = ServiceAccountCredentials.new(opts.oauth_scope, fd) + auth_creds = Google::Auth.get_application_default(opts.oauth_scope) stub_opts[:update_metadata] = auth_creds.updater_proc end end - # Add compute engine creds if specified - if %w(all compute_engine_creds).include?(opts.test_case) - unless opts.oauth_scope.nil? - stub_opts[:update_metadata] = GCECredentials.new.update_proc - end - end - logger.info("... connecting securely to #{address}") Grpc::Testing::TestService::Stub.new(address, **stub_opts) else @@ -193,11 +186,11 @@ class NamedTests def service_account_creds # ignore this test if the oauth options are not set - if @args.oauth_scope.nil? || @args.oauth_key_file.nil? + if @args.oauth_scope.nil? p 'NOT RUN: service_account_creds; no service_account settings' return end - json_key = File.read(@args.oauth_key_file) + json_key = File.read(ENV[AUTH_ENV]) wanted_email = MultiJson.load(json_key)['client_email'] resp = perform_large_unary(fill_username: true, fill_oauth_scope: true) @@ -285,7 +278,7 @@ end # Args is used to hold the command line info. Args = Struct.new(:default_service_account, :host, :host_override, - :oauth_scope, :oauth_key_file, :port, :secure, :test_case, + :oauth_scope, :port, :secure, :test_case, :use_test_ca) # validates the the command line options, returning them as a Hash. @@ -302,10 +295,6 @@ def parse_args 'email address of the default service account') do |v| args['default_service_account'] = v end - opts.on('--service_account_key_file PATH', - 'Path to the service account json key file') do |v| - args['oauth_key_file'] = v - end opts.on('--server_host_override HOST_OVERRIDE', 'override host via a HTTP header') do |v| args['host_override'] = v @@ -333,10 +322,6 @@ def _check_args(args) fail(OptionParser::MissingArgument, "please specify --#{arg}") end end - if args['oauth_key_file'].nil? ^ args['oauth_scope'].nil? - fail(OptionParser::MissingArgument, - 'please specify both of --service_account_key_file and --oauth_scope') - end args end diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 96c92e2be5d..483a31f60cc 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -32,6 +32,17 @@ require 'mkmf' LIBDIR = RbConfig::CONFIG['libdir'] INCLUDEDIR = RbConfig::CONFIG['includedir'] +if ENV.key? 'GRPC_ROOT' + GRPC_ROOT = ENV['GRPC_ROOT'] + if ENV.key? 'GRPC_LIB_DIR' + GRPC_LIB_DIR = ENV['GRPC_LIB_DIR'] + else + GRPC_LIB_DIR = 'libs/opt' + end +else + GRPC_ROOT = nil +end + HEADER_DIRS = [ # Search /opt/local (Mac source install) '/opt/local/include', @@ -54,6 +65,11 @@ LIB_DIRS = [ LIBDIR ] +unless GRPC_ROOT.nil? + HEADER_DIRS.unshift File.join(GRPC_ROOT, 'include') + LIB_DIRS.unshift File.join(GRPC_ROOT, GRPC_LIB_DIR) +end + def crash(msg) print(" extconf failure: #{msg}\n") exit 1 diff --git a/src/ruby/grpc.gemspec b/src/ruby/grpc.gemspec index bc59c234e5a..ed26fef4a97 100755 --- a/src/ruby/grpc.gemspec +++ b/src/ruby/grpc.gemspec @@ -11,6 +11,7 @@ Gem::Specification.new do |s| s.homepage = 'https://github.com/google/grpc/tree/master/src/ruby' s.summary = 'GRPC system in Ruby' s.description = 'Send RPCs from Ruby using GRPC' + s.license = 'BSD-3-Clause' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n") @@ -22,6 +23,7 @@ Gem::Specification.new do |s| s.add_dependency 'faraday', '~> 0.9' s.add_dependency 'google-protobuf', '~> 3.0.0alpha.1.1' + s.add_dependency 'googleauth', '~> 0.1' s.add_dependency 'logging', '~> 1.8' s.add_dependency 'jwt', '~> 1.2.1' s.add_dependency 'minitest', '~> 5.4' # reqd for interop tests diff --git a/src/ruby/lib/grpc.rb b/src/ruby/lib/grpc.rb index a2a609f59ee..dd02ef7666a 100644 --- a/src/ruby/lib/grpc.rb +++ b/src/ruby/lib/grpc.rb @@ -27,8 +27,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'grpc/auth/compute_engine.rb' -require 'grpc/auth/service_account.rb' require 'grpc/errors' require 'grpc/grpc' require 'grpc/logconfig' diff --git a/src/ruby/lib/grpc/generic/client_stub.rb b/src/ruby/lib/grpc/generic/client_stub.rb index 7fc0d83501a..f234984eec3 100644 --- a/src/ruby/lib/grpc/generic/client_stub.rb +++ b/src/ruby/lib/grpc/generic/client_stub.rb @@ -400,7 +400,12 @@ module GRPC # @param deadline [TimeConst] def new_active_call(ch, marshal, unmarshal, deadline = nil) absolute_deadline = Core::TimeConsts.from_relative_time(deadline) - call = @ch.create_call(ch, @host, absolute_deadline) + # It should be OK to to pass the hostname:port to create_call, but at + # the moment this fails a security check. This will be corrected. + # + # TODO: # remove this after create_call is updated + host = @host.split(':')[0] + call = @ch.create_call(ch, host, absolute_deadline) ActiveCall.new(call, @queue, marshal, unmarshal, absolute_deadline, started: false) end diff --git a/src/ruby/lib/grpc/generic/service.rb b/src/ruby/lib/grpc/generic/service.rb index 61d18716354..6ea0831a2e6 100644 --- a/src/ruby/lib/grpc/generic/service.rb +++ b/src/ruby/lib/grpc/generic/service.rb @@ -217,8 +217,8 @@ module GRPC def self.included(o) o.extend(Dsl) - # Update to the use the service name including module. Proivde a default - # that can be nil e,g. when modules are declared dynamically. + # Update to the use the service name including module. Provide a default + # that can be nil e.g. when modules are declared dynamically. return unless o.service_name.nil? if o.name.nil? o.service_name = 'GenericService' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index d4eb0ed24f6..513a53724f3 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '0.0.1' + VERSION = '0.5.0' end diff --git a/src/ruby/spec/auth/apply_auth_examples.rb b/src/ruby/spec/auth/apply_auth_examples.rb deleted file mode 100644 index 09b393026f0..00000000000 --- a/src/ruby/spec/auth/apply_auth_examples.rb +++ /dev/null @@ -1,163 +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. - -spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) -$LOAD_PATH.unshift(spec_dir) -$LOAD_PATH.uniq! - -require 'faraday' -require 'spec_helper' - -def build_json_response(payload) - [200, - { 'Content-Type' => 'application/json; charset=utf-8' }, - MultiJson.dump(payload)] -end - -WANTED_AUTH_KEY = :Authorization - -shared_examples 'apply/apply! are OK' do - # tests that use these examples need to define - # - # @client which should be an auth client - # - # @make_auth_stubs, which should stub out the expected http behaviour of the - # auth client - describe '#fetch_access_token' do - it 'should set access_token to the fetched value' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - @client.fetch_access_token!(connection: c) - expect(@client.access_token).to eq(token) - stubs.verify_stubbed_calls - end - end - - describe '#apply!' do - it 'should update the target hash with fetched access token' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - md = { foo: 'bar' } - @client.apply!(md, connection: c) - want = { :foo => 'bar', WANTED_AUTH_KEY => "Bearer #{token}" } - expect(md).to eq(want) - stubs.verify_stubbed_calls - end - end - - describe 'updater_proc' do - it 'should provide a proc that updates a hash with the access token' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - md = { foo: 'bar' } - the_proc = @client.updater_proc - got = the_proc.call(md, connection: c) - want = { :foo => 'bar', WANTED_AUTH_KEY => "Bearer #{token}" } - expect(got).to eq(want) - stubs.verify_stubbed_calls - end - end - - describe '#apply' do - it 'should not update the original hash with the access token' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - md = { foo: 'bar' } - @client.apply(md, connection: c) - want = { foo: 'bar' } - expect(md).to eq(want) - stubs.verify_stubbed_calls - end - - it 'should add the token to the returned hash' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - md = { foo: 'bar' } - got = @client.apply(md, connection: c) - want = { :foo => 'bar', WANTED_AUTH_KEY => "Bearer #{token}" } - expect(got).to eq(want) - stubs.verify_stubbed_calls - end - - it 'should not fetch a new token if the current is not expired' do - token = '1/abcdef1234567890' - stubs = make_auth_stubs with_access_token: token - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - - n = 5 # arbitrary - n.times do |_t| - md = { foo: 'bar' } - got = @client.apply(md, connection: c) - want = { :foo => 'bar', WANTED_AUTH_KEY => "Bearer #{token}" } - expect(got).to eq(want) - end - stubs.verify_stubbed_calls - end - - it 'should fetch a new token if the current one is expired' do - token_1 = '1/abcdef1234567890' - token_2 = '2/abcdef1234567890' - - [token_1, token_2].each do |t| - stubs = make_auth_stubs with_access_token: t - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - md = { foo: 'bar' } - got = @client.apply(md, connection: c) - want = { :foo => 'bar', WANTED_AUTH_KEY => "Bearer #{t}" } - expect(got).to eq(want) - stubs.verify_stubbed_calls - @client.expires_at -= 3601 # default is to expire in 1hr - end - end - end -end diff --git a/src/ruby/spec/auth/compute_engine_spec.rb b/src/ruby/spec/auth/compute_engine_spec.rb deleted file mode 100644 index c43214d0861..00000000000 --- a/src/ruby/spec/auth/compute_engine_spec.rb +++ /dev/null @@ -1,108 +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. - -spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) -$LOAD_PATH.unshift(spec_dir) -$LOAD_PATH.uniq! - -require 'apply_auth_examples' -require 'faraday' -require 'grpc/auth/compute_engine' -require 'spec_helper' - -describe GRPC::Auth::GCECredentials do - MD_URI = '/computeMetadata/v1/instance/service-accounts/default/token' - GCECredentials = GRPC::Auth::GCECredentials - - before(:example) do - @client = GCECredentials.new - end - - def make_auth_stubs(with_access_token: '') - Faraday::Adapter::Test::Stubs.new do |stub| - stub.get(MD_URI) do |env| - headers = env[:request_headers] - expect(headers['Metadata-Flavor']).to eq('Google') - build_json_response( - 'access_token' => with_access_token, - 'token_type' => 'Bearer', - 'expires_in' => 3600) - end - end - end - - it_behaves_like 'apply/apply! are OK' - - describe '#on_gce?' do - it 'should be true when Metadata-Flavor is Google' do - stubs = Faraday::Adapter::Test::Stubs.new do |stub| - stub.get('/') do |_env| - [200, - { 'Metadata-Flavor' => 'Google' }, - ''] - end - end - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - expect(GCECredentials.on_gce?(connection: c)).to eq(true) - stubs.verify_stubbed_calls - end - - it 'should be false when Metadata-Flavor is not Google' do - stubs = Faraday::Adapter::Test::Stubs.new do |stub| - stub.get('/') do |_env| - [200, - { 'Metadata-Flavor' => 'NotGoogle' }, - ''] - end - end - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - expect(GCECredentials.on_gce?(connection: c)).to eq(false) - stubs.verify_stubbed_calls - end - - it 'should be false if the response is not 200' do - stubs = Faraday::Adapter::Test::Stubs.new do |stub| - stub.get('/') do |_env| - [404, - { 'Metadata-Flavor' => 'Google' }, - ''] - end - end - c = Faraday.new do |b| - b.adapter(:test, stubs) - end - expect(GCECredentials.on_gce?(connection: c)).to eq(false) - stubs.verify_stubbed_calls - end - end -end diff --git a/src/ruby/spec/auth/service_account_spec.rb b/src/ruby/spec/auth/service_account_spec.rb deleted file mode 100644 index 2f14a1ae053..00000000000 --- a/src/ruby/spec/auth/service_account_spec.rb +++ /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. - -spec_dir = File.expand_path(File.join(File.dirname(__FILE__))) -$LOAD_PATH.unshift(spec_dir) -$LOAD_PATH.uniq! - -require 'apply_auth_examples' -require 'grpc/auth/service_account' -require 'jwt' -require 'multi_json' -require 'openssl' -require 'spec_helper' - -describe GRPC::Auth::ServiceAccountCredentials do - before(:example) do - @key = OpenSSL::PKey::RSA.new(2048) - cred_json = { - private_key_id: 'a_private_key_id', - private_key: @key.to_pem, - client_email: 'app@developer.gserviceaccount.com', - client_id: 'app.apps.googleusercontent.com', - type: 'service_account' - } - cred_json_text = MultiJson.dump(cred_json) - @client = GRPC::Auth::ServiceAccountCredentials.new( - 'https://www.googleapis.com/auth/userinfo.profile', - StringIO.new(cred_json_text)) - end - - def make_auth_stubs(with_access_token: '') - Faraday::Adapter::Test::Stubs.new do |stub| - stub.post('/oauth2/v3/token') do |env| - params = Addressable::URI.form_unencode(env[:body]) - _claim, _header = JWT.decode(params.assoc('assertion').last, - @key.public_key) - want = ['grant_type', 'urn:ietf:params:oauth:grant-type:jwt-bearer'] - expect(params.assoc('grant_type')).to eq(want) - build_json_response( - 'access_token' => with_access_token, - 'token_type' => 'Bearer', - 'expires_in' => 3600 - ) - end - end - end - - it_behaves_like 'apply/apply! are OK' -end diff --git a/src/ruby/spec/credentials_spec.rb b/src/ruby/spec/credentials_spec.rb index 001fecd12b6..fc97d11a878 100644 --- a/src/ruby/spec/credentials_spec.rb +++ b/src/ruby/spec/credentials_spec.rb @@ -68,10 +68,4 @@ describe Credentials do expect { cred1.compose(cred2) }.to_not raise_error end end - - describe 'Credentials#default' do - it 'is not implemented yet' do - expect { Credentials.default }.to raise_error RuntimeError - end - end end diff --git a/templates/Makefile.template b/templates/Makefile.template index 8240996cfc6..2e50e5d41ec 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -94,7 +94,7 @@ LDXX_valgrind = g++ CPPFLAGS_valgrind = -O0 OPENSSL_CFLAGS_valgrind = -DPURIFY LDFLAGS_valgrind = -DEFINES_valgrind = _DEBUG DEBUG +DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1 @@ -104,7 +104,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer LDFLAGS_tsan = -fsanitize=thread -DEFINES_tsan = NDEBUG +DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_asan = 1 REQUIRE_CUSTOM_LIBRARIES_asan = 1 @@ -114,7 +114,7 @@ LD_asan = clang LDXX_asan = clang++ CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer LDFLAGS_asan = -fsanitize=address -DEFINES_asan = NDEBUG +DEFINES_asan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -125,7 +125,7 @@ LDXX_msan = clang++-libc++ CPPFLAGS_msan = -O1 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 OPENSSL_CFLAGS_msan = -DPURIFY LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -DEFINES_msan = NDEBUG +DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 @@ -136,7 +136,7 @@ LDXX_ubsan = clang++ CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer OPENSSL_CFLAGS_ubsan = -DPURIFY LDFLAGS_ubsan = -fsanitize=undefined -DEFINES_ubsan = NDEBUG +DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 VALID_CONFIG_gcov = 1 CC_gcov = gcc @@ -160,7 +160,15 @@ CXX = $(CXX_$(CONFIG)) LD = $(LD_$(CONFIG)) LDXX = $(LDXX_$(CONFIG)) AR = ar +ifeq ($(SYSTEM),Linux) STRIP = strip --strip-unneeded +else +ifeq ($(SYSTEM),Darwin) +STRIP = strip -x +else +STRIP = strip +endif +endif INSTALL = install RM = rm -f @@ -169,6 +177,10 @@ $(error Invalid CONFIG value '$(CONFIG)') endif +# Detect if we can use C++11 +CXX11_CHECK_CMD = $(CXX) -std=c++11 -o /dev/null -c test/build/c++11.cc +HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) + # The HOST compiler settings are used to compile the protoc plugins. # In most cases, you won't have to change anything, but if you are # cross-compiling, you can override these variables from GNU make's @@ -183,8 +195,17 @@ CPPFLAGS += $(CPPFLAGS_$(CONFIG)) DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" LDFLAGS += $(LDFLAGS_$(CONFIG)) +ifdef EXTRA_DEFINES +DEFINES += $(EXTRA_DEFINES) +endif + CFLAGS += -std=c89 -pedantic +ifeq ($(HAS_CXX11),true) CXXFLAGS += -std=c++11 +else +CXXFLAGS += -std=c++0x +DEFINES += GRPC_OLD_CXX +endif CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter LDFLAGS += -g -fPIC @@ -495,7 +516,11 @@ third_party/protobuf/configure: $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure $(E) "[MAKE] Building protobuf" +ifeq ($(HAVE_CXX11),true) $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-DLANG_CXX11 -std=c++11" CPPFLAGS="-fPIC $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static) +else + $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-std=c++0x" CPPFLAGS="-fPIC $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static) +endif $(Q)$(MAKE) -C third_party/protobuf clean $(Q)$(MAKE) -C third_party/protobuf $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf @@ -1095,11 +1120,11 @@ else ## That simplifies the codegen a bit, but prevents a fully defined Makefile. ## I can live with that. ## -% if tgt.build == 'protoc': +% if tgt.build == 'protoc' or tgt.language == 'c++': ifeq ($(NO_PROTOBUF),true) -# You can't build the protoc plugins if you don't have protobuf 3.0.0+. +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error @@ -1154,7 +1179,7 @@ $(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\ $(LDLIBS_SECURE)\ % endif -o $(BINDIR)/$(CONFIG)/${tgt.name} -% if tgt.build == 'protoc': +% if tgt.build == 'protoc' or tgt.language == 'c++': endif % endif diff --git a/templates/tools/run_tests/tests.json.template b/templates/tools/run_tests/tests.json.template index bb544898615..6d7520bc0f8 100644 --- a/templates/tools/run_tests/tests.json.template +++ b/templates/tools/run_tests/tests.json.template @@ -2,7 +2,9 @@ import json %> -${json.dumps([{"name": tgt.name, "language": tgt.language} +${json.dumps([{"name": tgt.name, + "language": tgt.language, + "flaky": tgt.get("flaky", False)} for tgt in targets if tgt.get('run', True) and tgt.build == 'test'], sort_keys=True, indent=2)} diff --git a/test/build/c++11.cc b/test/build/c++11.cc new file mode 100644 index 00000000000..4822a20e7f2 --- /dev/null +++ b/test/build/c++11.cc @@ -0,0 +1,52 @@ +/* + * + * 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. + * + */ + +/* This is just a compilation test, to see if we have C++11. */ + +#include +#include + +class Base { + public: + virtual void foo() = 0; +}; + +class Foo final : public Base { + public: + void foo() override {} +}; + +int main() { + Foo().foo(); + return 0; +} diff --git a/test/compiler/python_plugin_test.py b/test/compiler/python_plugin_test.py index b0c9ec62d07..1981f49fbb8 100644 --- a/test/compiler/python_plugin_test.py +++ b/test/compiler/python_plugin_test.py @@ -40,6 +40,21 @@ import unittest from grpc.framework.face import exceptions from grpc.framework.foundation import future +# Identifiers of entities we expect to find in the generated module. +SERVICER_IDENTIFIER = 'EarlyAdopterTestServiceServicer' +SERVER_IDENTIFIER = 'EarlyAdopterTestServiceServer' +STUB_IDENTIFIER = 'EarlyAdopterTestServiceStub' +SERVER_FACTORY_IDENTIFIER = 'early_adopter_create_TestService_server' +STUB_FACTORY_IDENTIFIER = 'early_adopter_create_TestService_stub' + +# Timeouts and delays. +SHORT_TIMEOUT = 0.1 +NORMAL_TIMEOUT = 1 +LONG_TIMEOUT = 2 +DOES_NOT_MATTER_DELAY = 0 +NO_DELAY = 0 +LONG_DELAY = 1 + # Assigned in __main__. _build_mode = None @@ -71,14 +86,14 @@ class _ServicerMethods(object): while self._paused: time.sleep(0) - def UnaryCall(self, request): + def UnaryCall(self, request, unused_context): response = self.test_pb2.SimpleResponse() response.payload.payload_type = self.test_pb2.COMPRESSABLE response.payload.payload_compressable = 'a' * request.response_size self._control() return response - def StreamingOutputCall(self, request): + def StreamingOutputCall(self, request, unused_context): for parameter in request.response_parameters: response = self.test_pb2.StreamingOutputCallResponse() response.payload.payload_type = self.test_pb2.COMPRESSABLE @@ -86,7 +101,7 @@ class _ServicerMethods(object): self._control() yield response - def StreamingInputCall(self, request_iter): + def StreamingInputCall(self, request_iter, unused_context): response = self.test_pb2.StreamingInputCallResponse() aggregated_payload_size = 0 for request in request_iter: @@ -95,7 +110,7 @@ class _ServicerMethods(object): self._control() return response - def FullDuplexCall(self, request_iter): + def FullDuplexCall(self, request_iter, unused_context): for request in request_iter: for parameter in request.response_parameters: response = self.test_pb2.StreamingOutputCallResponse() @@ -104,7 +119,7 @@ class _ServicerMethods(object): self._control() yield response - def HalfDuplexCall(self, request_iter): + def HalfDuplexCall(self, request_iter, unused_context): responses = [] for request in request_iter: for parameter in request.response_parameters: @@ -117,7 +132,8 @@ class _ServicerMethods(object): yield response -def CreateService(test_pb2, delay=0, timeout=1): +@contextlib.contextmanager +def _CreateService(test_pb2, delay): """Provides a servicer backend and a stub. The servicer is just the implementation @@ -132,32 +148,39 @@ def CreateService(test_pb2, delay=0, timeout=1): test_pb2: the test_pb2 module generated by this test delay: delay in seconds per response from the servicer timeout: how long the stub will wait for the servicer by default. - Returns: - A two-tuple (servicer, stub), where the servicer is the back-end of the - service bound to the stub. + + Yields: + A three-tuple (servicer_methods, servicer, stub), where the servicer is + the back-end of the service bound to the stub and the server and stub + are both activated and ready for use. """ - class Servicer(test_pb2.TestServiceServicer): + servicer_methods = _ServicerMethods(test_pb2, delay) - def UnaryCall(self, request): - return servicer_methods.UnaryCall(request) + class Servicer(getattr(test_pb2, SERVICER_IDENTIFIER)): - def StreamingOutputCall(self, request): - return servicer_methods.StreamingOutputCall(request) + def UnaryCall(self, request, context): + return servicer_methods.UnaryCall(request, context) - def StreamingInputCall(self, request_iter): - return servicer_methods.StreamingInputCall(request_iter) + def StreamingOutputCall(self, request, context): + return servicer_methods.StreamingOutputCall(request, context) - def FullDuplexCall(self, request_iter): - return servicer_methods.FullDuplexCall(request_iter) + def StreamingInputCall(self, request_iter, context): + return servicer_methods.StreamingInputCall(request_iter, context) - def HalfDuplexCall(self, request_iter): - return servicer_methods.HalfDuplexCall(request_iter) + def FullDuplexCall(self, request_iter, context): + return servicer_methods.FullDuplexCall(request_iter, context) + + def HalfDuplexCall(self, request_iter, context): + return servicer_methods.HalfDuplexCall(request_iter, context) - servicer_methods = _ServicerMethods(test_pb2, delay) servicer = Servicer() - linked_pair = test_pb2.mock_TestService(servicer, timeout) - stub = linked_pair.stub - return servicer_methods, stub + server = getattr( + test_pb2, SERVER_FACTORY_IDENTIFIER)(servicer, 0, None, None) + with server: + port = server.port() + stub = getattr(test_pb2, STUB_FACTORY_IDENTIFIER)('localhost', port) + with stub: + yield servicer_methods, stub, server def StreamingInputRequest(test_pb2): @@ -198,19 +221,20 @@ class PythonPluginTest(unittest.TestCase): def setUp(self): protoc_command = '../../bins/%s/protobuf/protoc' % _build_mode protoc_plugin_filename = '../../bins/%s/grpc_python_plugin' % _build_mode - test_proto_filename = '../cpp/interop/test.proto' + test_proto_filename = './test.proto' if not os.path.isfile(protoc_command): # Assume that if we haven't built protoc that it's on the system. protoc_command = 'protoc' - # ensure that the output directory exists - outdir = '../../gens/test/compiler/python/' + # Ensure that the output directory exists. + outdir = '../../gens/test/compiler/python' try: os.makedirs(outdir) except OSError as exception: if exception.errno != errno.EEXIST: raise + # Invoke protoc with the plugin. cmd = [ protoc_command, '--plugin=protoc-gen-python-grpc=%s' % protoc_plugin_filename, @@ -222,232 +246,239 @@ class PythonPluginTest(unittest.TestCase): subprocess.call(' '.join(cmd), shell=True) sys.path.append(outdir) - self.delay = 1 # seconds - self.timeout = 2 # seconds + # TODO(atash): Figure out which of theses tests is hanging flakily with small + # probability. def testImportAttributes(self): - # check that we can access the members + # check that we can access the generated module and its members. import test_pb2 # pylint: disable=g-import-not-at-top - self.assertIsNotNone(getattr(test_pb2, 'TestServiceServicer', None)) - self.assertIsNotNone(getattr(test_pb2, 'TestServiceService', None)) - self.assertIsNotNone(getattr(test_pb2, 'TestServiceStub', None)) + self.assertIsNotNone(getattr(test_pb2, SERVICER_IDENTIFIER, None)) + self.assertIsNotNone(getattr(test_pb2, SERVER_IDENTIFIER, None)) + self.assertIsNotNone(getattr(test_pb2, STUB_IDENTIFIER, None)) + self.assertIsNotNone(getattr(test_pb2, SERVER_FACTORY_IDENTIFIER, None)) + self.assertIsNotNone(getattr(test_pb2, STUB_FACTORY_IDENTIFIER, None)) + + def testUpDown(self): + import test_pb2 + with _CreateService( + test_pb2, DOES_NOT_MATTER_DELAY) as (servicer, stub, unused_server): + request = test_pb2.SimpleRequest(response_size=13) def testUnaryCall(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - request = test_pb2.SimpleRequest(response_size=13) - response = stub.UnaryCall(request) - expected_response = servicer.UnaryCall(request) + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + request = test_pb2.SimpleRequest(response_size=13) + response = stub.UnaryCall(request, NORMAL_TIMEOUT) + expected_response = servicer.UnaryCall(request, None) self.assertEqual(expected_response, response) def testUnaryCallAsync(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService( - test_pb2, delay=self.delay, timeout=self.timeout) request = test_pb2.SimpleRequest(response_size=13) - # TODO(atash): consider using the 'profile' module? Does it even work here? - start_time = time.clock() - response_future = stub.UnaryCall.async(request) - self.assertGreater(self.delay, time.clock() - start_time) - response = response_future.result() - expected_response = servicer.UnaryCall(request) + with _CreateService(test_pb2, LONG_DELAY) as ( + servicer, stub, unused_server): + start_time = time.clock() + response_future = stub.UnaryCall.async(request, LONG_TIMEOUT) + # Check that we didn't block on the asynchronous call. + self.assertGreater(LONG_DELAY, time.clock() - start_time) + response = response_future.result() + expected_response = servicer.UnaryCall(request, None) self.assertEqual(expected_response, response) def testUnaryCallAsyncExpired(self): import test_pb2 # pylint: disable=g-import-not-at-top # set the timeout super low... - servicer, stub = CreateService(test_pb2, delay=1, timeout=0.1) - request = test_pb2.SimpleRequest(response_size=13) - with servicer.pause(): - response_future = stub.UnaryCall.async(request) - with self.assertRaises(exceptions.ExpirationError): - response_future.result() + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + request = test_pb2.SimpleRequest(response_size=13) + with servicer.pause(): + response_future = stub.UnaryCall.async(request, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + response_future.result() def testUnaryCallAsyncCancelled(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) request = test_pb2.SimpleRequest(response_size=13) - with servicer.pause(): - response_future = stub.UnaryCall.async(request) - response_future.cancel() - self.assertTrue(response_future.cancelled()) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.pause(): + response_future = stub.UnaryCall.async(request, 1) + response_future.cancel() + self.assertTrue(response_future.cancelled()) def testUnaryCallAsyncFailed(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) request = test_pb2.SimpleRequest(response_size=13) - with servicer.fail(): - response_future = stub.UnaryCall.async(request) - self.assertIsNotNone(response_future.exception()) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.fail(): + response_future = stub.UnaryCall.async(request, NORMAL_TIMEOUT) + self.assertIsNotNone(response_future.exception()) def testStreamingOutputCall(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) request = StreamingOutputRequest(test_pb2) - responses = stub.StreamingOutputCall(request) - expected_responses = servicer.StreamingOutputCall(request) - for check in itertools.izip_longest(expected_responses, responses): - expected_response, response = check - self.assertEqual(expected_response, response) - - def testStreamingOutputCallAsync(self): + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + responses = stub.StreamingOutputCall(request, NORMAL_TIMEOUT) + expected_responses = servicer.StreamingOutputCall(request, None) + for check in itertools.izip_longest(expected_responses, responses): + expected_response, response = check + self.assertEqual(expected_response, response) + + def testStreamingOutputCallExpired(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=self.timeout) request = StreamingOutputRequest(test_pb2) - responses = stub.StreamingOutputCall.async(request) - expected_responses = servicer.StreamingOutputCall(request) - for check in itertools.izip_longest(expected_responses, responses): - expected_response, response = check - self.assertEqual(expected_response, response) - - def testStreamingOutputCallAsyncExpired(self): - import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=0.1) - request = StreamingOutputRequest(test_pb2) - with servicer.pause(): - responses = stub.StreamingOutputCall.async(request) - with self.assertRaises(exceptions.ExpirationError): - list(responses) - - def testStreamingOutputCallAsyncCancelled(self): + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.pause(): + responses = stub.StreamingOutputCall(request, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + list(responses) + + def testStreamingOutputCallCancelled(self): import test_pb2 # pylint: disable=g-import-not-at-top - _, stub = CreateService(test_pb2, timeout=0.1) request = StreamingOutputRequest(test_pb2) - responses = stub.StreamingOutputCall.async(request) - next(responses) - responses.cancel() - with self.assertRaises(future.CancelledError): + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + unused_servicer, stub, unused_server): + responses = stub.StreamingOutputCall(request, SHORT_TIMEOUT) next(responses) + responses.cancel() + with self.assertRaises(future.CancelledError): + next(responses) - def testStreamingOutputCallAsyncFailed(self): + @unittest.skip('TODO(atash,nathaniel): figure out why this times out ' + 'instead of raising the proper error.') + def testStreamingOutputCallFailed(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=0.1) request = StreamingOutputRequest(test_pb2) - with servicer.fail(): - responses = stub.StreamingOutputCall.async(request) - self.assertIsNotNone(responses) - with self.assertRaises(exceptions.ServicerError): - next(responses) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.fail(): + responses = stub.StreamingOutputCall(request, 1) + self.assertIsNotNone(responses) + with self.assertRaises(exceptions.ServicerError): + next(responses) def testStreamingInputCall(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - response = stub.StreamingInputCall(StreamingInputRequest(test_pb2)) + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + response = stub.StreamingInputCall(StreamingInputRequest(test_pb2), + NORMAL_TIMEOUT) expected_response = servicer.StreamingInputCall( - StreamingInputRequest(test_pb2)) + StreamingInputRequest(test_pb2), None) self.assertEqual(expected_response, response) def testStreamingInputCallAsync(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService( - test_pb2, delay=self.delay, timeout=self.timeout) - start_time = time.clock() - response_future = stub.StreamingInputCall.async( - StreamingInputRequest(test_pb2)) - self.assertGreater(self.delay, time.clock() - start_time) - response = response_future.result() + with _CreateService(test_pb2, LONG_DELAY) as ( + servicer, stub, unused_server): + start_time = time.clock() + response_future = stub.StreamingInputCall.async( + StreamingInputRequest(test_pb2), LONG_TIMEOUT) + self.assertGreater(LONG_DELAY, time.clock() - start_time) + response = response_future.result() expected_response = servicer.StreamingInputCall( - StreamingInputRequest(test_pb2)) + StreamingInputRequest(test_pb2), None) self.assertEqual(expected_response, response) def testStreamingInputCallAsyncExpired(self): import test_pb2 # pylint: disable=g-import-not-at-top # set the timeout super low... - servicer, stub = CreateService(test_pb2, delay=1, timeout=0.1) - with servicer.pause(): - response_future = stub.StreamingInputCall.async( - StreamingInputRequest(test_pb2)) - with self.assertRaises(exceptions.ExpirationError): - response_future.result() - self.assertIsInstance( - response_future.exception(), exceptions.ExpirationError) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.pause(): + response_future = stub.StreamingInputCall.async( + StreamingInputRequest(test_pb2), SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + response_future.result() + self.assertIsInstance( + response_future.exception(), exceptions.ExpirationError) def testStreamingInputCallAsyncCancelled(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - with servicer.pause(): - response_future = stub.StreamingInputCall.async( - StreamingInputRequest(test_pb2)) - response_future.cancel() - self.assertTrue(response_future.cancelled()) - with self.assertRaises(future.CancelledError): - response_future.result() + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.pause(): + response_future = stub.StreamingInputCall.async( + StreamingInputRequest(test_pb2), NORMAL_TIMEOUT) + response_future.cancel() + self.assertTrue(response_future.cancelled()) + with self.assertRaises(future.CancelledError): + response_future.result() def testStreamingInputCallAsyncFailed(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - with servicer.fail(): - response_future = stub.StreamingInputCall.async( - StreamingInputRequest(test_pb2)) - self.assertIsNotNone(response_future.exception()) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.fail(): + response_future = stub.StreamingInputCall.async( + StreamingInputRequest(test_pb2), SHORT_TIMEOUT) + self.assertIsNotNone(response_future.exception()) def testFullDuplexCall(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - responses = stub.FullDuplexCall(FullDuplexRequest(test_pb2)) - expected_responses = servicer.FullDuplexCall(FullDuplexRequest(test_pb2)) - for check in itertools.izip_longest(expected_responses, responses): - expected_response, response = check - self.assertEqual(expected_response, response) - - def testFullDuplexCallAsync(self): - import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=self.timeout) - responses = stub.FullDuplexCall.async(FullDuplexRequest(test_pb2)) - expected_responses = servicer.FullDuplexCall(FullDuplexRequest(test_pb2)) - for check in itertools.izip_longest(expected_responses, responses): - expected_response, response = check - self.assertEqual(expected_response, response) - - def testFullDuplexCallAsyncExpired(self): + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + responses = stub.FullDuplexCall(FullDuplexRequest(test_pb2), + NORMAL_TIMEOUT) + expected_responses = servicer.FullDuplexCall(FullDuplexRequest(test_pb2), + None) + for check in itertools.izip_longest(expected_responses, responses): + expected_response, response = check + self.assertEqual(expected_response, response) + + def testFullDuplexCallExpired(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=0.1) request = FullDuplexRequest(test_pb2) - with servicer.pause(): - responses = stub.FullDuplexCall.async(request) - with self.assertRaises(exceptions.ExpirationError): - list(responses) - - def testFullDuplexCallAsyncCancelled(self): + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.pause(): + responses = stub.FullDuplexCall(request, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + list(responses) + + def testFullDuplexCallCancelled(self): import test_pb2 # pylint: disable=g-import-not-at-top - _, stub = CreateService(test_pb2, timeout=0.1) - request = FullDuplexRequest(test_pb2) - responses = stub.FullDuplexCall.async(request) - next(responses) - responses.cancel() - with self.assertRaises(future.CancelledError): + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + request = FullDuplexRequest(test_pb2) + responses = stub.FullDuplexCall(request, NORMAL_TIMEOUT) next(responses) + responses.cancel() + with self.assertRaises(future.CancelledError): + next(responses) - def testFullDuplexCallAsyncFailed(self): + @unittest.skip('TODO(atash,nathaniel): figure out why this hangs forever ' + 'and fix.') + def testFullDuplexCallFailed(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2, timeout=0.1) request = FullDuplexRequest(test_pb2) - with servicer.fail(): - responses = stub.FullDuplexCall.async(request) - self.assertIsNotNone(responses) - with self.assertRaises(exceptions.ServicerError): - next(responses) + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + with servicer.fail(): + responses = stub.FullDuplexCall(request, NORMAL_TIMEOUT) + self.assertIsNotNone(responses) + with self.assertRaises(exceptions.ServicerError): + next(responses) def testHalfDuplexCall(self): import test_pb2 # pylint: disable=g-import-not-at-top - servicer, stub = CreateService(test_pb2) - def HalfDuplexRequest(): - request = test_pb2.StreamingOutputCallRequest() - request.response_parameters.add(size=1, interval_us=0) - yield request - request = test_pb2.StreamingOutputCallRequest() - request.response_parameters.add(size=2, interval_us=0) - request.response_parameters.add(size=3, interval_us=0) - yield request - responses = stub.HalfDuplexCall(HalfDuplexRequest()) - expected_responses = servicer.HalfDuplexCall(HalfDuplexRequest()) - for check in itertools.izip_longest(expected_responses, responses): - expected_response, response = check - self.assertEqual(expected_response, response) - - def testHalfDuplexCallAsyncWedged(self): + with _CreateService(test_pb2, DOES_NOT_MATTER_DELAY) as ( + servicer, stub, unused_server): + def HalfDuplexRequest(): + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=2, interval_us=0) + request.response_parameters.add(size=3, interval_us=0) + yield request + responses = stub.HalfDuplexCall(HalfDuplexRequest(), NORMAL_TIMEOUT) + expected_responses = servicer.HalfDuplexCall(HalfDuplexRequest(), None) + for check in itertools.izip_longest(expected_responses, responses): + expected_response, response = check + self.assertEqual(expected_response, response) + + def testHalfDuplexCallWedged(self): import test_pb2 # pylint: disable=g-import-not-at-top - _, stub = CreateService(test_pb2, timeout=1) wait_flag = [False] @contextlib.contextmanager def wait(): # pylint: disable=invalid-name @@ -461,19 +492,23 @@ class PythonPluginTest(unittest.TestCase): yield request while wait_flag[0]: time.sleep(0.1) - with wait(): - responses = stub.HalfDuplexCall.async(HalfDuplexRequest()) - # half-duplex waits for the client to send all info - with self.assertRaises(exceptions.ExpirationError): - next(responses) + with _CreateService(test_pb2, NO_DELAY) as (servicer, stub, unused_server): + with wait(): + responses = stub.HalfDuplexCall(HalfDuplexRequest(), NORMAL_TIMEOUT) + # half-duplex waits for the client to send all info + with self.assertRaises(exceptions.ExpirationError): + next(responses) if __name__ == '__main__': os.chdir(os.path.dirname(sys.argv[0])) - parser = argparse.ArgumentParser(description='Run Python compiler plugin test.') - parser.add_argument('--build_mode', dest='build_mode', type=str, default='dbg', - help='The build mode of the targets to test, e.g. ' - '"dbg", "opt", "asan", etc.') + parser = argparse.ArgumentParser( + description='Run Python compiler plugin test.') + parser.add_argument( + '--build_mode', dest='build_mode', type=str, default='dbg', + help='The build mode of the targets to test, e.g. "dbg", "opt", "asan", ' + 'etc.') + parser.add_argument('--port', dest='port', type=int, default=0) args, remainder = parser.parse_known_args() _build_mode = args.build_mode sys.argv[1:] = remainder diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 59a4564220b..e92db592493 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -77,10 +77,10 @@ static void channel_func(grpc_channel_element *elem, } static void test_create_channel_stack(void) { - const grpc_channel_filter - filter = {call_func, channel_func, sizeof(int), - call_init_func, call_destroy_func, sizeof(int), - channel_init_func, channel_destroy_func, "some_test_filter" }; + const grpc_channel_filter filter = { + call_func, channel_func, sizeof(int), + call_init_func, call_destroy_func, sizeof(int), + channel_init_func, channel_destroy_func, "some_test_filter"}; const grpc_channel_filter *filters = &filter; grpc_channel_stack *channel_stack; grpc_call_stack *call_stack; diff --git a/test/core/channel/metadata_buffer_test.c b/test/core/channel/metadata_buffer_test.c index ba8100b7d2f..4fc434f9a5d 100644 --- a/test/core/channel/metadata_buffer_test.c +++ b/test/core/channel/metadata_buffer_test.c @@ -110,14 +110,14 @@ static void init_channel_elem(grpc_channel_element *elem, static void destroy_channel_elem(grpc_channel_element *elem) {} static const grpc_channel_filter top_filter = { - fail_call_op, fail_channel_op, sizeof(size_t), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "top_filter" }; + fail_call_op, fail_channel_op, sizeof(size_t), + init_call_elem, destroy_call_elem, sizeof(channel_data), + init_channel_elem, destroy_channel_elem, "top_filter"}; static const grpc_channel_filter bottom_filter = { - expect_call_op, fail_channel_op, sizeof(size_t), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "bottom_filter" }; + expect_call_op, fail_channel_op, sizeof(size_t), + init_call_elem, destroy_call_elem, sizeof(channel_data), + init_channel_elem, destroy_channel_elem, "bottom_filter"}; static const grpc_channel_filter *filters[2] = {&top_filter, &bottom_filter}; @@ -149,7 +149,7 @@ static void test_case(size_t key_prefix_len, size_t value_prefix_len, op.flags = i; op.data.metadata = grpc_mdelem_from_slices(mdctx, key, value); op.done_cb = do_nothing; - op.user_data = (void *)(gpr_uintptr)i; + op.user_data = (void *)(gpr_uintptr) i; grpc_metadata_buffer_queue(&buffer, &op); } diff --git a/test/core/echo/client.c b/test/core/echo/client.c index fb1e366b15b..f2b69ec3203 100644 --- a/test/core/echo/client.c +++ b/test/core/echo/client.c @@ -78,9 +78,8 @@ int main(int argc, char **argv) { GPR_ASSERT(argc == 2); channel = grpc_channel_create(argv[1], NULL); - call = grpc_channel_create_call_old( - channel, "/foo", "localhost", - gpr_time_add(gpr_time_from_seconds(5), gpr_now())); + call = grpc_channel_create_call_old(channel, "/foo", "localhost", + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)); GPR_ASSERT(grpc_call_invoke_old(call, cq, (void *)1, (void *)1, 0) == GRPC_CALL_OK); diff --git a/test/core/echo/server.c b/test/core/echo/server.c index 83da8b644d6..bc84645a040 100644 --- a/test/core/echo/server.c +++ b/test/core/echo/server.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(), gpr_time_from_micros(1000000))); + cq, gpr_time_add(gpr_now(), gpr_time_from_seconds(1))); if (!ev) continue; s = ev->tag; switch (ev->type) { diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 9ed98a43457..9369dfd7ec6 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -116,7 +116,8 @@ static int has_metadata(const grpc_metadata *md, size_t count, const char *key, return 0; } -int contains_metadata(grpc_metadata_array *array, const char *key, const char *value) { +int contains_metadata(grpc_metadata_array *array, const char *key, + const char *value) { return has_metadata(array->metadata, array->count, key, value); } @@ -327,8 +328,7 @@ static void fail_no_event_received(cq_verifier *v) { } void cq_verify(cq_verifier *v) { - gpr_timespec deadline = - gpr_time_add(gpr_now(), gpr_time_from_micros(10 * GPR_US_PER_SEC)); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); grpc_event *ev; expectation *e; char *s; @@ -371,8 +371,7 @@ void cq_verify(cq_verifier *v) { } void cq_verify_empty(cq_verifier *v) { - gpr_timespec deadline = - gpr_time_add(gpr_now(), gpr_time_from_micros(3000000)); + gpr_timespec deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(1)); grpc_event *ev; GPR_ASSERT(v->expect.next == &v->expect && "expectation queue must be empty"); diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index ad6481102e7..c1e25d8aa40 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -31,10 +31,11 @@ * */ -#ifndef __GRPC_TEST_END2END_CQ_VERIFIER_H__ -#define __GRPC_TEST_END2END_CQ_VERIFIER_H__ +#ifndef GRPC_TEST_CORE_END2END_CQ_VERIFIER_H +#define GRPC_TEST_CORE_END2END_CQ_VERIFIER_H #include +#include "test/core/util/test_config.h" /* A cq_verifier can verify that expected events arrive in a timely fashion on a single completion queue */ @@ -75,4 +76,4 @@ void cq_expect_server_shutdown(cq_verifier *v, void *tag); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, const char *value); -#endif /* __GRPC_TEST_END2END_CQ_VERIFIER_H__ */ +#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h index 41248670d62..4f4b30ef211 100644 --- a/test/core/end2end/data/ssl_test_data.h +++ b/test/core/end2end/data/ssl_test_data.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__ -#define __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__ +#ifndef GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H +#define GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H extern const char test_root_cert[]; extern const char test_server1_cert[]; extern const char test_server1_key[]; -#endif /* __GRPC_TEST_END2END_DATA_SSL_TEST_DATA_H__ */ +#endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 62676d01e09..66b76dc0523 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -45,7 +45,7 @@ static void *tag(gpr_intptr i) { return (void *)i; } static gpr_timespec ms_from_now(int ms) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_MS * ms)); + return GRPC_TIMEOUT_MILLIS_TO_DEADLINE(ms); } static void drain_cq(grpc_completion_queue *cq) { @@ -75,6 +75,10 @@ void test_connect(const char *server_host, const char *client_host, int port, gpr_timespec deadline; int got_port; + if (port == 0) { + port = grpc_pick_unused_port_or_die(); + } + gpr_join_host_port(&server_hostport, server_host, port); /* Create server. */ @@ -179,7 +183,6 @@ void test_connect(const char *server_host, const char *client_host, int port, int main(int argc, char **argv) { int do_ipv6 = 1; - int fixed_port; grpc_test_init(argc, argv); grpc_init(); @@ -189,32 +192,28 @@ int main(int argc, char **argv) { do_ipv6 = 0; } - for (fixed_port = 0; fixed_port <= 1; fixed_port++) { - int port = fixed_port ? grpc_pick_unused_port_or_die() : 0; - /* For coverage, test with and without dualstack sockets. */ - for (grpc_forbid_dualstack_sockets_for_testing = 0; - grpc_forbid_dualstack_sockets_for_testing <= 1; - grpc_forbid_dualstack_sockets_for_testing++) { - /* :: and 0.0.0.0 are handled identically. */ - test_connect("::", "127.0.0.1", port, 1); - test_connect("::", "::ffff:127.0.0.1", port, 1); - test_connect("::", "localhost", port, 1); - test_connect("0.0.0.0", "127.0.0.1", port, 1); - test_connect("0.0.0.0", "::ffff:127.0.0.1", port, 1); - test_connect("0.0.0.0", "localhost", port, 1); - if (do_ipv6) { - test_connect("::", "::1", port, 1); - test_connect("0.0.0.0", "::1", port, 1); - } - - /* These only work when the families agree. */ - test_connect("127.0.0.1", "127.0.0.1", port, 1); - if (do_ipv6) { - test_connect("::1", "::1", port, 1); - test_connect("::1", "127.0.0.1", port, 0); - test_connect("127.0.0.1", "::1", port, 0); - } + for (grpc_forbid_dualstack_sockets_for_testing = 0; + grpc_forbid_dualstack_sockets_for_testing <= 1; + grpc_forbid_dualstack_sockets_for_testing++) { + /* :: and 0.0.0.0 are handled identically. */ + test_connect("::", "127.0.0.1", 0, 1); + test_connect("::", "::ffff:127.0.0.1", 0, 1); + test_connect("::", "localhost", 0, 1); + test_connect("0.0.0.0", "127.0.0.1", 0, 1); + test_connect("0.0.0.0", "::ffff:127.0.0.1", 0, 1); + test_connect("0.0.0.0", "localhost", 0, 1); + if (do_ipv6) { + test_connect("::", "::1", 0, 1); + test_connect("0.0.0.0", "::1", 0, 1); + } + + /* These only work when the families agree. */ + test_connect("127.0.0.1", "127.0.0.1", 0, 1); + if (do_ipv6) { + test_connect("::1", "::1", 0, 1); + test_connect("::1", "127.0.0.1", 0, 0); + test_connect("127.0.0.1", "::1", 0, 0); } } diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 8f2cd0f2e05..b6d93252eb2 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_END2END_END2END_TESTS_H__ -#define __GRPC_TEST_END2END_END2END_TESTS_H__ +#ifndef GRPC_TEST_CORE_END2END_END2END_TESTS_H +#define GRPC_TEST_CORE_END2END_END2END_TESTS_H #include @@ -63,4 +63,4 @@ struct grpc_end2end_test_config { void grpc_end2end_tests(grpc_end2end_test_config config); -#endif /* __GRPC_TEST_END2END_END2END_TESTS_H__ */ +#endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/fixtures/chttp2_fake_security.c b/test/core/end2end/fixtures/chttp2_fake_security.c index 039909f76cb..247d1fd3223 100644 --- a/test/core/end2end/fixtures/chttp2_fake_security.c +++ b/test/core/end2end/fixtures/chttp2_fake_security.c @@ -117,7 +117,8 @@ static grpc_end2end_test_config configs[] = { chttp2_create_fixture_secure_fullstack, chttp2_init_client_fake_secure_fullstack, chttp2_init_server_fake_secure_fullstack, - chttp2_tear_down_secure_fullstack}, }; + chttp2_tear_down_secure_fullstack}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/fixtures/chttp2_fullstack.c b/test/core/end2end/fixtures/chttp2_fullstack.c index ea367f4446b..ab7c7f4caa9 100644 --- a/test/core/end2end/fixtures/chttp2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_fullstack.c @@ -99,7 +99,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { static grpc_end2end_test_config configs[] = { {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c index 9343eb5a427..16946d5f97e 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c @@ -101,8 +101,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *ssl_creds = - grpc_ssl_credentials_create(NULL, NULL); + grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; @@ -128,7 +127,8 @@ static grpc_end2end_test_config configs[] = { chttp2_create_fixture_secure_fullstack, chttp2_init_client_simple_ssl_secure_fullstack, chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, }; + chttp2_tear_down_secure_fullstack}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c index 9fb95c95d9d..c451e01024a 100644 --- a/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c +++ b/test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c @@ -133,7 +133,8 @@ static grpc_end2end_test_config configs[] = { chttp2_create_fixture_secure_fullstack, chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack, chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, }; + chttp2_tear_down_secure_fullstack}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/fixtures/chttp2_socket_pair.c b/test/core/end2end/fixtures/chttp2_socket_pair.c index 759c6b4b9d7..1225f7db0c2 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair.c @@ -133,7 +133,8 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { static grpc_end2end_test_config configs[] = { {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, chttp2_init_server_socketpair, - chttp2_tear_down_socketpair}, }; + chttp2_tear_down_socketpair}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c index c814527a8f0..9f6ad980063 100644 --- a/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c +++ b/test/core/end2end/fixtures/chttp2_socket_pair_one_byte_at_a_time.c @@ -133,7 +133,8 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { static grpc_end2end_test_config configs[] = { {"chttp2/socketpair_one_byte_at_a_time", 0, chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, - chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; + chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, +}; int main(int argc, char **argv) { size_t i; diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 92e8e5ad6bf..d953552c0a2 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -41,8 +41,7 @@ static void *tag(gpr_intptr i) { return (void *)i; } int main(int argc, char **argv) { grpc_channel *chan; grpc_call *call; - gpr_timespec timeout = gpr_time_from_seconds(4); - gpr_timespec deadline = gpr_time_add(gpr_now(), timeout); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); grpc_completion_queue *cq; cq_verifier *cqv; grpc_event *ev; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 1aeb723553a..9a19abf676f 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -163,11 +163,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1))); - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, - &call_details, - &request_metadata_recv, - f.server_cq, - tag(2))); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s, &call_details, + &request_metadata_recv, f.server_cq, tag(2))); cq_expect_completion(v_server, tag(2), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c index a69f86a3271..f360fa31a48 100644 --- a/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c +++ b/test/core/end2end/tests/cancel_after_accept_and_writes_closed.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -121,8 +121,8 @@ static void test_cancel_after_accept_and_writes_closed( grpc_call_invoke_old(c, f.client_cq, tag(2), tag(3), 0)); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/cancel_after_accept_and_writes_closed_legacy.c b/test/core/end2end/tests/cancel_after_accept_and_writes_closed_legacy.c index 6a3a6528b90..f360fa31a48 100644 --- a/test/core/end2end/tests/cancel_after_accept_and_writes_closed_legacy.c +++ b/test/core/end2end/tests/cancel_after_accept_and_writes_closed_legacy.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_after_accept_legacy.c b/test/core/end2end/tests/cancel_after_accept_legacy.c index 15338b5c7ad..904a06f8a18 100644 --- a/test/core/end2end/tests/cancel_after_accept_legacy.c +++ b/test/core/end2end/tests/cancel_after_accept_legacy.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 71d241ffee9..e15fa7fcd91 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_after_invoke_legacy.c b/test/core/end2end/tests/cancel_after_invoke_legacy.c index 092b35d0a9a..6ad471d6613 100644 --- a/test/core/end2end/tests/cancel_after_invoke_legacy.c +++ b/test/core/end2end/tests/cancel_after_invoke_legacy.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 0ab9ac6c2f2..6e100db1853 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -103,7 +103,8 @@ static void end_test(grpc_end2end_test_fixture *f) { } /* Cancel before invoke */ -static void test_cancel_before_invoke(grpc_end2end_test_config config, int test_ops) { +static void test_cancel_before_invoke(grpc_end2end_test_config config, + int test_ops) { grpc_op ops[6]; grpc_op *op; grpc_call *c; diff --git a/test/core/end2end/tests/cancel_before_invoke_legacy.c b/test/core/end2end/tests/cancel_before_invoke_legacy.c index 0c308acde03..c8db3d256cf 100644 --- a/test/core/end2end/tests/cancel_before_invoke_legacy.c +++ b/test/core/end2end/tests/cancel_before_invoke_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 6cb87525d00..a88ca0b5b7a 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum_legacy.c b/test/core/end2end/tests/cancel_in_a_vacuum_legacy.c index cc6297b1337..a827eed72c6 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum_legacy.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum_legacy.c @@ -60,7 +60,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index 3dd74373531..f2581dc32ff 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_END2END_TESTS_CANCEL_TEST_HELPERS_H__ -#define __GRPC_TEST_END2END_TESTS_CANCEL_TEST_HELPERS_H__ +#ifndef GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H +#define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H typedef struct { grpc_call_error (*initiate_cancel)(grpc_call *call); @@ -48,4 +48,4 @@ static const cancellation_mode cancellation_modes[] = { {grpc_call_cancel, GRPC_STATUS_CANCELLED, ""}, {wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, "Deadline Exceeded"}, }; -#endif +#endif /* GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H */ diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c index 98244db5412..dabdc56ed3b 100644 --- a/test/core/end2end/tests/census_simple_request.c +++ b/test/core/end2end/tests/census_simple_request.c @@ -46,7 +46,7 @@ #include "test/core/end2end/cq_verifier.h" static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/census_simple_request_legacy.c b/test/core/end2end/tests/census_simple_request_legacy.c index 98244db5412..dabdc56ed3b 100644 --- a/test/core/end2end/tests/census_simple_request_legacy.c +++ b/test/core/end2end/tests/census_simple_request_legacy.c @@ -46,7 +46,7 @@ #include "test/core/end2end/cq_verifier.h" static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index d5d1550f903..a65a9f37f56 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; static void *tag(gpr_intptr t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -109,8 +109,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f->server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/disappearing_server_legacy.c b/test/core/end2end/tests/disappearing_server_legacy.c index 7dd6804b380..a65a9f37f56 100644 --- a/test/core/end2end/tests/disappearing_server_legacy.c +++ b/test/core/end2end/tests/disappearing_server_legacy.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; static void *tag(gpr_intptr t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c index d65617c4735..16ed627f378 100644 --- a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c +++ b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -123,8 +123,8 @@ static void test_early_server_shutdown_finishes_inflight_calls( cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls_legacy.c b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls_legacy.c index 09ddfc1671a..16ed627f378 100644 --- a/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls_legacy.c +++ b/test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_tags.c b/test/core/end2end/tests/early_server_shutdown_finishes_tags.c index 49dddc79759..061a2d335c2 100644 --- a/test/core/end2end/tests/early_server_shutdown_finishes_tags.c +++ b/test/core/end2end/tests/early_server_shutdown_finishes_tags.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/early_server_shutdown_finishes_tags_legacy.c b/test/core/end2end/tests/early_server_shutdown_finishes_tags_legacy.c index ed8f839a973..bb0ef92542a 100644 --- a/test/core/end2end/tests/early_server_shutdown_finishes_tags_legacy.c +++ b/test/core/end2end/tests/early_server_shutdown_finishes_tags_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index de22518301b..6237e29b12a 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -63,7 +63,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 9227d3bd463..39830b0b4b4 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -122,8 +122,8 @@ static void test_early_server_shutdown_finishes_inflight_calls( cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/graceful_server_shutdown_legacy.c b/test/core/end2end/tests/graceful_server_shutdown_legacy.c index 19c895eaa28..39830b0b4b4 100644 --- a/test/core/end2end/tests/graceful_server_shutdown_legacy.c +++ b/test/core/end2end/tests/graceful_server_shutdown_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 86a0fbdb70d..55606ca6a72 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static void drain_cq(grpc_completion_queue *cq) { @@ -138,8 +138,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { request (as this request is very large) */ cq_verify_empty(v_client); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/invoke_large_request_legacy.c b/test/core/end2end/tests/invoke_large_request_legacy.c index d0a1cebfcb4..55606ca6a72 100644 --- a/test/core/end2end/tests/invoke_large_request_legacy.c +++ b/test/core/end2end/tests/invoke_large_request_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static void drain_cq(grpc_completion_queue *cq) { diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 743048881d7..af29e172bb7 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -121,8 +121,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) { cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == @@ -196,7 +196,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_invoke_old(c2, f.client_cq, tag(401), tag(402), 0)); GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c1, tag(303))); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c2, tag(303))); + GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c2, tag(403))); ev = grpc_completion_queue_next( f.client_cq, gpr_time_add(gpr_now(), gpr_time_from_seconds(10))); @@ -230,8 +230,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { /* first request is finished, we should be able to start the second */ cq_expect_finished_with_status(v_client, tag(live_call + 2), GRPC_STATUS_UNIMPLEMENTED, "xyz", NULL); - cq_expect_finish_accepted(v_client, tag(live_call + 3), GRPC_OP_OK); live_call = (live_call == 300) ? 400 : 300; + cq_expect_finish_accepted(v_client, tag(live_call + 3), GRPC_OP_OK); cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(200))); diff --git a/test/core/end2end/tests/max_concurrent_streams_legacy.c b/test/core/end2end/tests/max_concurrent_streams_legacy.c index 8bf11543878..af29e172bb7 100644 --- a/test/core/end2end/tests/max_concurrent_streams_legacy.c +++ b/test/core/end2end/tests/max_concurrent_streams_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -196,7 +196,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_invoke_old(c2, f.client_cq, tag(401), tag(402), 0)); GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c1, tag(303))); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c2, tag(303))); + GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c2, tag(403))); ev = grpc_completion_queue_next( f.client_cq, gpr_time_add(gpr_now(), gpr_time_from_seconds(10))); @@ -230,8 +230,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { /* first request is finished, we should be able to start the second */ cq_expect_finished_with_status(v_client, tag(live_call + 2), GRPC_STATUS_UNIMPLEMENTED, "xyz", NULL); - cq_expect_finish_accepted(v_client, tag(live_call + 3), GRPC_OP_OK); live_call = (live_call == 300) ? 400 : 300; + cq_expect_finish_accepted(v_client, tag(live_call + 3), GRPC_OP_OK); cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(200))); diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 00d940ddb54..497bdccdbd0 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/no_op_legacy.c b/test/core/end2end/tests/no_op_legacy.c index 00d940ddb54..497bdccdbd0 100644 --- a/test/core/end2end/tests/no_op_legacy.c +++ b/test/core/end2end/tests/no_op_legacy.c @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 06a029eb650..23721e91338 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -127,8 +127,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_accept_old(s, f.server_cq, tag(102))); diff --git a/test/core/end2end/tests/ping_pong_streaming_legacy.c b/test/core/end2end/tests/ping_pong_streaming_legacy.c index b4175b4d095..23721e91338 100644 --- a/test/core/end2end/tests/ping_pong_streaming_legacy.c +++ b/test/core/end2end/tests/ping_pong_streaming_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c index 45b2ea3e823..a120f275968 100644 --- a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -175,8 +175,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload_legacy.c b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload_legacy.c index be74e8bdce9..75fddeacb1f 100644 --- a/test/core/end2end/tests/request_response_with_binary_metadata_and_payload_legacy.c +++ b/test/core/end2end/tests/request_response_with_binary_metadata_and_payload_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -157,9 +157,10 @@ static void test_request_response_with_metadata_and_payload( cq_verify(v_client); cq_expect_server_rpc_new( - v_server, &s, tag(100), "/foo", "foo.test.google.fr", deadline, "key1-bin", - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", "key2-bin", - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", NULL); + v_server, &s, tag(100), "/foo", "foo.test.google.fr", deadline, + "key1-bin", "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", + "key2-bin", "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", + NULL); cq_verify(v_server); grpc_call_server_accept_old(s, f.server_cq, tag(102)); diff --git a/test/core/end2end/tests/request_response_with_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_metadata_and_payload.c index 1675a9e5377..d5f58d33b87 100644 --- a/test/core/end2end/tests/request_response_with_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_metadata_and_payload.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -168,8 +168,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_response_with_metadata_and_payload_legacy.c b/test/core/end2end/tests/request_response_with_metadata_and_payload_legacy.c index 5c0b9d5b12f..91a0442d268 100644 --- a/test/core/end2end/tests/request_response_with_metadata_and_payload_legacy.c +++ b/test/core/end2end/tests/request_response_with_metadata_and_payload_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/request_response_with_payload.c b/test/core/end2end/tests/request_response_with_payload.c index 16f07c7107b..92036590a77 100644 --- a/test/core/end2end/tests/request_response_with_payload.c +++ b/test/core/end2end/tests/request_response_with_payload.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -162,8 +162,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_response_with_payload_legacy.c b/test/core/end2end/tests/request_response_with_payload_legacy.c index 37ce89b29a5..bc9e0aec3e0 100644 --- a/test/core/end2end/tests/request_response_with_payload_legacy.c +++ b/test/core/end2end/tests/request_response_with_payload_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c index fa0d313f490..b7834a1e6ca 100644 --- a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c +++ b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -169,8 +169,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload_legacy.c b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload_legacy.c index 5bce89a3fa6..6431ec5ad5c 100644 --- a/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload_legacy.c +++ b/test/core/end2end/tests/request_response_with_trailing_metadata_and_payload_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/request_with_large_metadata.c b/test/core/end2end/tests/request_with_large_metadata.c index 7908493565d..c5b4e0c57ee 100644 --- a/test/core/end2end/tests/request_with_large_metadata.c +++ b/test/core/end2end/tests/request_with_large_metadata.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -134,7 +134,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { meta.key = "key"; meta.value = gpr_malloc(large_size + 1); memset((char *)meta.value, 'a', large_size); - ((char*)meta.value)[large_size] = 0; + ((char *)meta.value)[large_size] = 0; meta.value_length = large_size; grpc_metadata_array_init(&initial_metadata_recv); @@ -166,8 +166,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_with_large_metadata_legacy.c b/test/core/end2end/tests/request_with_large_metadata_legacy.c index 85926aac149..082b5ad05cb 100644 --- a/test/core/end2end/tests/request_with_large_metadata_legacy.c +++ b/test/core/end2end/tests/request_with_large_metadata_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -118,7 +118,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { meta.key = "key"; meta.value = gpr_malloc(large_size + 1); memset((char *)meta.value, 'a', large_size); - ((char*)meta.value)[large_size] = 0; + ((char *)meta.value)[large_size] = 0; meta.value_length = large_size; c = grpc_channel_create_call_old(f.client, "/foo", "foo.test.google.fr", diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 72614a0bf80..63b7c5ee40b 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -157,8 +157,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/request_with_payload_legacy.c b/test/core/end2end/tests/request_with_payload_legacy.c index b71e682b9d9..266f9bd560a 100644 --- a/test/core/end2end/tests/request_with_payload_legacy.c +++ b/test/core/end2end/tests/request_with_payload_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 83b065b59eb..0dbb35d4546 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; static void *tag(gpr_intptr t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -144,8 +144,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f->server, &s, &call_details, &request_metadata_recv, - f->server_cq, - tag(101))); + f->server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); diff --git a/test/core/end2end/tests/simple_delayed_request_legacy.c b/test/core/end2end/tests/simple_delayed_request_legacy.c index 325261449af..7ab97eec3b2 100644 --- a/test/core/end2end/tests/simple_delayed_request_legacy.c +++ b/test/core/end2end/tests/simple_delayed_request_legacy.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; static void *tag(gpr_intptr t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index dac82535be7..4d4d48a2112 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -63,7 +63,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -122,7 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, f.client_cq, "/foo", - "foo.test.google.fr", deadline); + "foo.test.google.fr:1234", deadline); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -150,8 +150,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s, &call_details, &request_metadata_recv, - f.server_cq, - tag(101))); + f.server_cq, tag(101))); cq_expect_completion(v_server, tag(101), GRPC_OP_OK); cq_verify(v_server); @@ -178,7 +177,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); GPR_ASSERT(was_cancelled == 0); gpr_free(details); diff --git a/test/core/end2end/tests/simple_request_legacy.c b/test/core/end2end/tests/simple_request_legacy.c index 52dd6b08451..3e1b3f6c7c5 100644 --- a/test/core/end2end/tests/simple_request_legacy.c +++ b/test/core/end2end/tests/simple_request_legacy.c @@ -62,7 +62,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } diff --git a/test/core/end2end/tests/thread_stress.c b/test/core/end2end/tests/thread_stress.c index 996229c2282..a42956f7bc0 100644 --- a/test/core/end2end/tests/thread_stress.c +++ b/test/core/end2end/tests/thread_stress.c @@ -41,6 +41,7 @@ #include #include #include +#include "test/core/util/test_config.h" #define SERVER_THREADS 16 #define CLIENT_THREADS 16 @@ -53,7 +54,7 @@ static gpr_mu g_mu; static int g_active_requests; static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -280,11 +281,11 @@ static void run_test(grpc_end2end_test_config config, int requests_in_flight) { /* kick off threads */ for (i = 0; i < CLIENT_THREADS; i++) { gpr_event_init(&g_client_done[i]); - gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr)i, NULL); + gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr) i, NULL); } for (i = 0; i < SERVER_THREADS; i++) { gpr_event_init(&g_server_done[i]); - gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr)i, NULL); + gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr) i, NULL); } /* start requests */ diff --git a/test/core/end2end/tests/thread_stress_legacy.c b/test/core/end2end/tests/thread_stress_legacy.c index 996229c2282..a42956f7bc0 100644 --- a/test/core/end2end/tests/thread_stress_legacy.c +++ b/test/core/end2end/tests/thread_stress_legacy.c @@ -41,6 +41,7 @@ #include #include #include +#include "test/core/util/test_config.h" #define SERVER_THREADS 16 #define CLIENT_THREADS 16 @@ -53,7 +54,7 @@ static gpr_mu g_mu; static int g_active_requests; static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -280,11 +281,11 @@ static void run_test(grpc_end2end_test_config config, int requests_in_flight) { /* kick off threads */ for (i = 0; i < CLIENT_THREADS; i++) { gpr_event_init(&g_client_done[i]); - gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr)i, NULL); + gpr_thd_new(&thd_id, client_thread, (void *)(gpr_intptr) i, NULL); } for (i = 0; i < SERVER_THREADS; i++) { gpr_event_init(&g_server_done[i]); - gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr)i, NULL); + gpr_thd_new(&thd_id, server_thread, (void *)(gpr_intptr) i, NULL); } /* start requests */ diff --git a/test/core/end2end/tests/writes_done_hangs_with_pending_read.c b/test/core/end2end/tests/writes_done_hangs_with_pending_read.c index 0189762b5eb..75b4bfba908 100644 --- a/test/core/end2end/tests/writes_done_hangs_with_pending_read.c +++ b/test/core/end2end/tests/writes_done_hangs_with_pending_read.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -140,8 +140,8 @@ static void test_writes_done_hangs_with_pending_read( cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/end2end/tests/writes_done_hangs_with_pending_read_legacy.c b/test/core/end2end/tests/writes_done_hangs_with_pending_read_legacy.c index 0189762b5eb..75b4bfba908 100644 --- a/test/core/end2end/tests/writes_done_hangs_with_pending_read_legacy.c +++ b/test/core/end2end/tests/writes_done_hangs_with_pending_read_legacy.c @@ -61,7 +61,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, } static gpr_timespec n_seconds_time(int n) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(GPR_US_PER_SEC * n)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } @@ -140,8 +140,8 @@ static void test_writes_done_hangs_with_pending_read( cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); - cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", - "foo.test.google.fr", deadline, NULL); + cq_expect_server_rpc_new(v_server, &s, tag(100), "/foo", "foo.test.google.fr", + deadline, NULL); cq_verify(v_server); GPR_ASSERT(GRPC_CALL_OK == diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c index 599b3ad4eaa..17a2996baab 100644 --- a/test/core/httpcli/httpcli_test.c +++ b/test/core/httpcli/httpcli_test.c @@ -43,7 +43,7 @@ static gpr_event g_done; static gpr_timespec n_seconds_time(int seconds) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(seconds * 1000000)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds); } static void on_finish(void *arg, const grpc_httpcli_response *response) { diff --git a/test/core/iomgr/alarm_list_test.c b/test/core/iomgr/alarm_list_test.c index f2ccd1fb357..684e3f579a4 100644 --- a/test/core/iomgr/alarm_list_test.c +++ b/test/core/iomgr/alarm_list_test.c @@ -61,13 +61,13 @@ static void add_test(void) { /* 10 ms alarms. will expire in the current epoch */ for (i = 0; i < 10; i++) { grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(10)), - cb, (void *)(gpr_intptr)i, start); + cb, (void *)(gpr_intptr) i, start); } /* 1010 ms alarms. will expire in the next epoch */ for (i = 10; i < 20; i++) { grpc_alarm_init(&alarms[i], gpr_time_add(start, gpr_time_from_millis(1010)), - cb, (void *)(gpr_intptr)i, start); + cb, (void *)(gpr_intptr) i, start); } /* collect alarms. Only the first batch should be ready. */ @@ -115,15 +115,15 @@ void destruction_test(void) { memset(cb_called, 0, sizeof(cb_called)); grpc_alarm_init(&alarms[0], gpr_time_from_millis(100), cb, - (void *)(gpr_intptr)0, gpr_time_0); + (void *)(gpr_intptr) 0, gpr_time_0); grpc_alarm_init(&alarms[1], gpr_time_from_millis(3), cb, - (void *)(gpr_intptr)1, gpr_time_0); + (void *)(gpr_intptr) 1, gpr_time_0); grpc_alarm_init(&alarms[2], gpr_time_from_millis(100), cb, - (void *)(gpr_intptr)2, gpr_time_0); + (void *)(gpr_intptr) 2, gpr_time_0); grpc_alarm_init(&alarms[3], gpr_time_from_millis(3), cb, - (void *)(gpr_intptr)3, gpr_time_0); + (void *)(gpr_intptr) 3, gpr_time_0); grpc_alarm_init(&alarms[4], gpr_time_from_millis(1), cb, - (void *)(gpr_intptr)4, gpr_time_0); + (void *)(gpr_intptr) 4, gpr_time_0); GPR_ASSERT(1 == grpc_alarm_check(NULL, gpr_time_from_millis(2), NULL)); GPR_ASSERT(1 == cb_called[4][1]); grpc_alarm_cancel(&alarms[0]); diff --git a/test/core/iomgr/alarm_test.c b/test/core/iomgr/alarm_test.c index 18f57725a26..8d49332fa65 100644 --- a/test/core/iomgr/alarm_test.c +++ b/test/core/iomgr/alarm_test.c @@ -113,10 +113,10 @@ static void test_grpc_alarm(void) { gpr_cv_init(&arg.cv); gpr_event_init(&arg.fcb_arg); - grpc_alarm_init(&alarm, gpr_time_add(gpr_time_from_millis(100), gpr_now()), - alarm_cb, &arg, gpr_now()); + grpc_alarm_init(&alarm, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100), alarm_cb, &arg, + gpr_now()); - alarm_deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(1)); + alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); gpr_mu_lock(&arg.mu); while (arg.done == 0) { if (gpr_cv_wait(&arg.cv, &arg.mu, alarm_deadline)) { @@ -126,7 +126,7 @@ static void test_grpc_alarm(void) { } gpr_mu_unlock(&arg.mu); - followup_deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(5)); + followup_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); fdone = gpr_event_wait(&arg.fcb_arg, followup_deadline); if (arg.counter != 1) { @@ -162,12 +162,11 @@ static void test_grpc_alarm(void) { gpr_cv_init(&arg2.cv); gpr_event_init(&arg2.fcb_arg); - grpc_alarm_init(&alarm_to_cancel, - gpr_time_add(gpr_time_from_millis(100), gpr_now()), alarm_cb, - &arg2, gpr_now()); + grpc_alarm_init(&alarm_to_cancel, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100), + alarm_cb, &arg2, gpr_now()); grpc_alarm_cancel(&alarm_to_cancel); - alarm_deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(1)); + alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); gpr_mu_lock(&arg2.mu); while (arg2.done == 0) { gpr_cv_wait(&arg2.cv, &arg2.mu, alarm_deadline); @@ -176,7 +175,7 @@ static void test_grpc_alarm(void) { gpr_log(GPR_INFO, "alarm done = %d", arg2.done); - followup_deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(5)); + followup_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5); fdone = gpr_event_wait(&arg2.fcb_arg, followup_deadline); if (arg2.counter != arg2.done_success_ctr) { diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index c08ee7d48f2..e63048e26c8 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -39,6 +39,7 @@ #include #include #include +#include "test/core/util/test_config.h" /* General test notes: @@ -211,7 +212,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, size_t num_bytes, size_t write_size, size_t slice_size, int shutdown) { struct read_and_write_test_state state; - gpr_timespec deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(20)); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); grpc_endpoint_test_fixture f = begin_test(config, __FUNCTION__, slice_size); if (shutdown) { @@ -290,7 +291,7 @@ static void shutdown_during_write_test_read_handler( if (error != GRPC_ENDPOINT_CB_OK) { grpc_endpoint_destroy(st->ep); - gpr_event_set(&st->ev, (void *)(gpr_intptr)error); + gpr_event_set(&st->ev, (void *)(gpr_intptr) error); } else { grpc_endpoint_notify_on_read( st->ep, shutdown_during_write_test_read_handler, user_data); @@ -309,7 +310,7 @@ static void shutdown_during_write_test_write_handler( gpr_log(GPR_ERROR, "shutdown_during_write_test_write_handler completed unexpectedly"); } - gpr_event_set(&st->ev, (void *)(gpr_intptr)1); + gpr_event_set(&st->ev, (void *)(gpr_intptr) 1); } static void shutdown_during_write_test(grpc_endpoint_test_config config, @@ -345,8 +346,7 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config, abort(); case GRPC_ENDPOINT_WRITE_PENDING: grpc_endpoint_shutdown(write_st.ep); - deadline = - gpr_time_add(gpr_now(), gpr_time_from_micros(10 * GPR_US_PER_SEC)); + deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); GPR_ASSERT(gpr_event_wait(&write_st.ev, deadline)); grpc_endpoint_destroy(write_st.ep); GPR_ASSERT(gpr_event_wait(&read_st.ev, deadline)); diff --git a/test/core/iomgr/endpoint_tests.h b/test/core/iomgr/endpoint_tests.h index 3be377c4e3d..1679d7bd4f0 100644 --- a/test/core/iomgr/endpoint_tests.h +++ b/test/core/iomgr/endpoint_tests.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_IOMGR_ENDPOINT_TESTS_H__ -#define __GRPC_TEST_IOMGR_ENDPOINT_TESTS_H__ +#ifndef GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H +#define GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H #include @@ -54,4 +54,4 @@ struct grpc_endpoint_test_config { void grpc_endpoint_tests(grpc_endpoint_test_config config); -#endif /* __GRPC_TEST_IOMGR_ENDPOINT_TESTS_H__ */ +#endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */ diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index 0961a3659f6..668c5399f90 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -39,7 +39,7 @@ #include "test/core/util/test_config.h" static gpr_timespec test_deadline(void) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(100000000)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100); } static void must_succeed(void* evp, grpc_resolved_addresses* p) { @@ -83,8 +83,9 @@ static void test_ipv6_with_port(void) { } static void test_ipv6_without_port(void) { - const char* const kCases[] = {"2001:db8::1", "2001:db8::1.2.3.4", - "[2001:db8::1]", }; + const char* const kCases[] = { + "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]", + }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { gpr_event ev; @@ -95,7 +96,9 @@ static void test_ipv6_without_port(void) { } static void test_invalid_ip_addresses(void) { - const char* const kCases[] = {"293.283.1238.3:1", "[2001:db8::11111]:1", }; + const char* const kCases[] = { + "293.283.1238.3:1", "[2001:db8::11111]:1", + }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { gpr_event ev; @@ -106,8 +109,9 @@ static void test_invalid_ip_addresses(void) { } static void test_unparseable_hostports(void) { - const char* const kCases[] = {"[", "[::1", "[::1]bad", - "[1.2.3.4]", "[localhost]", "[localhost]:1", }; + const char* const kCases[] = { + "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1", + }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { gpr_event ev; diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index ad5a3170448..3c4d8fed4f7 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -43,9 +43,10 @@ #include "src/core/iomgr/socket_utils_posix.h" #include #include +#include "test/core/util/test_config.h" static gpr_timespec test_deadline(void) { - return gpr_time_add(gpr_now(), gpr_time_from_seconds(10)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); } static void must_succeed(void *arg, grpc_endpoint *tcp) { @@ -150,13 +151,12 @@ void test_times_out(void) { /* connect to dummy server address */ - connect_deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(1000000)); + connect_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); grpc_tcp_client_connect(must_fail, &ev, (struct sockaddr *)&addr, addr_len, connect_deadline); /* Make sure the event doesn't trigger early */ - GPR_ASSERT(!gpr_event_wait( - &ev, gpr_time_add(gpr_now(), gpr_time_from_micros(500000)))); + GPR_ASSERT(!gpr_event_wait(&ev, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(500))); /* Now wait until it should have triggered */ sleep(1); @@ -168,7 +168,8 @@ void test_times_out(void) { } } -int main(void) { +int main(int argc, char **argv) { + grpc_test_init(argc, argv); grpc_iomgr_init(); test_succeeds(); gpr_log(GPR_ERROR, "End of first test"); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 0f81ba77344..59e525a8e1b 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -163,8 +163,7 @@ static void read_test(ssize_t num_bytes, ssize_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; ssize_t written_bytes; - gpr_timespec rel_deadline = {20, 0}; - gpr_timespec deadline = gpr_time_add(gpr_now(), rel_deadline); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); gpr_log(GPR_INFO, "Read test of size %d, slice size %d", num_bytes, slice_size); @@ -206,8 +205,7 @@ static void large_read_test(ssize_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; ssize_t written_bytes; - gpr_timespec rel_deadline = {20, 0}; - gpr_timespec deadline = gpr_time_add(gpr_now(), rel_deadline); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); gpr_log(GPR_INFO, "Start large read test, slice size %d", slice_size); @@ -343,8 +341,7 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) { size_t num_blocks; gpr_slice *slices; int current_data = 0; - gpr_timespec rel_deadline = {20, 0}; - gpr_timespec deadline = gpr_time_add(gpr_now(), rel_deadline); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); gpr_log(GPR_INFO, "Start write test with %d bytes, slice size %d", num_bytes, slice_size); @@ -400,8 +397,7 @@ static void write_error_test(ssize_t num_bytes, ssize_t slice_size) { size_t num_blocks; gpr_slice *slices; int current_data = 0; - gpr_timespec rel_deadline = {20, 0}; - gpr_timespec deadline = gpr_time_add(gpr_now(), rel_deadline); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); gpr_log(GPR_INFO, "Start write error test with %d bytes, slice size %d", num_bytes, slice_size); @@ -482,7 +478,8 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( } static grpc_endpoint_test_config configs[] = { - {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, }; + {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, +}; int main(int argc, char **argv) { grpc_test_init(argc, argv); diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index b26115bcd00..2689c3f38e5 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -123,7 +123,7 @@ static void test_connect(int n) { grpc_tcp_server_start(s, NULL, 0, on_connect, NULL); for (i = 0; i < n; i++) { - deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(10000000)); + deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); nconnects_before = nconnects; clifd = socket(addr.ss_family, SOCK_STREAM, 0); diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c index 203e75c7d57..02f60a3163c 100644 --- a/test/core/json/json_rewrite.c +++ b/test/core/json/json_rewrite.c @@ -40,9 +40,7 @@ #include "src/core/json/json_reader.h" #include "src/core/json/json_writer.h" -typedef struct json_writer_userdata { - FILE* out; -} json_writer_userdata; +typedef struct json_writer_userdata { FILE* out; } json_writer_userdata; typedef struct stacked_container { grpc_json_type type; @@ -76,11 +74,9 @@ static void json_writer_output_string_with_len(void* userdata, const char* str, fwrite(str, len, 1, state->out); } -grpc_json_writer_vtable writer_vtable = { - json_writer_output_char, - json_writer_output_string, - json_writer_output_string_with_len -}; +grpc_json_writer_vtable writer_vtable = {json_writer_output_char, + json_writer_output_string, + json_writer_output_string_with_len}; static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; @@ -202,19 +198,12 @@ static void json_reader_set_null(void* userdata) { } static grpc_json_reader_vtable reader_vtable = { - json_reader_string_clear, - json_reader_string_add_char, - json_reader_string_add_utf32, - json_reader_read_char, - json_reader_container_begins, - json_reader_container_ends, - json_reader_set_key, - json_reader_set_string, - json_reader_set_number, - json_reader_set_true, - json_reader_set_false, - json_reader_set_null -}; + json_reader_string_clear, json_reader_string_add_char, + json_reader_string_add_utf32, json_reader_read_char, + json_reader_container_begins, json_reader_container_ends, + json_reader_set_key, json_reader_set_string, + json_reader_set_number, json_reader_set_true, + json_reader_set_false, json_reader_set_null}; int rewrite(FILE* in, FILE* out, int indent) { grpc_json_writer writer; diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c index 78dff92a777..ec6deebe76c 100644 --- a/test/core/json/json_rewrite_test.c +++ b/test/core/json/json_rewrite_test.c @@ -42,9 +42,7 @@ #include "src/core/json/json_reader.h" #include "src/core/json/json_writer.h" -typedef struct json_writer_userdata { - FILE* cmp; -} json_writer_userdata; +typedef struct json_writer_userdata { FILE* cmp; } json_writer_userdata; typedef struct stacked_container { grpc_json_type type; @@ -83,11 +81,9 @@ static void json_writer_output_string_with_len(void* userdata, const char* str, } } -grpc_json_writer_vtable writer_vtable = { - json_writer_output_char, - json_writer_output_string, - json_writer_output_string_with_len -}; +grpc_json_writer_vtable writer_vtable = {json_writer_output_char, + json_writer_output_string, + json_writer_output_string_with_len}; static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; @@ -216,19 +212,12 @@ static void json_reader_set_null(void* userdata) { } static grpc_json_reader_vtable reader_vtable = { - json_reader_string_clear, - json_reader_string_add_char, - json_reader_string_add_utf32, - json_reader_read_char, - json_reader_container_begins, - json_reader_container_ends, - json_reader_set_key, - json_reader_set_string, - json_reader_set_number, - json_reader_set_true, - json_reader_set_false, - json_reader_set_null -}; + json_reader_string_clear, json_reader_string_add_char, + json_reader_string_add_utf32, json_reader_read_char, + json_reader_container_begins, json_reader_container_ends, + json_reader_set_key, json_reader_set_string, + json_reader_set_number, json_reader_set_true, + json_reader_set_false, json_reader_set_null}; int rewrite_and_compare(FILE* in, FILE* cmp, int indent) { grpc_json_writer writer; @@ -275,26 +264,14 @@ typedef struct test_file { } test_file; static test_file test_files[] = { - { - "test/core/json/rewrite_test_input.json", - "test/core/json/rewrite_test_output_condensed.json", - 0 - }, - { - "test/core/json/rewrite_test_input.json", - "test/core/json/rewrite_test_output_indented.json", - 2 - }, - { - "test/core/json/rewrite_test_output_indented.json", - "test/core/json/rewrite_test_output_condensed.json", - 0 - }, - { - "test/core/json/rewrite_test_output_condensed.json", - "test/core/json/rewrite_test_output_indented.json", - 2 - }, + {"test/core/json/rewrite_test_input.json", + "test/core/json/rewrite_test_output_condensed.json", 0}, + {"test/core/json/rewrite_test_input.json", + "test/core/json/rewrite_test_output_indented.json", 2}, + {"test/core/json/rewrite_test_output_indented.json", + "test/core/json/rewrite_test_output_condensed.json", 0}, + {"test/core/json/rewrite_test_output_condensed.json", + "test/core/json/rewrite_test_output_indented.json", 2}, }; void test_rewrites() { @@ -305,8 +282,8 @@ void test_rewrites() { FILE* input = fopen(test->input, "rb"); FILE* cmp = fopen(test->cmp, "rb"); int status; - gpr_log(GPR_INFO, "Testing file %s against %s using indent=%i", - test->input, test->cmp, test->indent); + gpr_log(GPR_INFO, "Testing file %s against %s using indent=%i", test->input, + test->cmp, test->indent); status = rewrite_and_compare(input, cmp, test->indent); GPR_ASSERT(status); fclose(input); diff --git a/test/core/json/json_test.c b/test/core/json/json_test.c index bc3c7a3da84..9a50a6929ee 100644 --- a/test/core/json/json_test.c +++ b/test/core/json/json_test.c @@ -47,80 +47,83 @@ typedef struct testing_pair { } testing_pair; static testing_pair testing_pairs[] = { - /* Testing valid parsing. */ - - /* Testing trivial parses, with de-indentation. */ - { " 0 ", "0" }, - { " 1 ", "1" }, - { " \"a\" ", "\"a\"" }, - { " true ", "true" }, - /* Testing the parser's ability to decode trivial UTF-16. */ - { "\"\\u0020\\\\\\u0010\\u000a\\u000D\"", "\" \\\\\\u0010\\n\\r\"" }, - /* Testing various UTF-8 sequences. */ - { "\"ßâñć௵⇒\"", "\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\"" }, - { "\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\"", "\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\"" }, - /* Testing UTF-8 character "𝄞", U+11D1E. */ - { "\"\xf0\x9d\x84\x9e\"", "\"\\ud834\\udd1e\"" }, - { "\"\\ud834\\udd1e\"", "\"\\ud834\\udd1e\"" }, - /* Testing nested empty containers. */ - { " [ [ ] , { } , [ ] ] ", "[[],{},[]]", }, - /* Testing escapes and control chars in key strings. */ - { " { \"\x7f\\n\\\\a , b\": 1, \"\": 0 } ", "{\"\\u007f\\n\\\\a , b\":1,\"\":0}" }, - /* Testing the writer's ability to cut off invalid UTF-8 sequences. */ - { "\"abc\xf0\x9d\x24\"", "\"abc\"" }, - { "\"\xff\"", "\"\"" }, - /* Testing valid number parsing. */ - { "[0, 42 , 0.0123, 123.456]", "[0,42,0.0123,123.456]"}, - { "[1e4,-53.235e-31, 0.3e+3]", "[1e4,-53.235e-31,0.3e+3]" }, - /* Testing keywords parsing. */ - { "[true, false, null]", "[true,false,null]" }, - - - /* Testing invalid parsing. */ - - /* Testing plain invalid things, exercising the state machine. */ - { "\\", NULL }, - { "nu ll", NULL }, - { "fals", NULL }, - /* Testing unterminated string. */ - { "\"\\x", NULL }, - /* Testing invalid UTF-16 number. */ - { "\"\\u123x", NULL }, - /* Testing imbalanced surrogate pairs. */ - { "\"\\ud834f", NULL }, - { "\"\\ud834\\n", NULL }, - { "\"\\udd1ef", NULL }, - { "\"\\ud834\\ud834\"", NULL }, - { "\"\\ud834\\u1234\"", NULL }, - /* Testing embedded invalid whitechars. */ - { "\"\n\"", NULL }, - { "\"\t\"", NULL }, - /* Testing empty json data. */ - { "", NULL }, - /* Testing extra characters after end of parsing. */ - { "{},", NULL }, - /* Testing imbalanced containers. */ - { "{}}", NULL }, - { "[]]", NULL }, - { "{{}", NULL }, - { "[[]", NULL }, - { "[}", NULL }, - { "{]", NULL }, - /*Testing trailing comma. */ - { "{,}", NULL }, - { "[1,2,3,4,]", NULL }, - /* Testing having a key syntax in an array. */ - { "[\"x\":0]", NULL }, - /* Testing invalid numbers. */ - { "1.", NULL }, - { "1e", NULL }, - { ".12", NULL }, - { "1.x", NULL }, - { "1.12x", NULL }, - { "1ex", NULL }, - { "1e12x", NULL }, - { ".12x", NULL }, - { "000", NULL }, + /* Testing valid parsing. */ + + /* Testing trivial parses, with de-indentation. */ + {" 0 ", "0"}, + {" 1 ", "1"}, + {" \"a\" ", "\"a\""}, + {" true ", "true"}, + /* Testing the parser's ability to decode trivial UTF-16. */ + {"\"\\u0020\\\\\\u0010\\u000a\\u000D\"", "\" \\\\\\u0010\\n\\r\""}, + /* Testing various UTF-8 sequences. */ + {"\"ßâñć௵⇒\"", "\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\""}, + {"\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\"", + "\"\\u00df\\u00e2\\u00f1\\u0107\\u0bf5\\u21d2\""}, + /* Testing UTF-8 character "𝄞", U+11D1E. */ + {"\"\xf0\x9d\x84\x9e\"", "\"\\ud834\\udd1e\""}, + {"\"\\ud834\\udd1e\"", "\"\\ud834\\udd1e\""}, + /* Testing nested empty containers. */ + { + " [ [ ] , { } , [ ] ] ", "[[],{},[]]", + }, + /* Testing escapes and control chars in key strings. */ + {" { \"\x7f\\n\\\\a , b\": 1, \"\": 0 } ", + "{\"\\u007f\\n\\\\a , b\":1,\"\":0}"}, + /* Testing the writer's ability to cut off invalid UTF-8 sequences. */ + {"\"abc\xf0\x9d\x24\"", "\"abc\""}, + {"\"\xff\"", "\"\""}, + /* Testing valid number parsing. */ + {"[0, 42 , 0.0123, 123.456]", "[0,42,0.0123,123.456]"}, + {"[1e4,-53.235e-31, 0.3e+3]", "[1e4,-53.235e-31,0.3e+3]"}, + /* Testing keywords parsing. */ + {"[true, false, null]", "[true,false,null]"}, + + /* Testing invalid parsing. */ + + /* Testing plain invalid things, exercising the state machine. */ + {"\\", NULL}, + {"nu ll", NULL}, + {"fals", NULL}, + /* Testing unterminated string. */ + {"\"\\x", NULL}, + /* Testing invalid UTF-16 number. */ + {"\"\\u123x", NULL}, + /* Testing imbalanced surrogate pairs. */ + {"\"\\ud834f", NULL}, + {"\"\\ud834\\n", NULL}, + {"\"\\udd1ef", NULL}, + {"\"\\ud834\\ud834\"", NULL}, + {"\"\\ud834\\u1234\"", NULL}, + /* Testing embedded invalid whitechars. */ + {"\"\n\"", NULL}, + {"\"\t\"", NULL}, + /* Testing empty json data. */ + {"", NULL}, + /* Testing extra characters after end of parsing. */ + {"{},", NULL}, + /* Testing imbalanced containers. */ + {"{}}", NULL}, + {"[]]", NULL}, + {"{{}", NULL}, + {"[[]", NULL}, + {"[}", NULL}, + {"{]", NULL}, + /*Testing trailing comma. */ + {"{,}", NULL}, + {"[1,2,3,4,]", NULL}, + /* Testing having a key syntax in an array. */ + {"[\"x\":0]", NULL}, + /* Testing invalid numbers. */ + {"1.", NULL}, + {"1e", NULL}, + {".12", NULL}, + {"1.x", NULL}, + {"1.12x", NULL}, + {"1ex", NULL}, + {"1e12x", NULL}, + {".12x", NULL}, + {"000", NULL}, }; static void test_pairs() { @@ -169,7 +172,7 @@ static void test_atypical() { gpr_free(scratchpad); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_pairs(); test_atypical(); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 91229c95c25..50ef2d7657e 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -55,7 +55,8 @@ static const char test_root_cert[] = "I am the root!"; Maximum size for a string literal is 509 chars in C89, yay! */ static const char test_json_key_str_part1[] = "{ \"private_key\": \"-----BEGIN PRIVATE KEY-----" - "\\nMIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOEvJsnoHnyHkXcp\\n7mJEqg" + "\\nMIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOEvJsnoHnyHkXcp\\n7mJE" + "qg" "WGjiw71NfXByguekSKho65FxaGbsnSM9SMQAqVk7Q2rG+I0OpsT0LrWQtZ\\nyjSeg/" "rWBQvS4hle4LfijkP3J5BG+" "IXDMP8RfziNRQsenAXDNPkY4kJCvKux2xdD\\nOnVF6N7dL3nTYZg+" @@ -66,11 +67,14 @@ static const char test_json_key_str_part1[] = static const char test_json_key_str_part2[] = "53XxNVnxBHsYb+AYEfklR96yVi8HywjVHP34+OQZ\\nCslxoHQM8s+" "dBnjfScLu22JqkPv04xyxmt0QAKm9+vTdAkEA4ib7YvEAn2jXzcCI\\nEkoy2L/" - "XydR1GCHoacdfdAwiL2npOdnbvi4ZmdYRPY1LSTO058tQHKVXV7NLeCa3\\nAARh2QJBAMKeDAG" - "W303SQv2cZTdbeaLKJbB5drz3eo3j7dDKjrTD9JupixFbzcGw\\n8FZi5c8idxiwC36kbAL6HzA" + "XydR1GCHoacdfdAwiL2npOdnbvi4ZmdYRPY1LSTO058tQHKVXV7NLeCa3\\nAARh2QJBAMKeDA" + "G" + "W303SQv2cZTdbeaLKJbB5drz3eo3j7dDKjrTD9JupixFbzcGw\\n8FZi5c8idxiwC36kbAL6Hz" + "A" "ZoX+ofI0CQE6KCzPJTtYNqyShgKAZdJ8hwOcvCZtf\\n6z8RJm0+" "6YBd38lfh5j8mZd7aHFf6I17j5AQY7oPEc47TjJj/" - "5nZ68ECQQDvYuI3\\nLyK5fS8g0SYbmPOL9TlcHDOqwG0mrX9qpg5DC2fniXNSrrZ64GTDKdzZY" + "5nZ68ECQQDvYuI3\\nLyK5fS8g0SYbmPOL9TlcHDOqwG0mrX9qpg5DC2fniXNSrrZ64GTDKdzZ" + "Y" "Ap6LI9W\\nIqv4vr6y38N79TTC\\n-----END PRIVATE KEY-----\\n\", "; static const char test_json_key_str_part3[] = "\"private_key_id\": \"e6b5137873db8d2ef81e06a47289e6434ec8a165\", " @@ -614,9 +618,10 @@ static void test_service_account_creds_signing_failure(void) { grpc_jwt_encode_and_sign_set_override(NULL); } -static void on_jwt_creds_get_metadata_success( - void *user_data, grpc_mdelem **md_elems, size_t num_md, - grpc_credentials_status status) { +static void on_jwt_creds_get_metadata_success(void *user_data, + grpc_mdelem **md_elems, + size_t num_md, + grpc_credentials_status status) { char *expected_md_value; gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt); GPR_ASSERT(status == GRPC_CREDENTIALS_OK); @@ -630,9 +635,10 @@ static void on_jwt_creds_get_metadata_success( gpr_free(expected_md_value); } -static void on_jwt_creds_get_metadata_failure( - void *user_data, grpc_mdelem **md_elems, size_t num_md, - grpc_credentials_status status) { +static void on_jwt_creds_get_metadata_failure(void *user_data, + grpc_mdelem **md_elems, + size_t num_md, + grpc_credentials_status status) { GPR_ASSERT(status == GRPC_CREDENTIALS_ERROR); GPR_ASSERT(num_md == 0); GPR_ASSERT(user_data != NULL); diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index eed0fdf3321..fae911721ad 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -49,7 +49,8 @@ Maximum size for a string literal is 509 chars in C89, yay! */ static const char test_json_key_str_part1[] = "{ \"private_key\": \"-----BEGIN PRIVATE KEY-----" - "\\nMIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOEvJsnoHnyHkXcp\\n7mJEqg" + "\\nMIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOEvJsnoHnyHkXcp\\n7mJE" + "qg" "WGjiw71NfXByguekSKho65FxaGbsnSM9SMQAqVk7Q2rG+I0OpsT0LrWQtZ\\nyjSeg/" "rWBQvS4hle4LfijkP3J5BG+" "IXDMP8RfziNRQsenAXDNPkY4kJCvKux2xdD\\nOnVF6N7dL3nTYZg+" @@ -60,11 +61,14 @@ static const char test_json_key_str_part1[] = static const char test_json_key_str_part2[] = "53XxNVnxBHsYb+AYEfklR96yVi8HywjVHP34+OQZ\\nCslxoHQM8s+" "dBnjfScLu22JqkPv04xyxmt0QAKm9+vTdAkEA4ib7YvEAn2jXzcCI\\nEkoy2L/" - "XydR1GCHoacdfdAwiL2npOdnbvi4ZmdYRPY1LSTO058tQHKVXV7NLeCa3\\nAARh2QJBAMKeDAG" - "W303SQv2cZTdbeaLKJbB5drz3eo3j7dDKjrTD9JupixFbzcGw\\n8FZi5c8idxiwC36kbAL6HzA" + "XydR1GCHoacdfdAwiL2npOdnbvi4ZmdYRPY1LSTO058tQHKVXV7NLeCa3\\nAARh2QJBAMKeDA" + "G" + "W303SQv2cZTdbeaLKJbB5drz3eo3j7dDKjrTD9JupixFbzcGw\\n8FZi5c8idxiwC36kbAL6Hz" + "A" "ZoX+ofI0CQE6KCzPJTtYNqyShgKAZdJ8hwOcvCZtf\\n6z8RJm0+" "6YBd38lfh5j8mZd7aHFf6I17j5AQY7oPEc47TjJj/" - "5nZ68ECQQDvYuI3\\nLyK5fS8g0SYbmPOL9TlcHDOqwG0mrX9qpg5DC2fniXNSrrZ64GTDKdzZY" + "5nZ68ECQQDvYuI3\\nLyK5fS8g0SYbmPOL9TlcHDOqwG0mrX9qpg5DC2fniXNSrrZ64GTDKdzZ" + "Y" "Ap6LI9W\\nIqv4vr6y38N79TTC\\n-----END PRIVATE KEY-----\\n\", "; static const char test_json_key_str_part3[] = "\"private_key_id\": \"e6b5137873db8d2ef81e06a47289e6434ec8a165\", " diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index cfd62cf6ccb..76e69ef7163 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -73,8 +73,7 @@ int main(int argc, char **argv) { char *service_url = "https://test.foo.google.com/Foo"; gpr_cmdline *cl = gpr_cmdline_create("print_google_default_creds_token"); gpr_cmdline_add_string(cl, "service_url", - "Service URL for the token request.", - &service_url); + "Service URL for the token request.", &service_url); gpr_cmdline_parse(cl, argc, argv); grpc_init(); diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index 03a4d3a1e69..f7bd3cb4ae0 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.c @@ -130,7 +130,8 @@ static grpc_endpoint_test_config configs[] = { {"secure_ep/tcp_socketpair", secure_endpoint_create_fixture_tcp_socketpair_noleftover, clean_up}, {"secure_ep/tcp_socketpair_leftover", - secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up}, }; + secure_endpoint_create_fixture_tcp_socketpair_leftover, clean_up}, +}; static void verify_leftover(void *user_data, gpr_slice *slices, size_t nslices, grpc_endpoint_cb_status error) { diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index fbc96bbde61..241ec1ce4f4 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -42,6 +42,7 @@ #include #include #include +#include "test/core/util/test_config.h" /* Fills in 'record' of size 'size'. Each byte in record is filled in with the same value. The value is extracted from 'record' pointer. */ @@ -123,8 +124,8 @@ static void assert_log_empty(void) { /* Given log size and record size, computes the minimum usable space. */ static gpr_int32 min_usable_space(size_t log_size, size_t record_size) { gpr_int32 usable_space; - gpr_int32 num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, - gpr_cpu_num_cores()); + gpr_int32 num_blocks = + GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, gpr_cpu_num_cores()); gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size; /* In the worst case, all except one core-local block is full. */ gpr_int32 num_full_blocks = num_blocks - 1; @@ -198,7 +199,7 @@ static void writer_thread(void* arg) { This should never happen for circular logs. */ printf(" Writer stalled due to out-of-space: %d out of %d written\n", records_written, args->num_records); - gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(10000))); + gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10)); } } /* Done. Decrement count and signal. */ diff --git a/test/core/statistics/census_log_tests.h b/test/core/statistics/census_log_tests.h index f829ab36833..28bde086f3b 100644 --- a/test/core/statistics/census_log_tests.h +++ b/test/core/statistics/census_log_tests.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_STATISTICS_LOG_TESTS_H__ -#define __GRPC_TEST_STATISTICS_LOG_TESTS_H__ +#ifndef GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H +#define GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H void test_invalid_record_size(); void test_end_write_with_different_size(); @@ -48,4 +48,4 @@ void test_multiple_writers(); void test_performance(); void test_small_log(); -#endif /* __GRPC_TEST_STATISTICS_LOG_TESTS_H__ */ +#endif /* GRPC_TEST_CORE_STATISTICS_CENSUS_LOG_TESTS_H */ diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c index 2752d6d89d5..1e9e1c8d236 100644 --- a/test/core/statistics/hash_table_test.c +++ b/test/core/statistics/hash_table_test.c @@ -97,7 +97,7 @@ static void test_table_with_int_key(void) { for (i = 0; i < 20; ++i) { census_ht_key key; key.val = i; - census_ht_insert(ht, key, (void*)(gpr_intptr)i); + census_ht_insert(ht, key, (void*)(gpr_intptr) i); GPR_ASSERT(census_ht_get_size(ht) == i + 1); } for (i = 0; i < 20; i++) { @@ -105,7 +105,7 @@ static void test_table_with_int_key(void) { census_ht_key key; key.val = i; val = census_ht_find(ht, key); - GPR_ASSERT(val == (void*)(gpr_intptr)i); + GPR_ASSERT(val == (void*)(gpr_intptr) i); } elements = census_ht_get_all_elements(ht, &num_elements); GPR_ASSERT(elements != NULL); diff --git a/test/core/statistics/trace_test.c b/test/core/statistics/trace_test.c index 65b70e1006a..b13fd03f70b 100644 --- a/test/core/statistics/trace_test.c +++ b/test/core/statistics/trace_test.c @@ -111,7 +111,7 @@ static void mimic_trace_op_sequences(void* arg) { id = census_tracing_start_op(); census_add_method_tag(id, method_name); /* pretend doing 1us work. */ - gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_micros(1))); + gpr_sleep_until(GRPC_TIMEOUT_MICROS_TO_DEADLINE(1)); census_tracing_end_op(id); } gpr_log(GPR_INFO, "End trace op sequence thread."); diff --git a/test/core/support/file_test.c b/test/core/support/file_test.c index c0c14ffa0e5..dd8caf7a80d 100644 --- a/test/core/support/file_test.c +++ b/test/core/support/file_test.c @@ -148,7 +148,6 @@ static void test_load_big_file(void) { gpr_slice_unref(slice); } - int main(int argc, char **argv) { grpc_test_init(argc, argv); test_load_empty_file(); diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 43d05c6302b..44bc6ba4711 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -56,9 +56,9 @@ typedef struct queue { (That is, except during initialization or destruction, the fields below should be accessed only by a thread that holds mu.) */ - int head; /* Index of head of queue 0..N-1. */ - int length; /* Number of valid elements in queue 0..N. */ - int elem[N]; /* elem[head .. head+length-1] are queue elements. */ + int head; /* Index of head of queue 0..N-1. */ + int length; /* Number of valid elements in queue 0..N. */ + int elem[N]; /* elem[head .. head+length-1] are queue elements. */ } queue; /* Initialize *q. */ diff --git a/test/core/surface/completion_queue_benchmark.c b/test/core/surface/completion_queue_benchmark.c index 9116fd0fe4c..81ebe15415f 100644 --- a/test/core/surface/completion_queue_benchmark.c +++ b/test/core/surface/completion_queue_benchmark.c @@ -53,23 +53,23 @@ static void producer_thread(void *arg) { test_thread_options *opt = arg; int i; - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future)); for (i = 0; i < opt->iterations; i++) { grpc_cq_begin_op(opt->cc, NULL, GRPC_WRITE_ACCEPTED); - grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL, - GRPC_OP_OK); + grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL, + NULL, GRPC_OP_OK); } - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1); } static void consumer_thread(void *arg) { test_thread_options *opt = arg; grpc_event *ev; - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->start, gpr_inf_future)); for (;;) { @@ -78,7 +78,7 @@ static void consumer_thread(void *arg) { case GRPC_WRITE_ACCEPTED: break; case GRPC_QUEUE_SHUTDOWN: - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1); return; default: gpr_log(GPR_ERROR, "Invalid event received: %d", ev->type); @@ -112,7 +112,7 @@ double ops_per_second(int consumers, int producers, int iterations) { /* start the benchmark */ t_start = gpr_now(); - gpr_event_set(&start, (void *)(gpr_intptr)1); + gpr_event_set(&start, (void *)(gpr_intptr) 1); /* wait for producers to finish */ for (i = 0; i < producers; i++) { diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 35f150c7815..414ca2eac9c 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -248,7 +248,7 @@ typedef struct test_thread_options { } test_thread_options; gpr_timespec ten_seconds_time(void) { - return gpr_time_add(gpr_now(), gpr_time_from_micros(10 * 1000000)); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1); } static void producer_thread(void *arg) { @@ -256,7 +256,7 @@ static void producer_thread(void *arg) { int i; gpr_log(GPR_INFO, "producer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 1", opt->id); @@ -265,18 +265,18 @@ static void producer_thread(void *arg) { } gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 2", opt->id); for (i = 0; i < TEST_THREAD_EVENTS; i++) { - grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr)1, NULL, NULL, NULL, - GRPC_OP_OK); + grpc_cq_end_write_accepted(opt->cc, (void *)(gpr_intptr) 1, NULL, NULL, + NULL, GRPC_OP_OK); opt->events_triggered++; } gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1); } static void consumer_thread(void *arg) { @@ -284,13 +284,13 @@ static void consumer_thread(void *arg) { grpc_event *ev; gpr_log(GPR_INFO, "consumer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 1", opt->id); gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 2", opt->id); @@ -305,7 +305,7 @@ static void consumer_thread(void *arg) { break; case GRPC_QUEUE_SHUTDOWN: gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1); grpc_event_finish(ev); return; default: @@ -350,7 +350,7 @@ static void test_threading(int producers, int consumers) { /* start phase1: producers will pre-declare all operations they will complete */ gpr_log(GPR_INFO, "start phase 1"); - gpr_event_set(&phase1, (void *)(gpr_intptr)1); + gpr_event_set(&phase1, (void *)(gpr_intptr) 1); gpr_log(GPR_INFO, "wait phase 1"); for (i = 0; i < producers + consumers; i++) { @@ -360,7 +360,7 @@ static void test_threading(int producers, int consumers) { /* start phase2: operations will complete, and consumers will consume them */ gpr_log(GPR_INFO, "start phase 2"); - gpr_event_set(&phase2, (void *)(gpr_intptr)1); + gpr_event_set(&phase2, (void *)(gpr_intptr) 1); /* in parallel, we shutdown the completion channel - all events should still be consumed */ diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 0142768261d..3653c5a1b0d 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -51,9 +51,8 @@ int main(int argc, char **argv) { chan = grpc_lame_client_channel_create(); GPR_ASSERT(chan); - call = grpc_channel_create_call_old( - chan, "/Foo", "anywhere", - gpr_time_add(gpr_now(), gpr_time_from_seconds(100))); + call = grpc_channel_create_call_old(chan, "/Foo", "anywhere", + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100)); GPR_ASSERT(call); cq = grpc_completion_queue_create(); cqv = cq_verifier_create(cq); diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index 86c6bb1f56a..1d6ad2a758e 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -42,9 +42,7 @@ #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" -typedef struct { - va_list args; -} test_checker; +typedef struct { va_list args; } test_checker; static void onhdr(void *ud, grpc_mdelem *md) { const char *ekey, *evalue; diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c index 49d58114f87..d678e0af73f 100644 --- a/test/core/transport/chttp2/stream_map_test.c +++ b/test/core/transport/chttp2/stream_map_test.c @@ -93,7 +93,7 @@ static void test_basic_add_find(size_t n) { grpc_chttp2_stream_map_init(&map, 8); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i); } GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); @@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i); } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { @@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t n) { grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr) i); if ((i & 1) == 0) { grpc_chttp2_stream_map_delete(&map, i); } @@ -213,7 +213,7 @@ int main(int argc, char **argv) { test_empty_find(); test_double_deletion(); - while (n < 10000000) { + while (n < 100000) { test_basic_add_find(n); test_delete_evens_sweep(n); test_delete_evens_incremental(n); diff --git a/test/core/transport/chttp2_transport_end2end_test.c b/test/core/transport/chttp2_transport_end2end_test.c index a3c9f97ce4c..b90fe229999 100644 --- a/test/core/transport/chttp2_transport_end2end_test.c +++ b/test/core/transport/chttp2_transport_end2end_test.c @@ -100,7 +100,8 @@ grpc_transport_test_config fixture_configs[] = { {"chttp2_on_socketpair/medium", create_http2_transport_for_test_medium_slices}, {"chttp2_on_socketpair/large", - create_http2_transport_for_test_large_slices}, }; + create_http2_transport_for_test_large_slices}, +}; /* Driver function: run the test suite for each test configuration */ int main(int argc, char **argv) { diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c index 6d13bf1f8c9..437a1c3ef55 100644 --- a/test/core/transport/transport_end2end_tests.c +++ b/test/core/transport/transport_end2end_tests.c @@ -43,8 +43,7 @@ #include #include #include - -enum { REQUEST_DEADLINE = 200000 }; /* valgrind need a large value */ +#include "test/core/util/test_config.h" static grpc_mdctx *g_metadata_context; @@ -63,9 +62,7 @@ static int g_pending_ops; typedef struct test_fixture test_fixture; /* User data passed to the transport and handed to each callback */ -typedef struct test_user_data { - test_fixture *fixture; -} test_user_data; +typedef struct test_user_data { test_fixture *fixture; } test_user_data; /* A message we expect to receive (forms a singly linked list with next) */ typedef struct expected_message { @@ -131,8 +128,7 @@ static void expect_metadata(test_stream *s, int from_client, const char *key, /* Convert some number of seconds into a gpr_timespec that many seconds in the future */ static gpr_timespec deadline_from_seconds(double deadline_seconds) { - return gpr_time_add(gpr_now(), - gpr_time_from_micros((long)(deadline_seconds * 1e6))); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(deadline_seconds); } /* Init a test_user_data instance */ @@ -576,7 +572,7 @@ static grpc_transport_setup_result setup_client_transport( name - the name of this test */ static void begin_test(test_fixture *f, grpc_transport_test_config *config, const char *name) { - gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_seconds(100)); + gpr_timespec timeout = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100); gpr_log(GPR_INFO, "BEGIN: %s/%s", name, config->name); @@ -591,9 +587,10 @@ static void begin_test(test_fixture *f, grpc_transport_test_config *config, f->client_transport = NULL; f->server_transport = NULL; - GPR_ASSERT(0 == config->create_transport(setup_client_transport, f, - setup_server_transport, f, - g_metadata_context)); + GPR_ASSERT(0 == + config->create_transport(setup_client_transport, f, + setup_server_transport, f, + g_metadata_context)); gpr_mu_lock(&f->mu); while (!f->client_transport || !f->server_transport) { @@ -909,8 +906,9 @@ static void test_ping(grpc_transport_test_config *config) { * Test driver */ -static const size_t interesting_message_lengths[] = {1, 100, 10000, - 100000, 1000000, }; +static const size_t interesting_message_lengths[] = { + 1, 100, 10000, 100000, 1000000, +}; void grpc_transport_end2end_tests(grpc_transport_test_config *config) { unsigned i; diff --git a/test/core/transport/transport_end2end_tests.h b/test/core/transport/transport_end2end_tests.h index 3dc2b9b0678..1edffe9a79e 100644 --- a/test/core/transport/transport_end2end_tests.h +++ b/test/core/transport/transport_end2end_tests.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_TRANSPORT_TRANSPORT_END2END_TESTS_H__ -#define __GRPC_TEST_TRANSPORT_TRANSPORT_END2END_TESTS_H__ +#ifndef GRPC_TEST_CORE_TRANSPORT_TRANSPORT_END2END_TESTS_H +#define GRPC_TEST_CORE_TRANSPORT_TRANSPORT_END2END_TESTS_H #include "src/core/transport/transport.h" @@ -65,4 +65,4 @@ typedef struct grpc_transport_test_config { /* Run the test suite on one configuration */ void grpc_transport_end2end_tests(grpc_transport_test_config *config); -#endif /* __GRPC_TEST_TRANSPORT_TRANSPORT_END2END_TESTS_H__ */ +#endif /* GRPC_TEST_CORE_TRANSPORT_TRANSPORT_END2END_TESTS_H */ diff --git a/test/core/tsi/transport_security_test.c b/test/core/tsi/transport_security_test.c index 597b390c9b9..c5882af966c 100644 --- a/test/core/tsi/transport_security_test.c +++ b/test/core/tsi/transport_security_test.c @@ -189,9 +189,9 @@ typedef struct name_list { } name_list; typedef struct { - size_t name_count; - char *buffer; - name_list *names; + size_t name_count; + char *buffer; + name_list *names; } parsed_dns_names; name_list *name_list_add(const char *n) { diff --git a/test/core/util/grpc_profiler.h b/test/core/util/grpc_profiler.h index a31fcc1db5f..347a1d39d51 100644 --- a/test/core/util/grpc_profiler.h +++ b/test/core/util/grpc_profiler.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_UTIL_GRPC_PROFILER_H__ -#define __GRPC_TEST_UTIL_GRPC_PROFILER_H__ +#ifndef GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H +#define GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H #ifdef __cplusplus extern "C" { @@ -45,4 +45,4 @@ void grpc_profiler_stop(); } #endif /* __cplusplus */ -#endif /* __GRPC_TEST_UTIL_GRPC_PROFILER_H__ */ +#endif /* GRPC_TEST_CORE_UTIL_GRPC_PROFILER_H */ diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h index 3fce0c9f7ac..22bbd1756fd 100644 --- a/test/core/util/parse_hexstring.h +++ b/test/core/util/parse_hexstring.h @@ -31,11 +31,11 @@ * */ -#ifndef __GRPC_TEST_UTIL_PARSE_HEXSTRING_H_ -#define __GRPC_TEST_UTIL_PARSE_HEXSTRING_H_ +#ifndef GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H +#define GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H #include gpr_slice parse_hexstring(const char *hexstring); -#endif /* __GRPC_TEST_UTIL_PARSE_HEXSTRING_H_ */ +#endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ diff --git a/test/core/util/port.h b/test/core/util/port.h index 2a12ab985e0..b516ec5a483 100644 --- a/test/core/util/port.h +++ b/test/core/util/port.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_UTIL_PORT_H__ -#define __GRPC_TEST_UTIL_PORT_H__ +#ifndef GRPC_TEST_CORE_UTIL_PORT_H +#define GRPC_TEST_CORE_UTIL_PORT_H #ifdef __cplusplus extern "C" { @@ -49,4 +49,4 @@ int grpc_pick_unused_port_or_die(); } #endif -#endif /* __GRPC_TEST_UTIL_PORT_H__ */ +#endif /* GRPC_TEST_CORE_UTIL_PORT_H */ diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index f0fe1a0e7c3..36f13e1b51e 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -116,11 +116,20 @@ int grpc_pick_unused_port(void) { int try = 0; for (;;) { - int port = - try < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0; + int port; + try++; + if (try == 1) { + port = getpid() % (65536 - 30000) + 30000; + } else if (try <= NUM_RANDOM_PORTS_TO_PICK) { + port = rand() % (65536 - 30000) + 30000; + } else { + port = 0; + } + if (!is_port_available(&port, is_tcp)) { continue; } + GPR_ASSERT(port > 0); /* Check that the port # is free for the other type of socket also */ if (!is_port_available(&port, !is_tcp)) { diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h index b67fe737cbd..1ce1c097e29 100644 --- a/test/core/util/slice_splitter.h +++ b/test/core/util/slice_splitter.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPC_TEST_UTIL_SLICE_SPLITTER_H__ -#define __GRPC_TEST_UTIL_SLICE_SPLITTER_H__ +#ifndef GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H +#define GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H /* utility function to split/merge slices together to help create test cases */ @@ -65,4 +65,4 @@ gpr_slice grpc_slice_merge(gpr_slice *slices, size_t nslices); const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode); -#endif /* __GRPC_TEST_UTIL_SLICE_SPLITTER_H__ */ +#endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 1c464073114..1f0f0175b1c 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -34,6 +34,7 @@ #include "test/core/util/test_config.h" #include +#include #include #include @@ -52,6 +53,9 @@ void grpc_test_init(int argc, char **argv) { /* disable SIGPIPE */ signal(SIGPIPE, SIG_IGN); #endif + gpr_log(GPR_DEBUG, "test slowdown: machine=%f build=%f total=%f", + GRPC_TEST_SLOWDOWN_MACHINE_FACTOR, GRPC_TEST_SLOWDOWN_BUILD_FACTOR, + GRPC_TEST_SLOWDOWN_FACTOR); /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ srand(seed()); diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index b97fbfa6138..668a069f267 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -31,17 +31,38 @@ * */ -#ifndef __GRPC_TEST_UTIL_TEST_CONFIG_H__ -#define __GRPC_TEST_UTIL_TEST_CONFIG_H__ +#ifndef GRPC_TEST_CORE_UTIL_TEST_CONFIG_H +#define GRPC_TEST_CORE_UTIL_TEST_CONFIG_H + +#include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifndef GRPC_TEST_SLOWDOWN_BUILD_FACTOR +#define GRPC_TEST_SLOWDOWN_BUILD_FACTOR 1.0 +#endif + +#ifndef GRPC_TEST_SLOWDOWN_MACHINE_FACTOR +#define GRPC_TEST_SLOWDOWN_MACHINE_FACTOR 1.0 +#endif + +#define GRPC_TEST_SLOWDOWN_FACTOR \ + (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR) + +#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ + gpr_time_add(gpr_now(), \ + gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x))) + +#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ + gpr_time_add(gpr_now(), \ + gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x))) + void grpc_test_init(int argc, char **argv); #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* __GRPC_TEST_UTIL_TEST_CONFIG_H__ */ +#endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */ diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 9e25a5308df..331a5ef8a02 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -65,9 +65,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; @@ -81,7 +79,7 @@ class AsyncEnd2endTest : public ::testing::Test { protected: AsyncEnd2endTest() : service_(&srv_cq_) {} - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; // Setup server @@ -91,7 +89,7 @@ class AsyncEnd2endTest : public ::testing::Test { server_ = builder.BuildAndStart(); } - void TearDown() override { + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); void* ignored_tag; bool ignored_ok; @@ -109,18 +107,10 @@ class AsyncEnd2endTest : public ::testing::Test { 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 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++) { @@ -135,12 +125,11 @@ class AsyncEnd2endTest : public ::testing::Test { grpc::ServerAsyncResponseWriter response_writer(&srv_ctx); send_request.set_message("Hello"); - std::unique_ptr > - response_reader(stub_->Echo( - &cli_ctx, send_request, &cli_cq_, tag(1))); + 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)); + service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, &srv_cq_, + tag(2)); server_ok(2); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -191,10 +180,9 @@ TEST_F(AsyncEnd2endTest, SimpleClientStreaming) { send_request.set_message("Hello"); std::unique_ptr > cli_stream( - stub_->RequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); + stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq_, tag(1))); - service_.RequestRequestStream( - &srv_ctx, &srv_stream, &srv_cq_, tag(2)); + service_.RequestRequestStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); server_ok(2); client_ok(1); @@ -245,10 +233,10 @@ TEST_F(AsyncEnd2endTest, SimpleServerStreaming) { send_request.set_message("Hello"); std::unique_ptr > cli_stream( - stub_->ResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); + stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq_, tag(1))); - service_.RequestResponseStream( - &srv_ctx, &recv_request, &srv_stream, &srv_cq_, tag(2)); + service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, &srv_cq_, + tag(2)); server_ok(2); client_ok(1); @@ -296,10 +284,9 @@ TEST_F(AsyncEnd2endTest, SimpleBidiStreaming) { send_request.set_message("Hello"); std::unique_ptr > - cli_stream(stub_->BidiStream(&cli_ctx, &cli_cq_, tag(1))); + cli_stream(stub_->AsyncBidiStream(&cli_ctx, &cli_cq_, tag(1))); - service_.RequestBidiStream( - &srv_ctx, &srv_stream, &srv_cq_, tag(2)); + service_.RequestBidiStream(&srv_ctx, &srv_stream, &srv_cq_, tag(2)); server_ok(2); client_ok(1); @@ -355,10 +342,10 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) { cli_ctx.AddMetadata(meta2.first, meta2.second); std::unique_ptr > response_reader( - stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1))); + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - service_.RequestEcho( - &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2)); + 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(); @@ -397,10 +384,10 @@ TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) { std::pair meta2("key2", "val2"); std::unique_ptr > response_reader( - stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1))); + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - service_.RequestEcho( - &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2)); + 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); @@ -445,10 +432,10 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) { std::pair meta2("key2", "val2"); std::unique_ptr > response_reader( - stub_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1))); + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - service_.RequestEcho( - &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2)); + 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)); @@ -462,7 +449,6 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) { server_ok(4); - response_reader->Finish(&recv_response, &recv_status, tag(5)); client_ok(5); EXPECT_EQ(send_response.message(), recv_response.message()); @@ -491,20 +477,22 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) { 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", + 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", + 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_->Echo(&cli_ctx, send_request, &cli_cq_, tag(1))); + stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1))); - service_.RequestEcho( - &srv_ctx, &recv_request, &response_writer, &srv_cq_, tag(2)); + 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(); @@ -531,7 +519,6 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) { server_ok(5); - response_reader->Finish(&recv_response, &recv_status, tag(6)); client_ok(6); EXPECT_EQ(send_response.message(), recv_response.message()); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 45f12a9e9d1..1d5dfc4e342 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -83,7 +83,7 @@ void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request, class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { public: Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { response->set_message(request->message()); MaybeEchoDeadline(context, request, response); return Status::OK; @@ -93,7 +93,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { Status RequestStream(ServerContext* context, ServerReader* reader, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { EchoRequest request; response->set_message(""); while (reader->Read(&request)) { @@ -105,7 +105,7 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { // Return 3 messages. // TODO(yangg) make it generic by adding a parameter into EchoRequest Status ResponseStream(ServerContext* context, const EchoRequest* request, - ServerWriter* writer) override { + ServerWriter* writer) GRPC_OVERRIDE { EchoResponse response; response.set_message(request->message() + "0"); writer->Write(response); @@ -117,9 +117,9 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { return Status::OK; } - Status BidiStream( - ServerContext* context, - ServerReaderWriter* stream) override { + Status BidiStream(ServerContext* context, + ServerReaderWriter* stream) + GRPC_OVERRIDE { EchoRequest request; EchoResponse response; while (stream->Read(&request)) { @@ -135,7 +135,7 @@ class TestServiceImplDupPkg : public ::grpc::cpp::test::util::duplicate::TestService::Service { public: Status Echo(ServerContext* context, const EchoRequest* request, - EchoResponse* response) override { + EchoResponse* response) GRPC_OVERRIDE { response->set_message("no package"); return Status::OK; } @@ -145,7 +145,7 @@ class End2endTest : public ::testing::Test { protected: End2endTest() : thread_pool_(2) {} - void SetUp() override { + void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; // Setup server @@ -157,7 +157,7 @@ class End2endTest : public ::testing::Test { server_ = builder.BuildAndStart(); } - void TearDown() override { server_->Shutdown(); } + void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { std::shared_ptr channel = diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index acfaa87ec8b..f7537c2d7b2 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -38,6 +38,8 @@ #include #include +#include + #include #include #include @@ -313,8 +315,7 @@ void DoResponseStreamingWithSlowConsumer() { GPR_ASSERT(response.payload().body() == grpc::string(kResponseMessageSize, '\0')); gpr_log(GPR_INFO, "received message %d", i); - std::this_thread::sleep_for( - std::chrono::milliseconds(kReceiveDelayMilliSeconds)); + usleep(kReceiveDelayMilliSeconds * 1000); ++i; } GPR_ASSERT(kNumResponseMessages == i); diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc index 263bd8e3042..9810ff6622b 100644 --- a/test/cpp/interop/server.cc +++ b/test/cpp/interop/server.cc @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -222,7 +223,7 @@ void RunServer() { std::unique_ptr server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); while (!got_sigint) { - std::this_thread::sleep_for(std::chrono::seconds(5)); + sleep(5); } } diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc new file mode 100644 index 00000000000..9ea9cfe8b9b --- /dev/null +++ b/test/cpp/qps/client_async.cc @@ -0,0 +1,341 @@ +/* + * + * 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "test/core/util/grpc_profiler.h" +#include "test/cpp/util/create_test_channel.h" +#include "test/cpp/qps/qpstest.pb.h" + +DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls."); +DEFINE_int32(server_port, 0, "Server port."); +DEFINE_string(server_host, "127.0.0.1", "Server host."); +DEFINE_int32(client_threads, 4, "Number of client threads."); + +// We have a configurable number of channels for sending RPCs. +// RPCs are sent round-robin on the available channels by the +// various threads. Interesting cases are 1 global channel or +// 1 per-thread channel, but we can support any number. +// The channels are assigned round-robin on an RPC by RPC basis +// rather than just at initialization time in order to also measure the +// impact of cache thrashing caused by channel changes. This is an issue +// if you are not in one of the above "interesting cases" +DEFINE_int32(client_channels, 4, "Number of client channels."); + +DEFINE_int32(num_rpcs, 1000, "Number of RPCs per thread."); +DEFINE_int32(payload_size, 1, "Payload size in bytes"); + +// Alternatively, specify parameters for test as a workload so that multiple +// tests are initiated back-to-back. This is convenient for keeping a borg +// allocation consistent. This is a space-separated list of +// [threads channels num_rpcs payload_size ]* +DEFINE_string(workload, "", "Workload parameters"); + +using grpc::ChannelInterface; +using grpc::CreateTestChannel; +using grpc::testing::ServerStats; +using grpc::testing::SimpleRequest; +using grpc::testing::SimpleResponse; +using grpc::testing::StatsRequest; +using grpc::testing::TestService; + +// 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 {} +using namespace google; +using namespace gflags; + +static double now() { + gpr_timespec tv = gpr_now(); + return 1e9 * tv.tv_sec + tv.tv_nsec; +} + +class ClientRpcContext { + public: + ClientRpcContext() {} + virtual ~ClientRpcContext() {} + virtual bool RunNextState() = 0; // do next state, return false if steps done + static void *tag(ClientRpcContext *c) { return reinterpret_cast(c); } + static ClientRpcContext *detag(void *t) { + return reinterpret_cast(t); + } + virtual void report_stats(gpr_histogram *hist) = 0; +}; +template +class ClientRpcContextUnaryImpl : public ClientRpcContext { + public: + ClientRpcContextUnaryImpl( + TestService::Stub *stub, + const RequestType &req, + std::function< + std::unique_ptr>( + TestService::Stub *, grpc::ClientContext *, const RequestType &, + void *)> start_req, + std::function on_done) + : context_(), + stub_(stub), + req_(req), + response_(), + next_state_(&ClientRpcContextUnaryImpl::ReqSent), + callback_(on_done), + start_(now()), + response_reader_( + start_req(stub_, &context_, req_, ClientRpcContext::tag(this))) {} + ~ClientRpcContextUnaryImpl() GRPC_OVERRIDE {} + bool RunNextState() GRPC_OVERRIDE { return (this->*next_state_)(); } + void report_stats(gpr_histogram *hist) GRPC_OVERRIDE { + gpr_histogram_add(hist, now() - start_); + } + + private: + bool ReqSent() { + next_state_ = &ClientRpcContextUnaryImpl::RespDone; + response_reader_->Finish(&response_, &status_, ClientRpcContext::tag(this)); + return true; + } + bool RespDone() { + next_state_ = &ClientRpcContextUnaryImpl::DoCallBack; + return false; + } + bool DoCallBack() { + callback_(status_, &response_); + return false; + } + grpc::ClientContext context_; + TestService::Stub *stub_; + RequestType req_; + ResponseType response_; + bool (ClientRpcContextUnaryImpl::*next_state_)(); + std::function callback_; + grpc::Status status_; + double start_; + std::unique_ptr> + response_reader_; +}; + +static void RunTest(const int client_threads, const int client_channels, + const int num_rpcs, const int payload_size) { + gpr_log(GPR_INFO, + "QPS test with parameters\n" + "enable_ssl = %d\n" + "client_channels = %d\n" + "client_threads = %d\n" + "num_rpcs = %d\n" + "payload_size = %d\n" + "server_host:server_port = %s:%d\n\n", + FLAGS_enable_ssl, client_channels, client_threads, num_rpcs, + payload_size, FLAGS_server_host.c_str(), FLAGS_server_port); + + std::ostringstream oss; + oss << FLAGS_server_host << ":" << FLAGS_server_port; + + class ClientChannelInfo { + public: + explicit ClientChannelInfo(const grpc::string &server) + : channel_(CreateTestChannel(server, FLAGS_enable_ssl)), + stub_(TestService::NewStub(channel_)) {} + ChannelInterface *get_channel() { return channel_.get(); } + TestService::Stub *get_stub() { return stub_.get(); } + + private: + std::shared_ptr channel_; + std::unique_ptr stub_; + }; + + std::vector channels; + for (int i = 0; i < client_channels; i++) { + channels.push_back(ClientChannelInfo(oss.str())); + } + + std::vector threads; // Will add threads when ready to execute + std::vector< ::gpr_histogram *> thread_stats(client_threads); + + TestService::Stub *stub_stats = channels[0].get_stub(); + grpc::ClientContext context_stats_begin; + StatsRequest stats_request; + ServerStats server_stats_begin; + stats_request.set_test_num(0); + grpc::Status status_beg = stub_stats->CollectServerStats( + &context_stats_begin, stats_request, &server_stats_begin); + + grpc_profiler_start("qps_client_async.prof"); + + auto CheckDone = [=](grpc::Status s, SimpleResponse *response) { + GPR_ASSERT(s.IsOk() && (response->payload().type() == + grpc::testing::PayloadType::COMPRESSABLE) && + (response->payload().body().length() == + static_cast(payload_size))); + }; + + for (int i = 0; i < client_threads; i++) { + gpr_histogram *hist = gpr_histogram_create(0.01, 60e9); + GPR_ASSERT(hist != NULL); + thread_stats[i] = hist; + + threads.push_back(std::thread( + [hist, client_threads, client_channels, num_rpcs, payload_size, + &channels, &CheckDone](int channel_num) { + using namespace std::placeholders; + SimpleRequest request; + request.set_response_type(grpc::testing::PayloadType::COMPRESSABLE); + request.set_response_size(payload_size); + + grpc::CompletionQueue cli_cq; + auto start_req = std::bind(&TestService::Stub::AsyncUnaryCall, _1, + _2, _3, &cli_cq, _4); + + int rpcs_sent = 0; + while (rpcs_sent < num_rpcs) { + rpcs_sent++; + TestService::Stub *stub = channels[channel_num].get_stub(); + new ClientRpcContextUnaryImpl(stub, + request, start_req, CheckDone); + void *got_tag; + bool ok; + + // Need to call 2 next for every 1 RPC (1 for req done, 1 for resp + // done) + cli_cq.Next(&got_tag, &ok); + if (!ok) break; + ClientRpcContext *ctx = ClientRpcContext::detag(got_tag); + if (ctx->RunNextState() == false) { + // call the callback and then delete it + ctx->report_stats(hist); + ctx->RunNextState(); + delete ctx; + } + cli_cq.Next(&got_tag, &ok); + if (!ok) break; + ctx = ClientRpcContext::detag(got_tag); + if (ctx->RunNextState() == false) { + // call the callback and then delete it + ctx->report_stats(hist); + ctx->RunNextState(); + delete ctx; + } + // Now do runtime round-robin assignment of the next + // channel number + channel_num += client_threads; + channel_num %= client_channels; + } + }, + i % client_channels)); + } + + gpr_histogram *hist = gpr_histogram_create(0.01, 60e9); + GPR_ASSERT(hist != NULL); + for (auto &t : threads) { + t.join(); + } + + grpc_profiler_stop(); + + for (int i = 0; i < client_threads; i++) { + gpr_histogram *h = thread_stats[i]; + gpr_log(GPR_INFO, "latency at thread %d (50/90/95/99/99.9): %f/%f/%f/%f/%f", + i, gpr_histogram_percentile(h, 50), gpr_histogram_percentile(h, 90), + gpr_histogram_percentile(h, 95), gpr_histogram_percentile(h, 99), + gpr_histogram_percentile(h, 99.9)); + gpr_histogram_merge(hist, h); + gpr_histogram_destroy(h); + } + + gpr_log( + GPR_INFO, + "latency across %d threads with %d channels and %d payload " + "(50/90/95/99/99.9): %f / %f / %f / %f / %f", + client_threads, client_channels, payload_size, + gpr_histogram_percentile(hist, 50), gpr_histogram_percentile(hist, 90), + gpr_histogram_percentile(hist, 95), gpr_histogram_percentile(hist, 99), + gpr_histogram_percentile(hist, 99.9)); + gpr_histogram_destroy(hist); + + grpc::ClientContext context_stats_end; + ServerStats server_stats_end; + grpc::Status status_end = stub_stats->CollectServerStats( + &context_stats_end, stats_request, &server_stats_end); + + double elapsed = server_stats_end.time_now() - server_stats_begin.time_now(); + int total_rpcs = client_threads * num_rpcs; + double utime = server_stats_end.time_user() - server_stats_begin.time_user(); + double stime = + server_stats_end.time_system() - server_stats_begin.time_system(); + gpr_log(GPR_INFO, + "Elapsed time: %.3f\n" + "RPC Count: %d\n" + "QPS: %.3f\n" + "System time: %.3f\n" + "User time: %.3f\n" + "Resource usage: %.1f%%\n", + elapsed, total_rpcs, total_rpcs / elapsed, stime, utime, + (stime + utime) / elapsed * 100.0); +} + +int main(int argc, char **argv) { + grpc_init(); + ParseCommandLineFlags(&argc, &argv, true); + + GPR_ASSERT(FLAGS_server_port); + + if (FLAGS_workload.length() == 0) { + RunTest(FLAGS_client_threads, FLAGS_client_channels, FLAGS_num_rpcs, + FLAGS_payload_size); + } else { + std::istringstream workload(FLAGS_workload); + int client_threads, client_channels, num_rpcs, payload_size; + workload >> client_threads; + while (!workload.eof()) { + workload >> client_channels >> num_rpcs >> payload_size; + RunTest(client_threads, client_channels, num_rpcs, payload_size); + workload >> client_threads; + } + gpr_log(GPR_INFO, "Done with specified workload."); + } + + grpc_shutdown(); + return 0; +} diff --git a/test/cpp/qps/server.cc b/test/cpp/qps/server.cc index 8e136349a15..be27c12b30a 100644 --- a/test/cpp/qps/server.cc +++ b/test/cpp/qps/server.cc @@ -36,6 +36,8 @@ #include #include +#include + #include #include #include @@ -97,7 +99,7 @@ static bool SetPayload(PayloadType type, int size, Payload* payload) { namespace { -class TestServiceImpl final : public TestService::Service { +class TestServiceImpl GRPC_FINAL : public TestService::Service { public: Status CollectServerStats(ServerContext* context, const StatsRequest*, ServerStats* response) { @@ -146,7 +148,7 @@ static void RunServer() { grpc_profiler_start("qps_server.prof"); while (!got_sigint) { - std::this_thread::sleep_for(std::chrono::seconds(5)); + sleep(5); } grpc_profiler_stop(); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc new file mode 100644 index 00000000000..c797d8af963 --- /dev/null +++ b/test/cpp/qps/server_async.cc @@ -0,0 +1,299 @@ +/* + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/cpp/server/thread_pool.h" +#include "test/core/util/grpc_profiler.h" +#include "test/cpp/qps/qpstest.pb.h" + +#include +#include + +DEFINE_bool(enable_ssl, false, "Whether to use ssl/tls."); +DEFINE_int32(port, 0, "Server port."); +DEFINE_int32(server_threads, 4, "Number of server threads."); + +using grpc::CompletionQueue; +using grpc::Server; +using grpc::ServerBuilder; +using grpc::ServerContext; +using grpc::ThreadPool; +using grpc::testing::Payload; +using grpc::testing::PayloadType; +using grpc::testing::ServerStats; +using grpc::testing::SimpleRequest; +using grpc::testing::SimpleResponse; +using grpc::testing::StatsRequest; +using grpc::testing::TestService; +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 {} +using namespace google; +using namespace gflags; + +static bool got_sigint = false; + +static void sigint_handler(int x) { got_sigint = 1; } + +static double time_double(struct timeval *tv) { + return tv->tv_sec + 1e-6 * tv->tv_usec; +} + +static bool SetPayload(PayloadType type, int size, Payload *payload) { + PayloadType response_type = type; + // TODO(yangg): Support UNCOMPRESSABLE payload. + if (type != PayloadType::COMPRESSABLE) { + return false; + } + payload->set_type(response_type); + std::unique_ptr body(new char[size]()); + payload->set_body(body.get(), size); + return true; +} + +namespace { + +class AsyncQpsServerTest { + public: + AsyncQpsServerTest() : srv_cq_(), async_service_(&srv_cq_), server_(nullptr) { + char *server_address = NULL; + gpr_join_host_port(&server_address, "::", FLAGS_port); + + ServerBuilder builder; + builder.AddPort(server_address); + + builder.RegisterAsyncService(&async_service_); + + server_ = builder.BuildAndStart(); + gpr_log(GPR_INFO, "Server listening on %s\n", server_address); + gpr_free(server_address); + + using namespace std::placeholders; + request_unary_ = std::bind(&TestService::AsyncService::RequestUnaryCall, + &async_service_, _1, _2, _3, &srv_cq_, _4); + request_stats_ = + std::bind(&TestService::AsyncService::RequestCollectServerStats, + &async_service_, _1, _2, _3, &srv_cq_, _4); + for (int i = 0; i < 100; i++) { + contexts_.push_front( + new ServerRpcContextUnaryImpl( + request_unary_, UnaryCall)); + contexts_.push_front( + new ServerRpcContextUnaryImpl( + request_stats_, CollectServerStats)); + } + } + ~AsyncQpsServerTest() { + server_->Shutdown(); + void *ignored_tag; + bool ignored_ok; + srv_cq_.Shutdown(); + while (srv_cq_.Next(&ignored_tag, &ignored_ok)) { + } + while (!contexts_.empty()) { + delete contexts_.front(); + contexts_.pop_front(); + } + } + void ServeRpcs(int num_threads) { + std::vector threads; + for (int i = 0; i < num_threads; i++) { + threads.push_back(std::thread([=]() { + // Wait until work is available or we are shutting down + bool ok; + void *got_tag; + while (srv_cq_.Next(&got_tag, &ok)) { + EXPECT_EQ(ok, true); + 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 + ctx->Reset(); + } + } + return; + })); + } + while (!got_sigint) { + std::this_thread::sleep_for(std::chrono::seconds(5)); + } + } + + private: + class ServerRpcContext { + public: + ServerRpcContext() {} + virtual ~ServerRpcContext(){}; + 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 ServerRpcContext *detag(void *tag) { + return reinterpret_cast(tag); + } + + template + class ServerRpcContextUnaryImpl : public ServerRpcContext { + public: + ServerRpcContextUnaryImpl( + std::function *, + void *)> request_method, + std::function + invoke_method) + : next_state_(&ServerRpcContextUnaryImpl::invoker), + request_method_(request_method), + invoke_method_(invoke_method), + response_writer_(&srv_ctx_) { + request_method_(&srv_ctx_, &req_, &response_writer_, + AsyncQpsServerTest::tag(this)); + } + ~ServerRpcContextUnaryImpl() GRPC_OVERRIDE {} + bool RunNextState() GRPC_OVERRIDE { return (this->*next_state_)(); } + void Reset() GRPC_OVERRIDE { + srv_ctx_ = ServerContext(); + req_ = RequestType(); + response_writer_ = + grpc::ServerAsyncResponseWriter(&srv_ctx_); + + // Then request the method + next_state_ = &ServerRpcContextUnaryImpl::invoker; + request_method_(&srv_ctx_, &req_, &response_writer_, + AsyncQpsServerTest::tag(this)); + } + + private: + bool finisher() { return false; } + bool invoker() { + ResponseType response; + + // Call the RPC processing function + grpc::Status status = invoke_method_(&req_, &response); + + // Have the response writer work and invoke on_finish when done + next_state_ = &ServerRpcContextUnaryImpl::finisher; + response_writer_.Finish(response, status, AsyncQpsServerTest::tag(this)); + return true; + } + ServerContext srv_ctx_; + RequestType req_; + bool (ServerRpcContextUnaryImpl::*next_state_)(); + std::function *, void *)> + request_method_; + std::function + invoke_method_; + grpc::ServerAsyncResponseWriter response_writer_; + }; + + static Status CollectServerStats(const StatsRequest *, + ServerStats *response) { + struct rusage usage; + struct timeval tv; + gettimeofday(&tv, NULL); + getrusage(RUSAGE_SELF, &usage); + response->set_time_now(time_double(&tv)); + response->set_time_user(time_double(&usage.ru_utime)); + response->set_time_system(time_double(&usage.ru_stime)); + return Status::OK; + } + 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())) { + return Status(grpc::StatusCode::INTERNAL, "Error creating payload."); + } + } + return Status::OK; + } + CompletionQueue srv_cq_; + TestService::AsyncService async_service_; + std::unique_ptr server_; + std::function *, void *)> + request_unary_; + std::function *, void *)> + request_stats_; + std::forward_list contexts_; +}; + +} // namespace + +static void RunServer() { + AsyncQpsServerTest server; + + grpc_profiler_start("qps_server_async.prof"); + + server.ServeRpcs(FLAGS_server_threads); + + grpc_profiler_stop(); +} + +int main(int argc, char **argv) { + grpc_init(); + ParseCommandLineFlags(&argc, &argv, true); + GPR_ASSERT(FLAGS_port != 0); + GPR_ASSERT(!FLAGS_enable_ssl); + + signal(SIGINT, sigint_handler); + + RunServer(); + + grpc_shutdown(); + google::protobuf::ShutdownProtobufLibrary(); + + return 0; +} diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 3476b8354b1..5c298ce8504 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -31,8 +31,8 @@ * */ -#ifndef __GRPCPP_TEST_UTIL_CREATE_TEST_CHANNEL_H_ -#define __GRPCPP_TEST_UTIL_CREATE_TEST_CHANNEL_H_ +#ifndef GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H +#define GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H #include @@ -56,4 +56,4 @@ std::shared_ptr CreateTestChannel( } // namespace grpc -#endif // __GRPCPP_TEST_UTIL_CREATE_TEST_CHANNEL_H_ +#endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H diff --git a/tools/distpackages/build_deb_packages.sh b/tools/distpackages/build_deb_packages.sh index a5f945bd9a1..7b2acb6577e 100755 --- a/tools/distpackages/build_deb_packages.sh +++ b/tools/distpackages/build_deb_packages.sh @@ -33,7 +33,8 @@ deb_dest="deb_out" mkdir -p $deb_dest -version='0.8.0.0' +version='0.5.0.0' +pkg_version='0.5.0' if [ -f /.dockerinit ]; then # We're in Docker where uname -p returns "unknown". @@ -97,7 +98,7 @@ do # Build the debian package fakeroot dpkg-deb --build $tmp_dir/$pkg_name || { echo "dpkg-deb failed"; exit 1; } - deb_path=$deb_dest/${pkg_name}_amd64.deb + deb_path=$deb_dest/${pkg_name}_${pkg_version}_amd64.deb # Copy the .deb file to destination dir cp $tmp_dir/$pkg_name.deb $deb_path diff --git a/tools/distpackages/templates/libgrpc-dev/DEBIAN/control b/tools/distpackages/templates/libgrpc-dev/DEBIAN/control index 64dc79af195..289a278c5fd 100644 --- a/tools/distpackages/templates/libgrpc-dev/DEBIAN/control +++ b/tools/distpackages/templates/libgrpc-dev/DEBIAN/control @@ -1,5 +1,5 @@ Package: libgrpc-dev -Version: 0.8.0 +Version: 0.5.0 Architecture: amd64 Maintainer: Jan Tattermusch Depends: libgrpc, libc6-dev | libc-dev diff --git a/tools/distpackages/templates/libgrpc-dev/usr/share/doc/libgrpc-dev/changelog.gz b/tools/distpackages/templates/libgrpc-dev/usr/share/doc/libgrpc-dev/changelog.gz index eabdf46e6e2..4f557b8e9f8 100644 Binary files a/tools/distpackages/templates/libgrpc-dev/usr/share/doc/libgrpc-dev/changelog.gz and b/tools/distpackages/templates/libgrpc-dev/usr/share/doc/libgrpc-dev/changelog.gz differ diff --git a/tools/distpackages/templates/libgrpc/DEBIAN/control b/tools/distpackages/templates/libgrpc/DEBIAN/control index 75c224e9a49..417a8258274 100644 --- a/tools/distpackages/templates/libgrpc/DEBIAN/control +++ b/tools/distpackages/templates/libgrpc/DEBIAN/control @@ -1,5 +1,5 @@ Package: libgrpc -Version: 0.8.0 +Version: 0.5.0 Architecture: amd64 Maintainer: Jan Tattermusch Depends: libc6 diff --git a/tools/distpackages/templates/libgrpc/usr/share/doc/libgrpc/changelog.gz b/tools/distpackages/templates/libgrpc/usr/share/doc/libgrpc/changelog.gz index c07b4d26371..12d4cd9300a 100644 Binary files a/tools/distpackages/templates/libgrpc/usr/share/doc/libgrpc/changelog.gz and b/tools/distpackages/templates/libgrpc/usr/share/doc/libgrpc/changelog.gz differ diff --git a/tools/distrib/guard_headers.sh b/tools/distrib/guard_headers.sh new file mode 100755 index 00000000000..2a54cf821a8 --- /dev/null +++ b/tools/distrib/guard_headers.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# 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. + + +set -e + +cd `dirname $0`/../.. + +function process_dir { + base_dir=$1 + prefix=$2 + comment_language=$3 + ( + cd $base_dir + find . -name "*.h" | while read f ; do + guard=${prefix}_`echo ${f#*/} | tr '[:lower:]/.-' '[:upper:]___'` + if [ "$comment_language" = "c++" ] ; then + comment="// $guard" + else + comment="/* $guard */" + fi + awk ' + BEGIN { + guard = "'${guard}'"; + comment_language = "'${comment_language}'"; + } + prev ~ /^#ifndef/ && !got_first_ifndef { + got_first_ifndef = 1; + prev = "#ifndef " guard; + } + prev ~ /^#define/ && !got_first_define { + got_first_define = 1; + prev = "#define " guard; + } + NR > 1 { print prev; } + { prev = $0; } + END { + if (prev ~ /^#endif/) { + if (comment_language ~ /^c$/) { + print "#endif /* " guard " */"; + } else if (comment_language ~ /^c\+\+$/) { + print "#endif // " guard; + } else { + print "ERROR: unknown comment language: " comment_language; + } + } else { + print "ERROR: file does not end with #endif"; + } + } + ' "${f}" > "${f}.rewritten" + mv "${f}.rewritten" "${f}" + done + ) +} + +process_dir include/grpc GRPC c +process_dir include/grpc++ GRPCXX c++ +process_dir src/core GRPC_INTERNAL_CORE c +process_dir src/cpp GRPC_INTERNAL_CPP c++ +process_dir src/compiler GRPC_INTERNAL_COMPILER c++ +process_dir test/core GRPC_TEST_CORE c +process_dir test/cpp GRPC_TEST_CPP c++ +process_dir examples GRPC_EXAMPLES c++ diff --git a/tools/dockerfile/grpc_base/Dockerfile b/tools/dockerfile/grpc_base/Dockerfile index d2b5569036d..91862773d57 100644 --- a/tools/dockerfile/grpc_base/Dockerfile +++ b/tools/dockerfile/grpc_base/Dockerfile @@ -64,13 +64,5 @@ ENV CLOUD_SDK /google-cloud-sdk RUN $CLOUD_SDK/install.sh --usage-reporting=true --path-update=true --bash-completion=true --rc-path=/.bashrc --disable-installation-options ENV PATH $CLOUD_SDK/bin:$PATH -# Install a GitHub SSH service credential that gives access to the GitHub repo while it's private -# TODO: remove this once the repo is public -ADD .ssh .ssh -RUN chmod 600 .ssh/github.rsa -RUN mkdir -p $HOME/.ssh && echo 'Host github.com' > $HOME/.ssh/config -RUN echo " IdentityFile /.ssh/github.rsa" >> $HOME/.ssh/config -RUN echo 'StrictHostKeyChecking no' >> $HOME/.ssh/config - # Define the default command. CMD ["bash"] diff --git a/tools/dockerfile/grpc_build_deb/Dockerfile b/tools/dockerfile/grpc_build_deb/Dockerfile index 6cba74e4c63..24ffc7379cf 100644 --- a/tools/dockerfile/grpc_build_deb/Dockerfile +++ b/tools/dockerfile/grpc_build_deb/Dockerfile @@ -34,7 +34,7 @@ FROM grpc/base RUN apt-get update && apt-get install -y lintian # Get the source from GitHub -RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone https://github.com/grpc/grpc.git /var/local/git/grpc RUN cd /var/local/git/grpc && \ git pull --recurse-submodules && \ git submodule update --init --recursive diff --git a/tools/dockerfile/grpc_cxx/Dockerfile b/tools/dockerfile/grpc_cxx/Dockerfile index 18c67324964..ac09e25e404 100644 --- a/tools/dockerfile/grpc_cxx/Dockerfile +++ b/tools/dockerfile/grpc_cxx/Dockerfile @@ -33,7 +33,7 @@ FROM grpc/base RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev # Get the source from GitHub -RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone https://github.com/grpc/grpc.git /var/local/git/grpc RUN cd /var/local/git/grpc && \ git pull --recurse-submodules && \ git submodule update --init --recursive diff --git a/tools/dockerfile/grpc_go/Dockerfile b/tools/dockerfile/grpc_go/Dockerfile index e1671eaee14..06bb3e2d5e7 100644 --- a/tools/dockerfile/grpc_go/Dockerfile +++ b/tools/dockerfile/grpc_go/Dockerfile @@ -30,21 +30,6 @@ # Dockerfile for gRPC Go FROM golang:1.4 -# Install SSH to that Go source can be pulled securely. -RUN apt-get update && apt-get install -y ssh - -# Install a GitHub SSH service credential that gives access to the GitHub repo while it's private -# -# TODO: remove this once the repo is public -ADD .ssh .ssh -RUN chmod 600 /.ssh/github.rsa -RUN mkdir -p $HOME/.ssh && echo 'Host github.com' > $HOME/.ssh/config -RUN echo " IdentityFile /.ssh/github.rsa" >> $HOME/.ssh/config -RUN echo 'StrictHostKeyChecking no' >> $HOME/.ssh/config - -# Force go get to use the GitHub ssh url instead of https, and use the SSH creds -RUN git config --global url."git@github.com:".insteadOf "https://github.com/" - # Get the source from GitHub RUN go get google.golang.org/grpc diff --git a/tools/dockerfile/grpc_java/Dockerfile b/tools/dockerfile/grpc_java/Dockerfile index affbec9b20f..6b2612b9b29 100644 --- a/tools/dockerfile/grpc_java/Dockerfile +++ b/tools/dockerfile/grpc_java/Dockerfile @@ -30,7 +30,7 @@ # Dockerfile for the gRPC Java dev image FROM grpc/java_base -RUN git clone --recursive --depth 1 git@github.com:grpc/grpc-java.git /var/local/git/grpc-java +RUN git clone --recursive --depth 1 https://github.com/grpc/grpc-java.git /var/local/git/grpc-java RUN cd /var/local/git/grpc-java/lib/netty && \ mvn -pl codec-http2 -am -DskipTests install clean RUN cd /var/local/git/grpc-java && \ diff --git a/tools/dockerfile/grpc_java_base/Dockerfile b/tools/dockerfile/grpc_java_base/Dockerfile index feac5e745e3..2ee0a623c7d 100644 --- a/tools/dockerfile/grpc_java_base/Dockerfile +++ b/tools/dockerfile/grpc_java_base/Dockerfile @@ -51,24 +51,19 @@ ENV PATH $PATH:$JAVA_HOME/bin:$M2_HOME/bin ENV LD_LIBRARY_PATH /usr/local/lib # Get the protobuf source from GitHub and install it -RUN wget -O - https://github.com/google/protobuf/archive/master.tar.gz | \ +RUN wget -O - https://github.com/google/protobuf/archive/v3.0.0-alpha-2.tar.gz | \ tar xz && \ - cd protobuf-master && \ + cd protobuf-3.0.0-alpha-2 && \ ./autogen.sh && \ ./configure --prefix=/usr && \ make -j12 && make check && make install && \ cd java && mvn install && cd .. && \ + cd javanano && mvn install && cd .. && \ rm -r "$(pwd)" -# Install a GitHub SSH service credential that gives access to the GitHub repo while it's private -# TODO: remove this once the repo is public -COPY .ssh/github.rsa /root/.ssh/id_rsa -RUN chmod 600 /root/.ssh/id_rsa -RUN echo 'Host github.com\nStrictHostKeyChecking no' > /root/.ssh/config - # Trigger download of as many Maven and Gradle artifacts as possible. We don't build grpc-java # because we don't want to install netty -RUN git clone --recursive --depth 1 git@github.com:grpc/grpc-java.git && \ +RUN git clone --recursive --depth 1 https://github.com/grpc/grpc-java.git && \ cd grpc-java/lib/netty && \ mvn -pl codec-http2 -am -DskipTests verify && \ cd ../.. && \ diff --git a/tools/dockerfile/grpc_node_base/Dockerfile b/tools/dockerfile/grpc_node_base/Dockerfile index 55ae6080201..1f3a2362e99 100644 --- a/tools/dockerfile/grpc_node_base/Dockerfile +++ b/tools/dockerfile/grpc_node_base/Dockerfile @@ -34,12 +34,12 @@ FROM grpc/base RUN curl -sL https://deb.nodesource.com/setup | bash - -RUN apt-get update && apt-get install -y nodejs +RUN apt-get update && apt-get install -y nodejs nodejs-legacy RUN npm install -g node-gyp # Get the source from GitHub, this gets the protobuf library as well -RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone https://github.com/grpc/grpc.git /var/local/git/grpc RUN cd /var/local/git/grpc && \ git pull --recurse-submodules && \ git submodule update --init --recursive diff --git a/tools/dockerfile/grpc_php_base/Dockerfile b/tools/dockerfile/grpc_php_base/Dockerfile index 49f5da846d7..cc874fd7c55 100644 --- a/tools/dockerfile/grpc_php_base/Dockerfile +++ b/tools/dockerfile/grpc_php_base/Dockerfile @@ -76,7 +76,7 @@ RUN cd /var/local \ # Download the patched PHP protobuf so that PHP gRPC clients can be generated # from proto3 schemas. -RUN git clone git@github.com:murgatroid99/Protobuf-PHP.git /var/local/git/protobuf-php +RUN git clone https://github.com/murgatroid99/Protobuf-PHP.git /var/local/git/protobuf-php # Install ruby (via RVM) as ruby tools are dependencies for building Protobuf # PHP extensions. @@ -91,7 +91,7 @@ ENV PATH /usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/s RUN rvm all do gem install ronn rake # Get the source from GitHub, this gets the protobuf library as well -RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone https://github.com/grpc/grpc.git /var/local/git/grpc RUN cd /var/local/git/grpc && \ git pull --recurse-submodules && \ git submodule update --init --recursive diff --git a/tools/dockerfile/grpc_python_base/Dockerfile b/tools/dockerfile/grpc_python_base/Dockerfile index 18dd40a05a3..0d45f402429 100644 --- a/tools/dockerfile/grpc_python_base/Dockerfile +++ b/tools/dockerfile/grpc_python_base/Dockerfile @@ -46,4 +46,4 @@ RUN apt-get update && apt-get install -y \ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.0.0-alpha-1 # Get the GRPC source from GitHub -RUN git clone --recursive git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone --recursive https://github.com/grpc/grpc.git /var/local/git/grpc diff --git a/tools/dockerfile/grpc_ruby_base/Dockerfile b/tools/dockerfile/grpc_ruby_base/Dockerfile index f3c7289943d..d58eeaaf709 100644 --- a/tools/dockerfile/grpc_ruby_base/Dockerfile +++ b/tools/dockerfile/grpc_ruby_base/Dockerfile @@ -72,7 +72,7 @@ RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc" RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc" # Get the source from GitHub -RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc +RUN git clone https://github.com/grpc/grpc.git /var/local/git/grpc RUN cd /var/local/git/grpc && \ git pull --recurse-submodules && \ git submodule update --init --recursive diff --git a/tools/gce_setup/cloud_prod_runner.sh b/tools/gce_setup/cloud_prod_runner.sh index 4732f952c26..e11185c226b 100755 --- a/tools/gce_setup/cloud_prod_runner.sh +++ b/tools/gce_setup/cloud_prod_runner.sh @@ -31,7 +31,7 @@ main() { source grpc_docker.sh - test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming service_account_creds compute_engine_creds) + test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_begin cancel_after_first_response) auth_test_cases=(service_account_creds compute_engine_creds) clients=(cxx java go ruby node) for test_case in "${test_cases[@]}" diff --git a/tools/gce_setup/grpc_docker.sh b/tools/gce_setup/grpc_docker.sh index 231625efb3a..02039261a35 100755 --- a/tools/gce_setup/grpc_docker.sh +++ b/tools/gce_setup/grpc_docker.sh @@ -926,7 +926,8 @@ grpc_cloud_prod_auth_service_account_creds_gen_go_cmd() { local cmd_prefix="sudo docker run grpc/go /bin/bash -c" local test_script="cd src/google.golang.org/grpc/interop/client" local test_script+=" && go run client.go --use_tls=true" - local gfe_flags=" --tls_ca_file=\"\" --tls_server_name=\"\" --server_port=443 --server_host=grpc-test.sandbox.google.com" + local gfe_flags=$(_grpc_prod_gfe_flags) + local gfe_flags+=" --tls_ca_file=\"\"" local added_gfe_flags=$(_grpc_svc_acc_test_flags) local the_cmd="$cmd_prefix '$test_script $gfe_flags $added_gfe_flags $@'" echo $the_cmd @@ -941,7 +942,8 @@ grpc_cloud_prod_auth_compute_engine_creds_gen_go_cmd() { local cmd_prefix="sudo docker run grpc/go /bin/bash -c" local test_script="cd src/google.golang.org/grpc/interop/client" local test_script+=" && go run client.go --use_tls=true" - local gfe_flags=" --tls_ca_file=\"\" --tls_server_name=\"\" --server_port=443 --server_host=grpc-test.sandbox.google.com" + local gfe_flags=$(_grpc_prod_gfe_flags) + local gfe_flags+=" --tls_ca_file=\"\"" local added_gfe_flags=$(_grpc_gce_test_flags) local the_cmd="$cmd_prefix '$test_script $gfe_flags $added_gfe_flags $@'" echo $the_cmd @@ -957,9 +959,10 @@ grpc_cloud_prod_auth_service_account_creds_gen_ruby_cmd() { local test_script="/var/local/git/grpc/src/ruby/bin/interop/interop_client.rb" local test_script+=" --use_tls" local gfe_flags=$(_grpc_prod_gfe_flags) - local added_gfe_flags=$(_grpc_svc_acc_test_flags) + local added_gfe_flags=$(_grpc_default_creds_test_flags) local env_prefix="SSL_CERT_FILE=/cacerts/roots.pem" - local the_cmd="$cmd_prefix '$env_prefix ruby $test_script $gfe_flags $added_gfe_flag $@'" + env_prefix+=" GOOGLE_APPLICATION_CREDENTIALS=/service_account/stubbyCloudTestingTest-7dd63462c60c.json" + local the_cmd="$cmd_prefix '$env_prefix ruby $test_script $gfe_flags $added_gfe_flags $@'" echo $the_cmd } @@ -975,7 +978,7 @@ grpc_cloud_prod_auth_compute_engine_creds_gen_ruby_cmd() { local gfe_flags=$(_grpc_prod_gfe_flags) local added_gfe_flags=$(_grpc_gce_test_flags) local env_prefix="SSL_CERT_FILE=/cacerts/roots.pem" - local the_cmd="$cmd_prefix '$env_prefix ruby $test_script $gfe_flags $added_gfe_flag $@'" + local the_cmd="$cmd_prefix '$env_prefix ruby $test_script $gfe_flags $added_gfe_flags $@'" echo $the_cmd } @@ -1001,7 +1004,8 @@ grpc_cloud_prod_gen_go_cmd() { local cmd_prefix="sudo docker run grpc/go /bin/bash -c" local test_script="cd src/google.golang.org/grpc/interop/client" local test_script+=" && go run client.go --use_tls=true" - local gfe_flags=" --tls_ca_file=\"\" --tls_server_name=\"\" --server_port=443 --server_host=grpc-test.sandbox.google.com" + local gfe_flags=$(_grpc_prod_gfe_flags) + local gfe_flags+=" --tls_ca_file=\"\"" local the_cmd="$cmd_prefix '$test_script $gfe_flags $@'" echo $the_cmd } @@ -1090,6 +1094,21 @@ grpc_cloud_prod_auth_service_account_creds_gen_node_cmd() { echo $the_cmd } +# constructs the full dockerized node gce auth interop test cmd. +# +# call-seq: +# flags= .... # generic flags to include the command +# cmd=$($grpc_gen_test_cmd $flags) +grpc_cloud_prod_auth_compute_engine_creds_gen_node_cmd() { + local env_flag="-e SSL_CERT_FILE=/cacerts/roots.pem " + local cmd_prefix="sudo docker run $env_flag grpc/node"; + local test_script="/usr/bin/nodejs /var/local/git/grpc/src/node/interop/interop_client.js --use_tls=true"; + local gfe_flags=$(_grpc_prod_gfe_flags) + local added_gfe_flags=$(_grpc_gce_test_flags) + local the_cmd="$cmd_prefix $test_script $gfe_flags $added_gfe_flags $@"; + echo $the_cmd +} + # constructs the full dockerized cpp interop test cmd. # # call-seq: @@ -1153,6 +1172,11 @@ _grpc_svc_acc_test_flags() { echo " --service_account_key_file=/service_account/stubbyCloudTestingTest-7dd63462c60c.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" } +# default credentials test flag +_grpc_default_creds_test_flags() { + echo " --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +} + # outputs the flags passed to the gcloud auth tests _grpc_gce_test_flags() { echo " --default_service_account=155450119199-r5aaqa2vqoa9g5mv2m6s3m1l293rlmel@developer.gserviceaccount.com --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" diff --git a/tools/gce_setup/interop_test_runner.sh b/tools/gce_setup/interop_test_runner.sh index 465c2ab6a78..5f8c0e70645 100755 --- a/tools/gce_setup/interop_test_runner.sh +++ b/tools/gce_setup/interop_test_runner.sh @@ -35,7 +35,7 @@ echo $result_file_name main() { source grpc_docker.sh - test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_being cancel_after_first_response) + test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_begin cancel_after_first_response) clients=(cxx java go ruby node) servers=(cxx java go ruby node python) for test_case in "${test_cases[@]}" diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh index 9303a67a1e6..5a3c720ba56 100755 --- a/tools/run_tests/build_python.sh +++ b/tools/run_tests/build_python.sh @@ -37,7 +37,6 @@ make -j6 root=`pwd` virtualenv python2.7_virtual_environment -ln -sf $root/include/grpc python2.7_virtual_environment/include/grpc source python2.7_virtual_environment/bin/activate pip install enum34==1.0.4 futures==2.2.0 protobuf==3.0.0-alpha-1 CFLAGS=-I$root/include LDFLAGS=-L$root/libs/opt pip install src/python/src diff --git a/src/ruby/lib/grpc/auth/service_account.rb b/tools/run_tests/build_ruby.sh old mode 100644 new mode 100755 similarity index 52% rename from src/ruby/lib/grpc/auth/service_account.rb rename to tools/run_tests/build_ruby.sh index 14b81a9e034..53a69cf0798 --- a/src/ruby/lib/grpc/auth/service_account.rb +++ b/tools/run_tests/build_ruby.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # Copyright 2015, Google Inc. # All rights reserved. # @@ -27,40 +29,19 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'grpc/auth/signet' -require 'multi_json' -require 'openssl' +set -ex + +CONFIG=${CONFIG:-opt} + +# change to grpc repo root +cd $(dirname $0)/../.. -# Reads the private key and client email fields from service account JSON key. -def read_json_key(json_key_io) - json_key = MultiJson.load(json_key_io.read) - fail 'missing client_email' unless json_key.key?('client_email') - fail 'missing private_key' unless json_key.key?('private_key') - [json_key['private_key'], json_key['client_email']] -end +# tells npm install to look for files in that directory +export GRPC_ROOT=`pwd` +# tells npm install the subdirectory with library files +export GRPC_LIB_SUBDIR=libs/$CONFIG -module GRPC - # Module Auth provides classes that provide Google-specific authentication - # used to access Google gRPC services. - module Auth - # Authenticates requests using Google's Service Account credentials. - # (cf https://developers.google.com/accounts/docs/OAuth2ServiceAccount) - class ServiceAccountCredentials < Signet::OAuth2::Client - TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token' - AUDIENCE = TOKEN_CRED_URI +cd src/ruby - # Initializes a ServiceAccountCredentials. - # - # @param scope [string|array] the scope(s) to access - # @param json_key_io [IO] an IO from which the JSON key can be read - def initialize(scope, json_key_io) - private_key, client_email = read_json_key(json_key_io) - super(token_credential_uri: TOKEN_CRED_URI, - audience: AUDIENCE, - scope: scope, - issuer: client_email, - signing_key: OpenSSL::PKey::RSA.new(private_key)) - end - end - end -end +bundle install +rake compile:grpc diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index 569cb5bac20..ad65da535b4 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -43,10 +43,17 @@ import time _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count() +have_alarm = False +def alarm_handler(unused_signum, unused_frame): + global have_alarm + have_alarm = False + + # setup a signal handler so that signal.pause registers 'something' # when a child finishes # not using futures and threading to avoid a dependency on subprocess32 signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None) +signal.signal(signal.SIGALRM, alarm_handler) def shuffle_iteratable(it): @@ -92,6 +99,7 @@ _CLEAR_LINE = '\x1b[2K' _TAG_COLOR = { 'FAILED': 'red', + 'TIMEOUT': 'red', 'PASSED': 'green', 'START': 'gray', 'WAITING': 'yellow', @@ -154,24 +162,27 @@ class JobSpec(object): class Job(object): """Manages one job.""" - def __init__(self, spec, bin_hash, newline_on_success): + def __init__(self, spec, bin_hash, newline_on_success, travis): self._spec = spec self._bin_hash = bin_hash self._tempfile = tempfile.TemporaryFile() env = os.environ.copy() for k, v in spec.environ.iteritems(): env[k] = v + self._start = time.time() self._process = subprocess.Popen(args=spec.cmdline, stderr=subprocess.STDOUT, stdout=self._tempfile, env=env) self._state = _RUNNING self._newline_on_success = newline_on_success - message('START', spec.shortname) + self._travis = travis + message('START', spec.shortname, do_newline=self._travis) def state(self, update_cache): """Poll current state of the job. Prints messages at completion.""" if self._state == _RUNNING and self._process.poll() is not None: + elapsed = time.time() - self._start if self._process.returncode != 0: self._state = _FAILURE self._tempfile.seek(0) @@ -180,10 +191,13 @@ class Job(object): self._spec.shortname, self._process.returncode), stdout) else: self._state = _SUCCESS - message('PASSED', self._spec.shortname, - do_newline=self._newline_on_success) + message('PASSED', '%s [time=%.1fsec]' % (self._spec.shortname, elapsed), + do_newline=self._newline_on_success or self._travis) if self._bin_hash: update_cache.finished(self._spec.identity(), self._bin_hash) + elif self._state == _RUNNING and time.time() - self._start > 300: + message('TIMEOUT', self._spec.shortname, do_newline=self._travis) + self.kill() return self._state def kill(self): @@ -195,7 +209,7 @@ class Job(object): class Jobset(object): """Manages one run of jobs.""" - def __init__(self, check_cancelled, maxjobs, newline_on_success, cache): + def __init__(self, check_cancelled, maxjobs, newline_on_success, travis, cache): self._running = set() self._check_cancelled = check_cancelled self._cancelled = False @@ -203,6 +217,7 @@ class Jobset(object): self._completed = 0 self._maxjobs = maxjobs self._newline_on_success = newline_on_success + self._travis = travis self._cache = cache def start(self, spec): @@ -224,7 +239,8 @@ class Jobset(object): if should_run: self._running.add(Job(spec, bin_hash, - self._newline_on_success)) + self._newline_on_success, + self._travis)) return True def reap(self): @@ -235,13 +251,19 @@ class Jobset(object): st = job.state(self._cache) if st == _RUNNING: continue if st == _FAILURE: self._failures += 1 + if st == _KILLED: self._failures += 1 dead.add(job) for job in dead: self._completed += 1 self._running.remove(job) if dead: return - message('WAITING', '%d jobs running, %d complete, %d failed' % ( - len(self._running), self._completed, self._failures)) + if (not self._travis): + message('WAITING', '%d jobs running, %d complete, %d failed' % ( + len(self._running), self._completed, self._failures)) + global have_alarm + if not have_alarm: + have_alarm = True + signal.alarm(10) signal.pause() def cancelled(self): @@ -277,12 +299,17 @@ def run(cmdlines, check_cancelled=_never_cancelled, maxjobs=None, newline_on_success=False, + travis=False, cache=None): js = Jobset(check_cancelled, maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS, - newline_on_success, + newline_on_success, travis, cache if cache is not None else NoCache()) - for cmdline in shuffle_iteratable(cmdlines): + if not travis: + cmdlines = shuffle_iteratable(cmdlines) + else: + cmdlines = sorted(cmdlines, key=lambda x: x.shortname) + for cmdline in cmdlines: if not js.start(cmdline): break return js.finish() diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh index fe40b511860..06ddb8e41ac 100755 --- a/tools/run_tests/run_python.sh +++ b/tools/run_tests/run_python.sh @@ -37,7 +37,8 @@ root=`pwd` export LD_LIBRARY_PATH=$root/libs/opt source python2.7_virtual_environment/bin/activate # TODO(issue 215): Properly itemize these in run_tests.py so that they can be parallelized. -python2.7 -B test/compiler/python_plugin_test.py +# TODO(atash): Enable dynamic unused port discovery for this test. +python2.7 -B test/compiler/python_plugin_test.py --build_mode=opt python2.7 -B -m grpc._adapter._blocking_invocation_inline_service_test python2.7 -B -m grpc._adapter._c_test python2.7 -B -m grpc._adapter._event_invocation_synchronous_event_service_test @@ -45,6 +46,7 @@ python2.7 -B -m grpc._adapter._future_invocation_asynchronous_event_service_test python2.7 -B -m grpc._adapter._links_test python2.7 -B -m grpc._adapter._lonely_rear_link_test python2.7 -B -m grpc._adapter._low_test +python2.7 -B -m grpc.early_adopter.implementations_test python2.7 -B -m grpc.framework.assembly.implementations_test python2.7 -B -m grpc.framework.base.packets.implementations_test python2.7 -B -m grpc.framework.face.blocking_invocation_inline_service_test diff --git a/src/ruby/lib/grpc/auth/compute_engine.rb b/tools/run_tests/run_ruby.sh old mode 100644 new mode 100755 similarity index 50% rename from src/ruby/lib/grpc/auth/compute_engine.rb rename to tools/run_tests/run_ruby.sh index 5cb1e1a4dcf..b82ce52af38 --- a/src/ruby/lib/grpc/auth/compute_engine.rb +++ b/tools/run_tests/run_ruby.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Copyright 2015, Google Inc. # All rights reserved. # @@ -27,41 +28,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'faraday' -require 'grpc/auth/signet' +set -ex -module GRPC - # Module Auth provides classes that provide Google-specific authentication - # used to access Google gRPC services. - module Auth - # Extends Signet::OAuth2::Client so that the auth token is obtained from - # the GCE metadata server. - class GCECredentials < Signet::OAuth2::Client - COMPUTE_AUTH_TOKEN_URI = 'http://metadata/computeMetadata/v1/'\ - 'instance/service-accounts/default/token' - COMPUTE_CHECK_URI = 'http://metadata.google.internal' +# change to grpc repo root +cd $(dirname $0)/../../src/ruby - # Detect if this appear to be a GCE instance, by checking if metadata - # is available - def self.on_gce?(options = {}) - c = options[:connection] || Faraday.default_connection - resp = c.get(COMPUTE_CHECK_URI) - return false unless resp.status == 200 - return false unless resp.headers.key?('Metadata-Flavor') - return resp.headers['Metadata-Flavor'] == 'Google' - rescue Faraday::ConnectionFailed - return false - end - - # Overrides the super class method to change how access tokens are - # fetched. - def fetch_access_token(options = {}) - c = options[:connection] || Faraday.default_connection - c.headers = { 'Metadata-Flavor' => 'Google' } - resp = c.get(COMPUTE_AUTH_TOKEN_URI) - Signet::OAuth2.parse_credentials(resp.body, - resp.headers['content-type']) - end - end - end -end +rake diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 7732466d6ea..b7370327ddd 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -44,6 +44,10 @@ import jobset import watch_dirs +ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..')) +os.chdir(ROOT) + + # SimpleConfig: just compile with CONFIG=config, and run the binary to test class SimpleConfig(object): @@ -83,14 +87,14 @@ class CLanguage(object): self.make_target = make_target with open('tools/run_tests/tests.json') as f: js = json.load(f) - self.binaries = [tgt['name'] - for tgt in js - if tgt['language'] == test_lang] + self.binaries = [tgt for tgt in js if tgt['language'] == test_lang] - def test_specs(self, config): + def test_specs(self, config, travis): out = [] - for name in self.binaries: - binary = 'bins/%s/%s' % (config.build_config, name) + for target in self.binaries: + if travis and target['flaky']: + continue + binary = 'bins/%s/%s' % (config.build_config, target['name']) out.append(config.job_spec(binary, [binary])) return out @@ -103,7 +107,7 @@ class CLanguage(object): class NodeLanguage(object): - def test_specs(self, config): + def test_specs(self, config, travis): return [config.job_spec('tools/run_tests/run_node.sh', None)] def make_targets(self): @@ -115,7 +119,7 @@ class NodeLanguage(object): class PhpLanguage(object): - def test_specs(self, config): + def test_specs(self, config, travis): return [config.job_spec('src/php/bin/run_tests.sh', None)] def make_targets(self): @@ -127,7 +131,7 @@ class PhpLanguage(object): class PythonLanguage(object): - def test_specs(self, config): + def test_specs(self, config, travis): return [config.job_spec('tools/run_tests/run_python.sh', None)] def make_targets(self): @@ -136,6 +140,17 @@ class PythonLanguage(object): def build_steps(self): return [['tools/run_tests/build_python.sh']] +class RubyLanguage(object): + + def test_specs(self, config, travis): + return [config.job_spec('tools/run_tests/run_ruby.sh', None)] + + def make_targets(self): + return ['static_c'] + + def build_steps(self): + return [['tools/run_tests/build_ruby.sh']] + # different configurations we can run under _CONFIGS = { @@ -160,6 +175,7 @@ _LANGUAGES = { 'node': NodeLanguage(), 'php': PhpLanguage(), 'python': PythonLanguage(), + 'ruby': RubyLanguage() } # parse command line @@ -171,10 +187,15 @@ argp.add_argument('-c', '--config', argp.add_argument('-n', '--runs_per_test', default=1, type=int) argp.add_argument('-r', '--regex', default='.*', type=str) argp.add_argument('-j', '--jobs', default=1000, type=int) +argp.add_argument('-s', '--slowdown', default=1.0, type=float) argp.add_argument('-f', '--forever', default=False, action='store_const', const=True) +argp.add_argument('-t', '--travis', + default=False, + action='store_const', + const=True) argp.add_argument('--newline_on_success', default=False, action='store_const', @@ -196,6 +217,7 @@ make_targets = [] languages = set(_LANGUAGES[l] for l in args.language) build_steps = [jobset.JobSpec(['make', '-j', '%d' % (multiprocessing.cpu_count() + 1), + 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown, 'CONFIG=%s' % cfg] + list(set( itertools.chain.from_iterable( l.make_targets() for l in languages)))) @@ -207,7 +229,7 @@ one_run = set( spec for config in run_configs for language in args.language - for spec in _LANGUAGES[language].test_specs(config) + for spec in _LANGUAGES[language].test_specs(config, args.travis) if re.search(args.regex, spec.shortname)) runs_per_test = args.runs_per_test @@ -232,6 +254,7 @@ class TestCache(object): def finished(self, cmdline, bin_hash): self._last_successful_run[cmdline] = bin_hash + self.save() def dump(self): return [{'cmdline': k, 'hash': v} @@ -250,17 +273,18 @@ class TestCache(object): self.parse(json.loads(f.read())) -def _build_and_run(check_cancelled, newline_on_success, cache): +def _build_and_run(check_cancelled, newline_on_success, travis, cache): """Do one pass of building & running tests.""" # build latest sequentially - if not jobset.run(build_steps, maxjobs=1): + if not jobset.run(build_steps, maxjobs=1, + newline_on_success=newline_on_success, travis=travis): return 1 # run all the tests all_runs = itertools.chain.from_iterable( itertools.repeat(one_run, runs_per_test)) if not jobset.run(all_runs, check_cancelled, - newline_on_success=newline_on_success, + newline_on_success=newline_on_success, travis=travis, maxjobs=min(args.jobs, min(c.maxjobs for c in run_configs)), cache=cache): return 2 @@ -286,16 +310,15 @@ if forever: 'All tests are now passing properly', do_newline=True) jobset.message('IDLE', 'No change detected') - test_cache.save() while not have_files_changed(): time.sleep(1) else: result = _build_and_run(check_cancelled=lambda: False, newline_on_success=args.newline_on_success, + travis=args.travis, cache=test_cache) if result == 0: jobset.message('SUCCESS', 'All tests passed', do_newline=True) else: jobset.message('FAILED', 'Some tests failed', do_newline=True) - test_cache.save() sys.exit(result) diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 4fb3e2d6b9e..772856b9c7f 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -2,1650 +2,2062 @@ [ { + "flaky": false, "language": "c", "name": "alarm_heap_test" }, { + "flaky": false, "language": "c", "name": "alarm_list_test" }, { + "flaky": false, "language": "c", "name": "alarm_test" }, { + "flaky": false, "language": "c", "name": "alpn_test" }, { + "flaky": false, "language": "c", "name": "bin_encoder_test" }, { + "flaky": false, "language": "c", "name": "census_hash_table_test" }, { + "flaky": true, "language": "c", "name": "census_statistics_multiple_writers_circular_buffer_test" }, { + "flaky": false, "language": "c", "name": "census_statistics_multiple_writers_test" }, { + "flaky": false, "language": "c", "name": "census_statistics_performance_test" }, { + "flaky": false, "language": "c", "name": "census_statistics_quick_test" }, { + "flaky": true, "language": "c", "name": "census_statistics_small_log_test" }, { + "flaky": false, "language": "c", "name": "census_stub_test" }, { + "flaky": false, "language": "c", "name": "census_window_stats_test" }, { + "flaky": false, "language": "c", "name": "chttp2_status_conversion_test" }, { + "flaky": false, "language": "c", "name": "chttp2_stream_encoder_test" }, { + "flaky": false, "language": "c", "name": "chttp2_stream_map_test" }, { + "flaky": false, "language": "c", "name": "chttp2_transport_end2end_test" }, { + "flaky": false, "language": "c", "name": "dualstack_socket_test" }, { + "flaky": false, "language": "c", "name": "echo_test" }, { + "flaky": false, "language": "c", "name": "fd_posix_test" }, { + "flaky": true, "language": "c", "name": "fling_stream_test" }, { + "flaky": true, "language": "c", "name": "fling_test" }, { + "flaky": false, "language": "c", "name": "gpr_cancellable_test" }, { + "flaky": false, "language": "c", "name": "gpr_cmdline_test" }, { + "flaky": false, "language": "c", "name": "gpr_env_test" }, { + "flaky": false, "language": "c", "name": "gpr_file_test" }, { + "flaky": false, "language": "c", "name": "gpr_histogram_test" }, { + "flaky": false, "language": "c", "name": "gpr_host_port_test" }, { + "flaky": false, "language": "c", "name": "gpr_log_test" }, { + "flaky": false, "language": "c", "name": "gpr_slice_buffer_test" }, { + "flaky": false, "language": "c", "name": "gpr_slice_test" }, { + "flaky": false, "language": "c", "name": "gpr_string_test" }, { + "flaky": false, "language": "c", "name": "gpr_sync_test" }, { + "flaky": false, "language": "c", "name": "gpr_thd_test" }, { + "flaky": false, "language": "c", "name": "gpr_time_test" }, { + "flaky": false, "language": "c", "name": "gpr_useful_test" }, { + "flaky": false, "language": "c", "name": "grpc_base64_test" }, { + "flaky": false, "language": "c", "name": "grpc_byte_buffer_reader_test" }, { + "flaky": false, "language": "c", "name": "grpc_channel_stack_test" }, { + "flaky": false, "language": "c", "name": "grpc_completion_queue_test" }, { + "flaky": false, "language": "c", "name": "grpc_credentials_test" }, { + "flaky": false, "language": "c", "name": "grpc_json_token_test" }, { + "flaky": false, "language": "c", "name": "grpc_stream_op_test" }, { + "flaky": false, "language": "c", "name": "hpack_parser_test" }, { + "flaky": false, "language": "c", "name": "hpack_table_test" }, { + "flaky": false, "language": "c", "name": "httpcli_format_request_test" }, { + "flaky": false, "language": "c", "name": "httpcli_parser_test" }, { + "flaky": false, "language": "c", "name": "json_rewrite_test" }, { + "flaky": false, "language": "c", "name": "json_test" }, { + "flaky": false, "language": "c", "name": "lame_client_test" }, { + "flaky": false, "language": "c", "name": "message_compress_test" }, { + "flaky": false, "language": "c", "name": "metadata_buffer_test" }, { + "flaky": false, "language": "c", "name": "multi_init_test" }, { + "flaky": false, "language": "c", "name": "murmur_hash_test" }, { + "flaky": false, "language": "c", "name": "no_server_test" }, { + "flaky": false, "language": "c", "name": "poll_kick_posix_test" }, { + "flaky": false, "language": "c", "name": "resolve_address_test" }, { + "flaky": false, "language": "c", "name": "secure_endpoint_test" }, { + "flaky": false, "language": "c", "name": "sockaddr_utils_test" }, { + "flaky": false, "language": "c", "name": "tcp_client_posix_test" }, { + "flaky": false, "language": "c", "name": "tcp_posix_test" }, { + "flaky": false, "language": "c", "name": "tcp_server_posix_test" }, { + "flaky": false, "language": "c", "name": "time_averaged_stats_test" }, { + "flaky": false, "language": "c", "name": "time_test" }, { + "flaky": false, "language": "c", "name": "timeout_encoding_test" }, { + "flaky": false, "language": "c", "name": "transport_metadata_test" }, { + "flaky": false, "language": "c", "name": "transport_security_test" }, { + "flaky": false, "language": "c++", "name": "async_end2end_test" }, { + "flaky": false, "language": "c++", "name": "channel_arguments_test" }, { + "flaky": false, "language": "c++", "name": "credentials_test" }, { + "flaky": false, "language": "c++", "name": "end2end_test" }, { + "flaky": false, "language": "c++", "name": "interop_test" }, { + "flaky": false, "language": "c++", "name": "pubsub_publisher_test" }, { + "flaky": false, "language": "c++", "name": "pubsub_subscriber_test" }, { + "flaky": false, "language": "c++", "name": "status_test" }, { + "flaky": false, "language": "c++", "name": "thread_pool_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fake_security_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_fullstack_uds_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_writes_done_hangs_with_pending_read_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_empty_batch_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_no_op_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_with_payload_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_simple_request_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_thread_stress_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_census_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_disappearing_server_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_no_op_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_with_large_metadata_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_request_with_payload_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_simple_request_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_thread_stress_legacy_test" }, { + "flaky": false, "language": "c", "name": "chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_legacy_test" } diff --git a/tools/tsan_suppressions.txt b/tools/tsan_suppressions.txt index 23d57f9fd1f..65e7e2ec4b3 100644 --- a/tools/tsan_suppressions.txt +++ b/tools/tsan_suppressions.txt @@ -1,2 +1,8 @@ # OPENSSL_cleanse does racy access to a global race:OPENSSL_cleanse +race:cleanse_ctr +# these are legitimate races in OpenSSL, and it appears those folks are looking at it +# https://www.mail-archive.com/openssl-dev@openssl.org/msg09019.html +race:ssleay_rand_add +race:ssleay_rand_bytes +