aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-02-04 12:51:14 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-02-04 12:51:14 -0800
commitfd9d0b47e504fc79bb58d809696c1b964070af7d (patch)
tree21c91490b0c56ad16e47009ade39ab307bc04fc4
parente2b2b1fb676eef687f0ea088aa74a13b52cbf755 (diff)
parentd6731628bcedbe150d4f7cd09656bd506979b00f (diff)
Merge branch 'async-api' of github.com:ctiller/grpc into async-api
-rw-r--r--.gitignore5
-rw-r--r--Makefile263
-rw-r--r--build.json100
-rw-r--r--examples/tips/README26
-rw-r--r--examples/tips/empty.proto2
-rw-r--r--examples/tips/label.proto2
-rw-r--r--examples/tips/main.cc (renamed from examples/tips/client_main.cc)94
-rw-r--r--examples/tips/publisher.cc (renamed from examples/tips/client.cc)46
-rw-r--r--examples/tips/publisher.h (renamed from examples/tips/client.h)23
-rw-r--r--examples/tips/publisher_test.cc (renamed from examples/tips/client_test.cc)69
-rw-r--r--examples/tips/pubsub.proto2
-rw-r--r--examples/tips/subscriber.cc118
-rw-r--r--examples/tips/subscriber.h68
-rw-r--r--examples/tips/subscriber_test.cc157
-rw-r--r--src/core/iomgr/iomgr.c8
-rw-r--r--src/core/support/cpu_linux.c35
-rw-r--r--src/core/surface/call.c64
-rw-r--r--src/csharp/.gitignore2
-rwxr-xr-xsrc/csharp/README.md22
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c113
-rwxr-xr-xsrc/php/README.md27
-rwxr-xr-xsrc/php/lib/Grpc/AbstractSurfaceActiveCall.php2
-rwxr-xr-xsrc/php/lib/Grpc/ActiveCall.php7
-rwxr-xr-xsrc/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php2
-rwxr-xr-xsrc/php/tests/generated_code/GeneratedCodeTest.php20
-rwxr-xr-xsrc/php/tests/interop/interop_client.php34
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php90
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php89
-rwxr-xr-xsrc/php/tests/unit_tests/TimevalTest.php2
-rw-r--r--test/core/end2end/README3
-rwxr-xr-xtest/core/end2end/gen_build_json.py2
-rwxr-xr-xtools/buildgen/mako_renderer.py2
-rw-r--r--tools/dockerfile/grpc_base/README.md3
-rw-r--r--tools/dockerfile/grpc_java/README.md2
-rw-r--r--tools/dockerfile/grpc_node/Dockerfile2
-rw-r--r--tools/dockerfile/grpc_php/README.md2
-rw-r--r--tools/dockerfile/grpc_php_base/Dockerfile6
-rw-r--r--tools/dockerfile/grpc_ruby/README.md2
-rwxr-xr-xtools/gce_setup/grpc_docker.sh6
-rwxr-xr-xtools/gce_setup/interop_test_runner.sh42
-rwxr-xr-xtools/gce_setup/new_grpc_docker_builder.sh1
-rwxr-xr-xtools/gce_setup/new_grpc_docker_builder_on_startup.sh7
-rwxr-xr-xtools/gce_setup/shared_startup_funcs.sh31
-rwxr-xr-xtools/run_tests/run_tests.py2
-rw-r--r--tools/run_tests/tests.json12
45 files changed, 1197 insertions, 420 deletions
diff --git a/.gitignore b/.gitignore
index 6eb55b1202..9c9ae5abd4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,11 @@ coverage
# python compiled objects
*.pyc
+#eclipse project files
+.cproject
+.project
+.settings
+
# cache for run_tests.py
.run_tests_cache
diff --git a/Makefile b/Makefile
index 7ec690ef22..5607edce11 100644
--- a/Makefile
+++ b/Makefile
@@ -385,14 +385,15 @@ credentials_test: bins/$(CONFIG)/credentials_test
end2end_test: bins/$(CONFIG)/end2end_test
interop_client: bins/$(CONFIG)/interop_client
interop_server: bins/$(CONFIG)/interop_server
+tips_client: bins/$(CONFIG)/tips_client
+tips_publisher_test: bins/$(CONFIG)/tips_publisher_test
+tips_subscriber_test: bins/$(CONFIG)/tips_subscriber_test
qps_client: bins/$(CONFIG)/qps_client
qps_server: bins/$(CONFIG)/qps_server
ruby_plugin: bins/$(CONFIG)/ruby_plugin
status_test: bins/$(CONFIG)/status_test
sync_client_async_server_test: bins/$(CONFIG)/sync_client_async_server_test
thread_pool_test: bins/$(CONFIG)/thread_pool_test
-tips_client: bins/$(CONFIG)/tips_client
-tips_client_test: bins/$(CONFIG)/tips_client_test
chttp2_fake_security_cancel_after_accept_test: bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test
chttp2_fake_security_cancel_after_accept_and_writes_closed_test: bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test
chttp2_fake_security_cancel_after_invoke_test: bins/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test
@@ -552,13 +553,13 @@ endif
static: static_c static_cxx
-static_c: libs/$(CONFIG)/libgpr.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgrpc_unsecure.a
+static_c: libs/$(CONFIG)/libgpr.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgrpc_unsecure.a libs/$(CONFIG)/libgrpc_csharp_ext.a
static_cxx: libs/$(CONFIG)/libgrpc++.a
shared: shared_c shared_cxx
-shared_c: libs/$(CONFIG)/libgpr.$(SHARED_EXT) libs/$(CONFIG)/libgrpc.$(SHARED_EXT) libs/$(CONFIG)/libgrpc_unsecure.$(SHARED_EXT)
+shared_c: libs/$(CONFIG)/libgpr.$(SHARED_EXT) libs/$(CONFIG)/libgrpc.$(SHARED_EXT) libs/$(CONFIG)/libgrpc_unsecure.$(SHARED_EXT) libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT)
shared_cxx: libs/$(CONFIG)/libgrpc++.$(SHARED_EXT)
@@ -572,7 +573,7 @@ buildtests: buildtests_c buildtests_cxx
buildtests_c: privatelibs_c bins/$(CONFIG)/alarm_heap_test bins/$(CONFIG)/alarm_list_test bins/$(CONFIG)/alarm_test bins/$(CONFIG)/alpn_test bins/$(CONFIG)/bin_encoder_test bins/$(CONFIG)/census_hash_table_test bins/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test bins/$(CONFIG)/census_statistics_multiple_writers_test bins/$(CONFIG)/census_statistics_performance_test bins/$(CONFIG)/census_statistics_quick_test bins/$(CONFIG)/census_statistics_small_log_test bins/$(CONFIG)/census_stub_test bins/$(CONFIG)/census_window_stats_test bins/$(CONFIG)/chttp2_status_conversion_test bins/$(CONFIG)/chttp2_stream_encoder_test bins/$(CONFIG)/chttp2_stream_map_test bins/$(CONFIG)/chttp2_transport_end2end_test bins/$(CONFIG)/dualstack_socket_test bins/$(CONFIG)/echo_client bins/$(CONFIG)/echo_server bins/$(CONFIG)/echo_test bins/$(CONFIG)/fd_posix_test bins/$(CONFIG)/fling_client bins/$(CONFIG)/fling_server bins/$(CONFIG)/fling_stream_test bins/$(CONFIG)/fling_test bins/$(CONFIG)/gpr_cancellable_test bins/$(CONFIG)/gpr_cmdline_test bins/$(CONFIG)/gpr_histogram_test bins/$(CONFIG)/gpr_host_port_test bins/$(CONFIG)/gpr_log_test bins/$(CONFIG)/gpr_slice_buffer_test bins/$(CONFIG)/gpr_slice_test bins/$(CONFIG)/gpr_string_test bins/$(CONFIG)/gpr_sync_test bins/$(CONFIG)/gpr_thd_test bins/$(CONFIG)/gpr_time_test bins/$(CONFIG)/gpr_useful_test bins/$(CONFIG)/grpc_base64_test bins/$(CONFIG)/grpc_byte_buffer_reader_test bins/$(CONFIG)/grpc_channel_stack_test bins/$(CONFIG)/grpc_completion_queue_test bins/$(CONFIG)/grpc_credentials_test bins/$(CONFIG)/grpc_json_token_test bins/$(CONFIG)/grpc_stream_op_test bins/$(CONFIG)/hpack_parser_test bins/$(CONFIG)/hpack_table_test bins/$(CONFIG)/httpcli_format_request_test bins/$(CONFIG)/httpcli_parser_test bins/$(CONFIG)/httpcli_test bins/$(CONFIG)/json_rewrite bins/$(CONFIG)/json_rewrite_test bins/$(CONFIG)/json_test bins/$(CONFIG)/lame_client_test bins/$(CONFIG)/message_compress_test bins/$(CONFIG)/metadata_buffer_test bins/$(CONFIG)/murmur_hash_test bins/$(CONFIG)/no_server_test bins/$(CONFIG)/poll_kick_posix_test bins/$(CONFIG)/resolve_address_test bins/$(CONFIG)/secure_endpoint_test bins/$(CONFIG)/sockaddr_utils_test bins/$(CONFIG)/tcp_client_posix_test bins/$(CONFIG)/tcp_posix_test bins/$(CONFIG)/tcp_server_posix_test bins/$(CONFIG)/time_averaged_stats_test bins/$(CONFIG)/time_test bins/$(CONFIG)/timeout_encoding_test bins/$(CONFIG)/transport_metadata_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fake_security_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fake_security_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fake_security_census_simple_request_test bins/$(CONFIG)/chttp2_fake_security_disappearing_server_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fake_security_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fake_security_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fake_security_invoke_large_request_test bins/$(CONFIG)/chttp2_fake_security_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fake_security_no_op_test bins/$(CONFIG)/chttp2_fake_security_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_payload_test bins/$(CONFIG)/chttp2_fake_security_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fake_security_simple_delayed_request_test bins/$(CONFIG)/chttp2_fake_security_simple_request_test bins/$(CONFIG)/chttp2_fake_security_thread_stress_test bins/$(CONFIG)/chttp2_fake_security_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_fullstack_no_op_test bins/$(CONFIG)/chttp2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_after_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_before_invoke_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_census_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_disappearing_server_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_invoke_large_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_max_concurrent_streams_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_no_op_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_ping_pong_streaming_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_delayed_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_simple_request_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_thread_stress_test bins/$(CONFIG)/chttp2_simple_ssl_with_oauth2_fullstack_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_no_op_test bins/$(CONFIG)/chttp2_socket_pair_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_writes_done_hangs_with_pending_read_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_accept_and_writes_closed_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_after_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_before_invoke_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_cancel_in_a_vacuum_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_census_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_disappearing_server_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_inflight_calls_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_early_server_shutdown_finishes_tags_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_graceful_server_shutdown_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_invoke_large_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_max_concurrent_streams_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_no_op_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_ping_pong_streaming_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_binary_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_request_response_with_trailing_metadata_and_payload_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_delayed_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_simple_request_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_thread_stress_test bins/$(CONFIG)/chttp2_socket_pair_one_byte_at_a_time_writes_done_hangs_with_pending_read_test
-buildtests_cxx: privatelibs_cxx bins/$(CONFIG)/channel_arguments_test bins/$(CONFIG)/credentials_test bins/$(CONFIG)/end2end_test bins/$(CONFIG)/interop_client bins/$(CONFIG)/interop_server bins/$(CONFIG)/qps_client bins/$(CONFIG)/qps_server bins/$(CONFIG)/status_test bins/$(CONFIG)/sync_client_async_server_test bins/$(CONFIG)/thread_pool_test bins/$(CONFIG)/tips_client bins/$(CONFIG)/tips_client_test
+buildtests_cxx: privatelibs_cxx bins/$(CONFIG)/channel_arguments_test bins/$(CONFIG)/credentials_test bins/$(CONFIG)/end2end_test bins/$(CONFIG)/interop_client bins/$(CONFIG)/interop_server bins/$(CONFIG)/tips_client bins/$(CONFIG)/tips_publisher_test bins/$(CONFIG)/tips_subscriber_test bins/$(CONFIG)/qps_client bins/$(CONFIG)/qps_server bins/$(CONFIG)/status_test bins/$(CONFIG)/sync_client_async_server_test bins/$(CONFIG)/thread_pool_test
test: test_c test_cxx
@@ -976,6 +977,10 @@ test_cxx: buildtests_cxx
$(Q) ./bins/$(CONFIG)/credentials_test || ( echo test credentials_test failed ; exit 1 )
$(E) "[RUN] Testing end2end_test"
$(Q) ./bins/$(CONFIG)/end2end_test || ( echo test end2end_test failed ; exit 1 )
+ $(E) "[RUN] Testing tips_publisher_test"
+ $(Q) ./bins/$(CONFIG)/tips_publisher_test || ( echo test tips_publisher_test failed ; exit 1 )
+ $(E) "[RUN] Testing tips_subscriber_test"
+ $(Q) ./bins/$(CONFIG)/tips_subscriber_test || ( echo test tips_subscriber_test failed ; exit 1 )
$(E) "[RUN] Testing qps_client"
$(Q) ./bins/$(CONFIG)/qps_client || ( echo test qps_client failed ; exit 1 )
$(E) "[RUN] Testing qps_server"
@@ -986,8 +991,6 @@ test_cxx: buildtests_cxx
$(Q) ./bins/$(CONFIG)/sync_client_async_server_test || ( echo test sync_client_async_server_test failed ; exit 1 )
$(E) "[RUN] Testing thread_pool_test"
$(Q) ./bins/$(CONFIG)/thread_pool_test || ( echo test thread_pool_test failed ; exit 1 )
- $(E) "[RUN] Testing tips_client_test"
- $(Q) ./bins/$(CONFIG)/tips_client_test || ( echo test tips_client_test failed ; exit 1 )
tools: privatelibs bins/$(CONFIG)/gen_hpack_tables bins/$(CONFIG)/grpc_fetch_oauth2
@@ -1015,6 +1018,8 @@ ifeq ($(CONFIG),opt)
$(Q) $(STRIP) libs/$(CONFIG)/libgrpc.a
$(E) "[STRIP] Stripping libgrpc_unsecure.a"
$(Q) $(STRIP) libs/$(CONFIG)/libgrpc_unsecure.a
+ $(E) "[STRIP] Stripping libgrpc_csharp_ext.a"
+ $(Q) $(STRIP) libs/$(CONFIG)/libgrpc_csharp_ext.a
endif
strip-static_cxx: static_cxx
@@ -1031,6 +1036,8 @@ ifeq ($(CONFIG),opt)
$(Q) $(STRIP) libs/$(CONFIG)/libgrpc.$(SHARED_EXT)
$(E) "[STRIP] Stripping libgrpc_unsecure.so"
$(Q) $(STRIP) libs/$(CONFIG)/libgrpc_unsecure.$(SHARED_EXT)
+ $(E) "[STRIP] Stripping libgrpc_csharp_ext.so"
+ $(Q) $(STRIP) libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT)
endif
strip-shared_cxx: shared_cxx
@@ -1136,6 +1143,8 @@ install-static_c: static_c strip-static_c
$(Q) $(INSTALL) libs/$(CONFIG)/libgrpc.a $(prefix)/lib/libgrpc.a
$(E) "[INSTALL] Installing libgrpc_unsecure.a"
$(Q) $(INSTALL) libs/$(CONFIG)/libgrpc_unsecure.a $(prefix)/lib/libgrpc_unsecure.a
+ $(E) "[INSTALL] Installing libgrpc_csharp_ext.a"
+ $(Q) $(INSTALL) libs/$(CONFIG)/libgrpc_csharp_ext.a $(prefix)/lib/libgrpc_csharp_ext.a
install-static_cxx: static_cxx strip-static_cxx
$(E) "[INSTALL] Installing libgrpc++.a"
@@ -1175,6 +1184,17 @@ ifneq ($(SYSTEM),Darwin)
$(Q) ln -sf libgrpc_unsecure.$(SHARED_EXT) $(prefix)/lib/libgrpc_unsecure.so
endif
endif
+ifeq ($(SYSTEM),MINGW32)
+ $(E) "[INSTALL] Installing grpc_csharp_ext.$(SHARED_EXT)"
+ $(Q) $(INSTALL) libs/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(prefix)/lib/grpc_csharp_ext.$(SHARED_EXT)
+ $(Q) $(INSTALL) libs/$(CONFIG)/libgrpc_csharp_ext-imp.a $(prefix)/lib/libgrpc_csharp_ext-imp.a
+else
+ $(E) "[INSTALL] Installing libgrpc_csharp_ext.$(SHARED_EXT)"
+ $(Q) $(INSTALL) libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(prefix)/lib/libgrpc_csharp_ext.$(SHARED_EXT)
+ifneq ($(SYSTEM),Darwin)
+ $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(prefix)/lib/libgrpc_csharp_ext.so
+endif
+endif
ifneq ($(SYSTEM),MINGW32)
ifneq ($(SYSTEM),Darwin)
$(Q) ldconfig
@@ -2249,7 +2269,8 @@ LIBTIPS_CLIENT_LIB_SRC = \
gens/examples/tips/label.pb.cc \
gens/examples/tips/empty.pb.cc \
gens/examples/tips/pubsub.pb.cc \
- examples/tips/client.cc \
+ examples/tips/publisher.cc \
+ examples/tips/subscriber.cc \
LIBTIPS_CLIENT_LIB_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBTIPS_CLIENT_LIB_SRC))))
@@ -2267,7 +2288,8 @@ ifneq ($(OPENSSL_DEP),)
examples/tips/label.proto: $(OPENSSL_DEP)
examples/tips/empty.proto: $(OPENSSL_DEP)
examples/tips/pubsub.proto: $(OPENSSL_DEP)
-examples/tips/client.cc: $(OPENSSL_DEP)
+examples/tips/publisher.cc: $(OPENSSL_DEP)
+examples/tips/subscriber.cc: $(OPENSSL_DEP)
endif
libs/$(CONFIG)/libtips_client_lib.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(LIBTIPS_CLIENT_LIB_OBJS)
@@ -2294,7 +2316,73 @@ endif
-objs/$(CONFIG)/examples/tips/client.o: gens/examples/tips/label.pb.cc gens/examples/tips/empty.pb.cc gens/examples/tips/pubsub.pb.cc
+objs/$(CONFIG)/examples/tips/publisher.o: gens/examples/tips/label.pb.cc gens/examples/tips/empty.pb.cc gens/examples/tips/pubsub.pb.cc
+objs/$(CONFIG)/examples/tips/subscriber.o: gens/examples/tips/label.pb.cc gens/examples/tips/empty.pb.cc gens/examples/tips/pubsub.pb.cc
+
+
+LIBGRPC_CSHARP_EXT_SRC = \
+ src/csharp/ext/grpc_csharp_ext.c \
+
+
+LIBGRPC_CSHARP_EXT_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_CSHARP_EXT_SRC))))
+
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure libraries if you don't have OpenSSL with ALPN.
+
+libs/$(CONFIG)/libgrpc_csharp_ext.a: openssl_dep_error
+
+ifeq ($(SYSTEM),MINGW32)
+libs/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): openssl_dep_error
+else
+libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): openssl_dep_error
+endif
+
+else
+
+ifneq ($(OPENSSL_DEP),)
+src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP)
+endif
+
+libs/$(CONFIG)/libgrpc_csharp_ext.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(LIBGRPC_CSHARP_EXT_OBJS)
+ $(E) "[AR] Creating $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) rm -f libs/$(CONFIG)/libgrpc_csharp_ext.a
+ $(Q) $(AR) rcs libs/$(CONFIG)/libgrpc_csharp_ext.a $(LIBGRPC_CSHARP_EXT_OBJS)
+ifeq ($(SYSTEM),Darwin)
+ $(Q) ranlib libs/$(CONFIG)/libgrpc_csharp_ext.a
+endif
+
+
+
+ifeq ($(SYSTEM),MINGW32)
+libs/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP)libs/$(CONFIG)/gpr.$(SHARED_EXT)libs/$(CONFIG)/grpc.$(SHARED_EXT) $(OPENSSL_DEP)
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) -Llibs/$(CONFIG) -shared -Wl,--output-def=libs/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=libs/$(CONFIG)/libgrpc_csharp_ext-imp.a -o libs/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS) -lgpr-imp -lgrpc-imp
+else
+libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) libs/$(CONFIG)/libgpr.$(SHARED_EXT) libs/$(CONFIG)/libgrpc.$(SHARED_EXT) $(OPENSSL_DEP)
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ifeq ($(SYSTEM),Darwin)
+ $(Q) $(LD) $(LDFLAGS) -Llibs/$(CONFIG) -dynamiclib -o libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS) -lgpr -lgrpc
+else
+ $(Q) $(LD) $(LDFLAGS) -Llibs/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o libs/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS) -lgpr -lgrpc
+ $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) libs/$(CONFIG)/libgrpc_csharp_ext.so.0
+ $(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) libs/$(CONFIG)/libgrpc_csharp_ext.so
+endif
+endif
+
+
+endif
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(LIBGRPC_CSHARP_EXT_OBJS:.o=.dep)
+endif
+endif
+
+objs/$(CONFIG)/src/csharp/ext/grpc_csharp_ext.o:
LIBEND2END_FIXTURE_CHTTP2_FAKE_SECURITY_SRC = \
@@ -5696,6 +5784,99 @@ endif
endif
+TIPS_CLIENT_SRC = \
+ examples/tips/main.cc \
+
+TIPS_CLIENT_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(TIPS_CLIENT_SRC))))
+
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL with ALPN.
+
+bins/$(CONFIG)/tips_client: openssl_dep_error
+
+else
+
+bins/$(CONFIG)/tips_client: $(TIPS_CLIENT_OBJS) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(TIPS_CLIENT_OBJS) $(GTEST_LIB) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/tips_client
+
+endif
+
+objs/$(CONFIG)/examples/tips/main.o: libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+
+deps_tips_client: $(TIPS_CLIENT_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(TIPS_CLIENT_OBJS:.o=.dep)
+endif
+endif
+
+
+TIPS_PUBLISHER_TEST_SRC = \
+ examples/tips/publisher_test.cc \
+
+TIPS_PUBLISHER_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(TIPS_PUBLISHER_TEST_SRC))))
+
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL with ALPN.
+
+bins/$(CONFIG)/tips_publisher_test: openssl_dep_error
+
+else
+
+bins/$(CONFIG)/tips_publisher_test: $(TIPS_PUBLISHER_TEST_OBJS) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(TIPS_PUBLISHER_TEST_OBJS) $(GTEST_LIB) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/tips_publisher_test
+
+endif
+
+objs/$(CONFIG)/examples/tips/publisher_test.o: libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+
+deps_tips_publisher_test: $(TIPS_PUBLISHER_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(TIPS_PUBLISHER_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
+TIPS_SUBSCRIBER_TEST_SRC = \
+ examples/tips/subscriber_test.cc \
+
+TIPS_SUBSCRIBER_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(TIPS_SUBSCRIBER_TEST_SRC))))
+
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL with ALPN.
+
+bins/$(CONFIG)/tips_subscriber_test: openssl_dep_error
+
+else
+
+bins/$(CONFIG)/tips_subscriber_test: $(TIPS_SUBSCRIBER_TEST_OBJS) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LDXX) $(LDFLAGS) $(TIPS_SUBSCRIBER_TEST_OBJS) $(GTEST_LIB) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/tips_subscriber_test
+
+endif
+
+objs/$(CONFIG)/examples/tips/subscriber_test.o: libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
+
+deps_tips_subscriber_test: $(TIPS_SUBSCRIBER_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(TIPS_SUBSCRIBER_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
QPS_CLIENT_SRC = \
gens/test/cpp/qps/qpstest.pb.cc \
test/cpp/qps/client.cc \
@@ -5876,68 +6057,6 @@ endif
endif
-TIPS_CLIENT_SRC = \
- examples/tips/client_main.cc \
-
-TIPS_CLIENT_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(TIPS_CLIENT_SRC))))
-
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL with ALPN.
-
-bins/$(CONFIG)/tips_client: openssl_dep_error
-
-else
-
-bins/$(CONFIG)/tips_client: $(TIPS_CLIENT_OBJS) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LDXX) $(LDFLAGS) $(TIPS_CLIENT_OBJS) $(GTEST_LIB) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/tips_client
-
-endif
-
-objs/$(CONFIG)/examples/tips/client_main.o: libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
-
-deps_tips_client: $(TIPS_CLIENT_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(TIPS_CLIENT_OBJS:.o=.dep)
-endif
-endif
-
-
-TIPS_CLIENT_TEST_SRC = \
- examples/tips/client_test.cc \
-
-TIPS_CLIENT_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(TIPS_CLIENT_TEST_SRC))))
-
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL with ALPN.
-
-bins/$(CONFIG)/tips_client_test: openssl_dep_error
-
-else
-
-bins/$(CONFIG)/tips_client_test: $(TIPS_CLIENT_TEST_OBJS) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LDXX) $(LDFLAGS) $(TIPS_CLIENT_TEST_OBJS) $(GTEST_LIB) libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS) $(LDLIBS_SECURE) -o bins/$(CONFIG)/tips_client_test
-
-endif
-
-objs/$(CONFIG)/examples/tips/client_test.o: libs/$(CONFIG)/libtips_client_lib.a libs/$(CONFIG)/libgrpc++_test_util.a libs/$(CONFIG)/libgrpc_test_util.a libs/$(CONFIG)/libgrpc++.a libs/$(CONFIG)/libgrpc.a libs/$(CONFIG)/libgpr_test_util.a libs/$(CONFIG)/libgpr.a
-
-deps_tips_client_test: $(TIPS_CLIENT_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(TIPS_CLIENT_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
CHTTP2_FAKE_SECURITY_CANCEL_AFTER_ACCEPT_TEST_SRC = \
CHTTP2_FAKE_SECURITY_CANCEL_AFTER_ACCEPT_TEST_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(CHTTP2_FAKE_SECURITY_CANCEL_AFTER_ACCEPT_TEST_SRC))))
diff --git a/build.json b/build.json
index 291c7e6f53..66d82b85d0 100644
--- a/build.json
+++ b/build.json
@@ -435,13 +435,26 @@
"examples/tips/label.proto",
"examples/tips/empty.proto",
"examples/tips/pubsub.proto",
- "examples/tips/client.cc"
+ "examples/tips/publisher.cc",
+ "examples/tips/subscriber.cc"
],
"deps": [
"grpc++",
"grpc",
"gpr"
]
+ },
+ {
+ "name": "grpc_csharp_ext",
+ "build": "all",
+ "language": "c",
+ "deps": [
+ "gpr",
+ "grpc"
+ ],
+ "src": [
+ "src/csharp/ext/grpc_csharp_ext.c"
+ ]
}
],
"targets": [
@@ -1570,31 +1583,32 @@
"run": false
},
{
- "name": "qps_client",
+ "name": "tips_client",
"build": "test",
"language": "c++",
"src": [
- "test/cpp/qps/qpstest.proto",
- "test/cpp/qps/client.cc"
+ "examples/tips/main.cc"
],
"deps": [
+ "tips_client_lib",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
- ]
+ ],
+ "run": false
},
{
- "name": "qps_server",
+ "name": "tips_publisher_test",
"build": "test",
"language": "c++",
"src": [
- "test/cpp/qps/qpstest.proto",
- "test/cpp/qps/server.cc"
+ "examples/tips/publisher_test.cc"
],
"deps": [
+ "tips_client_lib",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
@@ -1604,30 +1618,32 @@
]
},
{
- "name": "ruby_plugin",
- "build": "protoc",
+ "name": "tips_subscriber_test",
+ "build": "test",
"language": "c++",
- "headers": [
- "src/compiler/cpp_generator.h",
- "src/compiler/cpp_generator_helpers-inl.h",
- "src/compiler/cpp_generator_map-inl.h",
- "src/compiler/cpp_generator_string-inl.h"
- ],
"src": [
- "src/compiler/ruby_generator.cc",
- "src/compiler/ruby_plugin.cc"
+ "examples/tips/subscriber_test.cc"
],
- "deps": [],
- "secure": false
+ "deps": [
+ "tips_client_lib",
+ "grpc++_test_util",
+ "grpc_test_util",
+ "grpc++",
+ "grpc",
+ "gpr_test_util",
+ "gpr"
+ ]
},
{
- "name": "status_test",
+ "name": "qps_client",
"build": "test",
"language": "c++",
"src": [
- "test/cpp/util/status_test.cc"
+ "test/cpp/qps/qpstest.proto",
+ "test/cpp/qps/client.cc"
],
"deps": [
+ "grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
@@ -1636,11 +1652,12 @@
]
},
{
- "name": "sync_client_async_server_test",
+ "name": "qps_server",
"build": "test",
"language": "c++",
"src": [
- "test/cpp/end2end/sync_client_async_server_test.cc"
+ "test/cpp/qps/qpstest.proto",
+ "test/cpp/qps/server.cc"
],
"deps": [
"grpc++_test_util",
@@ -1652,11 +1669,28 @@
]
},
{
- "name": "thread_pool_test",
+ "name": "ruby_plugin",
+ "build": "protoc",
+ "language": "c++",
+ "headers": [
+ "src/compiler/cpp_generator.h",
+ "src/compiler/cpp_generator_helpers-inl.h",
+ "src/compiler/cpp_generator_map-inl.h",
+ "src/compiler/cpp_generator_string-inl.h"
+ ],
+ "src": [
+ "src/compiler/ruby_generator.cc",
+ "src/compiler/ruby_plugin.cc"
+ ],
+ "deps": [],
+ "secure": false
+ },
+ {
+ "name": "status_test",
"build": "test",
"language": "c++",
"src": [
- "test/cpp/server/thread_pool_test.cc"
+ "test/cpp/util/status_test.cc"
],
"deps": [
"grpc_test_util",
@@ -1667,33 +1701,29 @@
]
},
{
- "name": "tips_client",
+ "name": "sync_client_async_server_test",
"build": "test",
"language": "c++",
"src": [
- "examples/tips/client_main.cc"
+ "test/cpp/end2end/sync_client_async_server_test.cc"
],
"deps": [
- "tips_client_lib",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
- ],
- "run": false
+ ]
},
{
- "name": "tips_client_test",
+ "name": "thread_pool_test",
"build": "test",
"language": "c++",
"src": [
- "examples/tips/client_test.cc"
+ "test/cpp/server/thread_pool_test.cc"
],
"deps": [
- "tips_client_lib",
- "grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
diff --git a/examples/tips/README b/examples/tips/README
new file mode 100644
index 0000000000..ae7d096c2e
--- /dev/null
+++ b/examples/tips/README
@@ -0,0 +1,26 @@
+C++ Client implementation for Cloud Pub/Sub service (TIPS)
+(https://developers.google.com/apis-explorer/#p/pubsub/v1beta1/).
+
+"Google Cloud Pub/Sub" API needs to be enabled at
+https://console.developers.google.com/project to open the access for a client.
+Select the project name, select the "APIs" under "APIs & auth", and turn
+on "Google Cloud Pub/Sub" API.
+
+To run the client from Google Compute Engine (GCE), the GCE instance needs to
+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
+
+To run the client from GCE:
+make tips_client
+bins/opt/tips_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:
+
+bins/opt/tips_client
+ --project_id="your project id"
+ --service_account_key_file="absolute path to the JSON key file"
diff --git a/examples/tips/empty.proto b/examples/tips/empty.proto
index adf66b5e61..86aaa846a2 100644
--- a/examples/tips/empty.proto
+++ b/examples/tips/empty.proto
@@ -1,3 +1,5 @@
+// This file will be moved to a new location.
+
syntax = "proto2";
package proto2;
diff --git a/examples/tips/label.proto b/examples/tips/label.proto
index e93ac9dea3..6ac786f078 100644
--- a/examples/tips/label.proto
+++ b/examples/tips/label.proto
@@ -1,3 +1,5 @@
+// This file will be moved to a new location.
+
// Labels provide a way to associate user-defined metadata with various
// objects. Labels may be used to organize objects into non-hierarchical
// groups; think metadata tags attached to mp3s.
diff --git a/examples/tips/client_main.cc b/examples/tips/main.cc
index 5a3a0daab7..df9d984ae1 100644
--- a/examples/tips/client_main.cc
+++ b/examples/tips/main.cc
@@ -46,18 +46,30 @@
#include <grpc++/credentials.h>
#include <grpc++/status.h>
-#include "examples/tips/client.h"
+#include "examples/tips/publisher.h"
+#include "examples/tips/subscriber.h"
#include "test/cpp/util/create_test_channel.h"
DEFINE_int32(server_port, 443, "Server port.");
DEFINE_string(server_host,
"pubsub-staging.googleapis.com", "Server host to connect to");
+DEFINE_string(project_id, "", "GCE project id such as stoked-keyword-656");
DEFINE_string(service_account_key_file, "",
"Path to service account json key file.");
-DEFINE_string(oauth_scope, "", "Scope for OAuth tokens.");
+DEFINE_string(oauth_scope,
+ "https://www.googleapis.com/auth/cloud-platform",
+ "Scope for OAuth tokens.");
+
+namespace {
+
+const char kTopic[] = "testtopics";
+const char kSubscriptionName[] = "testsubscription";
+const char kMessageData[] = "Test Data";
+
+} // namespace
grpc::string GetServiceAccountJsonKey() {
- static grpc::string json_key;
+ grpc::string json_key;
if (json_key.empty()) {
std::ifstream json_key_file(FLAGS_service_account_key_file);
std::stringstream key_stream;
@@ -72,10 +84,7 @@ int main(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);
gpr_log(GPR_INFO, "Start TIPS client");
- const int host_port_buf_size = 1024;
- char host_port[host_port_buf_size];
- snprintf(host_port, host_port_buf_size, "%s:%d", FLAGS_server_host.c_str(),
- FLAGS_server_port);
+ std::ostringstream ss;
std::unique_ptr<grpc::Credentials> creds;
if (FLAGS_service_account_key_file != "") {
@@ -86,28 +95,83 @@ int main(int argc, char** argv) {
creds = grpc::CredentialsFactory::ComputeEngineCredentials();
}
+ ss << FLAGS_server_host << ":" << FLAGS_server_port;
std::shared_ptr<grpc::ChannelInterface> channel(
grpc::CreateTestChannel(
- host_port,
+ ss.str(),
FLAGS_server_host,
true, // enable SSL
true, // use prod roots
creds));
- grpc::examples::tips::Client client(channel);
+ grpc::examples::tips::Publisher publisher(channel);
+ grpc::examples::tips::Subscriber subscriber(channel);
+
+ GPR_ASSERT(FLAGS_project_id != "");
+ ss.str("");
+ ss << "/topics/" << FLAGS_project_id << "/" << kTopic;
+ grpc::string topic = ss.str();
+
+ ss.str("");
+ ss << FLAGS_project_id << "/" << kSubscriptionName;
+ grpc::string subscription_name = ss.str();
+
+ // Clean up test topic and subcription if they exist before.
+ grpc::string subscription_topic;
+ if (subscriber.GetSubscription(
+ subscription_name, &subscription_topic).IsOk()) {
+ subscriber.DeleteSubscription(subscription_name);
+ }
+ if (publisher.GetTopic(topic).IsOk()) publisher.DeleteTopic(topic);
+
+ grpc::Status s = publisher.CreateTopic(topic);
+ gpr_log(GPR_INFO, "Create topic returns code %d, %s",
+ s.code(), s.details().c_str());
+ GPR_ASSERT(s.IsOk());
- grpc::Status s = client.CreateTopic("/topics/stoked-keyword-656/testtopics");
- gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str());
+ s = publisher.GetTopic(topic);
+ gpr_log(GPR_INFO, "Get topic returns code %d, %s",
+ s.code(), s.details().c_str());
GPR_ASSERT(s.IsOk());
- s = client.GetTopic("/topics/stoked-keyword-656/testtopics");
- gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str());
+ std::vector<grpc::string> topics;
+ s = publisher.ListTopics(FLAGS_project_id, &topics);
+ gpr_log(GPR_INFO, "List topic returns code %d, %s",
+ s.code(), s.details().c_str());
+ bool topic_found = false;
+ for (unsigned int i = 0; i < topics.size(); i++) {
+ if (topics[i] == topic) topic_found = true;
+ gpr_log(GPR_INFO, "topic: %s", topics[i].c_str());
+ }
+ GPR_ASSERT(s.IsOk());
+ GPR_ASSERT(topic_found);
+
+ s = subscriber.CreateSubscription(topic, subscription_name);
+ gpr_log(GPR_INFO, "create subscrption returns code %d, %s",
+ s.code(), s.details().c_str());
+ GPR_ASSERT(s.IsOk());
+
+ s = publisher.Publish(topic, kMessageData);
+ gpr_log(GPR_INFO, "Publish %s returns code %d, %s",
+ kMessageData, s.code(), s.details().c_str());
+ GPR_ASSERT(s.IsOk());
+
+ grpc::string data;
+ s = subscriber.Pull(subscription_name, &data);
+ gpr_log(GPR_INFO, "Pull %s", data.c_str());
+
+ s = subscriber.DeleteSubscription(subscription_name);
+ gpr_log(GPR_INFO, "Delete subscription returns code %d, %s",
+ s.code(), s.details().c_str());
GPR_ASSERT(s.IsOk());
- s = client.DeleteTopic("/topics/stoked-keyword-656/testtopics");
- gpr_log(GPR_INFO, "return code %d, %s", s.code(), s.details().c_str());
+ s = publisher.DeleteTopic(topic);
+ gpr_log(GPR_INFO, "Delete topic returns code %d, %s",
+ s.code(), s.details().c_str());
GPR_ASSERT(s.IsOk());
+ subscriber.Shutdown();
+ publisher.Shutdown();
channel.reset();
grpc_shutdown();
return 0;
diff --git a/examples/tips/client.cc b/examples/tips/publisher.cc
index f9d53197ed..eae8731139 100644
--- a/examples/tips/client.cc
+++ b/examples/tips/publisher.cc
@@ -31,9 +31,11 @@
*
*/
+#include <sstream>
+
#include <grpc++/client_context.h>
-#include "examples/tips/client.h"
+#include "examples/tips/publisher.h"
using tech::pubsub::Topic;
using tech::pubsub::DeleteTopicRequest;
@@ -41,16 +43,22 @@ using tech::pubsub::GetTopicRequest;
using tech::pubsub::PublisherService;
using tech::pubsub::ListTopicsRequest;
using tech::pubsub::ListTopicsResponse;
+using tech::pubsub::PublishRequest;
+using tech::pubsub::PubsubMessage;
namespace grpc {
namespace examples {
namespace tips {
-Client::Client(std::shared_ptr<ChannelInterface> channel)
+Publisher::Publisher(std::shared_ptr<ChannelInterface> channel)
: stub_(PublisherService::NewStub(channel)) {
}
-Status Client::CreateTopic(grpc::string topic) {
+void Publisher::Shutdown() {
+ stub_.reset();
+}
+
+Status Publisher::CreateTopic(const grpc::string& topic) {
Topic request;
Topic response;
request.set_name(topic);
@@ -59,15 +67,28 @@ Status Client::CreateTopic(grpc::string topic) {
return stub_->CreateTopic(&context, request, &response);
}
-Status Client::ListTopics() {
+Status Publisher::ListTopics(const grpc::string& project_id,
+ std::vector<grpc::string>* topics) {
ListTopicsRequest request;
ListTopicsResponse response;
ClientContext context;
- return stub_->ListTopics(&context, request, &response);
+ std::ostringstream ss;
+ ss << "cloud.googleapis.com/project in (/projects/" << project_id << ")";
+ request.set_query(ss.str());
+
+ Status s = stub_->ListTopics(&context, request, &response);
+
+ tech::pubsub::Topic topic;
+ for (int i = 0; i < response.topic_size(); i++) {
+ topic = response.topic(i);
+ topics->push_back(topic.name());
+ }
+
+ return s;
}
-Status Client::GetTopic(grpc::string topic) {
+Status Publisher::GetTopic(const grpc::string& topic) {
GetTopicRequest request;
Topic response;
ClientContext context;
@@ -77,7 +98,7 @@ Status Client::GetTopic(grpc::string topic) {
return stub_->GetTopic(&context, request, &response);
}
-Status Client::DeleteTopic(grpc::string topic) {
+Status Publisher::DeleteTopic(const grpc::string& topic) {
DeleteTopicRequest request;
proto2::Empty response;
ClientContext context;
@@ -87,6 +108,17 @@ Status Client::DeleteTopic(grpc::string topic) {
return stub_->DeleteTopic(&context, request, &response);
}
+Status Publisher::Publish(const grpc::string& topic, const grpc::string& data) {
+ PublishRequest request;
+ proto2::Empty response;
+ ClientContext context;
+
+ request.mutable_message()->set_data(data);
+ request.set_topic(topic);
+
+ return stub_->Publish(&context, request, &response);
+}
+
} // namespace tips
} // namespace examples
} // namespace grpc
diff --git a/examples/tips/client.h b/examples/tips/publisher.h
index 661ee5c4af..d8d7353826 100644
--- a/examples/tips/client.h
+++ b/examples/tips/publisher.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef __GRPCPP_EXAMPLES_TIPS_CLIENT_H_
-#define __GRPCPP_EXAMPLES_TIPS_CLIENT_H_
+#ifndef __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_
+#define __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_
#include <grpc++/channel_interface.h>
#include <grpc++/status.h>
@@ -43,13 +43,18 @@ namespace grpc {
namespace examples {
namespace tips {
-class Client {
+class Publisher {
public:
- Client(std::shared_ptr<grpc::ChannelInterface> channel);
- Status CreateTopic(grpc::string topic);
- Status GetTopic(grpc::string topic);
- Status DeleteTopic(grpc::string topic);
- Status ListTopics();
+ Publisher(std::shared_ptr<ChannelInterface> channel);
+ void Shutdown();
+
+ Status CreateTopic(const grpc::string& topic);
+ Status GetTopic(const grpc::string& topic);
+ Status DeleteTopic(const grpc::string& topic);
+ Status ListTopics(const grpc::string& project_id,
+ std::vector<grpc::string>* topics);
+
+ Status Publish(const grpc::string& topic, const grpc::string& data);
private:
std::unique_ptr<tech::pubsub::PublisherService::Stub> stub_;
@@ -59,4 +64,4 @@ class Client {
} // namespace examples
} // namespace grpc
-#endif // __GRPCPP_EXAMPLES_TIPS_CLIENT_H_
+#endif // __GRPCPP_EXAMPLES_TIPS_PUBLISHER_H_
diff --git a/examples/tips/client_test.cc b/examples/tips/publisher_test.cc
index 69238f2c6f..e46576a2f6 100644
--- a/examples/tips/client_test.cc
+++ b/examples/tips/publisher_test.cc
@@ -41,7 +41,7 @@
#include <grpc++/status.h>
#include <gtest/gtest.h>
-#include "examples/tips/client.h"
+#include "examples/tips/publisher.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@@ -51,9 +51,11 @@ namespace grpc {
namespace testing {
namespace {
+const char kProjectId[] = "project id";
const char kTopic[] = "test topic";
+const char kMessageData[] = "test message data";
-class PublishServiceImpl : public tech::pubsub::PublisherService::Service {
+class PublisherServiceImpl : public tech::pubsub::PublisherService::Service {
public:
Status CreateTopic(::grpc::ServerContext* context,
const ::tech::pubsub::Topic* request,
@@ -61,34 +63,81 @@ class PublishServiceImpl : public tech::pubsub::PublisherService::Service {
EXPECT_EQ(request->name(), kTopic);
return Status::OK;
}
+
+ Status Publish(ServerContext* context,
+ const ::tech::pubsub::PublishRequest* request,
+ ::proto2::Empty* response) override {
+ EXPECT_EQ(request->message().data(), kMessageData);
+ return Status::OK;
+ }
+
+ Status GetTopic(ServerContext* context,
+ const ::tech::pubsub::GetTopicRequest* request,
+ ::tech::pubsub::Topic* response) override {
+ EXPECT_EQ(request->topic(), kTopic);
+ return Status::OK;
+ }
+
+ Status ListTopics(ServerContext* context,
+ const ::tech::pubsub::ListTopicsRequest* request,
+ ::tech::pubsub::ListTopicsResponse* response) override {
+ std::ostringstream ss;
+ ss << "cloud.googleapis.com/project in (/projects/" << kProjectId << ")";
+ EXPECT_EQ(request->query(), ss.str());
+ response->add_topic()->set_name(kTopic);
+ return Status::OK;
+ }
+
+ Status DeleteTopic(ServerContext* context,
+ const ::tech::pubsub::DeleteTopicRequest* request,
+ ::proto2::Empty* response) override {
+ EXPECT_EQ(request->topic(), kTopic);
+ return Status::OK;
+ }
+
};
-class End2endTest : public ::testing::Test {
+class PublisherTest : public ::testing::Test {
protected:
+ // Setup a server and a client for PublisherService.
void SetUp() override {
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
- // Setup server
ServerBuilder builder;
builder.AddPort(server_address_.str());
builder.RegisterService(service_.service());
server_ = builder.BuildAndStart();
channel_ = CreateChannel(server_address_.str(), ChannelArguments());
+
+ publisher_.reset(new grpc::examples::tips::Publisher(channel_));
}
- void TearDown() override { server_->Shutdown(); }
+ void TearDown() override {
+ server_->Shutdown();
+ publisher_->Shutdown();
+ }
- std::unique_ptr<Server> server_;
std::ostringstream server_address_;
- PublishServiceImpl service_;
+ std::unique_ptr<Server> server_;
+ PublisherServiceImpl service_;
std::shared_ptr<ChannelInterface> channel_;
+
+ std::unique_ptr<grpc::examples::tips::Publisher> publisher_;
};
-TEST_F(End2endTest, CreateTopic) {
- grpc::examples::tips::Client client(channel_);
- client.CreateTopic(kTopic);
+TEST_F(PublisherTest, TestPublisher) {
+ EXPECT_TRUE(publisher_->CreateTopic(kTopic).IsOk());
+
+ EXPECT_TRUE(publisher_->Publish(kTopic, kMessageData).IsOk());
+
+ EXPECT_TRUE(publisher_->GetTopic(kTopic).IsOk());
+
+ std::vector<grpc::string> topics;
+ EXPECT_TRUE(publisher_->ListTopics(kProjectId, &topics).IsOk());
+ EXPECT_EQ(topics.size(), 1);
+ EXPECT_EQ(topics[0], kTopic);
}
} // namespace
diff --git a/examples/tips/pubsub.proto b/examples/tips/pubsub.proto
index 0b3bd5d012..a2dd2f5ca8 100644
--- a/examples/tips/pubsub.proto
+++ b/examples/tips/pubsub.proto
@@ -1,3 +1,5 @@
+// This file will be moved to a new location.
+
// Specification of the Pubsub API.
syntax = "proto2";
diff --git a/examples/tips/subscriber.cc b/examples/tips/subscriber.cc
new file mode 100644
index 0000000000..c0673223ae
--- /dev/null
+++ b/examples/tips/subscriber.cc
@@ -0,0 +1,118 @@
+/*
+ *
+ * Copyright 2014, 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++/client_context.h>
+
+#include "examples/tips/subscriber.h"
+
+using tech::pubsub::Topic;
+using tech::pubsub::DeleteTopicRequest;
+using tech::pubsub::GetTopicRequest;
+using tech::pubsub::SubscriberService;
+using tech::pubsub::ListTopicsRequest;
+using tech::pubsub::ListTopicsResponse;
+using tech::pubsub::PublishRequest;
+using tech::pubsub::PubsubMessage;
+
+namespace grpc {
+namespace examples {
+namespace tips {
+
+Subscriber::Subscriber(std::shared_ptr<ChannelInterface> channel)
+ : stub_(SubscriberService::NewStub(channel)) {
+}
+
+void Subscriber::Shutdown() {
+ stub_.reset();
+}
+
+Status Subscriber::CreateSubscription(const grpc::string& topic,
+ const grpc::string& name) {
+ tech::pubsub::Subscription request;
+ tech::pubsub::Subscription response;
+ ClientContext context;
+
+ request.set_topic(topic);
+ request.set_name(name);
+
+ return stub_->CreateSubscription(&context, request, &response);
+}
+
+Status Subscriber::GetSubscription(const grpc::string& name,
+ grpc::string* topic) {
+ tech::pubsub::GetSubscriptionRequest request;
+ tech::pubsub::Subscription response;
+ ClientContext context;
+
+ request.set_subscription(name);
+
+ Status s = stub_->GetSubscription(&context, request, &response);
+ *topic = response.topic();
+ return s;
+}
+
+Status Subscriber::DeleteSubscription(const grpc::string& name) {
+ tech::pubsub::DeleteSubscriptionRequest request;
+ proto2::Empty response;
+ ClientContext context;
+
+ request.set_subscription(name);
+
+ return stub_->DeleteSubscription(&context, request, &response);
+}
+
+Status Subscriber::Pull(const grpc::string& name, grpc::string* data) {
+ tech::pubsub::PullRequest request;
+ tech::pubsub::PullResponse response;
+ ClientContext context;
+
+ request.set_subscription(name);
+ Status s = stub_->Pull(&context, request, &response);
+ if (s.IsOk()) {
+ tech::pubsub::PubsubEvent event = response.pubsub_event();
+ if (event.has_message()) {
+ *data = event.message().data();
+ }
+ tech::pubsub::AcknowledgeRequest ack;
+ proto2::Empty empty;
+ ClientContext ack_context;
+ ack.set_subscription(name);
+ ack.add_ack_id(response.ack_id());
+ stub_->Acknowledge(&ack_context, ack, &empty);
+ }
+ return s;
+}
+
+} // namespace tips
+} // namespace examples
+} // namespace grpc
diff --git a/examples/tips/subscriber.h b/examples/tips/subscriber.h
new file mode 100644
index 0000000000..ed706ff170
--- /dev/null
+++ b/examples/tips/subscriber.h
@@ -0,0 +1,68 @@
+/*
+ *
+ * Copyright 2014, 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 __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_
+#define __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_
+
+#include <grpc++/channel_interface.h>
+#include <grpc++/status.h>
+
+#include "examples/tips/pubsub.pb.h"
+
+namespace grpc {
+namespace examples {
+namespace tips {
+
+class Subscriber {
+ public:
+ Subscriber(std::shared_ptr<ChannelInterface> channel);
+ void Shutdown();
+
+ Status CreateSubscription(const grpc::string& topic,
+ const grpc::string& name);
+
+ Status GetSubscription(const grpc::string& name, grpc::string* topic);
+
+ Status DeleteSubscription(const grpc::string& name);
+
+ Status Pull(const grpc::string& name, grpc::string* data);
+
+ private:
+ std::unique_ptr<tech::pubsub::SubscriberService::Stub> stub_;
+};
+
+} // namespace tips
+} // namespace examples
+} // namespace grpc
+
+#endif // __GRPCPP_EXAMPLES_TIPS_SUBSCRIBER_H_
diff --git a/examples/tips/subscriber_test.cc b/examples/tips/subscriber_test.cc
new file mode 100644
index 0000000000..595a6a13a1
--- /dev/null
+++ b/examples/tips/subscriber_test.cc
@@ -0,0 +1,157 @@
+/*
+ *
+ * Copyright 2014, 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++/channel_arguments.h>
+#include <grpc++/channel_interface.h>
+#include <grpc++/client_context.h>
+#include <grpc++/create_channel.h>
+#include <grpc++/server.h>
+#include <grpc++/server_builder.h>
+#include <grpc++/server_context.h>
+#include <grpc++/status.h>
+#include <gtest/gtest.h>
+
+#include "examples/tips/subscriber.h"
+#include "test/core/util/port.h"
+#include "test/core/util/test_config.h"
+
+namespace grpc {
+namespace testing {
+namespace {
+
+const char kTopic[] = "test topic";
+const char kSubscriptionName[] = "subscription name";
+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 {
+ EXPECT_EQ(request->topic(), kTopic);
+ EXPECT_EQ(request->name(), kSubscriptionName);
+ return Status::OK;
+ }
+
+ Status GetSubscription(ServerContext* context,
+ const tech::pubsub::GetSubscriptionRequest* request,
+ tech::pubsub::Subscription* response) override {
+ EXPECT_EQ(request->subscription(), kSubscriptionName);
+ response->set_topic(kTopic);
+ return Status::OK;
+ }
+
+ Status DeleteSubscription(
+ ServerContext* context,
+ const tech::pubsub::DeleteSubscriptionRequest* request,
+ proto2::Empty* response) override {
+ EXPECT_EQ(request->subscription(), kSubscriptionName);
+ return Status::OK;
+ }
+
+ Status Pull(ServerContext* context,
+ const tech::pubsub::PullRequest* request,
+ tech::pubsub::PullResponse* response) override {
+ EXPECT_EQ(request->subscription(), kSubscriptionName);
+ response->set_ack_id("1");
+ response->mutable_pubsub_event()->mutable_message()->set_data(kData);
+ return Status::OK;
+ }
+
+ Status Acknowledge(ServerContext* context,
+ const tech::pubsub::AcknowledgeRequest* request,
+ proto2::Empty* response) override {
+ return Status::OK;
+ }
+
+};
+
+class SubscriberTest : public ::testing::Test {
+ protected:
+ // Setup a server and a client for SubscriberService.
+ void SetUp() override {
+ int port = grpc_pick_unused_port_or_die();
+ server_address_ << "localhost:" << port;
+ ServerBuilder builder;
+ builder.AddPort(server_address_.str());
+ builder.RegisterService(service_.service());
+ server_ = builder.BuildAndStart();
+
+ channel_ = CreateChannel(server_address_.str(), ChannelArguments());
+
+ subscriber_.reset(new grpc::examples::tips::Subscriber(channel_));
+ }
+
+ void TearDown() override {
+ server_->Shutdown();
+ subscriber_->Shutdown();
+ }
+
+ std::ostringstream server_address_;
+ std::unique_ptr<Server> server_;
+ SubscriberServiceImpl service_;
+
+ std::shared_ptr<ChannelInterface> channel_;
+
+ std::unique_ptr<grpc::examples::tips::Subscriber> subscriber_;
+};
+
+TEST_F(SubscriberTest, TestSubscriber) {
+ EXPECT_TRUE(subscriber_->CreateSubscription(kTopic,
+ kSubscriptionName).IsOk());
+
+ grpc::string topic;
+ EXPECT_TRUE(subscriber_->GetSubscription(kSubscriptionName,
+ &topic).IsOk());
+ EXPECT_EQ(topic, kTopic);
+
+ grpc::string data;
+ EXPECT_TRUE(subscriber_->Pull(kSubscriptionName,
+ &data).IsOk());
+
+ EXPECT_TRUE(subscriber_->DeleteSubscription(kSubscriptionName).IsOk());
+}
+
+} // namespace
+} // namespace testing
+} // namespace grpc
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ ::testing::InitGoogleTest(&argc, argv);
+ gpr_log(GPR_INFO, "Start test ...");
+ int result = RUN_ALL_TESTS();
+ grpc_shutdown();
+ return result;
+}
diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c
index 8989b491d5..3d6114ca18 100644
--- a/src/core/iomgr/iomgr.c
+++ b/src/core/iomgr/iomgr.c
@@ -51,6 +51,7 @@ typedef struct delayed_callback {
static gpr_mu g_mu;
static gpr_cv g_cv;
+static gpr_cv g_rcv;
static delayed_callback *g_cbs_head = NULL;
static delayed_callback *g_cbs_tail = NULL;
static int g_shutdown;
@@ -86,6 +87,7 @@ void grpc_iomgr_init(void) {
gpr_thd_id id;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_cv);
+ gpr_cv_init(&g_rcv);
grpc_alarm_list_init(gpr_now());
g_refs = 0;
grpc_iomgr_platform_init();
@@ -115,7 +117,7 @@ void grpc_iomgr_shutdown(void) {
gpr_mu_lock(&g_mu);
}
if (g_refs) {
- if (gpr_cv_wait(&g_cv, &g_mu, shutdown_deadline) && g_cbs_head == NULL) {
+ if (gpr_cv_wait(&g_rcv, &g_mu, shutdown_deadline) && g_cbs_head == NULL) {
gpr_log(GPR_DEBUG,
"Failed to free %d iomgr objects before shutdown deadline: "
"memory leaks are likely",
@@ -126,12 +128,14 @@ void grpc_iomgr_shutdown(void) {
}
gpr_mu_unlock(&g_mu);
+ grpc_kick_poller();
gpr_event_wait(&g_background_callback_executor_done, gpr_inf_future);
grpc_iomgr_platform_shutdown();
grpc_alarm_list_shutdown();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_cv);
+ gpr_cv_destroy(&g_rcv);
}
void grpc_iomgr_ref(void) {
@@ -143,7 +147,7 @@ void grpc_iomgr_ref(void) {
void grpc_iomgr_unref(void) {
gpr_mu_lock(&g_mu);
if (0 == --g_refs) {
- gpr_cv_signal(&g_cv);
+ gpr_cv_signal(&g_rcv);
}
gpr_mu_unlock(&g_mu);
}
diff --git a/src/core/support/cpu_linux.c b/src/core/support/cpu_linux.c
index eab8b7fbd0..ad82174894 100644
--- a/src/core/support/cpu_linux.c
+++ b/src/core/support/cpu_linux.c
@@ -31,44 +31,17 @@
*
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif /* _GNU_SOURCE */
+
#include <grpc/support/port_platform.h>
#ifdef GPR_CPU_LINUX
#include "src/core/support/cpu.h"
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#define GRPC_GNU_SOURCE
-#endif
-
-#ifndef __USE_GNU
-#define __USE_GNU
-#define GRPC_USE_GNU
-#endif
-
-#ifndef __USE_MISC
-#define __USE_MISC
-#define GRPC_USE_MISC
-#endif
-
#include <sched.h>
-
-#ifdef GRPC_GNU_SOURCE
-#undef _GNU_SOURCE
-#undef GRPC_GNU_SOURCE
-#endif
-
-#ifdef GRPC_USE_GNU
-#undef __USE_GNU
-#undef GRPC_USE_GNU
-#endif
-
-#ifdef GRPC_USE_MISC
-#undef __USE_MISC
-#undef GRPC_USE_MISC
-#endif
-
#include <errno.h>
#include <unistd.h>
#include <string.h>
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 561c24e547..ebd6ace962 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -76,7 +76,7 @@ typedef struct {
/* Completion function to call at the end of the operation */
grpc_ioreq_completion_func on_complete;
void *user_data;
- /* a bit mask of which request ops are needed (1 << opid) */
+ /* a bit mask of which request ops are needed (1u << opid) */
gpr_uint32 need_mask;
/* a bit mask of which request ops are now completed */
gpr_uint32 complete_mask;
@@ -128,30 +128,80 @@ struct grpc_call {
/* TODO(ctiller): share with cq if possible? */
gpr_mu mu;
- gpr_uint8 is_client;
+ /* how far through the stream have we read? */
read_state read_state;
+ /* how far through the stream have we written? */
write_state write_state;
+ /* client or server call */
+ gpr_uint8 is_client;
+ /* is the alarm set */
gpr_uint8 have_alarm;
+ /* are we currently performing a send operation */
gpr_uint8 sending;
+ /* pairs with completed_requests */
gpr_uint8 num_completed_requests;
+ /* flag that we need to request more data */
gpr_uint8 need_more_data;
+ /* Active ioreqs.
+ request_set and request_data contain one element per active ioreq
+ operation.
+
+ request_set[op] is an integer specifying a set of operations to which
+ the request belongs:
+ - if it is < GRPC_IOREQ_OP_COUNT, then this operation is pending
+ completion, and the integer represents to which group of operations
+ the ioreq belongs. Each group is represented by one master, and the
+ integer in request_set is an index into masters to find the master
+ data.
+ - if it is REQSET_EMPTY, the ioreq op is inactive and available to be
+ started
+ - finally, if request_set[op] is REQSET_DONE, then the operation is
+ complete and unavailable to be started again
+
+ request_data[op] is the request data as supplied by the initiator of
+ a request, and is valid iff request_set[op] <= GRPC_IOREQ_OP_COUNT.
+ The set fields are as per the request type specified by op.
+
+ Finally, one element of masters is set per active _set_ of ioreq
+ operations. It describes work left outstanding, result status, and
+ what work to perform upon operation completion. As one ioreq of each
+ op type can be active at once, by convention we choose the first element
+ of the group to be the master -- ie the master of in-progress operation
+ op is masters[request_set[op]]. This allows constant time allocation
+ and a strong upper bound of a count of masters to be calculated. */
gpr_uint8 request_set[GRPC_IOREQ_OP_COUNT];
grpc_ioreq_data request_data[GRPC_IOREQ_OP_COUNT];
reqinfo_master masters[GRPC_IOREQ_OP_COUNT];
+
+ /* Dynamic array of ioreq's that have completed: the count of
+ elements is queued in num_completed_requests.
+ This list is built up under lock(), and flushed entirely during
+ unlock().
+ We know the upper bound of the number of elements as we can only
+ have one ioreq of each type active at once. */
completed_request completed_requests[GRPC_IOREQ_OP_COUNT];
+ /* Incoming buffer of messages */
grpc_byte_buffer_queue incoming_queue;
+ /* Buffered read metadata waiting to be returned to the application.
+ Element 0 is initial metadata, element 1 is trailing metadata. */
grpc_metadata_array buffered_metadata[2];
+ /* All metadata received - unreffed at once at the end of the call */
grpc_mdelem **owned_metadata;
size_t owned_metadata_count;
size_t owned_metadata_capacity;
+ /* Received call statuses from various sources */
received_status status[STATUS_SOURCE_COUNT];
+ /* Deadline alarm - if have_alarm is non-zero */
grpc_alarm alarm;
+ /* Call refcount - to keep the call alive during asynchronous operations */
gpr_refcount internal_refcount;
+ /* Data that the legacy api needs to track. To be deleted at some point
+ soon */
legacy_state *legacy_state;
};
@@ -274,7 +324,7 @@ static int is_op_live(grpc_call *call, grpc_ioreq_op op) {
reqinfo_master *master;
if (set >= GRPC_IOREQ_OP_COUNT) return 0;
master = &call->masters[set];
- return (master->complete_mask & (1 << op)) == 0;
+ return (master->complete_mask & (1u << op)) == 0;
}
static void lock(grpc_call *call) { gpr_mu_lock(&call->mu); }
@@ -362,7 +412,7 @@ static void finish_live_ioreq_op(grpc_call *call, grpc_ioreq_op op,
size_t i;
/* ioreq is live: we need to do something */
master = &call->masters[master_set];
- master->complete_mask |= 1 << op;
+ master->complete_mask |= 1u << op;
if (status != GRPC_OP_OK) {
master->status = status;
master->complete_mask = master->need_mask;
@@ -564,7 +614,7 @@ static grpc_call_error start_ioreq_error(grpc_call *call,
grpc_call_error ret) {
size_t i;
for (i = 0; i < GRPC_IOREQ_OP_COUNT; i++) {
- if (mutated_ops & (1 << i)) {
+ if (mutated_ops & (1u << i)) {
call->request_set[i] = REQSET_EMPTY;
}
}
@@ -650,7 +700,7 @@ static grpc_call_error start_ioreq(grpc_call *call, const grpc_ioreq *reqs,
} else if (call->request_set[op] == REQSET_DONE) {
return start_ioreq_error(call, have_ops, GRPC_CALL_ERROR_ALREADY_INVOKED);
}
- have_ops |= 1 << op;
+ have_ops |= 1u << op;
data = reqs[i].data;
call->request_data[op] = data;
@@ -664,7 +714,7 @@ static grpc_call_error start_ioreq(grpc_call *call, const grpc_ioreq *reqs,
master->on_complete = completion;
master->user_data = user_data;
- if (have_ops & (1 << GRPC_IOREQ_RECV_MESSAGE)) {
+ if (have_ops & (1u << GRPC_IOREQ_RECV_MESSAGE)) {
call->need_more_data = 1;
}
diff --git a/src/csharp/.gitignore b/src/csharp/.gitignore
new file mode 100644
index 0000000000..dbf38f34b7
--- /dev/null
+++ b/src/csharp/.gitignore
@@ -0,0 +1,2 @@
+*.userprefs
+test-results
diff --git a/src/csharp/README.md b/src/csharp/README.md
new file mode 100755
index 0000000000..5b56303c14
--- /dev/null
+++ b/src/csharp/README.md
@@ -0,0 +1,22 @@
+gRPC C#
+=======
+
+A C# implementation of gRPC, Google's RPC library.
+
+EXPERIMENTAL ONLY
+-----------------
+
+**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
+ is in progress.
+- It is very possible that some parts of the code will be heavily refactored or
+ completely rewritten.
+
+CONTENTS
+--------
+
+- ext:
+ The extension library that wraps C API to be more digestible by C#.
+
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
new file mode 100644
index 0000000000..74d11c655b
--- /dev/null
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -0,0 +1,113 @@
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/slice.h>
+
+#include <string.h>
+
+grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) {
+ gpr_slice slice = gpr_slice_from_copied_buffer(buffer, len);
+ grpc_byte_buffer *bb = grpc_byte_buffer_create(&slice, 1);
+ gpr_slice_unref(slice);
+ return bb;
+}
+
+void grpc_call_start_write_from_copied_buffer(grpc_call *call,
+ const char *buffer, size_t len,
+ void *tag, gpr_uint32 flags) {
+ grpc_byte_buffer *byte_buffer = string_to_byte_buffer(buffer, len);
+ GPR_ASSERT(grpc_call_start_write_old(call, byte_buffer, tag, flags) ==
+ GRPC_CALL_OK);
+ grpc_byte_buffer_destroy(byte_buffer);
+}
+
+grpc_completion_type grpc_event_type(const grpc_event *event) {
+ return event->type;
+}
+
+grpc_op_error grpc_event_write_accepted(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_WRITE_ACCEPTED);
+ return event->data.invoke_accepted;
+}
+
+grpc_op_error grpc_event_finish_accepted(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_FINISH_ACCEPTED);
+ return event->data.finish_accepted;
+}
+
+grpc_status_code grpc_event_finished_status(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_FINISHED);
+ return event->data.finished.status;
+}
+
+const char *grpc_event_finished_details(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_FINISHED);
+ return event->data.finished.details;
+}
+
+gpr_intptr grpc_event_read_length(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_READ);
+ if (!event->data.read) {
+ return -1;
+ }
+ return grpc_byte_buffer_length(event->data.read);
+}
+
+/*
+ * Copies data from read event to a buffer. Fatal error occurs if
+ * buffer is too small.
+ */
+void grpc_event_read_copy_to_buffer(const grpc_event *event, char *buffer,
+ size_t buffer_len) {
+ grpc_byte_buffer_reader *reader;
+ gpr_slice slice;
+ size_t offset = 0;
+
+ GPR_ASSERT(event->type == GRPC_READ);
+ reader = grpc_byte_buffer_reader_create(event->data.read);
+
+ GPR_ASSERT(event->data.read);
+ while (grpc_byte_buffer_reader_next(reader, &slice)) {
+ size_t len = GPR_SLICE_LENGTH(slice);
+ GPR_ASSERT(offset + len <= buffer_len);
+ memcpy(buffer + offset, GPR_SLICE_START_PTR(slice),
+ GPR_SLICE_LENGTH(slice));
+ offset += len;
+ gpr_slice_unref(slice);
+ }
+ grpc_byte_buffer_reader_destroy(reader);
+}
+
+grpc_call *grpc_event_call(const grpc_event *event) {
+ /* we only allow this for newly incoming server calls. */
+ GPR_ASSERT(event->type == GRPC_SERVER_RPC_NEW);
+ return event->call;
+}
+
+const char *grpc_event_server_rpc_new_method(const grpc_event *event) {
+ GPR_ASSERT(event->type == GRPC_SERVER_RPC_NEW);
+ return event->data.server_rpc_new.method;
+}
+
+grpc_completion_type grpc_completion_queue_next_with_callback(
+ grpc_completion_queue *cq) {
+ grpc_event *ev;
+ grpc_completion_type t;
+ void (*callback)(grpc_event *);
+
+ ev = grpc_completion_queue_next(cq, gpr_inf_future);
+ t = ev->type;
+ if (ev->tag) {
+ /* call the callback in ev->tag */
+ /* C forbids to cast object pointers to function pointers, so
+ * we cast to intptr first.
+ */
+ callback = (void (*)(grpc_event *))(gpr_intptr)ev->tag;
+ (*callback)(ev);
+ }
+ grpc_event_finish(ev);
+
+ /* return completion type to allow some handling for events that have no
+ * tag - such as GRPC_QUEUE_SHUTDOWN
+ */
+ return t;
+}
diff --git a/src/php/README.md b/src/php/README.md
index 176bcfa028..620c68fd7b 100755
--- a/src/php/README.md
+++ b/src/php/README.md
@@ -7,31 +7,25 @@ Directory structure is as generated by the PHP utility
## ENVIRONMENT
-To build a PHP environment that works with this extension, download and extract
-PHP 5.5 (5.6 may also work), configure it, and install it:
+Install `php5` and `php5-dev`.
-```bash
-apt-get install libxml2 libxml2-dev
-curl http://php.net/get/php-5.5.16.tar.gz
-tar -xf php-5.5.16.tar.gz
-cd php-5.5.16
-./configure --with-zlib=/usr --with-libxml-dir=ext/libxml --with-openssl=/usr/local/ssl
-make
-make install
-```
+To run the tests, additionally install `php5-readline` and `phpunit`.
+
+Alternatively, build and install PHP 5.5 or later from source with standard
+configuration options.
-To also download and install the patched protoc and PHP code generator:
+To also download and install protoc and the PHP code generator.
```bash
apt-get install -y procps
curl -sSL https://get.rvm.io | sudo bash -s stable --ruby
-git clone sso://team/one-platform-grpc-team/protobuf
+git clone git@github.com:google/protobuf.git
cd protobuf
./configure
make
make install
-git clone sso://team/one-platform-grpc-team/grpc-php-protobuf-php
-cd grpc-php-protobuf-php
+git clone git@github.com:murgatroid99/Protobuf-PHP.git
+cd Protobuf-PHP
rake pear:package version=1.0
pear install Protobuf-1.0.tgz
```
@@ -52,5 +46,4 @@ This repo now has PHPUnit tests, which can by run by executing
There is also a generated code test (`./bin/run_gen_code_test.sh`), which tests
the stub `./tests/generated_code/math.php` against a running localhost server
serving the math service. That stub is generated from
-`./tests/generated_code/math.proto` with the head of the repo
-`sso://team/one-platform-grpc-team/grpc-php-protobuf-php`.
+`./tests/generated_code/math.proto`.
diff --git a/src/php/lib/Grpc/AbstractSurfaceActiveCall.php b/src/php/lib/Grpc/AbstractSurfaceActiveCall.php
index 53c7d4cd1a..83e4719c9a 100755
--- a/src/php/lib/Grpc/AbstractSurfaceActiveCall.php
+++ b/src/php/lib/Grpc/AbstractSurfaceActiveCall.php
@@ -44,7 +44,7 @@ abstract class AbstractSurfaceActiveCall {
protected function _read() {
$response = $this->active_call->read();
- if ($response == null) {
+ if ($response === null) {
return null;
}
return call_user_func($this->deserialize, $response);
diff --git a/src/php/lib/Grpc/ActiveCall.php b/src/php/lib/Grpc/ActiveCall.php
index e0ea43ab08..847cfee1ec 100755
--- a/src/php/lib/Grpc/ActiveCall.php
+++ b/src/php/lib/Grpc/ActiveCall.php
@@ -66,12 +66,7 @@ class ActiveCall {
* @param ByteBuffer $data The data to write
*/
public function write($data) {
- if($this->call->start_write($data,
- WRITE_ACCEPTED,
- $this->flags) != OP_OK) {
- // TODO(mlumish): more useful error
- throw new \Exception("Cannot call write after writesDone");
- }
+ $this->call->start_write($data, WRITE_ACCEPTED, $this->flags);
$this->completion_queue->pluck(WRITE_ACCEPTED, Timeval::inf_future());
}
diff --git a/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php b/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php
index 082f995d8a..f131d6bab5 100755
--- a/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php
+++ b/src/php/lib/Grpc/ServerStreamingSurfaceActiveCall.php
@@ -31,7 +31,7 @@ class ServerStreamingSurfaceActiveCall extends AbstractSurfaceActiveCall {
* @return An iterator of response values
*/
public function responses() {
- while(($response = $this->_read()) != null) {
+ while(($response = $this->_read()) !== null) {
yield $response;
}
}
diff --git a/src/php/tests/generated_code/GeneratedCodeTest.php b/src/php/tests/generated_code/GeneratedCodeTest.php
index 42d25e4614..ee7b871123 100755
--- a/src/php/tests/generated_code/GeneratedCodeTest.php
+++ b/src/php/tests/generated_code/GeneratedCodeTest.php
@@ -17,9 +17,9 @@ class GeneratedCodeTest extends PHPUnit_Framework_TestCase {
$div_arg->setDividend(7);
$div_arg->setDivisor(4);
list($response, $status) = self::$client->Div($div_arg)->wait();
- $this->assertEquals(1, $response->getQuotient());
- $this->assertEquals(3, $response->getRemainder());
- $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ $this->assertSame(1, $response->getQuotient());
+ $this->assertSame(3, $response->getRemainder());
+ $this->assertSame(\Grpc\STATUS_OK, $status->code);
}
public function testServerStreaming() {
@@ -31,9 +31,9 @@ class GeneratedCodeTest extends PHPUnit_Framework_TestCase {
return $num->getNum();
};
$values = array_map($extract_num, $result_array);
- $this->assertEquals([1, 1, 2, 3, 5, 8, 13], $values);
+ $this->assertSame([1, 1, 2, 3, 5, 8, 13], $values);
$status = $call->getStatus();
- $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ $this->assertSame(\Grpc\STATUS_OK, $status->code);
}
public function testClientStreaming() {
@@ -46,8 +46,8 @@ class GeneratedCodeTest extends PHPUnit_Framework_TestCase {
};
$call = self::$client->Sum($num_iter());
list($response, $status) = $call->wait();
- $this->assertEquals(21, $response->getNum());
- $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ $this->assertSame(21, $response->getNum());
+ $this->assertSame(\Grpc\STATUS_OK, $status->code);
}
public function testBidiStreaming() {
@@ -58,11 +58,11 @@ class GeneratedCodeTest extends PHPUnit_Framework_TestCase {
$div_arg->setDivisor(2);
$call->write($div_arg);
$response = $call->read();
- $this->assertEquals($i, $response->getQuotient());
- $this->assertEquals(1, $response->getRemainder());
+ $this->assertSame($i, $response->getQuotient());
+ $this->assertSame(1, $response->getRemainder());
}
$call->writesDone();
$status = $call->getStatus();
- $this->assertEquals(\Grpc\STATUS_OK, $status->code);
+ $this->assertSame(\Grpc\STATUS_OK, $status->code);
}
} \ No newline at end of file
diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php
index 2ff2be7bca..d1f994a84b 100755
--- a/src/php/tests/interop/interop_client.php
+++ b/src/php/tests/interop/interop_client.php
@@ -26,8 +26,8 @@ function hardAssert($value, $error_message) {
*/
function emptyUnary($stub) {
list($result, $status) = $stub->EmptyCall(new grpc\testing\EmptyMessage())->wait();
- hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
- hardAssert($result != null, 'Call completed with a null response');
+ hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result !== null, 'Call completed with a null response');
}
/**
@@ -49,14 +49,14 @@ function largeUnary($stub) {
$request->setPayload($payload);
list($result, $status) = $stub->UnaryCall($request)->wait();
- hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
- hardAssert($result != null, 'Call returned a null response');
+ hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result !== null, 'Call returned a null response');
$payload = $result->getPayload();
- hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE,
'Payload had the wrong type');
- hardAssert(strlen($payload->getBody()) == $response_len,
+ hardAssert(strlen($payload->getBody()) === $response_len,
'Payload had the wrong length');
- hardAssert($payload->getBody() == str_repeat("\0", $response_len),
+ hardAssert($payload->getBody() === str_repeat("\0", $response_len),
'Payload had the wrong content');
}
@@ -78,8 +78,8 @@ function clientStreaming($stub) {
}, $request_lengths);
list($result, $status) = $stub->StreamingInputCall($requests)->wait();
- hardAssert($status->code == Grpc\STATUS_OK, 'Call did not complete successfully');
- hardAssert($result->getAggregatedPayloadSize() == 74922,
+ hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully');
+ hardAssert($result->getAggregatedPayloadSize() === 74922,
'aggregated_payload_size was incorrect');
}
@@ -100,15 +100,15 @@ function serverStreaming($stub) {
}
$call = $stub->StreamingOutputCall($request);
- hardAssert($call->getStatus()->code == Grpc\STATUS_OK,
+ hardAssert($call->getStatus()->code === Grpc\STATUS_OK,
'Call did not complete successfully');
$i = 0;
foreach($call->responses() as $value) {
hardAssert($i < 4, 'Too many responses');
$payload = $value->getPayload();
- hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE,
'Payload ' . $i . ' had the wrong type');
- hardAssert(strlen($payload->getBody()) == $sizes[$i],
+ hardAssert(strlen($payload->getBody()) === $sizes[$i],
'Response ' . $i . ' had the wrong length');
}
}
@@ -136,16 +136,16 @@ function pingPong($stub) {
$call->write($request);
$response = $call->read();
- hardAssert($response != null, 'Server returned too few responses');
+ hardAssert($response !== null, 'Server returned too few responses');
$payload = $response->getPayload();
- hardAssert($payload->getType() == grpc\testing\PayloadType::COMPRESSABLE,
+ hardAssert($payload->getType() === grpc\testing\PayloadType::COMPRESSABLE,
'Payload ' . $i . ' had the wrong type');
- hardAssert(strlen($payload->getBody()) == $response_lengths[$i],
+ hardAssert(strlen($payload->getBody()) === $response_lengths[$i],
'Payload ' . $i . ' had the wrong length');
}
$call->writesDone();
- hardAssert($call->read() == null, 'Server returned too many responses');
- hardAssert($call->getStatus()->code == Grpc\STATUS_OK,
+ hardAssert($call->read() === null, 'Server returned too many responses');
+ hardAssert($call->getStatus()->code === Grpc\STATUS_OK,
'Call did not complete successfully');
}
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index 78c5e9f93b..a2d8029b04 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -24,62 +24,52 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
'dummy_method',
$deadline);
$tag = 1;
- $this->assertEquals(Grpc\CALL_OK,
- $call->invoke($this->client_queue,
- $tag,
- $tag));
-
+ $call->invoke($this->client_queue, $tag, $tag);
$server_tag = 2;
$call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// check that a server rpc new was received
$this->server->start();
$this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
+ $this->assertSame(Grpc\SERVER_RPC_NEW, $event->type);
$server_call = $event->call;
$this->assertNotNull($server_call);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_accept($this->server_queue,
- $server_tag));
+ $server_call->server_accept($this->server_queue, $server_tag);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_end_initial_metadata());
+ $server_call->server_end_initial_metadata();
// the server sends the status
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write_status(Grpc\STATUS_OK,
- $status_text,
- $server_tag));
+ $server_call->start_write_status(Grpc\STATUS_OK, $status_text, $server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the client gets CLIENT_METADATA_READ
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
+ $this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type);
// the client gets FINISHED
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
- $this->assertEquals(Grpc\STATUS_OK, $status->code);
- $this->assertEquals($status_text, $status->details);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
// and the server gets FINISHED
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
unset($call);
@@ -96,10 +86,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
'dummy_method',
$deadline);
$tag = 1;
- $this->assertEquals(Grpc\CALL_OK,
- $call->invoke($this->client_queue,
- $tag,
- $tag));
+ $call->invoke($this->client_queue, $tag, $tag);
$server_tag = 2;
@@ -107,76 +94,69 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$call->start_write($req_text, $tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\WRITE_ACCEPTED, $event->type);
// check that a server rpc new was received
$this->server->start();
$this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
+ $this->assertSame(Grpc\SERVER_RPC_NEW, $event->type);
$server_call = $event->call;
$this->assertNotNull($server_call);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_accept($this->server_queue,
- $server_tag));
+ $server_call->server_accept($this->server_queue, $server_tag);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_end_initial_metadata());
+ $server_call->server_end_initial_metadata();
// start the server read
$server_call->start_read($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\READ, $event->type);
- $this->assertEquals($req_text, $event->data);
+ $this->assertSame(Grpc\READ, $event->type);
+ $this->assertSame($req_text, $event->data);
// the server replies
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write($reply_text, $server_tag));
+ $server_call->start_write($reply_text, $server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\WRITE_ACCEPTED, $event->type);
// the client reads the metadata
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
+ $this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type);
// the client reads the reply
$call->start_read($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\READ, $event->type);
- $this->assertEquals($reply_text, $event->data);
+ $this->assertSame(Grpc\READ, $event->type);
+ $this->assertSame($reply_text, $event->data);
// the client sends writes done
$call->writes_done($tag);
$event = $this->client_queue->next($deadline);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the server sends the status
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write_status(GRPC\STATUS_OK,
- $status_text,
- $server_tag));
+ $server_call->start_write_status(GRPC\STATUS_OK, $status_text, $server_tag);
$event = $this->server_queue->next($deadline);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the client gets FINISHED
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
- $this->assertEquals(Grpc\STATUS_OK, $status->code);
- $this->assertEquals($status_text, $status->details);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
// and the server gets FINISHED
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
unset($call);
unset($server_call);
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
index 7c3ad8a07c..7ba4984bd8 100755
--- a/src/php/tests/unit_tests/SecureEndToEndTest.php
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -36,59 +36,50 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
'dummy_method',
$deadline);
$tag = 1;
- $this->assertEquals(Grpc\CALL_OK,
- $call->invoke($this->client_queue,
- $tag,
- $tag));
+ $call->invoke($this->client_queue, $tag, $tag);
$server_tag = 2;
$call->writes_done($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// check that a server rpc new was received
$this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
+ $this->assertSame(Grpc\SERVER_RPC_NEW, $event->type);
$server_call = $event->call;
$this->assertNotNull($server_call);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_accept($this->server_queue,
- $server_tag));
+ $server_call->server_accept($this->server_queue, $server_tag);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_end_initial_metadata());
+ $server_call->server_end_initial_metadata();
// the server sends the status
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write_status(Grpc\STATUS_OK,
- $status_text,
- $server_tag));
+ $server_call->start_write_status(Grpc\STATUS_OK, $status_text, $server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the client gets CLIENT_METADATA_READ
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
+ $this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type);
// the client gets FINISHED
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
- $this->assertEquals(Grpc\STATUS_OK, $status->code);
- $this->assertEquals($status_text, $status->details);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
// and the server gets FINISHED
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
unset($call);
@@ -106,10 +97,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
'dummy_method',
$deadline);
$tag = 1;
- $this->assertEquals(Grpc\CALL_OK,
- $call->invoke($this->client_queue,
- $tag,
- $tag));
+ $call->invoke($this->client_queue, $tag, $tag);
$server_tag = 2;
@@ -117,75 +105,68 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$call->start_write($req_text, $tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\WRITE_ACCEPTED, $event->type);
// check that a server rpc new was received
$this->server->request_call($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type);
+ $this->assertSame(Grpc\SERVER_RPC_NEW, $event->type);
$server_call = $event->call;
$this->assertNotNull($server_call);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_accept($this->server_queue,
- $server_tag));
+ $server_call->server_accept($this->server_queue, $server_tag);
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->server_end_initial_metadata());
+ $server_call->server_end_initial_metadata();
// start the server read
$server_call->start_read($server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\READ, $event->type);
- $this->assertEquals($req_text, $event->data);
+ $this->assertSame(Grpc\READ, $event->type);
+ $this->assertSame($req_text, $event->data);
// the server replies
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write($reply_text, $server_tag));
+ $server_call->start_write($reply_text, $server_tag);
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\WRITE_ACCEPTED, $event->type);
// the client reads the metadata
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type);
+ $this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type);
// the client reads the reply
$call->start_read($tag);
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\READ, $event->type);
- $this->assertEquals($reply_text, $event->data);
+ $this->assertSame(Grpc\READ, $event->type);
+ $this->assertSame($reply_text, $event->data);
// the client sends writes done
$call->writes_done($tag);
$event = $this->client_queue->next($deadline);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the server sends the status
- $this->assertEquals(Grpc\CALL_OK,
- $server_call->start_write_status(GRPC\STATUS_OK,
- $status_text,
- $server_tag));
+ $server_call->start_write_status(GRPC\STATUS_OK, $status_text, $server_tag);
$event = $this->server_queue->next($deadline);
- $this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type);
- $this->assertEquals(Grpc\OP_OK, $event->data);
+ $this->assertSame(Grpc\FINISH_ACCEPTED, $event->type);
+ $this->assertSame(Grpc\OP_OK, $event->data);
// the client gets FINISHED
$event = $this->client_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
$status = $event->data;
- $this->assertEquals(Grpc\STATUS_OK, $status->code);
- $this->assertEquals($status_text, $status->details);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
// and the server gets FINISHED
$event = $this->server_queue->next($deadline);
$this->assertNotNull($event);
- $this->assertEquals(Grpc\FINISHED, $event->type);
+ $this->assertSame(Grpc\FINISHED, $event->type);
unset($call);
unset($server_call);
diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php
index 6af9fba043..067254b55b 100755
--- a/src/php/tests/unit_tests/TimevalTest.php
+++ b/src/php/tests/unit_tests/TimevalTest.php
@@ -2,7 +2,7 @@
class TimevalTest extends PHPUnit_Framework_TestCase{
public function testCompareSame() {
$zero = Grpc\Timeval::zero();
- $this->assertEquals(0, Grpc\Timeval::compare($zero, $zero));
+ $this->assertSame(0, Grpc\Timeval::compare($zero, $zero));
}
public function testPastIsLessThanZero() {
diff --git a/test/core/end2end/README b/test/core/end2end/README
index 31598b61b8..59daec45d0 100644
--- a/test/core/end2end/README
+++ b/test/core/end2end/README
@@ -5,6 +5,3 @@ To add a new test or fixture:
- add the code to the relevant directory
- update gen_build_json.py to reflect the change
- regenerate projects
-// MOE:begin_strip
-- update net/grpc/c/BUILD to reflect the change
-// MOE:end_strip \ No newline at end of file
diff --git a/test/core/end2end/gen_build_json.py b/test/core/end2end/gen_build_json.py
index 2c4368fe76..e28dbdb85d 100755
--- a/test/core/end2end/gen_build_json.py
+++ b/test/core/end2end/gen_build_json.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2.7
"""Generates the appropriate build.json data for all the end2end tests."""
diff --git a/tools/buildgen/mako_renderer.py b/tools/buildgen/mako_renderer.py
index 29c7cf0307..18f6eeaba6 100755
--- a/tools/buildgen/mako_renderer.py
+++ b/tools/buildgen/mako_renderer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2.7
"""Simple Mako renderer.
diff --git a/tools/dockerfile/grpc_base/README.md b/tools/dockerfile/grpc_base/README.md
index 4745141fc4..e3b5f2ef37 100644
--- a/tools/dockerfile/grpc_base/README.md
+++ b/tools/dockerfile/grpc_base/README.md
@@ -4,8 +4,7 @@ Base GRPC Dockerfile
Dockerfile for creating the base gRPC development Docker instance.
For now, this assumes that the development will be done on GCE instances, with source code on Git-on-Borg.
-As of 2014/09/29, it includes
+As of 2015/02/02, it includes
- git
- some useful tools like curl, emacs, strace, telnet etc
-- downloads the gerrit-compute-tools and installs the script that allows access to gerrit when on git-on-borg
- a patched version of protoc, to allow protos with stream tags to work
diff --git a/tools/dockerfile/grpc_java/README.md b/tools/dockerfile/grpc_java/README.md
index 2da2393bef..808f0fc5f3 100644
--- a/tools/dockerfile/grpc_java/README.md
+++ b/tools/dockerfile/grpc_java/README.md
@@ -5,5 +5,5 @@ Dockerfile for creating the Java development image
As of 2014/12 this
- is based on the gRPC Java base
- - pulls from gRPC Java on git-on-borg
+ - pulls from gRPC Java on GitHub
- installs it and runs the tests \ No newline at end of file
diff --git a/tools/dockerfile/grpc_node/Dockerfile b/tools/dockerfile/grpc_node/Dockerfile
index baec0e21d8..ce582d2ef1 100644
--- a/tools/dockerfile/grpc_node/Dockerfile
+++ b/tools/dockerfile/grpc_node/Dockerfile
@@ -11,4 +11,4 @@ RUN make install_c -C /var/local/git/grpc
RUN cd /var/local/git/grpc/src/node && npm install && node-gyp rebuild
-CMD ["/usr/bin/nodejs", "/var/local/git/grpc/src/node/interop/interop_server.js", "--use_tls=true", "--port 8040"] \ No newline at end of file
+CMD ["/usr/bin/nodejs", "/var/local/git/grpc/src/node/interop/interop_server.js", "--use_tls=true", "--port=8040"] \ No newline at end of file
diff --git a/tools/dockerfile/grpc_php/README.md b/tools/dockerfile/grpc_php/README.md
index a37389ff60..f3c332b8b3 100644
--- a/tools/dockerfile/grpc_php/README.md
+++ b/tools/dockerfile/grpc_php/README.md
@@ -5,6 +5,6 @@ Dockerfile for creating the PHP development instances
As of 2014/10 this
- is based on the GRPC PHP base
-- adds a pull of the HEAD GRPC PHP source from git-on-borg
+- adds a pull of the HEAD GRPC PHP source from GitHub
- it builds it
- runs the tests, i.e, the image won't be created if the tests don't pass
diff --git a/tools/dockerfile/grpc_php_base/Dockerfile b/tools/dockerfile/grpc_php_base/Dockerfile
index 47266a310e..ef58f3a887 100644
--- a/tools/dockerfile/grpc_php_base/Dockerfile
+++ b/tools/dockerfile/grpc_php_base/Dockerfile
@@ -45,13 +45,9 @@ RUN cd /var/local \
&& ./configure --with-zlib=/usr --with-libxml-dir=ext/libxml \
&& make -j12 && make install
-# Start the daemon that allows access to the protected git-on-borg repos
-RUN git clone https://gerrit.googlesource.com/gcompute-tools /var/local/git/gcompute-tools
-RUN /var/local/git/gcompute-tools/git-cookie-authdaemon
-
# Download the patched PHP protobuf so that PHP gRPC clients can be generated
# from proto3 schemas.
-RUN git clone https://team.googlesource.com/one-platform-grpc-team/grpc-php-protobuf-php /var/local/git/protobuf-php
+RUN git clone git@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.
diff --git a/tools/dockerfile/grpc_ruby/README.md b/tools/dockerfile/grpc_ruby/README.md
index 51fb2f5970..eaa8382f1c 100644
--- a/tools/dockerfile/grpc_ruby/README.md
+++ b/tools/dockerfile/grpc_ruby/README.md
@@ -5,6 +5,6 @@ Dockerfile for creating the Ruby development instances
As of 2014/10 this
- is based on the GRPC Ruby base
-- adds a pull of the HEAD gRPC Ruby source from git-on-borg
+- adds a pull of the HEAD gRPC Ruby source from GitHub
- it builds it
- runs the tests, i.e, the image won't be created if the tests don't pass
diff --git a/tools/gce_setup/grpc_docker.sh b/tools/gce_setup/grpc_docker.sh
index a97cc88aee..2e7ed97a87 100755
--- a/tools/gce_setup/grpc_docker.sh
+++ b/tools/gce_setup/grpc_docker.sh
@@ -317,7 +317,7 @@ grpc_interop_test_flags() {
echo "$FUNCNAME: missing arg: test_case" 1>&2
return 1
}
- echo "--server_host=$server_ip --server_port=$port --test_case=$test_case"
+ echo "--server_host_override=foo.test.google.fr --server_host=$server_ip --server_port=$port --test_case=$test_case"
}
# checks the positional args and assigns them to variables visible in the caller
@@ -874,7 +874,7 @@ grpc_cloud_prod_gen_go_cmd() {
grpc_interop_gen_java_cmd() {
local cmd_prefix="sudo docker run grpc/java";
local test_script="/var/local/git/grpc-java/run-test-client.sh";
- local test_script+=" --server_host_override=foo.test.google.fr --use_test_ca=true --use_tls=true"
+ local test_script+=" --use_test_ca=true --use_tls=true"
local the_cmd="$cmd_prefix $test_script $@";
echo $the_cmd
}
@@ -895,7 +895,7 @@ grpc_cloud_prod_gen_java_cmd() {
# constructs the full dockerized php interop test cmd.
#
-# TODO(mlumish): update this to use the script once that's on git-on-borg
+# TODO(mlumish): update this to use the script once that's on git
#
# call-seq:
# flags= .... # generic flags to include the command
diff --git a/tools/gce_setup/interop_test_runner.sh b/tools/gce_setup/interop_test_runner.sh
index edc8bba4b5..1244307912 100755
--- a/tools/gce_setup/interop_test_runner.sh
+++ b/tools/gce_setup/interop_test_runner.sh
@@ -1,4 +1,33 @@
#!/bin/bash
+thisfile=$(readlink -ne "${BASH_SOURCE[0]}")
+
+run_test() {
+ local test_case=$1
+ shift
+ local client=$1
+ shift
+ local server=$1
+ if grpc_interop_test $test_case grpc-docker-testclients $client grpc-docker-server $server
+ then
+ echo "$test_case $client $server passed" >> /tmp/interop_result.txt
+ else
+ echo "$test_case $client $server failed" >> /tmp/interop_result.txt
+ fi
+}
+
+time_out() {
+ local test_case=$1
+ shift
+ local client=$1
+ shift
+ local server=$1
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
+ if ! timeout 20s bash -l -c "source $thisfile && run_test $test_case $client $server"
+ then
+ echo "$test_case $client $server timed out" >> /tmp/interop_result.txt
+ fi
+ fi
+}
main() {
source grpc_docker.sh
@@ -11,17 +40,14 @@ main() {
do
for server in "${servers[@]}"
do
- if grpc_interop_test $test_case grpc-docker-testclients $client grpc-docker-server $server
- then
- echo "$test_case $client $server passed" >> /tmp/interop_result.txt
- else
- echo "$test_case $client $server failed" >> /tmp/interop_result.txt
- fi
+ time_out $test_case $client $server
done
done
done
- gsutil cp /tmp/interop_result.txt gs://stoked-keyword-656-output/interop_result.txt
- rm /tmp/interop_result.txt
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
+ gsutil cp /tmp/interop_result.txt gs://stoked-keyword-656-output/interop_result.txt
+ rm /tmp/interop_result.txt
+ fi
}
set -x
diff --git a/tools/gce_setup/new_grpc_docker_builder.sh b/tools/gce_setup/new_grpc_docker_builder.sh
index 5d4fc361ad..ea36cc5606 100755
--- a/tools/gce_setup/new_grpc_docker_builder.sh
+++ b/tools/gce_setup/new_grpc_docker_builder.sh
@@ -86,7 +86,6 @@ add_instance() {
[[ -n $the_address ]] && address_flag="--address $the_address"
local the_image='container-vm-v20140925'
local scopes='compute-rw storage-full'
- scopes+=' https://www.googleapis.com/auth/gerritcodereview'
scopes+=' https://www.googleapis.com/auth/xapi.zoo'
gcloud --project $project compute instances create $instance \
$address_flag \
diff --git a/tools/gce_setup/new_grpc_docker_builder_on_startup.sh b/tools/gce_setup/new_grpc_docker_builder_on_startup.sh
index 87e8aac1e7..4b20a8be7d 100755
--- a/tools/gce_setup/new_grpc_docker_builder_on_startup.sh
+++ b/tools/gce_setup/new_grpc_docker_builder_on_startup.sh
@@ -3,8 +3,7 @@
#
# A grpc-docker GCE machine is based on docker container image.
#
-# On startup, it copies the grpc dockerfiles to a local directory, and update its address
-# so that the docker containers within it have git-on-borg-access.
+# On startup, it copies the grpc dockerfiles to a local directory, and update its address.
# _load_metadata curls a metadata url
_load_metadata() {
@@ -54,10 +53,6 @@ main() {
# Install git and emacs
apt-get update && apt-get install -y git emacs || return 1
- # Enable access to git repos on git-on-borg
- local git_root='/var/local/git'
- install_gob_daemon $git_root/gerrit-gcompute-tools || return 1
-
# Startup the docker registry
grpc_docker_launch_registry && grpc_docker_pull_known
diff --git a/tools/gce_setup/shared_startup_funcs.sh b/tools/gce_setup/shared_startup_funcs.sh
index 3300eb257d..3410a2a2c8 100755
--- a/tools/gce_setup/shared_startup_funcs.sh
+++ b/tools/gce_setup/shared_startup_funcs.sh
@@ -251,37 +251,6 @@ update_address_to() {
}
}
-# Allows instances to checkout repos on git-on-borg.
-#
-install_gob_daemon() {
- local gob_dir=$1
- [[ -n $gob_dir ]] || { echo "missing args: gob_dir" >&2; return 1; }
-
- local gob_repo=$2
- [[ -n $gob_repo ]] || gob_repo='https://gerrit.googlesource.com/gcompute-tools/'
-
- if [[ -e $gob_dir ]]
- then
- rm -fv $gob_dir || {
- echo "could not remove existing git repo at $gob_dir" >&2
- return 1
- }
- fi
-
- git clone $gob_repo $gob_dir || { echo "failed to pull gerrit cookie repo" >&2; return 1; }
- local startup_script=/etc/profile.d/gob_cookie_daemon.sh
-
- cat <<EOF >> $startup_script
-#!/bin/bash
-
-$gob_dir/git-cookie-authdaemon
-
-EOF
-
- chmod 755 $startup_script
- $startup_script
-}
-
# grpc_docker_add_docker_group
#
# Adds a docker group, restarts docker, relaunches the docker registry
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 8cc029e3cc..280c3f05cb 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2.7
"""Run tests in parallel."""
import argparse
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index fd15182120..939a1a6095 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -271,19 +271,23 @@
},
{
"language": "c++",
- "name": "status_test"
+ "name": "tips_publisher_test"
},
{
"language": "c++",
- "name": "sync_client_async_server_test"
+ "name": "tips_subscriber_test"
},
{
"language": "c++",
- "name": "thread_pool_test"
+ "name": "status_test"
},
{
"language": "c++",
- "name": "tips_client_test"
+ "name": "sync_client_async_server_test"
+ },
+ {
+ "language": "c++",
+ "name": "thread_pool_test"
},
{
"language": "c",