Merge branch 'master' into genericstub

pull/1144/head
Yang Gao 10 years ago
commit d1b9e64b2d
  1. 3
      include/grpc++/async_generic_service.h
  2. 3
      include/grpc++/async_unary_call.h
  3. 4
      include/grpc++/byte_buffer.h
  4. 8
      include/grpc++/client_context.h
  5. 5
      include/grpc++/completion_queue.h
  6. 7
      include/grpc++/config.h
  7. 2
      include/grpc/support/atm.h
  8. 2
      include/grpc/support/atm_win32.h
  9. 14
      include/grpc/support/port_platform.h
  10. 5
      src/cpp/client/create_channel.cc
  11. 4
      src/cpp/proto/proto_utils.cc
  12. 1
      src/cpp/server/async_generic_service.cc
  13. 3
      src/cpp/server/insecure_server_credentials.cc
  14. 6
      src/cpp/server/secure_server_credentials.cc
  15. 5
      src/cpp/server/server.cc
  16. 3
      src/cpp/server/server_builder.cc
  17. 4
      src/cpp/util/slice.cc
  18. 14
      src/node/ext/call.cc
  19. 2
      src/node/package.json
  20. 4
      src/node/test/call_test.js
  21. 16
      src/node/test/end_to_end_test.js
  22. 2
      test/core/transport/metadata_test.c
  23. 16
      test/cpp/end2end/async_end2end_test.cc
  24. 5
      test/cpp/end2end/generic_end2end_test.cc
  25. 26
      test/cpp/interop/client.cc
  26. 3
      test/cpp/util/create_test_channel.cc
  27. 76
      tools/dockerfile/grpc_dist_proto/Dockerfile
  28. 1
      tools/dockerfile/grpc_dist_proto/version.txt
  29. 2
      tools/gce_setup/cloud_prod_runner.sh
  30. 85
      tools/gce_setup/grpc_docker.sh

@ -41,7 +41,8 @@ struct grpc_server;
namespace grpc { namespace grpc {
typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer> GenericServerAsyncReaderWriter; typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericServerAsyncReaderWriter;
class GenericServerContext GRPC_FINAL : public ServerContext { class GenericServerContext GRPC_FINAL : public ServerContext {
public: public:

@ -50,8 +50,7 @@ class ClientAsyncResponseReader GRPC_FINAL {
ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq,
const RpcMethod& method, ClientContext* context, const RpcMethod& method, ClientContext* context,
const grpc::protobuf::Message& request, void* tag) const grpc::protobuf::Message& request, void* tag)
: context_(context), : context_(context), call_(channel->CreateCall(method, context, cq)) {
call_(channel->CreateCall(method, context, cq)) {
init_buf_.Reset(tag); init_buf_.Reset(tag);
init_buf_.AddSendInitialMetadata(&context->send_initial_metadata_); init_buf_.AddSendInitialMetadata(&context->send_initial_metadata_);
init_buf_.AddSendMessage(request); init_buf_.AddSendMessage(request);

@ -72,9 +72,7 @@ class ByteBuffer GRPC_FINAL {
buffer_ = buf; buffer_ = buf;
} }
grpc_byte_buffer* buffer() const { grpc_byte_buffer* buffer() const { return buffer_; }
return buffer_;
}
grpc_byte_buffer* buffer_; grpc_byte_buffer* buffer_;
}; };

@ -90,9 +90,7 @@ class ClientContext {
void set_absolute_deadline(const system_clock::time_point& deadline); void set_absolute_deadline(const system_clock::time_point& deadline);
system_clock::time_point absolute_deadline(); system_clock::time_point absolute_deadline();
void set_authority(const grpc::string& authority) { void set_authority(const grpc::string& authority) { authority_ = authority; }
authority_ = authority;
}
void TryCancel(); void TryCancel();
@ -129,9 +127,7 @@ class ClientContext {
gpr_timespec RawDeadline() { return absolute_deadline_; } gpr_timespec RawDeadline() { return absolute_deadline_; }
grpc::string authority() { grpc::string authority() { return authority_; }
return authority_;
}
bool initial_metadata_received_; bool initial_metadata_received_;
grpc_call* call_; grpc_call* call_;

@ -86,9 +86,10 @@ class CompletionQueue {
// Blocking (until deadline) read from queue. // Blocking (until deadline) read from queue.
// Returns false if the queue is ready for destruction, true if event // Returns false if the queue is ready for destruction, true if event
bool Next(void** tag, bool* ok) { bool Next(void** tag, bool* ok) {
return (AsyncNext(tag,ok, return (
std::chrono::system_clock::time_point::max()) != AsyncNext(tag, ok, (std::chrono::system_clock::time_point::max)()) !=
SHUTDOWN); SHUTDOWN);
} }

@ -59,11 +59,12 @@
#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM #ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ::google::protobuf::io::ZeroCopyOutputStream #define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \
#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ::google::protobuf::io::ZeroCopyInputStream ::google::protobuf::io::ZeroCopyOutputStream
#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \
::google::protobuf::io::ZeroCopyInputStream
#endif #endif
namespace grpc { namespace grpc {
typedef GRPC_CUSTOM_STRING string; typedef GRPC_CUSTOM_STRING string;

@ -83,7 +83,7 @@
#include <grpc/support/atm_gcc_atomic.h> #include <grpc/support/atm_gcc_atomic.h>
#elif defined(GPR_GCC_SYNC) #elif defined(GPR_GCC_SYNC)
#include <grpc/support/atm_gcc_sync.h> #include <grpc/support/atm_gcc_sync.h>
#elif defined(GPR_WIN32) #elif defined(GPR_WIN32_ATOMIC)
#include <grpc/support/atm_win32.h> #include <grpc/support/atm_win32.h>
#else #else
#error could not determine platform for atm #error could not determine platform for atm

@ -51,7 +51,7 @@ static __inline gpr_atm gpr_atm_acq_load(const gpr_atm *p) {
static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) { static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) {
/* TODO(dklempner): Can we implement something better here? */ /* TODO(dklempner): Can we implement something better here? */
gpr_atm_acq_load(p); return gpr_atm_acq_load(p);
} }
static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) {

@ -43,11 +43,21 @@
#define GPR_ARCH_64 1 #define GPR_ARCH_64 1
#define GPR_GETPID_IN_PROCESS_H 1 #define GPR_GETPID_IN_PROCESS_H 1
#define GPR_WINSOCK_SOCKET 1 #define GPR_WINSOCK_SOCKET 1
#ifdef __GNUC__
#define GPR_GCC_ATOMIC 1
#else
#define GPR_WIN32_ATOMIC 1
#endif
#elif defined(_WIN32) || defined(WIN32) #elif defined(_WIN32) || defined(WIN32)
#define GPR_ARCH_32 1 #define GPR_ARCH_32 1
#define GPR_WIN32 1 #define GPR_WIN32 1
#define GPR_GETPID_IN_PROCESS_H 1 #define GPR_GETPID_IN_PROCESS_H 1
#define GPR_WINSOCK_SOCKET 1 #define GPR_WINSOCK_SOCKET 1
#ifdef __GNUC__
#define GPR_GCC_ATOMIC 1
#else
#define GPR_WIN32_ATOMIC 1
#endif
#elif defined(ANDROID) || defined(__ANDROID__) #elif defined(ANDROID) || defined(__ANDROID__)
#define GPR_ANDROID 1 #define GPR_ANDROID 1
#define GPR_ARCH_32 1 #define GPR_ARCH_32 1
@ -167,8 +177,8 @@
#endif #endif
/* Validate platform combinations */ /* Validate platform combinations */
#if defined(GPR_GCC_ATOMIC) + defined(GPR_GCC_SYNC) + defined(GPR_WIN32) != 1 #if defined(GPR_GCC_ATOMIC) + defined(GPR_GCC_SYNC) + defined(GPR_WIN32_ATOMIC) != 1
#error Must define exactly one of GPR_GCC_ATOMIC, GPR_GCC_SYNC, GPR_WIN32 #error Must define exactly one of GPR_GCC_ATOMIC, GPR_GCC_SYNC, GPR_WIN32_ATOMIC
#endif #endif
#if defined(GPR_ARCH_32) + defined(GPR_ARCH_64) != 1 #if defined(GPR_ARCH_32) + defined(GPR_ARCH_64) != 1

@ -43,7 +43,8 @@ class ChannelArguments;
std::shared_ptr<ChannelInterface> CreateChannel( std::shared_ptr<ChannelInterface> CreateChannel(
const grpc::string& target, const std::unique_ptr<Credentials>& creds, const grpc::string& target, const std::unique_ptr<Credentials>& creds,
const ChannelArguments& args) { const ChannelArguments& args) {
return creds ? creds->CreateChannel(target, args) : return creds ? creds->CreateChannel(target, args)
std::shared_ptr<ChannelInterface>(new Channel(target, grpc_lame_client_channel_create())); : std::shared_ptr<ChannelInterface>(
new Channel(target, grpc_lame_client_channel_create()));
} }
} // namespace grpc } // namespace grpc

@ -123,9 +123,7 @@ class GrpcBufferReader GRPC_FINAL
return true; return true;
} }
void BackUp(int count) GRPC_OVERRIDE { void BackUp(int count) GRPC_OVERRIDE { backup_count_ = count; }
backup_count_ = count;
}
bool Skip(int count) GRPC_OVERRIDE { bool Skip(int count) GRPC_OVERRIDE {
const void* data; const void* data;

@ -48,4 +48,3 @@ CompletionQueue* AsyncGenericService::completion_queue() {
} }
} // namespace grpc } // namespace grpc

@ -46,7 +46,8 @@ class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials {
} // namespace } // namespace
std::shared_ptr<ServerCredentials> InsecureServerCredentials() { std::shared_ptr<ServerCredentials> InsecureServerCredentials() {
return std::shared_ptr<ServerCredentials>(new InsecureServerCredentialsImpl()); return std::shared_ptr<ServerCredentials>(
new InsecureServerCredentialsImpl());
} }
} // namespace grpc } // namespace grpc

@ -40,7 +40,8 @@ namespace grpc {
namespace { namespace {
class SecureServerCredentials GRPC_FINAL : public ServerCredentials { class SecureServerCredentials GRPC_FINAL : public ServerCredentials {
public: public:
explicit SecureServerCredentials(grpc_server_credentials* creds) : creds_(creds) {} explicit SecureServerCredentials(grpc_server_credentials* creds)
: creds_(creds) {}
~SecureServerCredentials() GRPC_OVERRIDE { ~SecureServerCredentials() GRPC_OVERRIDE {
grpc_server_credentials_release(creds_); grpc_server_credentials_release(creds_);
} }
@ -65,7 +66,8 @@ std::shared_ptr<ServerCredentials> SslServerCredentials(
grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create( grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create(
options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(), options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
&pem_key_cert_pairs[0], pem_key_cert_pairs.size()); &pem_key_cert_pairs[0], pem_key_cert_pairs.size());
return std::shared_ptr<ServerCredentials>(new SecureServerCredentials(c_creds)); return std::shared_ptr<ServerCredentials>(
new SecureServerCredentials(c_creds));
} }
} // namespace grpc } // namespace grpc

@ -322,11 +322,10 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
payload_(nullptr) { payload_(nullptr) {
memset(&array_, 0, sizeof(array_)); memset(&array_, 0, sizeof(array_));
grpc_call_details_init(&call_details_); grpc_call_details_init(&call_details_);
grpc_server_request_call( grpc_server_request_call(server->server_, &call_, &call_details_, &array_,
server->server_, &call_, &call_details_, &array_, cq->cq(), this); cq->cq(), this);
} }
~AsyncRequest() { ~AsyncRequest() {
if (payload_) { if (payload_) {
grpc_byte_buffer_destroy(payload_); grpc_byte_buffer_destroy(payload_);

@ -56,7 +56,8 @@ void ServerBuilder::RegisterAsyncGenericService(AsyncGenericService* service) {
if (generic_service_) { if (generic_service_) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Adding multiple AsyncGenericService is unsupported for now. " "Adding multiple AsyncGenericService is unsupported for now. "
"Dropping the service %p", service); "Dropping the service %p",
service);
return; return;
} }
generic_service_ = service; generic_service_ = service;

@ -37,9 +37,7 @@ namespace grpc {
Slice::Slice() : slice_(gpr_empty_slice()) {} Slice::Slice() : slice_(gpr_empty_slice()) {}
Slice::~Slice() { Slice::~Slice() { gpr_slice_unref(slice_); }
gpr_slice_unref(slice_);
}
Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {} Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {}

@ -75,6 +75,9 @@ using v8::Value;
NanCallback *Call::constructor; NanCallback *Call::constructor;
Persistent<FunctionTemplate> Call::fun_tpl; Persistent<FunctionTemplate> Call::fun_tpl;
bool EndsWith(const char *str, const char *substr) {
return strcmp(str+strlen(str)-strlen(substr), substr) == 0;
}
bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array, bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array,
shared_ptr<Resources> resources) { shared_ptr<Resources> resources) {
@ -99,6 +102,8 @@ bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array,
Handle<Value> value = values->Get(j); Handle<Value> value = values->Get(j);
grpc_metadata *current = &array->metadata[array->count]; grpc_metadata *current = &array->metadata[array->count];
current->key = **utf8_key; current->key = **utf8_key;
// Only allow binary headers for "-bin" keys
if (EndsWith(current->key, "-bin")) {
if (::node::Buffer::HasInstance(value)) { if (::node::Buffer::HasInstance(value)) {
current->value = ::node::Buffer::Data(value); current->value = ::node::Buffer::Data(value);
current->value_length = ::node::Buffer::Length(value); current->value_length = ::node::Buffer::Length(value);
@ -106,7 +111,10 @@ bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array,
NanAssignPersistent(*handle, value); NanAssignPersistent(*handle, value);
resources->handles.push_back(unique_ptr<PersistentHolder>( resources->handles.push_back(unique_ptr<PersistentHolder>(
new PersistentHolder(handle))); new PersistentHolder(handle)));
} else if (value->IsString()) { continue;
}
}
if (value->IsString()) {
Handle<String> string_value = value->ToString(); Handle<String> string_value = value->ToString();
NanUtf8String *utf8_value = new NanUtf8String(string_value); NanUtf8String *utf8_value = new NanUtf8String(string_value);
resources->strings.push_back(unique_ptr<NanUtf8String>(utf8_value)); resources->strings.push_back(unique_ptr<NanUtf8String>(utf8_value));
@ -146,9 +154,13 @@ Handle<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
array = NanNew<Array>(size_map[elem->key]); array = NanNew<Array>(size_map[elem->key]);
metadata_object->Set(key_string, array); metadata_object->Set(key_string, array);
} }
if (EndsWith(elem->key, "-bin")) {
array->Set(index_map[elem->key], array->Set(index_map[elem->key],
MakeFastBuffer( MakeFastBuffer(
NanNewBufferHandle(elem->value, elem->value_length))); NanNewBufferHandle(elem->value, elem->value_length)));
} else {
array->Set(index_map[elem->key], NanNew(elem->value));
}
index_map[elem->key] += 1; index_map[elem->key] += 1;
} }
return NanEscapeScope(metadata_object); return NanEscapeScope(metadata_object);

@ -1,6 +1,6 @@
{ {
"name": "grpc", "name": "grpc",
"version": "0.5.5", "version": "0.6.0",
"author": "Google Inc.", "author": "Google Inc.",
"description": "gRPC Library for Node", "description": "gRPC Library for Node",
"homepage": "http://www.grpc.io/", "homepage": "http://www.grpc.io/",

@ -142,8 +142,8 @@ describe('call', function() {
assert.doesNotThrow(function() { assert.doesNotThrow(function() {
var batch = {}; var batch = {};
batch[grpc.opType.SEND_INITIAL_METADATA] = { batch[grpc.opType.SEND_INITIAL_METADATA] = {
'key1': [new Buffer('value1')], 'key1-bin': [new Buffer('value1')],
'key2': [new Buffer('value2')] 'key2-bin': [new Buffer('value2')]
}; };
call.startBatch(batch, function(err, resp) { call.startBatch(batch, function(err, resp) {
assert.ifError(err); assert.ifError(err);

@ -138,21 +138,21 @@ describe('end-to-end', function() {
client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true; client_batch[grpc.opType.RECV_STATUS_ON_CLIENT] = true;
call.startBatch(client_batch, function(err, response) { call.startBatch(client_batch, function(err, response) {
assert.ifError(err); assert.ifError(err);
assert(response['send metadata']); assert.deepEqual(response,{
assert(response['client close']); 'send metadata': true,
assert(response.hasOwnProperty('metadata')); 'client close': true,
assert.strictEqual(response.metadata.server_key[0].toString(), metadata: {server_key: ['server_value']},
'server_value'); status: {'code': grpc.status.OK,
assert.deepEqual(response.status, {'code': grpc.status.OK,
'details': status_text, 'details': status_text,
'metadata': {}}); 'metadata': {}}
});
done(); done();
}); });
server.requestCall(function(err, call_details) { server.requestCall(function(err, call_details) {
var new_call = call_details['new call']; var new_call = call_details['new call'];
assert.notEqual(new_call, null); assert.notEqual(new_call, null);
assert.strictEqual(new_call.metadata.client_key[0].toString(), assert.strictEqual(new_call.metadata.client_key[0],
'client_value'); 'client_value');
var server_call = new_call.call; var server_call = new_call.call;
assert.notEqual(server_call, null); assert.notEqual(server_call, null);

@ -178,7 +178,7 @@ static void test_things_stick_around(void) {
grpc_mdctx *ctx; grpc_mdctx *ctx;
int i, j; int i, j;
char *buffer; char *buffer;
int nstrs = 10000; int nstrs = 1000;
grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs); grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs);
int *shuf = gpr_malloc(sizeof(int) * nstrs); int *shuf = gpr_malloc(sizeof(int) * nstrs);
grpc_mdstr *test; grpc_mdstr *test;

@ -76,11 +76,11 @@ void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
EXPECT_EQ(tag(i), got_tag); EXPECT_EQ(tag(i), got_tag);
} }
void verify_timed_ok(CompletionQueue* cq, int i, bool expect_ok, void verify_timed_ok(
CompletionQueue* cq, int i, bool expect_ok,
std::chrono::system_clock::time_point deadline = std::chrono::system_clock::time_point deadline =
std::chrono::system_clock::time_point::max(), std::chrono::system_clock::time_point::max(),
CompletionQueue::NextStatus expected_outcome = CompletionQueue::NextStatus expected_outcome = CompletionQueue::GOT_EVENT) {
CompletionQueue::GOT_EVENT) {
bool ok; bool ok;
void* got_tag; void* got_tag;
EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome); EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), expected_outcome);
@ -195,12 +195,11 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) {
grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx);
send_request.set_message("Hello"); send_request.set_message("Hello");
std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > std::unique_ptr<ClientAsyncResponseReader<EchoResponse> > response_reader(
response_reader(stub_->AsyncEcho(&cli_ctx, send_request, stub_->AsyncEcho(&cli_ctx, send_request, &cli_cq_, tag(1)));
&cli_cq_, tag(1)));
std::chrono::system_clock::time_point std::chrono::system_clock::time_point time_now(
time_now(std::chrono::system_clock::now()), std::chrono::system_clock::now()),
time_limit(std::chrono::system_clock::now() + std::chrono::seconds(5)); time_limit(std::chrono::system_clock::now() + std::chrono::seconds(5));
verify_timed_ok(&srv_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); verify_timed_ok(&srv_cq_, -1, true, time_now, CompletionQueue::TIMEOUT);
verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT); verify_timed_ok(&cli_cq_, -1, true, time_now, CompletionQueue::TIMEOUT);
@ -221,7 +220,6 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) {
EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_EQ(send_response.message(), recv_response.message());
EXPECT_TRUE(recv_status.IsOk()); EXPECT_TRUE(recv_status.IsOk());
} }
// Two pings and a final pong. // Two pings and a final pong.

@ -116,8 +116,8 @@ class GenericEnd2endTest : public ::testing::Test {
} }
void ResetStub() { void ResetStub() {
std::shared_ptr<ChannelInterface> channel = std::shared_ptr<ChannelInterface> channel = CreateChannel(
CreateChannel(server_address_.str(), InsecureCredentials(), ChannelArguments()); server_address_.str(), InsecureCredentials(), ChannelArguments());
stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel)); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel));
} }
@ -238,7 +238,6 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
client_ok(6); client_ok(6);
EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_EQ(send_response.message(), recv_response.message());
cli_stream->WritesDone(tag(7)); cli_stream->WritesDone(tag(7));
client_ok(7); client_ok(7);

@ -161,6 +161,15 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
} }
} }
void AssertOkOrPrintErrorStatus(const grpc::Status& s) {
if (s.IsOk()) {
return;
}
gpr_log(GPR_INFO, "Error status code: %d, message: %s", s.code(),
s.details().c_str());
GPR_ASSERT(0);
}
void DoEmpty() { void DoEmpty() {
gpr_log(GPR_INFO, "Sending an empty rpc..."); gpr_log(GPR_INFO, "Sending an empty rpc...");
std::shared_ptr<ChannelInterface> channel = std::shared_ptr<ChannelInterface> channel =
@ -172,8 +181,8 @@ void DoEmpty() {
ClientContext context; ClientContext context;
grpc::Status s = stub->EmptyCall(&context, request, &response); grpc::Status s = stub->EmptyCall(&context, request, &response);
AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(s.IsOk());
gpr_log(GPR_INFO, "Empty rpc done."); gpr_log(GPR_INFO, "Empty rpc done.");
} }
@ -190,7 +199,7 @@ void PerformLargeUnary(std::shared_ptr<ChannelInterface> channel,
grpc::Status s = stub->UnaryCall(&context, *request, response); grpc::Status s = stub->UnaryCall(&context, *request, response);
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(response->payload().type() == GPR_ASSERT(response->payload().type() ==
grpc::testing::PayloadType::COMPRESSABLE); grpc::testing::PayloadType::COMPRESSABLE);
GPR_ASSERT(response->payload().body() == GPR_ASSERT(response->payload().body() ==
@ -237,8 +246,7 @@ void DoServiceAccountCreds() {
} }
void DoJwtTokenCreds() { void DoJwtTokenCreds() {
gpr_log(GPR_INFO, gpr_log(GPR_INFO, "Sending a large unary rpc with JWT token credentials ...");
"Sending a large unary rpc with JWT token credentials ...");
std::shared_ptr<ChannelInterface> channel = std::shared_ptr<ChannelInterface> channel =
CreateChannelForTestCase("jwt_token_creds"); CreateChannelForTestCase("jwt_token_creds");
SimpleRequest request; SimpleRequest request;
@ -285,7 +293,7 @@ void DoRequestStreaming() {
grpc::Status s = stream->Finish(); grpc::Status s = stream->Finish();
GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size); GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size);
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Request streaming done."); gpr_log(GPR_INFO, "Request streaming done.");
} }
@ -314,7 +322,7 @@ void DoResponseStreaming() {
GPR_ASSERT(response_stream_sizes.size() == i); GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish(); grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done."); gpr_log(GPR_INFO, "Response streaming done.");
} }
@ -346,7 +354,7 @@ void DoResponseStreamingWithSlowConsumer() {
GPR_ASSERT(kNumResponseMessages == i); GPR_ASSERT(kNumResponseMessages == i);
grpc::Status s = stream->Finish(); grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done."); gpr_log(GPR_INFO, "Response streaming done.");
} }
@ -379,7 +387,7 @@ void DoHalfDuplex() {
} }
GPR_ASSERT(response_stream_sizes.size() == i); GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish(); grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Half-duplex streaming rpc done."); gpr_log(GPR_INFO, "Half-duplex streaming rpc done.");
} }
@ -412,7 +420,7 @@ void DoPingPong() {
stream->WritesDone(); stream->WritesDone();
GPR_ASSERT(!stream->Read(&response)); GPR_ASSERT(!stream->Read(&response));
grpc::Status s = stream->Finish(); grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk()); AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Ping pong streaming done."); gpr_log(GPR_INFO, "Ping pong streaming done.");
} }

@ -72,8 +72,7 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& connect_to = const grpc::string& connect_to =
server.empty() ? override_hostname : server; server.empty() ? override_hostname : server;
if (creds.get()) { if (creds.get()) {
channel_creds = channel_creds = CompositeCredentials(creds, channel_creds);
CompositeCredentials(creds, channel_creds);
} }
return CreateChannel(connect_to, channel_creds, channel_args); return CreateChannel(connect_to, channel_creds, channel_args);
} else { } else {

@ -0,0 +1,76 @@
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Dockerfile to build protoc and plugins for inclusion in a release.
FROM grpc/base
# Add the file containing the gRPC version
ADD version.txt version.txt
# Install tools needed for building protoc.
RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev
# Get the protobuf source from GitHub.
RUN mkdir -p /var/local/git
RUN git clone https://github.com/google/protobuf.git /var/local/git/protobuf
# Build the protobuf library statically and install to /tmp/protoc_static.
WORKDIR /var/local/git/protobuf
RUN ./autogen.sh && \
./configure --disable-shared --prefix=/tmp/protoc_static \
LDFLAGS="-lgcc_eh -static-libgcc -static-libstdc++" && \
make -j12 && make check && make install
# Build the protobuf library dynamically and install to /usr/local.
WORKDIR /var/local/git/protobuf
RUN ./autogen.sh && \
./configure --prefix=/usr/local && \
make -j12 && make check && make install
# Build the grpc plugins.
RUN git clone https://github.com/google/grpc.git /var/local/git/grpc
WORKDIR /var/local/git/grpc
RUN LDFLAGS=-static make plugins
# Create an archive containing all the generated binaries.
RUN mkdir /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
RUN cp -v bins/opt/* /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
RUN cp -v /tmp/protoc_static/bin/protoc /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m)
RUN cd /tmp && \
tar -czf proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz proto-bins_$(cat /version.txt)_linux-$(uname -m)
# List the tar contents: provides a way to visually confirm that the contents
# are correct.
RUN echo 'proto-bins_$(cat /version.txt)_linux-tar-$(uname -m) contents:' && \
tar -ztf /tmp/proto-bins_$(cat /version.txt)_linux-$(uname -m).tar.gz

@ -36,7 +36,7 @@ echo $result_file_name
main() { main() {
source grpc_docker.sh source grpc_docker.sh
test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_begin cancel_after_first_response) test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_begin cancel_after_first_response)
auth_test_cases=(service_account_creds compute_engine_creds) auth_test_cases=(service_account_creds compute_engine_creds jwt_token_creds)
clients=(cxx java go ruby node csharp_mono) clients=(cxx java go ruby node csharp_mono)
for test_case in "${test_cases[@]}" for test_case in "${test_cases[@]}"
do do

@ -560,7 +560,7 @@ grpc_sync_scripts() {
_grpc_ensure_gcloud_ssh || return 1; _grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
local grpc_hosts grpc_gce_script_root local grpc_hosts grpc_gce_script_root
@ -600,7 +600,7 @@ grpc_sync_images() {
_grpc_ensure_gcloud_ssh || return 1; _grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
local grpc_hosts local grpc_hosts
@ -645,7 +645,7 @@ _grpc_show_servers_args() {
# Shows the grpc servers on the GCE instance <server_name> # Shows the grpc servers on the GCE instance <server_name>
grpc_show_servers() { grpc_show_servers() {
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# set by _grpc_show_servers # set by _grpc_show_servers
local host local host
@ -663,6 +663,58 @@ grpc_show_servers() {
gcloud compute $project_opt ssh $zone_opt $host --command "$cmd" gcloud compute $project_opt ssh $zone_opt $host --command "$cmd"
} }
_grpc_build_proto_bins_args() {
[[ -n $1 ]] && { # host
host=$1
shift
} || {
host='grpc-docker-builder'
}
}
# grpc_build_proto_bins
#
# - rebuilds the dist_proto docker image
# * doing this builds the protoc and the ruby, python and cpp bins statically
#
# - runs a docker command that copies the built protos to the GCE host
# - copies the built protos to the local machine
grpc_build_proto_bins() {
_grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment
# where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# set by _grpc_build_proto_bins_args
local host
# set the project zone and check that all necessary args are provided
_grpc_set_project_and_zone -f _grpc_build_proto_bins_args "$@" || return 1
gce_has_instance $grpc_project $host || return 1;
local project_opt="--project $grpc_project"
local zone_opt="--zone $grpc_zone"
# rebuild the dist_proto image
local label='dist_proto'
grpc_update_image -- -h $host $label || return 1
# run a command to copy the generated archive to the docker host
local docker_prefix='sudo docker run -v /tmp:/tmp/proto_bins_out'
local tar_name='proto-bins*.tar.gz'
local cp_cmd="/bin/bash -c 'cp -v /tmp/$tar_name /tmp/proto_bins_out'"
local cmd="$docker_prefix grpc/$label $cp_cmd"
local ssh_cmd="bash -l -c \"$cmd\""
echo "will run:"
echo " $ssh_cmd"
echo "on $host"
gcloud compute $project_opt ssh $zone_opt $host --command "$cmd" || return 1
# copy the tar.gz locally
local rmt_tar="$host:/tmp/$tar_name"
local local_copy="$(pwd)"
gcloud compute copy-files $rmt_tar $local_copy $project_opt $zone_opt || return 1
}
_grpc_launch_servers_args() { _grpc_launch_servers_args() {
[[ -n $1 ]] && { # host [[ -n $1 ]] && { # host
host=$1 host=$1
@ -690,7 +742,7 @@ _grpc_launch_servers_args() {
# If no servers are specified, it launches all known servers # If no servers are specified, it launches all known servers
grpc_launch_servers() { grpc_launch_servers() {
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# set by _grpc_launch_servers_args # set by _grpc_launch_servers_args
local host servers local host servers
@ -811,7 +863,7 @@ test_runner() {
grpc_interop_test() { grpc_interop_test() {
_grpc_ensure_gcloud_ssh || return 1; _grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# grpc_interop_test_args # grpc_interop_test_args
@ -853,7 +905,7 @@ grpc_interop_test() {
grpc_cloud_prod_test() { grpc_cloud_prod_test() {
_grpc_ensure_gcloud_ssh || return 1; _grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# grpc_cloud_prod_test_args # grpc_cloud_prod_test_args
@ -892,7 +944,7 @@ grpc_cloud_prod_test() {
grpc_cloud_prod_auth_test() { grpc_cloud_prod_auth_test() {
_grpc_ensure_gcloud_ssh || return 1; _grpc_ensure_gcloud_ssh || return 1;
# declare vars local so that they don't pollute the shell environment # declare vars local so that they don't pollute the shell environment
# where they this func is used. # where this func is used.
local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone local grpc_zone grpc_project dry_run # set by _grpc_set_project_and_zone
# grpc_cloud_prod_test_args # grpc_cloud_prod_test_args
@ -1192,6 +1244,20 @@ grpc_cloud_prod_auth_compute_engine_creds_gen_cxx_cmd() {
echo $the_cmd echo $the_cmd
} }
# constructs the full dockerized cpp jwt_token auth interop test cmd.
#
# call-seq:
# flags= .... # generic flags to include the command
# cmd=$($grpc_gen_test_cmd $flags)
grpc_cloud_prod_auth_jwt_token_creds_gen_cxx_cmd() {
local cmd_prefix="sudo docker run grpc/cxx";
local test_script="/var/local/git/grpc/bins/opt/interop_client --enable_ssl --use_prod_roots";
local gfe_flags=$(_grpc_prod_gfe_flags)
local added_gfe_flags=$(_grpc_jwt_token_test_flags)
local the_cmd="$cmd_prefix $test_script $gfe_flags $added_gfe_flags $@";
echo $the_cmd
}
# constructs the full dockerized csharp-mono interop test cmd. # constructs the full dockerized csharp-mono interop test cmd.
# #
# call-seq: # call-seq:
@ -1230,6 +1296,11 @@ _grpc_svc_acc_test_flags() {
echo " --service_account_key_file=/service_account/stubbyCloudTestingTest-7dd63462c60c.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" echo " --service_account_key_file=/service_account/stubbyCloudTestingTest-7dd63462c60c.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo"
} }
# outputs the flags passed to the service account auth tests
_grpc_jwt_token_test_flags() {
echo " --service_account_key_file=/service_account/stubbyCloudTestingTest-7dd63462c60c.json"
}
# default credentials test flag # default credentials test flag
_grpc_default_creds_test_flags() { _grpc_default_creds_test_flags() {
echo " --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" echo " --oauth_scope=https://www.googleapis.com/auth/xapi.zoo"

Loading…
Cancel
Save