Merge remote-tracking branch 'upstream/master' into cancel

pull/2789/head
yang-g 9 years ago
commit 5239ee2bd0
  1. 38
      Makefile
  2. 5
      src/core/iomgr/sockaddr_utils.c
  3. 4
      src/core/surface/channel.c
  4. 12
      src/cpp/client/channel.cc
  5. 5
      src/cpp/client/channel.h
  6. 4
      src/cpp/client/create_channel.cc
  7. 2
      src/cpp/client/insecure_credentials.cc
  8. 3
      src/cpp/client/secure_credentials.cc
  9. 12
      src/python/grpcio_test/grpc_test/_links/_transmission_test.py
  10. 71
      src/python/grpcio_test/grpc_test/test_common.py
  11. 8
      templates/Makefile.template
  12. 14
      test/core/iomgr/sockaddr_utils_test.c
  13. 9
      test/cpp/end2end/generic_end2end_test.cc
  14. 2
      third_party/openssl
  15. 18
      tools/README.md
  16. 6
      tools/run_tests/jobset.py
  17. 2
      tools/run_tests/run_sanity.sh

@ -18680,6 +18680,8 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
examples/pubsub/publisher.cc: $(OPENSSL_DEP)
examples/pubsub/subscriber.cc: $(OPENSSL_DEP)
src/core/httpcli/format_request.c: $(OPENSSL_DEP)
src/core/httpcli/httpcli.c: $(OPENSSL_DEP)
src/core/httpcli/httpcli_security_connector.c: $(OPENSSL_DEP)
@ -18704,6 +18706,42 @@ src/core/surface/secure_channel_create.c: $(OPENSSL_DEP)
src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/transport_security.c: $(OPENSSL_DEP)
src/cpp/client/secure_channel_arguments.cc: $(OPENSSL_DEP)
src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP)
src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP)
src/cpp/common/secure_auth_context.cc: $(OPENSSL_DEP)
src/cpp/common/secure_create_auth_context.cc: $(OPENSSL_DEP)
src/cpp/server/secure_server_credentials.cc: $(OPENSSL_DEP)
src/csharp/ext/grpc_csharp_ext.c: $(OPENSSL_DEP)
test/core/bad_client/bad_client.c: $(OPENSSL_DEP)
test/core/end2end/data/server1_cert.c: $(OPENSSL_DEP)
test/core/end2end/data/server1_key.c: $(OPENSSL_DEP)
test/core/end2end/data/test_root_cert.c: $(OPENSSL_DEP)
test/core/end2end/fixtures/chttp2_fake_security.c: $(OPENSSL_DEP)
test/core/end2end/fixtures/chttp2_simple_ssl_fullstack.c: $(OPENSSL_DEP)
test/core/end2end/fixtures/chttp2_simple_ssl_fullstack_with_poll.c: $(OPENSSL_DEP)
test/core/end2end/fixtures/chttp2_simple_ssl_with_oauth2_fullstack.c: $(OPENSSL_DEP)
test/core/end2end/tests/request_response_with_payload_and_call_creds.c: $(OPENSSL_DEP)
test/cpp/interop/client.cc: $(OPENSSL_DEP)
test/cpp/interop/client_helper.cc: $(OPENSSL_DEP)
test/cpp/interop/interop_client.cc: $(OPENSSL_DEP)
test/cpp/interop/server.cc: $(OPENSSL_DEP)
test/cpp/interop/server_helper.cc: $(OPENSSL_DEP)
test/cpp/qps/client_async.cc: $(OPENSSL_DEP)
test/cpp/qps/client_sync.cc: $(OPENSSL_DEP)
test/cpp/qps/driver.cc: $(OPENSSL_DEP)
test/cpp/qps/perf_db_client.cc: $(OPENSSL_DEP)
test/cpp/qps/qps_worker.cc: $(OPENSSL_DEP)
test/cpp/qps/report.cc: $(OPENSSL_DEP)
test/cpp/qps/server_async.cc: $(OPENSSL_DEP)
test/cpp/qps/server_sync.cc: $(OPENSSL_DEP)
test/cpp/qps/timer.cc: $(OPENSSL_DEP)
test/cpp/util/benchmark_config.cc: $(OPENSSL_DEP)
test/cpp/util/cli_call.cc: $(OPENSSL_DEP)
test/cpp/util/create_test_channel.cc: $(OPENSSL_DEP)
test/cpp/util/fake_credentials.cc: $(OPENSSL_DEP)
test/cpp/util/subprocess.cc: $(OPENSSL_DEP)
test/cpp/util/test_config.cc: $(OPENSSL_DEP)
endif
.PHONY: all strip tools dep_error openssl_dep_error openssl_dep_message git_update stop buildtests buildtests_c buildtests_cxx test test_c test_cxx install install_c install_cxx install-headers install-headers_c install-headers_cxx install-shared install-shared_c install-shared_cxx install-static install-static_c install-static_cxx strip strip-shared strip-static strip_c strip-shared_c strip-static_c strip_cxx strip-shared_cxx strip-static_cxx dep_c dep_cxx bins_dep_c bins_dep_cxx clean

@ -170,6 +170,11 @@ int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
char *grpc_sockaddr_to_uri(const struct sockaddr *addr) {
char *temp;
char *result;
struct sockaddr_in addr_normalized;
if (grpc_sockaddr_is_v4mapped(addr, &addr_normalized)) {
addr = (const struct sockaddr *)&addr_normalized;
}
switch (addr->sa_family) {
case AF_INET:

@ -229,7 +229,9 @@ static void destroy_channel(void *p, int ok) {
registered_call *rc = channel->registered_calls;
channel->registered_calls = rc->next;
GRPC_MDELEM_UNREF(rc->path);
GRPC_MDELEM_UNREF(rc->authority);
if (rc->authority) {
GRPC_MDELEM_UNREF(rc->authority);
}
gpr_free(rc);
}
grpc_mdctx_unref(channel->metadata_context);

@ -51,13 +51,16 @@
namespace grpc {
Channel::Channel(const grpc::string& target, grpc_channel* channel)
: target_(target), c_channel_(channel) {}
Channel::Channel(grpc_channel* channel) : c_channel_(channel) {}
Channel::Channel(const grpc::string& host, grpc_channel* channel)
: host_(host), c_channel_(channel) {}
Channel::~Channel() { grpc_channel_destroy(c_channel_); }
Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
CompletionQueue* cq) {
const char* host_str = host_.empty() ? NULL : host_.c_str();
auto c_call =
method.channel_tag() && context->authority().empty()
? grpc_channel_create_registered_call(c_channel_, cq->cq(),
@ -65,7 +68,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
context->raw_deadline())
: grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
context->authority().empty()
? target_.c_str()
? host_str
: context->authority().c_str(),
context->raw_deadline());
grpc_census_call_set_context(c_call, context->census_context());
@ -86,7 +89,8 @@ void Channel::PerformOpsOnCall(CallOpSetInterface* ops, Call* call) {
}
void* Channel::RegisterMethod(const char* method) {
return grpc_channel_register_call(c_channel_, method, target_.c_str());
return grpc_channel_register_call(c_channel_, method,
host_.empty() ? NULL : host_.c_str());
}
} // namespace grpc

@ -52,7 +52,8 @@ class StreamContextInterface;
class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface {
public:
Channel(const grpc::string& target, grpc_channel* c_channel);
explicit Channel(grpc_channel* c_channel);
Channel(const grpc::string& host, grpc_channel* c_channel);
~Channel() GRPC_OVERRIDE;
virtual void* RegisterMethod(const char* method) GRPC_OVERRIDE;
@ -62,7 +63,7 @@ class Channel GRPC_FINAL : public GrpcLibrary, public ChannelInterface {
Call* call) GRPC_OVERRIDE;
private:
const grpc::string target_;
const grpc::string host_;
grpc_channel* const c_channel_; // owned
};

@ -51,7 +51,7 @@ std::shared_ptr<ChannelInterface> CreateChannel(
cp_args.SetString(GRPC_ARG_PRIMARY_USER_AGENT_STRING,
user_agent_prefix.str());
return creds ? creds->CreateChannel(target, cp_args)
: std::shared_ptr<ChannelInterface>(new Channel(
target, grpc_lame_client_channel_create(NULL)));
: std::shared_ptr<ChannelInterface>(
new Channel(grpc_lame_client_channel_create(NULL)));
}
} // namespace grpc

@ -49,7 +49,7 @@ class InsecureCredentialsImpl GRPC_FINAL : public Credentials {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return std::shared_ptr<ChannelInterface>(new Channel(
target, grpc_insecure_channel_create(target.c_str(), &channel_args)));
grpc_insecure_channel_create(target.c_str(), &channel_args)));
}
// InsecureCredentials should not be applied to a call.

@ -44,8 +44,7 @@ std::shared_ptr<grpc::ChannelInterface> SecureCredentials::CreateChannel(
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return std::shared_ptr<ChannelInterface>(new Channel(
args.GetSslTargetNameOverride().empty() ? target
: args.GetSslTargetNameOverride(),
args.GetSslTargetNameOverride(),
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args)));
}

@ -35,6 +35,7 @@ from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
from grpc.framework.interfaces.links import links
from grpc_test import test_common
from grpc_test._links import _proto_scenarios
from grpc_test.framework.common import test_constants
from grpc_test.framework.interfaces.links import test_cases
@ -94,12 +95,11 @@ class TransmissionTest(test_cases.TransmissionTest, unittest.TestCase):
return _intermediary_low.Code.OK, 'An exuberant test "details" message!'
def assertMetadataTransmitted(self, original_metadata, transmitted_metadata):
# we need to filter out any additional metadata added in transmitted_metadata
# since implementations are allowed to add to what is sent (in any position)
keys, _ = zip(*original_metadata)
self.assertSequenceEqual(
original_metadata,
[x for x in transmitted_metadata if x[0] in keys])
self.assertTrue(
test_common.metadata_transmitted(
original_metadata, transmitted_metadata),
'%s erroneously transmitted as %s' % (
original_metadata, transmitted_metadata))
class RoundTripTest(unittest.TestCase):

@ -0,0 +1,71 @@
# 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.
"""Common code used throughout tests of gRPC."""
import collections
def metadata_transmitted(original_metadata, transmitted_metadata):
"""Judges whether or not metadata was acceptably transmitted.
gRPC is allowed to insert key-value pairs into the metadata values given by
applications and to reorder key-value pairs with different keys but it is not
allowed to alter existing key-value pairs or to reorder key-value pairs with
the same key.
Args:
original_metadata: A metadata value used in a test of gRPC.
transmitted_metadata: A metadata value corresponding to original_metadata
after having been transmitted via gRPC.
Returns:
A boolean indicating whether transmitted_metadata accurately reflects
original_metadata after having been transmitted via gRPC.
"""
original = collections.defaultdict(list)
for key, value in original_metadata:
original[key].append(value)
transmitted = collections.defaultdict(list)
for key, value in transmitted_metadata:
transmitted[key].append(value)
for key, values in original.iteritems():
transmitted_values = transmitted[key]
transmitted_iterator = iter(transmitted_values)
try:
for value in values:
while True:
transmitted_value = next(transmitted_iterator)
if value == transmitted_value:
break
except StopIteration:
return False
else:
return True

@ -1468,10 +1468,14 @@ endif
mingw_libs = mingw_libs + ' -l' + dep + '-imp'
mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
if lib.get('secure', 'check') == 'yes':
security = lib.get('secure', 'check')
if security == 'yes':
common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
if security in ['yes', 'check']:
for src in lib.src:
sources_that_need_openssl.add(src)
if not proto_re.match(src):
sources_that_need_openssl.add(src)
else:
for src in lib.src:
sources_that_don_t_need_openssl.add(src)

@ -187,6 +187,15 @@ static void expect_sockaddr_str(const char *expected, void *addr,
gpr_free(str);
}
static void expect_sockaddr_uri(const char *expected, void *addr) {
char *str;
gpr_log(GPR_INFO, " expect_sockaddr_uri(%s)", expected);
str = grpc_sockaddr_to_uri((struct sockaddr *)addr);
GPR_ASSERT(str != NULL);
GPR_ASSERT(strcmp(expected, str) == 0);
gpr_free(str);
}
static void test_sockaddr_to_string(void) {
struct sockaddr_in input4;
struct sockaddr_in6 input6;
@ -199,23 +208,28 @@ static void test_sockaddr_to_string(void) {
input4 = make_addr4(kIPv4, sizeof(kIPv4));
expect_sockaddr_str("192.0.2.1:12345", &input4, 0);
expect_sockaddr_str("192.0.2.1:12345", &input4, 1);
expect_sockaddr_uri("ipv4:192.0.2.1:12345", &input4);
input6 = make_addr6(kIPv6, sizeof(kIPv6));
expect_sockaddr_str("[2001:db8::1]:12345", &input6, 0);
expect_sockaddr_str("[2001:db8::1]:12345", &input6, 1);
expect_sockaddr_uri("ipv6:[2001:db8::1]:12345", &input6);
input6 = make_addr6(kMapped, sizeof(kMapped));
expect_sockaddr_str("[::ffff:192.0.2.1]:12345", &input6, 0);
expect_sockaddr_str("192.0.2.1:12345", &input6, 1);
expect_sockaddr_uri("ipv4:192.0.2.1:12345", &input6);
input6 = make_addr6(kNotQuiteMapped, sizeof(kNotQuiteMapped));
expect_sockaddr_str("[::fffe:c000:263]:12345", &input6, 0);
expect_sockaddr_str("[::fffe:c000:263]:12345", &input6, 1);
expect_sockaddr_uri("ipv6:[::fffe:c000:263]:12345", &input6);
memset(&dummy, 0, sizeof(dummy));
dummy.sa_family = 123;
expect_sockaddr_str("(sockaddr family=123)", &dummy, 0);
expect_sockaddr_str("(sockaddr family=123)", &dummy, 1);
GPR_ASSERT(grpc_sockaddr_to_uri(&dummy) == NULL);
GPR_ASSERT(errno == 0x7EADBEEF);
}

@ -100,11 +100,11 @@ std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
class GenericEnd2endTest : public ::testing::Test {
protected:
GenericEnd2endTest() : generic_service_("*") {}
GenericEnd2endTest() : generic_service_("*"), server_host_("localhost") {}
void SetUp() GRPC_OVERRIDE {
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
server_address_ << server_host_ << ":" << port;
// Setup server
ServerBuilder builder;
builder.AddListeningPort(server_address_.str(), InsecureServerCredentials());
@ -165,7 +165,7 @@ class GenericEnd2endTest : public ::testing::Test {
srv_cq_.get(), tag(4));
verify_ok(srv_cq_.get(), 4, true);
EXPECT_EQ(server_address_.str(), srv_ctx.host());
EXPECT_EQ(server_host_, srv_ctx.host());
EXPECT_EQ(kMethodName, srv_ctx.method());
ByteBuffer recv_buffer;
stream.Read(&recv_buffer, tag(5));
@ -200,6 +200,7 @@ class GenericEnd2endTest : public ::testing::Test {
std::unique_ptr<grpc::GenericStub> generic_stub_;
std::unique_ptr<Server> server_;
AsyncGenericService generic_service_;
const grpc::string server_host_;
std::ostringstream server_address_;
};
@ -237,7 +238,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
srv_cq_.get(), tag(2));
verify_ok(srv_cq_.get(), 2, true);
EXPECT_EQ(server_address_.str(), srv_ctx.host());
EXPECT_EQ(server_host_, srv_ctx.host());
EXPECT_EQ(kMethodName, srv_ctx.method());
std::unique_ptr<ByteBuffer> send_buffer =

@ -1 +1 @@
Subproject commit 3df69d3aefde7671053d4e3c242b228e5d79c83f
Subproject commit 33dd08320648ac71d7d9d732be774ed3818dccc5

@ -1,11 +1,17 @@
buildgen: contains the template renderer for our build system.
buildgen: template renderer for our build system.
distpackages: contains script to generate debian packages.
distpackages: script to generate debian packages.
dockerfile: contains all of the docker files to test gRPC.
distrib: scripts to distribute language-specific packages.
gce_setup: contains boilerplate for running the docker files under GCE.
dockerfile: Docker files to test gRPC.
jenkins: support for running tests on Jenkins
doxygen: gRPC C/C++ documentation generation via Doxygen.
run_tests: contains python scripts to properly run the tests in parallel.
gce_setup: boilerplate to run the Docker files under GCE.
jenkins: support for running tests on Jenkins.
profile_analyzer: pretty printer for gRPC profiling data.
run_tests: scripts to run gRPC tests in parallel.

@ -130,7 +130,8 @@ def which(filename):
class JobSpec(object):
"""Specifies what to run for a job."""
def __init__(self, cmdline, shortname=None, environ=None, hash_targets=None, cwd=None, shell=False):
def __init__(self, cmdline, shortname=None, environ=None, hash_targets=None,
cwd=None, shell=False, timeout_seconds=900):
"""
Arguments:
cmdline: a list of arguments to pass as the command line
@ -148,6 +149,7 @@ class JobSpec(object):
self.hash_targets = hash_targets or []
self.cwd = cwd
self.shell = shell
self.timeout_seconds = timeout_seconds
def identity(self):
return '%r %r %r' % (self.cmdline, self.environ, self.hash_targets)
@ -206,7 +208,7 @@ class Job(object):
do_newline=self._newline_on_success or self._travis)
if self._bin_hash:
update_cache.finished(self._spec.identity(), self._bin_hash)
elif self._state == _RUNNING and time.time() - self._start > 900:
elif self._state == _RUNNING and time.time() - self._start > self._spec.timeout_seconds:
self._tempfile.seek(0)
stdout = self._tempfile.read()
filtered_stdout = filter(lambda x: x in string.printable, stdout.decode(errors='ignore'))

@ -44,7 +44,7 @@ git submodule > $submodules
diff -u $submodules - << EOF
05b155ff59114735ec8cd089f669c4c3d8f59029 third_party/gflags (v2.1.0-45-g05b155f)
3df69d3aefde7671053d4e3c242b228e5d79c83f third_party/openssl (OpenSSL_1_0_2a)
33dd08320648ac71d7d9d732be774ed3818dccc5 third_party/openssl (OpenSSL_1_0_2d)
3e2c8a5dd79481e1d36572cdf65be93514ba6581 third_party/protobuf (v3.0.0-alpha-1-1048-g3e2c8a5)
50893291621658f355bc5b4d450a8d06a563053d third_party/zlib (v1.2.8)
EOF

Loading…
Cancel
Save