Merge remote-tracking branch 'ctiller-repo/we-dont-need-no-backup' into poller2

pull/2105/head
Vijay Pai 10 years ago
commit d03adc340a
  1. 2
      Makefile
  2. 6
      gRPC.podspec
  3. 4
      include/grpc++/channel_arguments.h
  4. 3
      include/grpc/byte_buffer.h
  5. 2
      include/grpc/byte_buffer_reader.h
  6. 15
      include/grpc/compression.h
  7. 22
      include/grpc/grpc.h
  8. 5
      include/grpc/grpc_security.h
  9. 2
      include/grpc/support/slice.h
  10. 5
      include/grpc/support/tls_pthread.h
  11. 24
      src/core/channel/channel_args.c
  12. 18
      src/core/channel/channel_args.h
  13. 3
      src/core/channel/child_channel.c
  14. 16
      src/core/channel/client_setup.c
  15. 18
      src/core/compression/algorithm.c
  16. 2
      src/core/compression/message_compress.h
  17. 18
      src/core/httpcli/httpcli.h
  18. 2
      src/core/iomgr/pollset.h
  19. 8
      src/core/iomgr/pollset_kick_posix.h
  20. 10
      src/core/iomgr/pollset_multipoller_with_epoll.c
  21. 10
      src/core/iomgr/pollset_multipoller_with_poll_posix.c
  22. 29
      src/core/iomgr/pollset_posix.c
  23. 9
      src/core/iomgr/pollset_posix.h
  24. 2
      src/core/iomgr/pollset_set.h
  25. 4
      src/core/iomgr/pollset_set_windows.c
  26. 4
      src/core/iomgr/tcp_client.h
  27. 6
      src/core/iomgr/tcp_server_posix.c
  28. 4
      src/core/security/client_auth_filter.c
  29. 17
      src/core/support/log_win32.c
  30. 8
      src/core/surface/byte_buffer_reader.c
  31. 2
      src/core/surface/call.c
  32. 2
      src/core/surface/call.h
  33. 9
      src/core/transport/chttp2_transport.c
  34. 5
      src/cpp/client/channel_arguments.cc
  35. 2
      src/csharp/Grpc.Core.Tests/ClientServerTest.cs
  36. 4
      src/objective-c/GRPCClient/GRPCCall.m
  37. 2
      src/objective-c/README.md
  38. 95
      src/python/src/grpc/_adapter/_intermediary_low_test.py
  39. 2
      src/ruby/.rspec
  40. 2
      src/ruby/spec/spec_helper.rb
  41. 2
      templates/Makefile.template
  42. 127
      templates/gRPC.podspec.template
  43. 11
      test/core/end2end/dualstack_socket_test.c
  44. 2
      test/core/end2end/end2end_tests.h
  45. 3
      test/core/end2end/fixtures/chttp2_fake_security.c
  46. 3
      test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c
  47. 5
      test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c
  48. 3
      test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c
  49. 8
      test/core/end2end/tests/bad_hostname.c
  50. 18
      test/core/end2end/tests/cancel_after_accept.c
  51. 18
      test/core/end2end/tests/cancel_after_accept_and_writes_closed.c
  52. 8
      test/core/end2end/tests/cancel_after_invoke.c
  53. 11
      test/core/end2end/tests/cancel_before_invoke.c
  54. 11
      test/core/end2end/tests/cancel_in_a_vacuum.c
  55. 11
      test/core/end2end/tests/census_simple_request.c
  56. 8
      test/core/end2end/tests/disappearing_server.c
  57. 14
      test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c
  58. 10
      test/core/end2end/tests/early_server_shutdown_finishes_tags.c
  59. 8
      test/core/end2end/tests/empty_batch.c
  60. 14
      test/core/end2end/tests/graceful_server_shutdown.c
  61. 18
      test/core/end2end/tests/invoke_large_request.c
  62. 31
      test/core/end2end/tests/max_concurrent_streams.c
  63. 11
      test/core/end2end/tests/max_message_length.c
  64. 4
      test/core/end2end/tests/no_op.c
  65. 14
      test/core/end2end/tests/ping_pong_streaming.c
  66. 17
      test/core/end2end/tests/registered_call.c
  67. 18
      test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c
  68. 18
      test/core/end2end/tests/request_response_with_metadata_and_payload.c
  69. 21
      test/core/end2end/tests/request_response_with_payload.c
  70. 41
      test/core/end2end/tests/request_response_with_payload_and_call_creds.c
  71. 28
      test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c
  72. 10
      test/core/end2end/tests/request_with_flags.c
  73. 18
      test/core/end2end/tests/request_with_large_metadata.c
  74. 18
      test/core/end2end/tests/request_with_payload.c
  75. 11
      test/core/end2end/tests/server_finishes_request.c
  76. 16
      test/core/end2end/tests/simple_delayed_request.c
  77. 14
      test/core/end2end/tests/simple_request.c
  78. 14
      test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c
  79. 4
      test/core/fling/server.c
  80. 20
      test/core/httpcli/httpcli_test.c
  81. 12
      test/core/iomgr/endpoint_tests.c
  82. 5
      test/core/iomgr/endpoint_tests.h
  83. 13
      test/core/iomgr/fd_posix_test.c
  84. 2
      test/core/iomgr/poll_kick_posix_test.c
  85. 26
      test/core/iomgr/tcp_client_posix_test.c
  86. 4
      test/core/iomgr/tcp_posix_test.c
  87. 7
      test/core/iomgr/tcp_server_posix_test.c
  88. 33
      test/core/security/credentials_test.c
  89. 4
      test/core/security/secure_endpoint_test.c
  90. 6
      test/core/surface/byte_buffer_reader_test.c
  91. 26
      test/core/surface/completion_queue_test.c
  92. 24
      test/cpp/util/cli_call.cc
  93. 12
      test/cpp/util/cli_call.h
  94. 20
      test/cpp/util/cli_call_test.cc
  95. 74
      test/cpp/util/grpc_cli.cc
  96. 3
      tools/jenkins/grpc_jenkins_slave/Dockerfile
  97. 11
      tools/jenkins/run_jenkins.sh

@ -1216,7 +1216,7 @@ else
endif
endif
$(Q)$(MAKE) -C third_party/openssl clean
$(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
$(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl)
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
$(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl

File diff suppressed because one or more lines are too long

@ -38,6 +38,7 @@
#include <list>
#include <grpc++/config.h>
#include <grpc/compression.h>
#include <grpc/grpc.h>
namespace grpc {
@ -58,6 +59,9 @@ class ChannelArguments {
void SetSslTargetNameOverride(const grpc::string& name);
// TODO(yangg) add flow control options
// Set the compression level for the channel.
void SetCompressionLevel(grpc_compression_level level);
// Generic channel argument setters. Only for advanced use cases.
void SetInt(const grpc::string& key, int value);
void SetString(const grpc::string& key, const grpc::string& value);

@ -85,7 +85,6 @@ size_t grpc_byte_buffer_length(grpc_byte_buffer *bb);
/** Destroys \a byte_buffer deallocating all its memory. */
void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer);
/** Reader for byte buffers. Iterates over slices in the byte buffer */
struct grpc_byte_buffer_reader;
typedef struct grpc_byte_buffer_reader grpc_byte_buffer_reader;
@ -107,4 +106,4 @@ int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
}
#endif
#endif /* GRPC_BYTE_BUFFER_H */
#endif /* GRPC_BYTE_BUFFER_H */

@ -55,4 +55,4 @@ struct grpc_byte_buffer_reader {
}
#endif
#endif /* GRPC_BYTE_BUFFER_READER_H */
#endif /* GRPC_BYTE_BUFFER_READER_H */

@ -34,6 +34,9 @@
#ifndef GRPC_COMPRESSION_H
#define GRPC_COMPRESSION_H
/** To be used in channel arguments */
#define GRPC_COMPRESSION_LEVEL_ARG "grpc.compression_level"
/* The various compression algorithms supported by GRPC */
typedef enum {
GRPC_COMPRESS_NONE = 0,
@ -43,7 +46,17 @@ typedef enum {
GRPC_COMPRESS_ALGORITHMS_COUNT
} grpc_compression_algorithm;
typedef enum {
GRPC_COMPRESS_LEVEL_NONE = 0,
GRPC_COMPRESS_LEVEL_LOW,
GRPC_COMPRESS_LEVEL_MED,
GRPC_COMPRESS_LEVEL_HIGH
} grpc_compression_level;
const char *grpc_compression_algorithm_name(
grpc_compression_algorithm algorithm);
#endif /* GRPC_COMPRESSION_H */
grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level);
#endif /* GRPC_COMPRESSION_H */

@ -99,7 +99,8 @@ typedef struct {
These configuration options are modelled as key-value pairs as defined
by grpc_arg; keys are strings to allow easy backwards-compatible extension
by arbitrary parties.
All evaluation is performed at channel creation time. */
All evaluation is performed at channel creation time (i.e. the values in
this structure need only live through the creation invocation). */
typedef struct {
size_t num_args;
grpc_arg *args;
@ -255,7 +256,7 @@ typedef enum {
no arguments) */
typedef struct grpc_op {
grpc_op_type op;
gpr_uint32 flags; /**< Write flags bitset for grpc_begin_messages */
gpr_uint32 flags; /**< Write flags bitset for grpc_begin_messages */
union {
struct {
size_t count;
@ -274,6 +275,8 @@ typedef struct grpc_op {
After the operation completes, call grpc_metadata_array_destroy on this
value, or reuse it in a future op. */
grpc_metadata_array *recv_initial_metadata;
/* ownership of the byte buffer is moved to the caller; the caller must call
grpc_byte_buffer_destroy on this value, or reuse it in a future op. */
grpc_byte_buffer **recv_message;
struct {
/* ownership of the array is with the caller, but ownership of the
@ -374,7 +377,8 @@ void grpc_completion_queue_destroy(grpc_completion_queue *cq);
/* Create a call given a grpc_channel, in order to call 'method'. The request
is not sent until grpc_call_invoke is called. All completions are sent to
'completion_queue'. */
'completion_queue'. 'method' and 'host' need only live through the invocation
of this function. */
grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_completion_queue *completion_queue,
const char *method, const char *host,
@ -399,8 +403,9 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
/* Create a client channel to 'target'. Additional channel level configuration
MAY be provided by grpc_channel_args, though the expectation is that most
clients will want to simply pass NULL. See grpc_channel_args definition
for more on this. */
clients will want to simply pass NULL. See grpc_channel_args definition for
more on this. The data in 'args' need only live through the invocation of
this function. */
grpc_channel *grpc_channel_create(const char *target,
const grpc_channel_args *args);
@ -471,7 +476,8 @@ grpc_call_error grpc_server_request_registered_call(
/* Create a server. Additional configuration for each incoming channel can
be specified with args. If no additional configuration is needed, args can
be NULL. See grpc_channel_args for more. */
be NULL. See grpc_channel_args for more. The data in 'args' need only live
through the invocation of this function. */
grpc_server *grpc_server_create(const grpc_channel_args *args);
/* Register a completion queue with the server. Must be done for any completion
@ -511,9 +517,9 @@ void grpc_server_destroy(grpc_server *server);
Tracers (usually controlled by the environment variable GRPC_TRACE)
allow printf-style debugging on GRPC internals, and are useful for
tracking down problems in the field.
tracking down problems in the field.
Use of this function is not strictly thread-safe, but the
Use of this function is not strictly thread-safe, but the
thread-safety issues raised by it should not be of concern. */
int grpc_tracer_set_enabled(const char *name, int enabled);

@ -195,8 +195,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call *call,
/* TODO(jboeuf): Define some well-known property names. */
#define GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME \
"transport_security_type"
#define GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME "transport_security_type"
#define GRPC_FAKE_TRANSPORT_SECURITY_TYPE "fake"
#define GRPC_SSL_TRANSPORT_SECURITY_TYPE "ssl"
@ -251,4 +250,4 @@ const grpc_auth_context *grpc_call_auth_context(grpc_call *call);
}
#endif
#endif /* GRPC_GRPC_SECURITY_H */
#endif /* GRPC_GRPC_SECURITY_H */

@ -176,4 +176,4 @@ int gpr_slice_str_cmp(gpr_slice a, const char *b);
}
#endif
#endif /* GRPC_SUPPORT_SLICE_H */
#endif /* GRPC_SUPPORT_SLICE_H */

@ -34,7 +34,7 @@
#ifndef GRPC_SUPPORT_TLS_PTHREAD_H
#define GRPC_SUPPORT_TLS_PTHREAD_H
#include <grpc/support/log.h> /* for GPR_ASSERT */
#include <grpc/support/log.h> /* for GPR_ASSERT */
#include <pthread.h>
/* Thread local storage based on pthread library calls.
@ -44,8 +44,7 @@ struct gpr_pthread_thread_local {
pthread_key_t key;
};
#define GPR_TLS_DECL(name) \
static struct gpr_pthread_thread_local name = {0}
#define GPR_TLS_DECL(name) static struct gpr_pthread_thread_local name = {0}
#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL))
#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key)

@ -115,3 +115,27 @@ int grpc_channel_args_is_census_enabled(const grpc_channel_args *a) {
}
return 0;
}
grpc_compression_level grpc_channel_args_get_compression_level(
const grpc_channel_args *a) {
size_t i;
if (a) {
for (i = 0; a && i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER &&
!strcmp(GRPC_COMPRESSION_LEVEL_ARG, a->args[i].key)) {
return a->args[i].value.integer;
break;
}
}
}
return GRPC_COMPRESS_LEVEL_NONE;
}
void grpc_channel_args_set_compression_level(
grpc_channel_args **a, grpc_compression_level level) {
grpc_arg tmp;
tmp.type = GRPC_ARG_INTEGER;
tmp.key = GRPC_COMPRESSION_LEVEL_ARG;
tmp.value.integer = level;
*a = grpc_channel_args_copy_and_add(*a, &tmp);
}

@ -34,21 +34,31 @@
#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H
#define GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H
#include <grpc/compression.h>
#include <grpc/grpc.h>
/* Copy some arguments */
grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src);
/* Copy some arguments and add the to_add parameter in the end.
/** Copy some arguments and add the to_add parameter in the end.
If to_add is NULL, it is equivalent to call grpc_channel_args_copy. */
grpc_channel_args *grpc_channel_args_copy_and_add(const grpc_channel_args *src,
const grpc_arg *to_add);
/* Destroy arguments created by grpc_channel_args_copy */
/** Destroy arguments created by grpc_channel_args_copy */
void grpc_channel_args_destroy(grpc_channel_args *a);
/* Reads census_enabled settings from channel args. Returns 1 if census_enabled
is specified in channel args, otherwise returns 0. */
/** Reads census_enabled settings from channel args. Returns 1 if census_enabled
* is specified in channel args, otherwise returns 0. */
int grpc_channel_args_is_census_enabled(const grpc_channel_args *a);
/** Returns the compression level set in \a a. */
grpc_compression_level grpc_channel_args_get_compression_level(
const grpc_channel_args *a);
/** Sets the compression level in \a a to \a level. Setting it to
* GRPC_COMPRESS_LEVEL_NONE disables compression for the channel. */
void grpc_channel_args_set_compression_level(
grpc_channel_args **a, grpc_compression_level level);
#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */

@ -158,11 +158,8 @@ static void lb_destroy_channel_elem(grpc_channel_element *elem) {
const grpc_channel_filter grpc_child_channel_top_filter = {
lb_start_transport_op, lb_channel_op,
sizeof(lb_call_data), lb_init_call_elem, lb_destroy_call_elem,
sizeof(lb_channel_data), lb_init_channel_elem, lb_destroy_channel_elem,
"child-channel",
};

@ -56,6 +56,8 @@ struct grpc_client_setup {
gpr_cv cv;
grpc_client_setup_request *active_request;
int refs;
/** The set of pollsets that are currently interested in this
connection being established */
grpc_pollset_set interested_parties;
};
@ -83,9 +85,7 @@ static void destroy_setup(grpc_client_setup *s) {
gpr_free(s);
}
static void destroy_request(grpc_client_setup_request *r) {
gpr_free(r);
}
static void destroy_request(grpc_client_setup_request *r) { gpr_free(r); }
/* initiate handshaking */
static void setup_initiate(grpc_transport_setup *sp) {
@ -94,7 +94,6 @@ static void setup_initiate(grpc_transport_setup *sp) {
int in_alarm = 0;
r->setup = s;
/* TODO(klempner): Actually set a deadline */
r->deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(60));
gpr_mu_lock(&s->mu);
@ -119,25 +118,23 @@ static void setup_initiate(grpc_transport_setup *sp) {
}
}
/** implementation of add_interested_party for setup vtable */
static void setup_add_interested_party(grpc_transport_setup *sp,
grpc_pollset *pollset) {
grpc_client_setup *s = (grpc_client_setup *)sp;
gpr_mu_lock(&s->mu);
grpc_pollset_set_add_pollset(&s->interested_parties, pollset);
gpr_mu_unlock(&s->mu);
}
/** implementation of del_interested_party for setup vtable */
static void setup_del_interested_party(grpc_transport_setup *sp,
grpc_pollset *pollset) {
grpc_client_setup *s = (grpc_client_setup *)sp;
gpr_mu_lock(&s->mu);
grpc_pollset_set_del_pollset(&s->interested_parties, pollset);
gpr_mu_unlock(&s->mu);
}
@ -234,7 +231,8 @@ int grpc_client_setup_request_should_continue(grpc_client_setup_request *r,
return result;
}
static void backoff_alarm_done(void *arg /* grpc_client_setup */, int success) {
static void backoff_alarm_done(void *arg /* grpc_client_setup_request */,
int success) {
grpc_client_setup_request *r = arg;
grpc_client_setup *s = r->setup;
/* Handle status cancelled? */

@ -31,6 +31,7 @@
*
*/
#include <stdlib.h>
#include <grpc/compression.h>
const char *grpc_compression_algorithm_name(
@ -47,3 +48,20 @@ const char *grpc_compression_algorithm_name(
}
return "error";
}
/* TODO(dgq): Add the ability to specify parameters to the individual
* compression algorithms */
grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level) {
switch (level) {
case GRPC_COMPRESS_LEVEL_NONE:
return GRPC_COMPRESS_NONE;
case GRPC_COMPRESS_LEVEL_LOW:
case GRPC_COMPRESS_LEVEL_MED:
case GRPC_COMPRESS_LEVEL_HIGH:
return GRPC_COMPRESS_DEFLATE;
default:
/* we shouldn't be making it here */
abort();
}
}

@ -49,4 +49,4 @@ int grpc_msg_compress(grpc_compression_algorithm algorithm,
int grpc_msg_decompress(grpc_compression_algorithm algorithm,
gpr_slice_buffer *input, gpr_slice_buffer *output);
#endif /* GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H */
#endif /* GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H */

@ -93,6 +93,10 @@ void grpc_httpcli_context_init(grpc_httpcli_context *context);
void grpc_httpcli_context_destroy(grpc_httpcli_context *context);
/* Asynchronously perform a HTTP GET.
'context' specifies the http context under which to do the get
'pollset' indicates a grpc_pollset that is interested in the result
of the get - work on this pollset may be used to progress the get
operation
'request' contains request parameters - these are caller owned and can be
destroyed once the call returns
'deadline' contains a deadline for the request (or gpr_inf_future)
@ -106,7 +110,19 @@ void grpc_httpcli_get(grpc_httpcli_context *context, grpc_pollset *pollset,
grpc_httpcli_response_cb on_response, void *user_data);
/* Asynchronously perform a HTTP POST.
When there is no body, pass in NULL as body_bytes.
'context' specifies the http context under which to do the post
'pollset' indicates a grpc_pollset that is interested in the result
of the post - work on this pollset may be used to progress the post
operation
'request' contains request parameters - these are caller owned and can be
destroyed once the call returns
'body_bytes' and 'body_size' specify the payload for the post.
When there is no body, pass in NULL as body_bytes.
'deadline' contains a deadline for the request (or gpr_inf_future)
'em' points to a caller owned event manager that must be alive for the
lifetime of the request
'on_response' is a callback to report results to (and 'user_data' is a user
supplied pointer to pass to said call)
Does not support ?var1=val1&var2=val2 in the path. */
void grpc_httpcli_post(grpc_httpcli_context *context, grpc_pollset *pollset,
const grpc_httpcli_request *request,

@ -65,7 +65,7 @@ void grpc_pollset_destroy(grpc_pollset *pollset);
May unlock GRPC_POLLSET_MU(pollset) during its execution. */
int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline);
/* Break a pollset out of polling work
/* Break one polling thread out of polling work for this pollset.
Requires GRPC_POLLSET_MU(pollset) locked. */
void grpc_pollset_kick(grpc_pollset *pollset);

@ -37,6 +37,11 @@
#include "src/core/iomgr/wakeup_fd_posix.h"
#include <grpc/support/sync.h>
/* pollset kicking allows breaking a thread out of polling work for
a given pollset.
writing a byte to a pipe is used as a posix-ly portable base
mechanism, and eventfds are utilized on Linux for better performance. */
typedef struct grpc_kick_fd_info {
grpc_wakeup_fd_info wakeup_fd;
/* used for polling list and free list */
@ -67,7 +72,7 @@ void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state);
* applicable. Intended for testing. */
void grpc_pollset_kick_global_init_fallback_fd(void);
/* Must be called before entering poll(). If return value is -1, this consumed
/* Must be called before entering poll(). If return value is NULL, this consumed
an existing kick. Otherwise the return value is an FD to add to the poll set.
*/
grpc_kick_fd_info *grpc_pollset_kick_pre_poll(
@ -82,6 +87,7 @@ void grpc_pollset_kick_consume(grpc_pollset_kick_state *kick_state,
void grpc_pollset_kick_post_poll(grpc_pollset_kick_state *kick_state,
grpc_kick_fd_info *fd_info);
/* Actually kick */
void grpc_pollset_kick_kick(grpc_pollset_kick_state *kick_state);
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_KICK_POSIX_H */

@ -97,15 +97,7 @@ static int multipoll_with_epoll_pollset_maybe_work(
* here.
*/
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout_ms = -1;
} else {
timeout_ms = gpr_time_to_millis(
gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
if (timeout_ms < 0) {
return 1;
}
}
timeout_ms = grpc_poll_deadline_to_millis_timeout(deadline, now);
pollset->counter += 1;
gpr_mu_unlock(&pollset->mu);

@ -113,15 +113,7 @@ static int multipoll_with_poll_pollset_maybe_work(
grpc_kick_fd_info *kfd;
h = pollset->data.ptr;
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout = -1;
} else {
timeout = gpr_time_to_millis(
gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
if (timeout < 0) {
return 1;
}
}
timeout = grpc_poll_deadline_to_millis_timeout(deadline, now);
if (h->pfd_capacity < h->fd_count + 1) {
h->pfd_capacity = GPR_MAX(h->pfd_capacity * 3 / 2, h->fd_count + 1);
gpr_free(h->pfds);

@ -163,7 +163,8 @@ void grpc_pollset_shutdown(grpc_pollset *pollset,
gpr_mu_lock(&pollset->mu);
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = 1;
if (!pollset->called_shutdown && pollset->in_flight_cbs == 0 && pollset->counter == 0) {
if (!pollset->called_shutdown && pollset->in_flight_cbs == 0 &&
pollset->counter == 0) {
pollset->called_shutdown = 1;
call_shutdown = 1;
}
@ -187,6 +188,22 @@ void grpc_pollset_destroy(grpc_pollset *pollset) {
gpr_mu_destroy(&pollset->mu);
}
int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline, gpr_timespec now) {
gpr_timespec timeout;
static const int max_spin_polling_us = 10;
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
return -1;
}
if (gpr_time_cmp(
deadline,
gpr_time_add(now, gpr_time_from_micros(max_spin_polling_us))) <= 0) {
return 0;
}
timeout = gpr_time_sub(deadline, now);
return gpr_time_to_millis(
gpr_time_add(timeout, gpr_time_from_nanos(GPR_NS_PER_SEC - 1)));
}
/*
* basic_pollset - a vtable that provides polling for zero or one file
* descriptor via poll()
@ -343,15 +360,7 @@ static int basic_pollset_maybe_work(grpc_pollset *pollset,
GRPC_FD_UNREF(fd, "basicpoll");
fd = pollset->data.ptr = NULL;
}
if (gpr_time_cmp(deadline, gpr_inf_future) == 0) {
timeout = -1;
} else {
timeout = gpr_time_to_millis(
gpr_time_add(gpr_time_sub(deadline, now), gpr_time_from_micros(500)));
if (timeout < 0) {
return 1;
}
}
timeout = grpc_poll_deadline_to_millis_timeout(deadline, now);
kfd = grpc_pollset_kick_pre_poll(&pollset->kick_state);
if (kfd == NULL) {
/* Already kicked */

@ -94,6 +94,15 @@ int grpc_kick_read_fd(grpc_pollset *p);
/* Call after polling has been kicked to leave the kicked state */
void grpc_kick_drain(grpc_pollset *p);
/* Convert a timespec to milliseconds:
- very small or negative poll times are clamped to zero to do a
non-blocking poll (which becomes spin polling)
- other small values are rounded up to one millisecond
- longer than a millisecond polls are rounded up to the next nearest
millisecond to avoid spinning
- infinite timeouts are converted to -1 */
int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline, gpr_timespec now);
/* turn a pollset into a multipoller: platform specific */
typedef void (*grpc_platform_become_multipoller_type)(grpc_pollset *pollset,
struct grpc_fd **fds,

@ -39,7 +39,7 @@
/* A grpc_pollset_set is a set of pollsets that are interested in an
action. Adding a pollset to a pollset_set automatically adds any
fd's (etc) that have been registered with the set_set with that pollset.
Registering fd's automatically iterates all current pollsets. */
Registering fd's automatically adds them to all current pollsets. */
#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/pollset_set_posix.h"

@ -42,9 +42,9 @@ void grpc_pollset_set_init(grpc_pollset_set *pollset_set) {}
void grpc_pollset_set_destroy(grpc_pollset_set *pollset_set) {}
void grpc_pollset_set_add_pollset(grpc_pollset_set *pollset_set,
grpc_pollset *pollset) {}
grpc_pollset *pollset) {}
void grpc_pollset_set_del_pollset(grpc_pollset_set *pollset_set,
grpc_pollset *pollset) {}
grpc_pollset *pollset) {}
#endif /* GPR_WINSOCK_SOCKET */

@ -41,7 +41,9 @@
/* Asynchronously connect to an address (specified as (addr, len)), and call
cb with arg and the completed connection when done (or call cb with arg and
NULL on failure) */
NULL on failure).
interested_parties points to a set of pollsets that would be interested
in this connection being established (in order to continue their work) */
void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *tcp),
void *arg, grpc_pollset_set *interested_parties,
const struct sockaddr *addr, int addr_len,

@ -108,6 +108,7 @@ struct grpc_tcp_server {
/* destroyed port count: how many ports are completely destroyed */
size_t destroyed_ports;
/* is this server shutting down? (boolean) */
int shutdown;
/* all listening ports */
@ -119,7 +120,9 @@ struct grpc_tcp_server {
void (*shutdown_complete)(void *);
void *shutdown_complete_arg;
/* all pollsets interested in new connections */
grpc_pollset **pollsets;
/* number of pollsets in the pollsets array */
size_t pollset_count;
};
@ -160,6 +163,9 @@ static void destroyed_port(void *server, int success) {
static void dont_care_about_shutdown_completion(void *ignored) {}
/* called when all listening endpoints have been shutdown, so no further
events will be received on them - at this point it's safe to destroy
things */
static void deactivated_all_ports(grpc_tcp_server *s) {
size_t i;

@ -53,6 +53,10 @@ typedef struct {
grpc_credentials *creds;
grpc_mdstr *host;
grpc_mdstr *method;
/* pollset bound to this call; if we need to make external
network requests, they should be done under this pollset
so that work can progress when this call wants work to
progress */
grpc_pollset *pollset;
grpc_transport_op op;
size_t op_md_idx;

@ -94,23 +94,22 @@ void gpr_default_log(gpr_log_func_args *args) {
fprintf(stderr, "%s%s.%09u %5lu %s:%d] %s\n",
gpr_log_severity_string(args->severity), time_buffer,
(int)(now.tv_nsec), GetCurrentThreadId(),
args->file, args->line, args->message);
(int)(now.tv_nsec), GetCurrentThreadId(), args->file, args->line,
args->message);
}
char *gpr_format_message(DWORD messageid) {
LPTSTR tmessage;
char *message;
DWORD status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageid,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&tmessage), 0, NULL);
DWORD status = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, messageid, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&tmessage), 0, NULL);
if (status == 0) return gpr_strdup("Unable to retrieve error string");
message = gpr_tchar_to_char(tmessage);
LocalFree(tmessage);
return message;
}
#endif /* GPR_WIN32 */
#endif /* GPR_WIN32 */

@ -64,11 +64,11 @@ void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
grpc_msg_decompress(reader->buffer_in->data.raw.compression,
&reader->buffer_in->data.raw.slice_buffer,
&decompressed_slices_buffer);
reader->buffer_out = grpc_raw_byte_buffer_create(
decompressed_slices_buffer.slices,
decompressed_slices_buffer.count);
reader->buffer_out =
grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices,
decompressed_slices_buffer.count);
gpr_slice_buffer_destroy(&decompressed_slices_buffer);
} else { /* not compressed, use the input buffer as output */
} else { /* not compressed, use the input buffer as output */
reader->buffer_out = reader->buffer_in;
}
reader->current.index = 0;

@ -1288,7 +1288,7 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
req->flags = op->flags;
break;
case GRPC_OP_SEND_MESSAGE:
if (!are_write_flags_valid(op->flags)){
if (!are_write_flags_valid(op->flags)) {
return GRPC_CALL_ERROR_INVALID_FLAGS;
}
req = &reqs[out++];

@ -79,7 +79,7 @@ typedef union {
typedef struct {
grpc_ioreq_op op;
grpc_ioreq_data data;
gpr_uint32 flags; /**< A copy of the write flags from grpc_op */
gpr_uint32 flags; /**< A copy of the write flags from grpc_op */
} grpc_ioreq;
typedef void (*grpc_ioreq_completion_func)(grpc_call *call, int success,

@ -1606,15 +1606,16 @@ static int init_settings_frame_parser(transport *t) {
int ok;
if (t->incoming_stream_id != 0) {
gpr_log(GPR_ERROR, "settings frame received for stream %d", t->incoming_stream_id);
gpr_log(GPR_ERROR, "settings frame received for stream %d",
t->incoming_stream_id);
drop_connection(t);
return 0;
}
ok = GRPC_CHTTP2_PARSE_OK ==
grpc_chttp2_settings_parser_begin_frame(
&t->simple_parsers.settings, t->incoming_frame_size,
t->incoming_frame_flags, t->settings[PEER_SETTINGS]);
grpc_chttp2_settings_parser_begin_frame(
&t->simple_parsers.settings, t->incoming_frame_size,
t->incoming_frame_flags, t->settings[PEER_SETTINGS]);
if (!ok) {
drop_connection(t);
return 0;

@ -34,6 +34,7 @@
#include <grpc++/channel_arguments.h>
#include <grpc/grpc_security.h>
#include "src/core/channel/channel_args.h"
namespace grpc {
@ -41,6 +42,10 @@ void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) {
SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name);
}
void ChannelArguments::SetCompressionLevel(grpc_compression_level level) {
SetInt(GRPC_COMPRESSION_LEVEL_ARG, level);
}
grpc::string ChannelArguments::GetSslTargetNameOverride() const {
for (unsigned int i = 0; i < args_.size(); i++) {
if (grpc::string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == args_[i].key) {

@ -204,7 +204,7 @@ namespace Grpc.Core.Tests
BenchmarkUtil.RunBenchmark(100, 100,
() => { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); });
}
[Test]
public void UnknownMethodHandler()
{

@ -100,7 +100,9 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
if (!host || !method) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor method can be nil."];
}
// TODO(jcanizales): Throw if the requestWriter was already started.
if (requestWriter.state != GRXWriterStateNotStarted) {
[NSException raise:NSInvalidArgumentException format:@"The requests writer can't be already started."];
}
if ((self = [super init])) {
static dispatch_once_t initialization;
dispatch_once(&initialization, ^{

@ -163,7 +163,7 @@ files:
* [Podspec](https://github.com/grpc/grpc/blob/master/gRPC.podspec) for the Objective-C gRPC runtime
library. This can be tedious to configure manually.
* [Podspec](https://github.com/jcanizales/protobuf/blob/add-podspec/Protobuf.podspec) for the
* [Podspec](https://github.com/google/protobuf/blob/master/Protobuf.podspec) for the
Objective-C Protobuf runtime library.
[Protocol Buffers]:https://developers.google.com/protocol-buffers/

@ -29,6 +29,8 @@
"""Tests for the old '_low'."""
import Queue
import threading
import time
import unittest
@ -43,6 +45,7 @@ _BYTE_SEQUENCE_SEQUENCE = tuple(
bytes(bytearray((row + column) % 256 for column in range(row)))
for row in range(_STREAM_LENGTH))
class LonelyClientTest(unittest.TestCase):
def testLonelyClient(self):
@ -79,6 +82,14 @@ class LonelyClientTest(unittest.TestCase):
del completion_queue
def _drive_completion_queue(completion_queue, event_queue):
while True:
event = completion_queue.get(_FUTURE)
if event.kind is _low.Event.Kind.STOP:
break
event_queue.put(event)
class EchoTest(unittest.TestCase):
def setUp(self):
@ -88,24 +99,26 @@ class EchoTest(unittest.TestCase):
self.server = _low.Server(self.server_completion_queue)
port = self.server.add_http2_addr('[::]:0')
self.server.start()
self.server_events = Queue.Queue()
self.server_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.server_completion_queue, self.server_events))
self.server_completion_queue_thread.start()
self.client_completion_queue = _low.CompletionQueue()
self.channel = _low.Channel('%s:%d' % (self.host, port), None)
self.client_events = Queue.Queue()
self.client_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.client_completion_queue, self.client_events))
self.client_completion_queue_thread.start()
def tearDown(self):
self.server.stop()
self.server_completion_queue.stop()
self.client_completion_queue.stop()
while True:
event = self.server_completion_queue.get(_FUTURE)
if event is not None and event.kind is _low.Event.Kind.STOP:
break
while True:
event = self.client_completion_queue.get(_FUTURE)
if event is not None and event.kind is _low.Event.Kind.STOP:
break
self.server_completion_queue = None
self.client_completion_queue = None
self.server_completion_queue_thread.join()
self.client_completion_queue_thread.join()
del self.server
def _perform_echo_test(self, test_data):
@ -144,7 +157,7 @@ class EchoTest(unittest.TestCase):
client_call.invoke(self.client_completion_queue, metadata_tag, finish_tag)
self.server.service(service_tag)
service_accepted = self.server_completion_queue.get(_FUTURE)
service_accepted = self.server_events.get()
self.assertIsNotNone(service_accepted)
self.assertIs(service_accepted.kind, _low.Event.Kind.SERVICE_ACCEPTED)
self.assertIs(service_accepted.tag, service_tag)
@ -165,7 +178,7 @@ class EchoTest(unittest.TestCase):
server_leading_binary_metadata_value)
server_call.premetadata()
metadata_accepted = self.client_completion_queue.get(_FUTURE)
metadata_accepted = self.client_events.get()
self.assertIsNotNone(metadata_accepted)
self.assertEqual(_low.Event.Kind.METADATA_ACCEPTED, metadata_accepted.kind)
self.assertEqual(metadata_tag, metadata_accepted.tag)
@ -179,14 +192,14 @@ class EchoTest(unittest.TestCase):
for datum in test_data:
client_call.write(datum, write_tag)
write_accepted = self.client_completion_queue.get(_FUTURE)
write_accepted = self.client_events.get()
self.assertIsNotNone(write_accepted)
self.assertIs(write_accepted.kind, _low.Event.Kind.WRITE_ACCEPTED)
self.assertIs(write_accepted.tag, write_tag)
self.assertIs(write_accepted.write_accepted, True)
server_call.read(read_tag)
read_accepted = self.server_completion_queue.get(_FUTURE)
read_accepted = self.server_events.get()
self.assertIsNotNone(read_accepted)
self.assertEqual(_low.Event.Kind.READ_ACCEPTED, read_accepted.kind)
self.assertEqual(read_tag, read_accepted.tag)
@ -194,14 +207,14 @@ class EchoTest(unittest.TestCase):
server_data.append(read_accepted.bytes)
server_call.write(read_accepted.bytes, write_tag)
write_accepted = self.server_completion_queue.get(_FUTURE)
write_accepted = self.server_events.get()
self.assertIsNotNone(write_accepted)
self.assertEqual(_low.Event.Kind.WRITE_ACCEPTED, write_accepted.kind)
self.assertEqual(write_tag, write_accepted.tag)
self.assertTrue(write_accepted.write_accepted)
client_call.read(read_tag)
read_accepted = self.client_completion_queue.get(_FUTURE)
read_accepted = self.client_events.get()
self.assertIsNotNone(read_accepted)
self.assertEqual(_low.Event.Kind.READ_ACCEPTED, read_accepted.kind)
self.assertEqual(read_tag, read_accepted.tag)
@ -209,14 +222,14 @@ class EchoTest(unittest.TestCase):
client_data.append(read_accepted.bytes)
client_call.complete(complete_tag)
complete_accepted = self.client_completion_queue.get(_FUTURE)
complete_accepted = self.client_events.get()
self.assertIsNotNone(complete_accepted)
self.assertIs(complete_accepted.kind, _low.Event.Kind.COMPLETE_ACCEPTED)
self.assertIs(complete_accepted.tag, complete_tag)
self.assertIs(complete_accepted.complete_accepted, True)
server_call.read(read_tag)
read_accepted = self.server_completion_queue.get(_FUTURE)
read_accepted = self.server_events.get()
self.assertIsNotNone(read_accepted)
self.assertEqual(_low.Event.Kind.READ_ACCEPTED, read_accepted.kind)
self.assertEqual(read_tag, read_accepted.tag)
@ -228,8 +241,8 @@ class EchoTest(unittest.TestCase):
server_trailing_binary_metadata_value)
server_call.status(_low.Status(_low.Code.OK, details), status_tag)
server_terminal_event_one = self.server_completion_queue.get(_FUTURE)
server_terminal_event_two = self.server_completion_queue.get(_FUTURE)
server_terminal_event_one = self.server_events.get()
server_terminal_event_two = self.server_events.get()
if server_terminal_event_one.kind == _low.Event.Kind.COMPLETE_ACCEPTED:
status_accepted = server_terminal_event_one
rpc_accepted = server_terminal_event_two
@ -246,8 +259,8 @@ class EchoTest(unittest.TestCase):
self.assertEqual(_low.Status(_low.Code.OK, ''), rpc_accepted.status)
client_call.read(read_tag)
client_terminal_event_one = self.client_completion_queue.get(_FUTURE)
client_terminal_event_two = self.client_completion_queue.get(_FUTURE)
client_terminal_event_one = self.client_events.get()
client_terminal_event_two = self.client_events.get()
if client_terminal_event_one.kind == _low.Event.Kind.READ_ACCEPTED:
read_accepted = client_terminal_event_one
finish_accepted = client_terminal_event_two
@ -303,22 +316,26 @@ class CancellationTest(unittest.TestCase):
self.server = _low.Server(self.server_completion_queue)
port = self.server.add_http2_addr('[::]:0')
self.server.start()
self.server_events = Queue.Queue()
self.server_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.server_completion_queue, self.server_events))
self.server_completion_queue_thread.start()
self.client_completion_queue = _low.CompletionQueue()
self.channel = _low.Channel('%s:%d' % (self.host, port), None)
self.client_events = Queue.Queue()
self.client_completion_queue_thread = threading.Thread(
target=_drive_completion_queue,
args=(self.client_completion_queue, self.client_events))
self.client_completion_queue_thread.start()
def tearDown(self):
self.server.stop()
self.server_completion_queue.stop()
self.client_completion_queue.stop()
while True:
event = self.server_completion_queue.get(0)
if event is not None and event.kind is _low.Event.Kind.STOP:
break
while True:
event = self.client_completion_queue.get(0)
if event is not None and event.kind is _low.Event.Kind.STOP:
break
self.server_completion_queue_thread.join()
self.client_completion_queue_thread.join()
del self.server
def testCancellation(self):
@ -340,29 +357,29 @@ class CancellationTest(unittest.TestCase):
client_call.invoke(self.client_completion_queue, metadata_tag, finish_tag)
self.server.service(service_tag)
service_accepted = self.server_completion_queue.get(_FUTURE)
service_accepted = self.server_events.get()
server_call = service_accepted.service_acceptance.call
server_call.accept(self.server_completion_queue, finish_tag)
server_call.premetadata()
metadata_accepted = self.client_completion_queue.get(_FUTURE)
metadata_accepted = self.client_events.get()
self.assertIsNotNone(metadata_accepted)
for datum in test_data:
client_call.write(datum, write_tag)
write_accepted = self.client_completion_queue.get(_FUTURE)
write_accepted = self.client_events.get()
server_call.read(read_tag)
read_accepted = self.server_completion_queue.get(_FUTURE)
read_accepted = self.server_events.get()
server_data.append(read_accepted.bytes)
server_call.write(read_accepted.bytes, write_tag)
write_accepted = self.server_completion_queue.get(_FUTURE)
write_accepted = self.server_events.get()
self.assertIsNotNone(write_accepted)
client_call.read(read_tag)
read_accepted = self.client_completion_queue.get(_FUTURE)
read_accepted = self.client_events.get()
client_data.append(read_accepted.bytes)
client_call.cancel()
@ -373,8 +390,8 @@ class CancellationTest(unittest.TestCase):
server_call.read(read_tag)
server_terminal_event_one = self.server_completion_queue.get(_FUTURE)
server_terminal_event_two = self.server_completion_queue.get(_FUTURE)
server_terminal_event_one = self.server_events.get()
server_terminal_event_two = self.server_events.get()
if server_terminal_event_one.kind == _low.Event.Kind.READ_ACCEPTED:
read_accepted = server_terminal_event_one
rpc_accepted = server_terminal_event_two
@ -388,7 +405,7 @@ class CancellationTest(unittest.TestCase):
self.assertEqual(_low.Event.Kind.FINISH, rpc_accepted.kind)
self.assertEqual(_low.Status(_low.Code.CANCELLED, ''), rpc_accepted.status)
finish_event = self.client_completion_queue.get(_FUTURE)
finish_event = self.client_events.get()
self.assertEqual(_low.Event.Kind.FINISH, finish_event.kind)
self.assertEqual(_low.Status(_low.Code.CANCELLED, 'Cancelled'),
finish_event.status)

@ -1,2 +1,4 @@
-I.
--require spec_helper
--format documentation
--color

@ -53,3 +53,5 @@ RSpec.configure do |config|
include RSpec::LoggingHelper
config.capture_log_messages
end
RSpec::Expectations.configuration.warn_about_potential_false_positives = false

@ -665,7 +665,7 @@ else
endif
endif
$(Q)$(MAKE) -C third_party/openssl clean
$(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
$(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl)
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
$(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl

@ -0,0 +1,127 @@
<%!
bad_header_names = ('time.h', 'string.h')
def fix_header_name(name):
split_name = name.split('/')
if split_name[-1] in bad_header_names:
return '/'.join(split_name[:-1] + ['grpc_' + split_name[-1]])
else:
return name
%>
Pod::Spec.new do |s|
s.name = 'gRPC'
s.version = '0.6.0'
s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'http://www.grpc.io'
s.license = 'New BSD'
s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
# s.source = { :git => 'https://github.com/grpc/grpc.git',
# :tag => 'release-0_9_1-objectivec-0.5.1' }
s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8'
s.requires_arc = true
# Reactive Extensions library for iOS.
s.subspec 'RxLibrary' do |rs|
rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
'src/objective-c/RxLibrary/transformations/*.{h,m}',
'src/objective-c/RxLibrary/private/*.{h,m}'
rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
end
# Core cross-platform gRPC library, written in C.
s.subspec 'C-Core' do |cs|
cs.source_files = \
% for lib in libs:
% if lib.name in ("grpc", "gpr"):
% for hdr in lib.get("headers", []):
'${fix_header_name(hdr)}', \
% endfor
% for hdr in lib.get("public_headers", []):
'${fix_header_name(hdr)}', \
% endfor
% for src in lib.src:
'${src}', \
% endfor
% endif
% endfor
cs.private_header_files = \
% for lib in libs:
% if lib.name in ("grpc", "gpr"):
% for hdr in lib.get("headers", []):
'${hdr}', \
% endfor
% endif
% endfor
cs.header_mappings_dir = '.'
# The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
# to tell XCode to look for headers under the "include" subdirectory too.
#
# TODO(jcanizales): Instead of doing this, during installation move everything under
# "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
# details of Cocoapods, and have changed in the past, breaking this podspec.
cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
'"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
cs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
cs.requires_arc = false
cs.libraries = 'z'
cs.dependency 'OpenSSL', '~> 1.0.200'
end
# This is a workaround for Cocoapods Issue #1437.
# It renames time.h and string.h to grpc_time.h and grpc_string.h.
# It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
# prepare_command's of subspecs.
#
# TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
s.prepare_command = <<-CMD
DIR_TIME="grpc/support"
BAD_TIME="$DIR_TIME/time.h"
GOOD_TIME="$DIR_TIME/grpc_time.h"
grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
if [ -f "include/$BAD_TIME" ];
then
mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
fi
DIR_STRING="src/core/support"
BAD_STRING="$DIR_STRING/string.h"
GOOD_STRING="$DIR_STRING/grpc_string.h"
grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
if [ -f "$BAD_STRING" ];
then
mv -f "$BAD_STRING" "$GOOD_STRING"
fi
CMD
# Objective-C wrapper around the core gRPC library.
s.subspec 'GRPCClient' do |gs|
gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
'src/objective-c/GRPCClient/private/*.{h,m}'
gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
gs.dependency 'gRPC/C-Core'
# TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
# one directory up.
gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
gs.dependency 'gRPC/RxLibrary'
# Certificates, to be able to establish TLS connections:
gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
end
# RPC library for ProtocolBuffers, based on gRPC
s.subspec 'ProtoRPC' do |ps|
ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
ps.dependency 'gRPC/GRPCClient'
ps.dependency 'gRPC/RxLibrary'
ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
end
end

@ -151,10 +151,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
if (expect_ok) {
/* Check for a successful request. */
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(server, &s, &call_details,
&request_metadata_recv, cq,
cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
server, &s, &call_details,
&request_metadata_recv, cq, cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -204,7 +203,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
/* Destroy server. */
grpc_server_shutdown_and_notify(server, cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(server);
grpc_completion_queue_shutdown(cq);
drain_cq(cq);

@ -64,4 +64,4 @@ struct grpc_end2end_test_config {
void grpc_end2end_tests(grpc_end2end_test_config config);
#endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */
#endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */

@ -83,7 +83,8 @@ static void chttp2_init_server_secure_fullstack(
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}

@ -86,7 +86,8 @@ static void chttp2_init_server_secure_fullstack(
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}

@ -86,7 +86,8 @@ static void chttp2_init_server_secure_fullstack(
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}
@ -142,7 +143,7 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
/* Set the SSL roots env var. */
roots_file = gpr_tmpfile("chttp2_simple_ssl_with_poll_fullstack_test",
roots_file = gpr_tmpfile("chttp2_simple_ssl_with_poll_fullstack_test",
&roots_filename);
GPR_ASSERT(roots_filename != NULL);
GPR_ASSERT(roots_file != NULL);

@ -84,7 +84,8 @@ static void chttp2_init_server_secure_fullstack(
}
f->server = grpc_server_create(server_args);
grpc_server_register_completion_queue(f->server, f->cq);
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds));
GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr,
server_creds));
grpc_server_credentials_release(server_creds);
grpc_server_start(f->server);
}

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -111,8 +113,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
char *details = NULL;
size_t details_capacity = 0;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"slartibartfast.local", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "slartibartfast.local",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);

@ -76,7 +76,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -103,7 +105,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_op *op;
grpc_call *c;
grpc_call *s;
grpc_end2end_test_fixture f = begin_test(config, "cancel_after_accept", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "cancel_after_accept", NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
@ -123,8 +126,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -158,10 +161,9 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(2)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(2)));
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);

@ -76,7 +76,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -103,7 +105,8 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_op *op;
grpc_call *c;
grpc_call *s;
grpc_end2end_test_fixture f = begin_test(config, "test_cancel_after_accept_and_writes_closed", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_cancel_after_accept_and_writes_closed", NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
@ -123,8 +126,8 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -161,10 +164,9 @@ static void test_cancel_after_accept_and_writes_closed(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(2)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(2)));
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -119,8 +121,8 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -101,7 +103,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_op ops[6];
grpc_op *op;
grpc_call *c;
grpc_end2end_test_fixture f = begin_test(config, "cancel_before_invoke", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "cancel_before_invoke", NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_metadata_array initial_metadata_recv;
@ -116,8 +119,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c));

@ -76,7 +76,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -100,12 +102,13 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
cancellation_mode mode) {
grpc_call *c;
grpc_end2end_test_fixture f = begin_test(config, "test_cancel_in_a_vacuum", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_cancel_in_a_vacuum", NULL, NULL);
gpr_timespec deadline = five_seconds_time();
cq_verifier *v_client = cq_verifier_create(f.cq);
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c));

@ -66,7 +66,9 @@ static void *tag(gpr_intptr t) { return (void *)t; }
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -139,10 +141,9 @@ static void test_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -127,10 +127,10 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f->server, &s, &call_details,
&request_metadata_recv, f->cq,
f->cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f->server, &s,
&call_details,
&request_metadata_recv,
f->cq, f->cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -91,7 +91,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -104,8 +105,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -135,10 +136,9 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -88,7 +88,8 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void test_early_server_shutdown_finishes_tags(
grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_call *s = (void *)1;
grpc_call_details call_details;
@ -99,10 +100,9 @@ static void test_early_server_shutdown_finishes_tags(
/* upon shutdown, the server should finish all requested calls indicating
no new call */
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
grpc_server_shutdown_and_notify(f.server, f.cq, tag(1000));
cq_expect_completion(cqv, tag(101), 0);
cq_expect_completion(cqv, tag(1000), 1);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -103,8 +105,8 @@ static void empty_batch_body(grpc_end2end_test_fixture f) {
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op *op = NULL;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, op, 0, tag(1)));

@ -98,7 +98,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -111,8 +112,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -142,10 +143,9 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -73,7 +73,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -100,7 +102,8 @@ static gpr_slice large_slice(void) {
}
static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_large_request", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_large_request", NULL, NULL);
gpr_slice request_payload_slice = large_slice();
gpr_slice response_payload_slice = large_slice();
@ -125,8 +128,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -163,10 +166,9 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -141,10 +143,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -250,10 +251,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
"foo.test.google.fr:1234", deadline);
GPR_ASSERT(c2);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s1, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s1, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@ -311,8 +311,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
got_server_start = 0;
live_call = -1;
while (!got_client_start || !got_server_start) {
ev = grpc_completion_queue_next(f.cq,
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3));
ev = grpc_completion_queue_next(f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3));
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
GPR_ASSERT(ev.success);
if (ev.tag == tag(101)) {
@ -321,7 +320,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
} else {
GPR_ASSERT(!got_client_start);
GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401));
/* The /alpha or /beta calls started above could be invoked (but NOT both);
/* The /alpha or /beta calls started above could be invoked (but NOT
* both);
* check this here */
/* We'll get tag 303 or 403, we want 300, 400 */
live_call = ((int)(gpr_intptr)ev.tag) - 1;
@ -355,10 +355,9 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(live_call + 1), 1);
cq_verify(cqv);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s2, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(201)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s2, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(201)));
cq_expect_completion(cqv, tag(201), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -160,10 +162,9 @@ static void test_max_message_length(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -98,7 +100,8 @@ static void end_test(grpc_end2end_test_fixture *f) {
/* Client pings and server pongs. Repeat messages rounds before finishing. */
static void test_pingpong_streaming(grpc_end2end_test_config config,
int messages) {
grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_pingpong_streaming", NULL, NULL);
grpc_call *c;
grpc_call *s;
gpr_timespec deadline = five_seconds_time();
@ -148,10 +151,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(100)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(100)));
cq_expect_completion(cqv, tag(100), 1);
cq_verify(cqv);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -142,10 +144,9 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -189,7 +190,8 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
}
static void test_invoke_simple_request(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_simple_request", NULL, NULL);
void *rc =
grpc_channel_register_call(f.client, "/foo", "foo.test.google.fr:1234");
@ -200,7 +202,8 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
void *rc =
grpc_channel_register_call(f.client, "/foo", "foo.test.google.fr:1234");

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -125,7 +127,8 @@ static void test_request_response_with_metadata_and_payload(
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
16,
{{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(config, "test_request_response_with_metadata_and_payload", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_request_response_with_metadata_and_payload", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -140,8 +143,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -179,10 +182,9 @@ static void test_request_response_with_metadata_and_payload(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -111,7 +113,8 @@ static void test_request_response_with_metadata_and_payload(
{"key2", "val2", 4, {{NULL, NULL, NULL}}}};
grpc_metadata meta_s[2] = {{"key3", "val3", 4, {{NULL, NULL, NULL}}},
{"key4", "val4", 4, {{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(config, "test_request_response_with_metadata_and_payload", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_request_response_with_metadata_and_payload", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -126,8 +129,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -165,10 +168,9 @@ static void test_request_response_with_metadata_and_payload(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -119,8 +121,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -157,10 +159,9 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -228,7 +229,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
payload and status. */
static void test_invoke_request_response_with_payload(
grpc_end2end_test_config config) {
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_response_with_payload", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_invoke_request_response_with_payload", NULL, NULL);
request_response_with_payload(f);
end_test(&f);
config.tear_down_data(&f);
@ -237,7 +239,8 @@ static void test_invoke_request_response_with_payload(
static void test_invoke_10_request_response_with_payload(
grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_request_response_with_payload", NULL, NULL);
grpc_end2end_test_fixture f = begin_test(
config, "test_invoke_10_request_response_with_payload", NULL, NULL);
for (i = 0; i < 10; i++) {
request_response_with_payload(f);
}

@ -51,11 +51,7 @@ static const char iam_selector[] = "selector";
static const char overridden_iam_token[] = "overridden_token";
static const char overridden_iam_selector[] = "overridden_selector";
typedef enum {
NONE,
OVERRIDE,
DESTROY
} override_mode;
typedef enum { NONE, OVERRIDE, DESTROY } override_mode;
enum { TIMEOUT = 200000 };
@ -89,7 +85,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -129,10 +127,11 @@ static void print_auth_context(int is_client, const grpc_auth_context *ctx) {
static void test_call_creds_failure(grpc_end2end_test_config config) {
grpc_call *c;
grpc_credentials *creds = NULL;
grpc_end2end_test_fixture f = begin_test(config, "test_call_creds_failure", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_call_creds_failure", NULL, NULL);
gpr_timespec deadline = five_seconds_time();
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
/* Try with credentials unfit to be set on a call (channel creds). */
@ -176,8 +175,8 @@ static void request_response_with_payload_and_call_creds(
grpc_credentials *creds = NULL;
const grpc_auth_context *s_auth_context = NULL;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
creds = grpc_iam_credentials_create(iam_token, iam_selector);
GPR_ASSERT(creds != NULL);
@ -232,11 +231,9 @@ static void request_response_with_payload_and_call_creds(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s,
&call_details,
&request_metadata_recv,
f.cq, f.cq,
tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
s_auth_context = grpc_call_auth_context(s);
@ -344,17 +341,22 @@ static void request_response_with_payload_and_call_creds(
void test_request_response_with_payload_and_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds("test_request_response_with_payload_and_call_creds", config, NONE);
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_call_creds", config, NONE);
}
void test_request_response_with_payload_and_overridden_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds("test_request_response_with_payload_and_overridden_call_creds", config, OVERRIDE);
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_overridden_call_creds", config,
OVERRIDE);
}
void test_request_response_with_payload_and_deleted_call_creds(
grpc_end2end_test_config config) {
request_response_with_payload_and_call_creds("test_request_response_with_payload_and_deleted_call_creds", config, DESTROY);
request_response_with_payload_and_call_creds(
"test_request_response_with_payload_and_deleted_call_creds", config,
DESTROY);
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
@ -365,4 +367,3 @@ void grpc_end2end_tests(grpc_end2end_test_config config) {
test_request_response_with_payload_and_deleted_call_creds(config);
}
}

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -107,10 +109,14 @@ static void test_request_response_with_metadata_and_payload(
grpc_byte_buffer *response_payload =
grpc_raw_byte_buffer_create(&response_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta_c[2] = {{"key1", "val1", 4, {{NULL, NULL, NULL}}}, {"key2", "val2", 4, {{NULL, NULL, NULL}}}};
grpc_metadata meta_s[2] = {{"key3", "val3", 4, {{NULL, NULL, NULL}}}, {"key4", "val4", 4, {{NULL, NULL, NULL}}}};
grpc_metadata meta_t[2] = {{"key5", "val5", 4, {{NULL, NULL, NULL}}}, {"key6", "val6", 4, {{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(config, "test_request_response_with_metadata_and_payload", NULL, NULL);
grpc_metadata meta_c[2] = {{"key1", "val1", 4, {{NULL, NULL, NULL}}},
{"key2", "val2", 4, {{NULL, NULL, NULL}}}};
grpc_metadata meta_s[2] = {{"key3", "val3", 4, {{NULL, NULL, NULL}}},
{"key4", "val4", 4, {{NULL, NULL, NULL}}}};
grpc_metadata meta_t[2] = {{"key5", "val5", 4, {{NULL, NULL, NULL}}},
{"key6", "val6", 4, {{NULL, NULL, NULL}}}};
grpc_end2end_test_fixture f = begin_test(
config, "test_request_response_with_metadata_and_payload", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -125,8 +131,8 @@ static void test_request_response_with_metadata_and_payload(
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -164,11 +170,9 @@ static void test_request_response_with_metadata_and_payload(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s,
&call_details,
&request_metadata_recv,
f.cq, f.cq,
tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -76,7 +76,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -119,8 +121,8 @@ static void test_invoke_request_with_flags(
size_t details_capacity = 0;
grpc_call_error expectation;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -173,7 +175,7 @@ static void test_invoke_request_with_flags(
void grpc_end2end_tests(grpc_end2end_test_config config) {
size_t i;
gpr_uint32 flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER+1];
gpr_uint32 flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1];
{
/* check that all grpc_op_types fail when their flag value is set to an

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -104,7 +106,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
grpc_metadata meta;
grpc_end2end_test_fixture f = begin_test(config, "test_request_with_large_metadata", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_request_with_large_metadata", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -119,8 +122,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
int was_cancelled = 2;
const int large_size = 64 * 1024;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
meta.key = "key";
@ -160,10 +163,9 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -75,7 +75,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -103,7 +105,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
gpr_timespec deadline = five_seconds_time();
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_request_with_payload", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_op ops[6];
grpc_op *op;
@ -117,8 +120,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
size_t details_capacity = 0;
int was_cancelled = 2;
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f.client, f.cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -151,10 +154,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -140,10 +142,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -63,7 +63,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -105,8 +107,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
config.init_client(f, client_args);
c = grpc_channel_create_call(f->client, f->cq, "/foo",
"foo.test.google.fr", deadline);
c = grpc_channel_create_call(f->client, f->cq, "/foo", "foo.test.google.fr",
deadline);
GPR_ASSERT(c);
grpc_metadata_array_init(&initial_metadata_recv);
@ -137,10 +139,10 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
config.init_server(f, server_args);
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f->server, &s, &call_details,
&request_metadata_recv, f->cq,
f->cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f->server, &s,
&call_details,
&request_metadata_recv,
f->cq, f->cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -143,10 +145,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -200,7 +201,8 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config) {
int i;
grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_10_simple_requests", NULL, NULL);
for (i = 0; i < 10; i++) {
simple_request_body(f);
gpr_log(GPR_INFO, "Passed simple request %d", i);

@ -77,7 +77,9 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
f->server = NULL;
}
@ -143,10 +145,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, op - ops, tag(1)));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq,
f.cq, tag(101)));
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
@ -189,7 +190,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_verifier_destroy(cqv);
}
static void test_invoke_10_simple_requests(grpc_end2end_test_config config, int initial_sequence_number) {
static void test_invoke_10_simple_requests(grpc_end2end_test_config config,
int initial_sequence_number) {
int i;
grpc_end2end_test_fixture f;
grpc_arg client_arg;

@ -234,7 +234,9 @@ int main(int argc, char **argv) {
if (got_sigint && !shutdown_started) {
gpr_log(GPR_INFO, "Shutting down due to SIGINT");
grpc_server_shutdown_and_notify(server, cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5)).type == GRPC_OP_COMPLETE);
GPR_ASSERT(grpc_completion_queue_pluck(
cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_completion_queue_shutdown(cq);
shutdown_started = 1;
}

@ -54,7 +54,7 @@ static gpr_timespec n_seconds_time(int seconds) {
}
static void on_finish(void *arg, const grpc_httpcli_response *response) {
const char *expect =
const char *expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
GPR_ASSERT(arg == (void *)42);
@ -70,7 +70,7 @@ static void on_finish(void *arg, const grpc_httpcli_response *response) {
static void test_get(int use_ssl, int port) {
grpc_httpcli_request req;
char* host;
char *host;
g_done = 0;
gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_get", use_ssl);
@ -95,7 +95,7 @@ static void test_get(int use_ssl, int port) {
static void test_post(int use_ssl, int port) {
grpc_httpcli_request req;
char* host;
char *host;
g_done = 0;
gpr_log(GPR_INFO, "running %s with use_ssl=%d.", "test_post", (int)use_ssl);
@ -108,8 +108,8 @@ static void test_post(int use_ssl, int port) {
req.path = "/post";
req.use_ssl = use_ssl;
grpc_httpcli_post(&g_context, &g_pollset, &req, "hello", 5, n_seconds_time(15), on_finish,
(void *)42);
grpc_httpcli_post(&g_context, &g_pollset, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42);
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (!g_done) {
grpc_pollset_work(&g_pollset, n_seconds_time(20));
@ -118,15 +118,13 @@ static void test_post(int use_ssl, int port) {
gpr_free(host);
}
static void destroy_pollset(void* ignored) {
grpc_pollset_destroy(&g_pollset);
}
static void destroy_pollset(void *ignored) { grpc_pollset_destroy(&g_pollset); }
int main(int argc, char **argv) {
gpr_subprocess* server;
gpr_subprocess *server;
char *me = argv[0];
char *lslash = strrchr(me, '/');
char* args[4];
char *args[4];
char root[1024];
int port = grpc_pick_unused_port_or_die();
@ -142,7 +140,7 @@ int main(int argc, char **argv) {
gpr_asprintf(&args[0], "%s/../../test/core/httpcli/test_server.py", root);
args[1] = "--port";
gpr_asprintf(&args[2], "%d", port);
server = gpr_subprocess_create(3, (const char**)args);
server = gpr_subprocess_create(3, (const char **)args);
GPR_ASSERT(server);
gpr_free(args[0]);
gpr_free(args[2]);

@ -160,7 +160,8 @@ static void read_and_write_test_write_handler(void *data,
GPR_ASSERT(error != GRPC_ENDPOINT_CB_ERROR);
gpr_log(GPR_DEBUG, "%s: error=%d", "read_and_write_test_write_handler", error);
gpr_log(GPR_DEBUG, "%s: error=%d", "read_and_write_test_write_handler",
error);
if (error == GRPC_ENDPOINT_CB_SHUTDOWN) {
gpr_log(GPR_INFO, "Write handler shutdown");
@ -213,7 +214,8 @@ static void read_and_write_test(grpc_endpoint_test_config config,
size_t slice_size, int shutdown) {
struct read_and_write_test_state state;
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20);
grpc_endpoint_test_fixture f = begin_test(config, "read_and_write_test", slice_size);
grpc_endpoint_test_fixture f =
begin_test(config, "read_and_write_test", slice_size);
if (shutdown) {
gpr_log(GPR_INFO, "Start read and write shutdown test");
@ -321,7 +323,8 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
shutdown_during_write_test_state read_st;
shutdown_during_write_test_state write_st;
gpr_slice *slices;
grpc_endpoint_test_fixture f = begin_test(config, "shutdown_during_write_test", slice_size);
grpc_endpoint_test_fixture f =
begin_test(config, "shutdown_during_write_test", slice_size);
gpr_log(GPR_INFO, "testing shutdown during a write");
@ -369,7 +372,8 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
abort();
}
void grpc_endpoint_tests(grpc_endpoint_test_config config, grpc_pollset *pollset) {
void grpc_endpoint_tests(grpc_endpoint_test_config config,
grpc_pollset *pollset) {
g_pollset = pollset;
read_and_write_test(config, 10000000, 100000, 8192, 0);
read_and_write_test(config, 1000000, 100000, 1, 0);

@ -52,6 +52,7 @@ struct grpc_endpoint_test_config {
void (*clean_up)();
};
void grpc_endpoint_tests(grpc_endpoint_test_config config, grpc_pollset *pollset);
void grpc_endpoint_tests(grpc_endpoint_test_config config,
grpc_pollset *pollset);
#endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */
#endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */

@ -270,7 +270,7 @@ typedef struct {
notify_on_write to schedule another write. */
int client_write_cnt;
int done; /* set to 1 when a client finishes sending */
int done; /* set to 1 when a client finishes sending */
grpc_iomgr_closure write_closure;
} client;
@ -383,12 +383,9 @@ typedef struct fd_change_data {
void (*cb_that_ran)(void *, int success);
} fd_change_data;
void init_change_data(fd_change_data *fdc) {
fdc->cb_that_ran = NULL;
}
void init_change_data(fd_change_data *fdc) { fdc->cb_that_ran = NULL; }
void destroy_change_data(fd_change_data *fdc) {
}
void destroy_change_data(fd_change_data *fdc) {}
static void first_read_callback(void *arg /* fd_change_data */, int success) {
fd_change_data *fdc = arg;
@ -478,9 +475,7 @@ static void test_grpc_fd_change(void) {
close(sv[1]);
}
static void destroy_pollset(void *p) {
grpc_pollset_destroy(p);
}
static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) {
grpc_test_init(argc, argv);

@ -93,7 +93,7 @@ static void test_over_free(void) {
/* Check high watermark pipe free logic */
int i;
grpc_kick_fd_info **kfds =
gpr_malloc(sizeof(grpc_kick_fd_info*) * GRPC_MAX_CACHED_PIPES);
gpr_malloc(sizeof(grpc_kick_fd_info *) * GRPC_MAX_CACHED_PIPES);
grpc_pollset_kick_state state;
grpc_pollset_kick_init(&state);
for (i = 0; i < GRPC_MAX_CACHED_PIPES; ++i) {

@ -94,8 +94,8 @@ void test_succeeds(void) {
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0);
grpc_tcp_client_connect(must_succeed, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
gpr_inf_future);
grpc_tcp_client_connect(must_succeed, NULL, &g_pollset_set,
(struct sockaddr *)&addr, addr_len, gpr_inf_future);
/* await the connection */
do {
@ -127,8 +127,8 @@ void test_fails(void) {
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
/* connect to a broken address */
grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
gpr_inf_future);
grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set,
(struct sockaddr *)&addr, addr_len, gpr_inf_future);
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
@ -181,17 +181,21 @@ void test_times_out(void) {
connections_complete_before = g_connections_complete;
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set, (struct sockaddr *)&addr, addr_len,
connect_deadline);
grpc_tcp_client_connect(must_fail, NULL, &g_pollset_set,
(struct sockaddr *)&addr, addr_len, connect_deadline);
/* Make sure the event doesn't trigger early */
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(2)), gpr_now()) > 0) {
while (gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(2)),
gpr_now()) > 0) {
int is_after_deadline = gpr_time_cmp(connect_deadline, gpr_now()) <= 0;
if (is_after_deadline && gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(1)), gpr_now()) > 0) {
if (is_after_deadline &&
gpr_time_cmp(gpr_time_add(connect_deadline, gpr_time_from_seconds(1)),
gpr_now()) > 0) {
/* allow some slack before insisting that things be done */
} else {
GPR_ASSERT(g_connections_complete == connections_complete_before + is_after_deadline);
GPR_ASSERT(g_connections_complete ==
connections_complete_before + is_after_deadline);
}
grpc_pollset_work(&g_pollset, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10));
}
@ -203,9 +207,7 @@ void test_times_out(void) {
}
}
static void destroy_pollset(void *p) {
grpc_pollset_destroy(p);
}
static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) {
grpc_test_init(argc, argv);

@ -473,9 +473,7 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
};
static void destroy_pollset(void *p) {
grpc_pollset_destroy(p);
}
static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) {
grpc_test_init(argc, argv);

@ -134,7 +134,8 @@ static void test_connect(int n) {
GPR_ASSERT(connect(clifd, (struct sockaddr *)&addr, addr_len) == 0);
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before && gpr_time_cmp(deadline, gpr_now()) > 0) {
while (g_nconnects == nconnects_before &&
gpr_time_cmp(deadline, gpr_now()) > 0) {
grpc_pollset_work(&g_pollset, deadline);
}
gpr_log(GPR_DEBUG, "wait done");
@ -148,9 +149,7 @@ static void test_connect(int n) {
grpc_tcp_server_destroy(s, NULL, NULL);
}
static void destroy_pollset(void *p) {
grpc_pollset_destroy(p);
}
static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) {
grpc_test_init(argc, argv);

@ -210,8 +210,7 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
&response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_OK);
&response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK);
GPR_ASSERT(token_lifetime.tv_sec == 3599);
GPR_ASSERT(token_lifetime.tv_nsec == 0);
GPR_ASSERT(token_md->num_entries == 1);
@ -354,8 +353,8 @@ static void test_ssl_oauth2_composite_creds(void) {
grpc_composite_credentials_create(ssl_creds, oauth2_creds);
grpc_credentials_unref(ssl_creds);
grpc_credentials_unref(oauth2_creds);
GPR_ASSERT(strcmp(composite_creds->type,
GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0);
GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) ==
0);
GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds));
GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds));
creds_array = grpc_composite_credentials_get_credentials(composite_creds);
@ -370,8 +369,7 @@ static void test_ssl_oauth2_composite_creds(void) {
}
void test_ssl_fake_transport_security_composite_creds_failure(void) {
grpc_credentials *ssl_creds =
grpc_ssl_credentials_create(NULL, NULL);
grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL);
grpc_credentials *fake_transport_security_creds =
grpc_fake_transport_security_credentials_create();
@ -412,8 +410,8 @@ static void test_ssl_oauth2_iam_composite_creds(void) {
grpc_credentials_unref(oauth2_creds);
grpc_credentials_unref(aux_creds);
grpc_credentials_unref(iam_creds);
GPR_ASSERT(strcmp(composite_creds->type,
GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0);
GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) ==
0);
GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds));
GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds));
creds_array = grpc_composite_credentials_get_credentials(composite_creds);
@ -455,9 +453,10 @@ static void validate_compute_engine_http_request(
const grpc_httpcli_request *request) {
GPR_ASSERT(!request->use_ssl);
GPR_ASSERT(strcmp(request->host, "metadata") == 0);
GPR_ASSERT(strcmp(request->path,
"/computeMetadata/v1/instance/service-accounts/default/token")
== 0);
GPR_ASSERT(
strcmp(request->path,
"/computeMetadata/v1/instance/service-accounts/default/token") ==
0);
GPR_ASSERT(request->hdr_count == 1);
GPR_ASSERT(strcmp(request->hdrs[0].key, "Metadata-Flavor") == 0);
GPR_ASSERT(strcmp(request->hdrs[0].value, "Google") == 0);
@ -553,8 +552,8 @@ static void validate_refresh_token_http_request(
GPR_ASSERT(strcmp(request->path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH) == 0);
GPR_ASSERT(request->hdr_count == 1);
GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0);
GPR_ASSERT(strcmp(request->hdrs[0].value,
"application/x-www-form-urlencoded") == 0);
GPR_ASSERT(
strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0);
}
static int refresh_token_httpcli_post_success(
@ -667,8 +666,8 @@ static void validate_service_account_http_request(
char *expected_body = NULL;
GPR_ASSERT(body != NULL);
GPR_ASSERT(body_size != 0);
gpr_asprintf(&expected_body, "%s%s",
GRPC_SERVICE_ACCOUNT_POST_BODY_PREFIX, test_signed_jwt);
gpr_asprintf(&expected_body, "%s%s", GRPC_SERVICE_ACCOUNT_POST_BODY_PREFIX,
test_signed_jwt);
GPR_ASSERT(strlen(expected_body) == body_size);
GPR_ASSERT(memcmp(expected_body, body, body_size) == 0);
gpr_free(expected_body);
@ -677,8 +676,8 @@ static void validate_service_account_http_request(
GPR_ASSERT(strcmp(request->path, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH) == 0);
GPR_ASSERT(request->hdr_count == 1);
GPR_ASSERT(strcmp(request->hdrs[0].key, "Content-Type") == 0);
GPR_ASSERT(strcmp(request->hdrs[0].value,
"application/x-www-form-urlencoded") == 0);
GPR_ASSERT(
strcmp(request->hdrs[0].value, "application/x-www-form-urlencoded") == 0);
}
static int service_account_httpcli_post_success(

@ -194,9 +194,7 @@ static void test_destroy_ep_early(grpc_endpoint_test_config config,
clean_up();
}
static void destroy_pollset(void *p) {
grpc_pollset_destroy(p);
}
static void destroy_pollset(void *p) { grpc_pollset_destroy(p); }
int main(int argc, char **argv) {
grpc_test_init(argc, argv);

@ -127,11 +127,11 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
input_slice = gpr_slice_malloc(input_size);
memset(GPR_SLICE_START_PTR(input_slice), 'a', input_size);
gpr_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
gpr_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
buffer = grpc_raw_compressed_byte_buffer_create(
sliceb_out.slices, sliceb_out.count, algorithm);
buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices,
sliceb_out.count, algorithm);
grpc_byte_buffer_reader_init(&reader, buffer);
while (grpc_byte_buffer_reader_next(&reader, &read_slice)) {

@ -100,7 +100,8 @@ static void test_shutdown_then_next_polling(void) {
cc = grpc_completion_queue_create();
grpc_completion_queue_shutdown(cc);
GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_past).type == GRPC_QUEUE_SHUTDOWN);
GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_past).type ==
GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@ -110,7 +111,8 @@ static void test_shutdown_then_next_with_timeout(void) {
cc = grpc_completion_queue_create();
grpc_completion_queue_shutdown(cc);
GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_future).type == GRPC_QUEUE_SHUTDOWN);
GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_future).type ==
GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@ -177,7 +179,7 @@ static void producer_thread(void *arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@ -186,7 +188,7 @@ static void producer_thread(void *arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
@ -196,7 +198,7 @@ static void producer_thread(void *arg) {
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
}
static void consumer_thread(void *arg) {
@ -204,13 +206,13 @@ static void consumer_thread(void *arg) {
grpc_event ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1);
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@ -223,7 +225,7 @@ static void consumer_thread(void *arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr) 1);
gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1);
return;
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Invalid timeout received");
@ -242,8 +244,8 @@ static void test_threading(int producers, int consumers) {
int total_consumed = 0;
static int optid = 101;
gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading", producers,
consumers);
gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading",
producers, consumers);
/* start all threads: they will wait for phase1 */
for (i = 0; i < producers + consumers; i++) {
@ -265,7 +267,7 @@ static void test_threading(int producers, int consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
gpr_event_set(&phase1, (void *)(gpr_intptr) 1);
gpr_event_set(&phase1, (void *)(gpr_intptr)1);
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@ -275,7 +277,7 @@ static void test_threading(int producers, int consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
gpr_event_set(&phase2, (void *)(gpr_intptr) 1);
gpr_event_set(&phase2, (void *)(gpr_intptr)1);
/* in parallel, we shutdown the completion channel - all events should still
be consumed */

@ -52,11 +52,20 @@ namespace {
void* tag(int i) { return (void*)(gpr_intptr) i; }
} // namespace
void CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel,
const grpc::string& method, const grpc::string& request,
grpc::string* response) {
Status CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel,
const grpc::string& method, const grpc::string& request,
grpc::string* response, const MetadataContainer& metadata,
MetadataContainer* server_initial_metadata,
MetadataContainer* server_trailing_metadata) {
std::unique_ptr<grpc::GenericStub> stub(new grpc::GenericStub(channel));
grpc::ClientContext ctx;
if (!metadata.empty()) {
for (std::multimap<grpc::string, grpc::string>::const_iterator iter =
metadata.begin();
iter != metadata.end(); ++iter) {
ctx.AddMetadata(iter->first, iter->second);
}
}
grpc::CompletionQueue cq;
std::unique_ptr<grpc::GenericClientAsyncReaderWriter> call(
stub->Call(&ctx, method, &cq, tag(1)));
@ -79,7 +88,7 @@ void CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel,
cq.Next(&got_tag, &ok);
if (!ok) {
std::cout << "Failed to read response." << std::endl;
return;
return Status(StatusCode::INTERNAL, "Failed to read response");
}
grpc::Status status;
call->Finish(&status, tag(5));
@ -87,7 +96,6 @@ void CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel,
GPR_ASSERT(ok);
if (status.ok()) {
std::cout << "RPC finished with OK status." << std::endl;
std::vector<grpc::Slice> slices;
recv_buffer.Dump(&slices);
@ -96,10 +104,10 @@ void CliCall::Call(std::shared_ptr<grpc::ChannelInterface> channel,
response->append(reinterpret_cast<const char*>(slices[i].begin()),
slices[i].size());
}
} else {
std::cout << "RPC finished with status code " << status.error_code()
<< " details: " << status.error_message() << std::endl;
}
*server_initial_metadata = ctx.GetServerInitialMetadata();
*server_trailing_metadata = ctx.GetServerTrailingMetadata();
return status;
}
} // namespace testing

@ -34,17 +34,23 @@
#ifndef GRPC_TEST_CPP_UTIL_CLI_CALL_H
#define GRPC_TEST_CPP_UTIL_CLI_CALL_H
#include <map>
#include <grpc++/channel_interface.h>
#include <grpc++/config.h>
#include <grpc++/status.h>
namespace grpc {
namespace testing {
class CliCall GRPC_FINAL {
public:
static void Call(std::shared_ptr<grpc::ChannelInterface> channel,
const grpc::string& method, const grpc::string& request,
grpc::string* response);
typedef std::multimap<grpc::string, grpc::string> MetadataContainer;
static Status Call(std::shared_ptr<grpc::ChannelInterface> channel,
const grpc::string& method, const grpc::string& request,
grpc::string* response, const MetadataContainer& metadata,
MetadataContainer* server_initial_metadata,
MetadataContainer* server_trailing_metadata);
};
} // namespace testing

@ -60,6 +60,14 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
public:
Status Echo(ServerContext* context, const EchoRequest* request,
EchoResponse* response) GRPC_OVERRIDE {
if (!context->client_metadata().empty()) {
for (std::multimap<grpc::string, grpc::string>::const_iterator iter =
context->client_metadata().begin();
iter != context->client_metadata().end(); ++iter) {
context->AddInitialMetadata(iter->first, iter->second);
}
}
context->AddTrailingMetadata("trailing_key", "trailing_value");
response->set_message(request->message());
return Status::OK;
}
@ -106,6 +114,7 @@ TEST_F(CliCallTest, SimpleRpc) {
request.set_message("Hello");
ClientContext context;
context.AddMetadata("key1", "val1");
Status s = stub_->Echo(&context, request, &response);
EXPECT_EQ(response.message(), request.message());
EXPECT_TRUE(s.ok());
@ -114,8 +123,17 @@ TEST_F(CliCallTest, SimpleRpc) {
grpc::string request_bin, response_bin, expected_response_bin;
EXPECT_TRUE(request.SerializeToString(&request_bin));
EXPECT_TRUE(response.SerializeToString(&expected_response_bin));
CliCall::Call(channel_, kMethod, request_bin, &response_bin);
std::multimap<grpc::string, grpc::string> client_metadata,
server_initial_metadata, server_trailing_metadata;
client_metadata.insert(std::pair<grpc::string, grpc::string>("key1", "val1"));
Status s2 = CliCall::Call(channel_, kMethod, request_bin, &response_bin,
client_metadata, &server_initial_metadata,
&server_trailing_metadata);
EXPECT_TRUE(s2.ok());
EXPECT_EQ(expected_response_bin, response_bin);
EXPECT_EQ(context.GetServerInitialMetadata(), server_initial_metadata);
EXPECT_EQ(context.GetServerTrailingMetadata(), server_trailing_metadata);
}
} // namespace testing

@ -41,8 +41,8 @@
body: "hello world"
}
b. under grpc/ run
protoc --proto_path=test/cpp/interop/ \
--encode=grpc.testing.SimpleRequest test/cpp/interop/messages.proto \
protoc --proto_path=test/proto/ \
--encode=grpc.testing.SimpleRequest test/proto/messages.proto \
< input.txt > input.bin
2. Start a server
make interop_server && bins/opt/interop_server --port=50051
@ -51,10 +51,12 @@
/grpc.testing.TestService/UnaryCall --enable_ssl=false \
--input_binary_file=input.bin --output_binary_file=output.bin
4. Decode response
protoc --proto_path=test/cpp/interop/ \
--decode=grpc.testing.SimpleResponse test/cpp/interop/messages.proto \
protoc --proto_path=test/proto/ \
--decode=grpc.testing.SimpleResponse test/proto/messages.proto \
< output.bin > output.txt
5. Now the text form of response should be in output.txt
Optionally, metadata can be passed to server via flag --metadata, e.g.
--metadata="MyHeaderKey1:Value1:MyHeaderKey2:Value2"
*/
#include <fstream>
@ -77,6 +79,44 @@ DEFINE_string(input_binary_file, "",
"Path to input file containing serialized request.");
DEFINE_string(output_binary_file, "output.bin",
"Path to output file to write serialized response.");
DEFINE_string(metadata, "",
"Metadata to send to server, in the form of key1:val1:key2:val2");
void ParseMetadataFlag(
std::multimap<grpc::string, grpc::string>* client_metadata) {
if (FLAGS_metadata.empty()) {
return;
}
std::vector<grpc::string> fields;
grpc::string delim(":");
size_t cur, next = -1;
do {
cur = next + 1;
next = FLAGS_metadata.find_first_of(delim, cur);
fields.push_back(FLAGS_metadata.substr(cur, next - cur));
} while (next != grpc::string::npos);
if (fields.size() % 2) {
std::cout << "Failed to parse metadata flag" << std::endl;
exit(1);
}
for (size_t i = 0; i < fields.size(); i += 2) {
client_metadata->insert(
std::pair<grpc::string, grpc::string>(fields[i], fields[i + 1]));
}
}
void PrintMetadata(const std::multimap<grpc::string, grpc::string>& m,
const grpc::string& message) {
if (m.empty()) {
return;
}
std::cout << message << std::endl;
for (std::multimap<grpc::string, grpc::string>::const_iterator iter =
m.begin();
iter != m.end(); ++iter) {
std::cout << iter->first << " : " << iter->second << std::endl;
}
}
int main(int argc, char** argv) {
grpc::testing::InitTest(&argc, &argv, true);
@ -118,11 +158,27 @@ int main(int argc, char** argv) {
grpc::CreateChannel(server_address, creds, grpc::ChannelArguments());
grpc::string response;
grpc::testing::CliCall::Call(channel, method, input_stream.str(), &response);
if (!response.empty()) {
std::ofstream output_file(FLAGS_output_binary_file,
std::ios::trunc | std::ios::binary);
output_file << response;
std::multimap<grpc::string, grpc::string> client_metadata,
server_initial_metadata, server_trailing_metadata;
ParseMetadataFlag(&client_metadata);
PrintMetadata(client_metadata, "Sending client initial metadata:");
grpc::Status s = grpc::testing::CliCall::Call(
channel, method, input_stream.str(), &response, client_metadata,
&server_initial_metadata, &server_trailing_metadata);
PrintMetadata(server_initial_metadata,
"Received initial metadata from server:");
PrintMetadata(server_trailing_metadata,
"Received trailing metadata from server:");
if (s.ok()) {
std::cout << "Rpc succeeded with OK status" << std::endl;
if (!response.empty()) {
std::ofstream output_file(FLAGS_output_binary_file,
std::ios::trunc | std::ios::binary);
output_file << response;
}
} else {
std::cout << "Rpc failed with status code " << s.error_code()
<< " error message " << s.error_message() << std::endl;
}
return 0;

@ -116,6 +116,9 @@ RUN apt-get update && apt-get install -y \
# Install Python packages from PyPI
RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.0.0a2
# For sanity test
RUN pip install simplejson mako
##################
# PHP dependencies

@ -41,6 +41,12 @@ if [ "$platform" == "linux" ]
then
echo "building $language on Linux"
# Use image name based on Dockerfile checksum
DOCKER_IMAGE_NAME=grpc_jenkins_slave_`sha1sum tools/jenkins/grpc_jenkins_slave/Dockerfile | cut -f1 -d\ `
# Make sure docker image has been built. Should be instantaneous if so.
docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_jenkins_slave
if [ "$ghprbPullId" != "" ]
then
# if we are building a pull request, grab corresponding refs.
@ -51,12 +57,11 @@ then
rm -f docker.cid
# Run tests inside docker
docker run --cidfile=docker.cid grpc/grpc_jenkins_slave bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \
docker run --cidfile=docker.cid $DOCKER_IMAGE_NAME bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \
&& cd /var/local/git/grpc \
$FETCH_PULL_REQUEST_CMD \
&& git checkout -f $GIT_COMMIT \
&& git submodule update \
&& pip install simplejson mako \
&& nvm use 0.12 \
&& rvm use ruby-2.1 \
&& CONFIG=$config tools/run_tests/prepare_travis.sh \
@ -69,7 +74,7 @@ then
docker rm $DOCKER_CID
else
echo "Docker exited with failure, keeping container $DOCKER_CID."
echo "You can SSH to the worker and use 'docker start CID' and 'docker exec -i -t CID bash' to debug the problem."
echo "You can SSH to the worker and use 'docker commit CID YOUR_IMAGE_NAME' and 'docker run -i -t YOUR_IMAGE_NAME bash' to debug the problem."
exit 1
fi

Loading…
Cancel
Save