From 95e8187c74e28e622aacf9a8e962977243f90bf8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 8 Feb 2016 15:48:55 -0800 Subject: [PATCH 01/32] Sanity check for version metadata --- tools/run_tests/sanity/check_version.py | 97 ++++++++++++++++++++++++ tools/run_tests/sanity/sanity_tests.yaml | 3 +- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100755 tools/run_tests/sanity/check_version.py diff --git a/tools/run_tests/sanity/check_version.py b/tools/run_tests/sanity/check_version.py new file mode 100755 index 00000000000..41dd5efe388 --- /dev/null +++ b/tools/run_tests/sanity/check_version.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python2.7 + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import sys +import yaml +import os +import re +import subprocess + +errors = 0 + +os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) + +# hack import paths to pick up extra code +sys.path.insert(0, os.path.abspath('tools/buildgen/plugins')) +from expand_version import Version + +try: + branch_name = subprocess.check_output( + 'git rev-parse --abbrev-ref HEAD', + shell=True) +except: + print 'WARNING: not a git repository' + branch_name = None + +if branch_name is not None: + m = re.match(r'^release-([0-9]+)_([0-9]+)$', branch_name) + if m: + print 'RELEASE branch' + # version number should align with the branched version + check_version = lambda version: ( + version.major == int(m.group(1)) and + version.minor == int(m.group(2))) + warning = 'Version key "%%s" value "%%s" should have a major version %s and minor version %s' % (m.group(1), m.group(2)) + elif re.match(r'^debian/.*$', branch_name): + # no additional version checks for debian branches + check_version = lambda version: True + else: + # all other branches should have a -dev tag + check_version = lambda version: version.tag == 'dev' + warning = 'Version key "%s" value "%s" should have a -dev tag' +else: + check_version = lambda version: True + +with open('build.yaml', 'r') as f: + build_yaml = yaml.load(f.read()) + +settings = build_yaml['settings'] + +top_version = Version(settings['version']) +if not check_version(top_version): + errors += 1 + print warning % ('version', top_version) + +for tag, value in settings.iteritems(): + if re.match(r'^[a-z]+_version$', tag): + value = Version(value) + if value.major != top_version.major: + errors += 1 + print 'major version mismatch on %s: %d vs %d' % (tag, value.major, top_version.major) + if value.minor != top_version.minor: + errors += 1 + print 'minor version mismatch on %s: %d vs %d' % (tag, value.minor, top_version.minor) + if not check_version(value): + errors += 1 + print warning % (tag, value) + +sys.exit(errors) + diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index 809e6ce6454..50864b5d879 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -1,7 +1,8 @@ # a set of tests that are run in parallel for sanity tests +- script: tools/run_tests/sanity/check_cache_mk.sh - script: tools/run_tests/sanity/check_sources_and_headers.py - script: tools/run_tests/sanity/check_submodules.sh -- script: tools/run_tests/sanity/check_cache_mk.sh +- script: tools/run_tests/sanity/check_version.py - script: tools/buildgen/generate_projects.sh -j 3 cpu_cost: 3 - script: tools/distrib/check_copyright.py From eb841e20108e0e54f99800f099c044f9f183a632 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 11 Feb 2016 15:49:16 -0800 Subject: [PATCH 02/32] Revert "Revert "Proto API for LB request/responses"" --- .gitmodules | 3 + BUILD | 33 +++ Makefile | 76 ++++++ binding.gyp | 5 + build.yaml | 27 +++ gRPC.podspec | 21 +- grpc.gemspec | 11 + package.json | 11 + .../lb_policies/load_balancer_api.c | 163 +++++++++++++ .../lb_policies/load_balancer_api.h | 85 +++++++ src/core/proto/grpc/lb/v0/load_balancer.pb.c | 150 ++++++++++++ src/core/proto/grpc/lb/v0/load_balancer.pb.h | 221 ++++++++++++++++++ src/proto/grpc/lb/v0/load_balancer.options | 6 + src/proto/grpc/lb/v0/load_balancer.proto | 144 ++++++++++++ src/python/grpcio/grpc_core_dependencies.py | 5 + .../sources_and_headers.json.template | 21 +- test/cpp/grpclb/grpclb_api_test.cc | 133 +++++++++++ third_party/nanopb | 1 + .../codegen/core/gen_load_balancing_proto.sh | 133 +++++++++++ tools/distrib/check_nanopb_output.sh | 86 +++++++ tools/doxygen/Doxyfile.core.internal | 11 + tools/jenkins/build_docker_and_run_tests.sh | 6 +- tools/run_tests/sanity/check_submodules.sh | 1 + tools/run_tests/sanity/sanity_tests.yaml | 1 + tools/run_tests/sources_and_headers.json | 41 +++- tools/run_tests/tests.json | 20 ++ vsprojects/vcxproj/grpc/grpc.vcxproj | 16 ++ vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 51 ++++ .../grpc_unsecure/grpc_unsecure.vcxproj | 16 ++ .../grpc_unsecure.vcxproj.filters | 51 ++++ .../grpclb_api_test/grpclb_api_test.vcxproj | 209 +++++++++++++++++ .../grpclb_api_test.vcxproj.filters | 39 ++++ 32 files changed, 1785 insertions(+), 12 deletions(-) create mode 100644 src/core/client_config/lb_policies/load_balancer_api.c create mode 100644 src/core/client_config/lb_policies/load_balancer_api.h create mode 100644 src/core/proto/grpc/lb/v0/load_balancer.pb.c create mode 100644 src/core/proto/grpc/lb/v0/load_balancer.pb.h create mode 100644 src/proto/grpc/lb/v0/load_balancer.options create mode 100644 src/proto/grpc/lb/v0/load_balancer.proto create mode 100644 test/cpp/grpclb/grpclb_api_test.cc create mode 160000 third_party/nanopb create mode 100755 tools/codegen/core/gen_load_balancing_proto.sh create mode 100755 tools/distrib/check_nanopb_output.sh create mode 100644 vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj create mode 100644 vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj.filters diff --git a/.gitmodules b/.gitmodules index 008bc5fae80..c37d0abdf0b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,3 +14,6 @@ [submodule "third_party/boringssl"] path = third_party/boringssl url = https://boringssl.googlesource.com/boringssl +[submodule "third_party/nanopb"] + path = third_party/nanopb + url = https://github.com/nanopb/nanopb.git diff --git a/BUILD b/BUILD index 72d5caa8d43..31e0f3aacc6 100644 --- a/BUILD +++ b/BUILD @@ -182,6 +182,7 @@ cc_library( "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -242,6 +243,7 @@ cc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -283,6 +285,10 @@ cc_library( "src/core/transport/transport_impl.h", "src/core/census/aggregation.h", "src/core/census/rpc_metric_id.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h", "src/core/httpcli/httpcli_security_connector.c", "src/core/security/base64.c", "src/core/security/client_auth_filter.c", @@ -319,6 +325,7 @@ cc_library( "src/core/client_config/connector.c", "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", + "src/core/client_config/lb_policies/load_balancer_api.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/round_robin.c", "src/core/client_config/lb_policy.c", @@ -382,6 +389,7 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", "src/core/surface/alarm.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", @@ -436,6 +444,9 @@ cc_library( "src/core/census/operation.c", "src/core/census/placeholders.c", "src/core/census/tracing.c", + "third_party/nanopb/pb_common.c", + "third_party/nanopb/pb_decode.c", + "third_party/nanopb/pb_encode.c", ], hdrs = [ "include/grpc/grpc_security.h", @@ -484,6 +495,7 @@ cc_library( "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -544,6 +556,7 @@ cc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -585,6 +598,10 @@ cc_library( "src/core/transport/transport_impl.h", "src/core/census/aggregation.h", "src/core/census/rpc_metric_id.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h", "src/core/surface/init_unsecure.c", "src/core/census/grpc_context.c", "src/core/census/grpc_filter.c", @@ -601,6 +618,7 @@ cc_library( "src/core/client_config/connector.c", "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", + "src/core/client_config/lb_policies/load_balancer_api.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/round_robin.c", "src/core/client_config/lb_policy.c", @@ -664,6 +682,7 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", "src/core/surface/alarm.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", @@ -718,6 +737,9 @@ cc_library( "src/core/census/operation.c", "src/core/census/placeholders.c", "src/core/census/tracing.c", + "third_party/nanopb/pb_common.c", + "third_party/nanopb/pb_decode.c", + "third_party/nanopb/pb_encode.c", ], hdrs = [ "include/grpc/byte_buffer.h", @@ -1281,6 +1303,7 @@ objc_library( "src/core/client_config/connector.c", "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", + "src/core/client_config/lb_policies/load_balancer_api.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/round_robin.c", "src/core/client_config/lb_policy.c", @@ -1344,6 +1367,7 @@ objc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", "src/core/surface/alarm.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", @@ -1398,6 +1422,9 @@ objc_library( "src/core/census/operation.c", "src/core/census/placeholders.c", "src/core/census/tracing.c", + "third_party/nanopb/pb_common.c", + "third_party/nanopb/pb_decode.c", + "third_party/nanopb/pb_encode.c", ], hdrs = [ "include/grpc/grpc_security.h", @@ -1441,6 +1468,7 @@ objc_library( "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -1501,6 +1529,7 @@ objc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -1542,6 +1571,10 @@ objc_library( "src/core/transport/transport_impl.h", "src/core/census/aggregation.h", "src/core/census/rpc_metric_id.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h", ], includes = [ "include", diff --git a/Makefile b/Makefile index 3c215b35b64..01bbb2cb3c4 100644 --- a/Makefile +++ b/Makefile @@ -940,6 +940,7 @@ grpc_csharp_plugin: $(BINDIR)/$(CONFIG)/grpc_csharp_plugin grpc_objective_c_plugin: $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin grpc_python_plugin: $(BINDIR)/$(CONFIG)/grpc_python_plugin grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin +grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test interop_client: $(BINDIR)/$(CONFIG)/interop_client interop_server: $(BINDIR)/$(CONFIG)/interop_server @@ -1283,6 +1284,7 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \ $(BINDIR)/$(CONFIG)/generic_async_streaming_ping_pong_test \ $(BINDIR)/$(CONFIG)/generic_end2end_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ + $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/hybrid_end2end_test \ $(BINDIR)/$(CONFIG)/interop_client \ $(BINDIR)/$(CONFIG)/interop_server \ @@ -1591,6 +1593,8 @@ test_cxx: test_zookeeper buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/generic_async_streaming_ping_pong_test || ( echo test generic_async_streaming_ping_pong_test failed ; exit 1 ) $(E) "[RUN] Testing generic_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/generic_end2end_test || ( echo test generic_end2end_test failed ; exit 1 ) + $(E) "[RUN] Testing grpclb_api_test" + $(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 ) $(E) "[RUN] Testing hybrid_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/hybrid_end2end_test || ( echo test hybrid_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing interop_test" @@ -1740,6 +1744,21 @@ $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(Q) mkdir -p $(@D) $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@ +ifeq ($(NO_PROTOC),true) +$(GENDIR)/src/proto/grpc/lb/v0/load_balancer.pb.cc: protoc_dep_error +$(GENDIR)/src/proto/grpc/lb/v0/load_balancer.grpc.pb.cc: protoc_dep_error +else +$(GENDIR)/src/proto/grpc/lb/v0/load_balancer.pb.cc: src/proto/grpc/lb/v0/load_balancer.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[PROTOC] Generating protobuf CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) --cpp_out=$(GENDIR) $< + +$(GENDIR)/src/proto/grpc/lb/v0/load_balancer.grpc.pb.cc: src/proto/grpc/lb/v0/load_balancer.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) + $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< +endif + ifeq ($(NO_PROTOC),true) $(GENDIR)/src/proto/grpc/testing/control.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc: protoc_dep_error @@ -2348,6 +2367,7 @@ LIBGRPC_SRC = \ src/core/client_config/connector.c \ src/core/client_config/default_initial_connect_string.c \ src/core/client_config/initial_connect_string.c \ + src/core/client_config/lb_policies/load_balancer_api.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policies/round_robin.c \ src/core/client_config/lb_policy.c \ @@ -2411,6 +2431,7 @@ LIBGRPC_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ + src/core/proto/grpc/lb/v0/load_balancer.pb.c \ src/core/surface/alarm.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ @@ -2465,6 +2486,9 @@ LIBGRPC_SRC = \ src/core/census/operation.c \ src/core/census/placeholders.c \ src/core/census/tracing.c \ + third_party/nanopb/pb_common.c \ + third_party/nanopb/pb_decode.c \ + third_party/nanopb/pb_encode.c \ PUBLIC_HEADERS_C += \ include/grpc/grpc_security.h \ @@ -2632,6 +2656,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/client_config/connector.c \ src/core/client_config/default_initial_connect_string.c \ src/core/client_config/initial_connect_string.c \ + src/core/client_config/lb_policies/load_balancer_api.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policies/round_robin.c \ src/core/client_config/lb_policy.c \ @@ -2695,6 +2720,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ + src/core/proto/grpc/lb/v0/load_balancer.pb.c \ src/core/surface/alarm.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ @@ -2749,6 +2775,9 @@ LIBGRPC_UNSECURE_SRC = \ src/core/census/operation.c \ src/core/census/placeholders.c \ src/core/census/tracing.c \ + third_party/nanopb/pb_common.c \ + third_party/nanopb/pb_decode.c \ + third_party/nanopb/pb_encode.c \ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer.h \ @@ -9670,6 +9699,53 @@ ifneq ($(NO_DEPS),true) endif +GRPCLB_API_TEST_SRC = \ + $(GENDIR)/src/proto/grpc/lb/v0/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v0/load_balancer.grpc.pb.cc \ + test/cpp/grpclb/grpclb_api_test.cc \ + +GRPCLB_API_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPCLB_API_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/grpclb_api_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/grpclb_api_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/grpclb_api_test: $(PROTOBUF_DEP) $(GRPCLB_API_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(GRPCLB_API_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpclb_api_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v0/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a + +$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_api_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a + +deps_grpclb_api_test: $(GRPCLB_API_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(GRPCLB_API_TEST_OBJS:.o=.dep) +endif +endif +$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_api_test.o: $(GENDIR)/src/proto/grpc/lb/v0/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v0/load_balancer.grpc.pb.cc + + HYBRID_END2END_TEST_SRC = \ test/cpp/end2end/hybrid_end2end_test.cc \ diff --git a/binding.gyp b/binding.gyp index 3659bfcf13e..f7a21e56cd2 100644 --- a/binding.gyp +++ b/binding.gyp @@ -591,6 +591,7 @@ 'src/core/client_config/connector.c', 'src/core/client_config/default_initial_connect_string.c', 'src/core/client_config/initial_connect_string.c', + 'src/core/client_config/lb_policies/load_balancer_api.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policies/round_robin.c', 'src/core/client_config/lb_policy.c', @@ -654,6 +655,7 @@ 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', + 'src/core/proto/grpc/lb/v0/load_balancer.pb.c', 'src/core/surface/alarm.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', @@ -708,6 +710,9 @@ 'src/core/census/operation.c', 'src/core/census/placeholders.c', 'src/core/census/tracing.c', + 'third_party/nanopb/pb_common.c', + 'third_party/nanopb/pb_decode.c', + 'third_party/nanopb/pb_encode.c', ], "conditions": [ ['OS == "mac"', { diff --git a/build.yaml b/build.yaml index 7f33ef3f0e5..ffa16675d82 100644 --- a/build.yaml +++ b/build.yaml @@ -258,6 +258,7 @@ filegroups: - src/core/client_config/client_config.h - src/core/client_config/connector.h - src/core/client_config/initial_connect_string.h + - src/core/client_config/lb_policies/load_balancer_api.h - src/core/client_config/lb_policies/pick_first.h - src/core/client_config/lb_policies/round_robin.h - src/core/client_config/lb_policy.h @@ -318,6 +319,7 @@ filegroups: - src/core/json/json_common.h - src/core/json/json_reader.h - src/core/json/json_writer.h + - src/core/proto/grpc/lb/v0/load_balancer.pb.h - src/core/statistics/census_interface.h - src/core/statistics/census_rpc_stats.h - src/core/surface/api_trace.h @@ -373,6 +375,7 @@ filegroups: - src/core/client_config/connector.c - src/core/client_config/default_initial_connect_string.c - src/core/client_config/initial_connect_string.c + - src/core/client_config/lb_policies/load_balancer_api.c - src/core/client_config/lb_policies/pick_first.c - src/core/client_config/lb_policies/round_robin.c - src/core/client_config/lb_policy.c @@ -436,6 +439,7 @@ filegroups: - src/core/json/json_reader.c - src/core/json/json_string.c - src/core/json/json_writer.c + - src/core/proto/grpc/lb/v0/load_balancer.pb.c - src/core/surface/alarm.c - src/core/surface/api_trace.c - src/core/surface/byte_buffer.c @@ -511,6 +515,16 @@ filegroups: - test/core/util/port_posix.c - test/core/util/port_windows.c - test/core/util/slice_splitter.c +- name: nanopb + headers: + - third_party/nanopb/pb.h + - third_party/nanopb/pb_common.h + - third_party/nanopb/pb_decode.h + - third_party/nanopb/pb_encode.h + src: + - third_party/nanopb/pb_common.c + - third_party/nanopb/pb_decode.c + - third_party/nanopb/pb_encode.c libs: - name: gpr build: all @@ -582,6 +596,7 @@ libs: - grpc_codegen - grpc_base - census + - nanopb secure: true vs_packages: - grpc.dependencies.openssl @@ -630,6 +645,7 @@ libs: - grpc_base - grpc_codegen - census + - nanopb secure: false vs_project_guid: '{46CEDFFF-9692-456A-AA24-38B5D6BCF4C5}' - name: grpc_zookeeper @@ -2174,6 +2190,17 @@ targets: secure: false vs_config_type: Application vs_project_guid: '{069E9D05-B78B-4751-9252-D21EBAE7DE8E}' +- name: grpclb_api_test + build: test + language: c++ + src: + - src/proto/grpc/lb/v0/load_balancer.proto + - test/cpp/grpclb/grpclb_api_test.cc + deps: + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc - name: hybrid_end2end_test build: test language: c++ diff --git a/gRPC.podspec b/gRPC.podspec index 5b4d24e4820..05e3802b77f 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -186,6 +186,7 @@ Pod::Spec.new do |s| 'src/core/client_config/client_config.h', 'src/core/client_config/connector.h', 'src/core/client_config/initial_connect_string.h', + 'src/core/client_config/lb_policies/load_balancer_api.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policies/round_robin.h', 'src/core/client_config/lb_policy.h', @@ -246,6 +247,7 @@ Pod::Spec.new do |s| 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', + 'src/core/proto/grpc/lb/v0/load_balancer.pb.h', 'src/core/statistics/census_interface.h', 'src/core/statistics/census_rpc_stats.h', 'src/core/surface/api_trace.h', @@ -287,6 +289,10 @@ Pod::Spec.new do |s| 'src/core/transport/transport_impl.h', 'src/core/census/aggregation.h', 'src/core/census/rpc_metric_id.h', + 'third_party/nanopb/pb.h', + 'third_party/nanopb/pb_common.h', + 'third_party/nanopb/pb_decode.h', + 'third_party/nanopb/pb_encode.h', 'include/grpc/grpc_security.h', 'include/grpc/impl/codegen/byte_buffer.h', 'include/grpc/impl/codegen/compression_types.h', @@ -336,6 +342,7 @@ Pod::Spec.new do |s| 'src/core/client_config/connector.c', 'src/core/client_config/default_initial_connect_string.c', 'src/core/client_config/initial_connect_string.c', + 'src/core/client_config/lb_policies/load_balancer_api.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policies/round_robin.c', 'src/core/client_config/lb_policy.c', @@ -399,6 +406,7 @@ Pod::Spec.new do |s| 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', + 'src/core/proto/grpc/lb/v0/load_balancer.pb.c', 'src/core/surface/alarm.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', @@ -452,7 +460,10 @@ Pod::Spec.new do |s| 'src/core/census/initialize.c', 'src/core/census/operation.c', 'src/core/census/placeholders.c', - 'src/core/census/tracing.c' + 'src/core/census/tracing.c', + 'third_party/nanopb/pb_common.c', + 'third_party/nanopb/pb_decode.c', + 'third_party/nanopb/pb_encode.c' ss.private_header_files = 'src/core/profiling/timers.h', 'src/core/support/block_annotate.h', @@ -492,6 +503,7 @@ Pod::Spec.new do |s| 'src/core/client_config/client_config.h', 'src/core/client_config/connector.h', 'src/core/client_config/initial_connect_string.h', + 'src/core/client_config/lb_policies/load_balancer_api.h', 'src/core/client_config/lb_policies/pick_first.h', 'src/core/client_config/lb_policies/round_robin.h', 'src/core/client_config/lb_policy.h', @@ -552,6 +564,7 @@ Pod::Spec.new do |s| 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', + 'src/core/proto/grpc/lb/v0/load_balancer.pb.h', 'src/core/statistics/census_interface.h', 'src/core/statistics/census_rpc_stats.h', 'src/core/surface/api_trace.h', @@ -592,7 +605,11 @@ Pod::Spec.new do |s| 'src/core/transport/transport.h', 'src/core/transport/transport_impl.h', 'src/core/census/aggregation.h', - 'src/core/census/rpc_metric_id.h' + 'src/core/census/rpc_metric_id.h', + 'third_party/nanopb/pb.h', + 'third_party/nanopb/pb_common.h', + 'third_party/nanopb/pb_decode.h', + 'third_party/nanopb/pb_encode.h' ss.header_mappings_dir = '.' # This isn't officially supported in Cocoapods. We've asked for an alternative: diff --git a/grpc.gemspec b/grpc.gemspec index 9e4683f41c7..1ef26761b72 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -182,6 +182,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/client_config/client_config.h ) s.files += %w( src/core/client_config/connector.h ) s.files += %w( src/core/client_config/initial_connect_string.h ) + s.files += %w( src/core/client_config/lb_policies/load_balancer_api.h ) s.files += %w( src/core/client_config/lb_policies/pick_first.h ) s.files += %w( src/core/client_config/lb_policies/round_robin.h ) s.files += %w( src/core/client_config/lb_policy.h ) @@ -242,6 +243,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/json/json_common.h ) s.files += %w( src/core/json/json_reader.h ) s.files += %w( src/core/json/json_writer.h ) + s.files += %w( src/core/proto/grpc/lb/v0/load_balancer.pb.h ) s.files += %w( src/core/statistics/census_interface.h ) s.files += %w( src/core/statistics/census_rpc_stats.h ) s.files += %w( src/core/surface/api_trace.h ) @@ -283,6 +285,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/transport/transport_impl.h ) s.files += %w( src/core/census/aggregation.h ) s.files += %w( src/core/census/rpc_metric_id.h ) + s.files += %w( third_party/nanopb/pb.h ) + s.files += %w( third_party/nanopb/pb_common.h ) + s.files += %w( third_party/nanopb/pb_decode.h ) + s.files += %w( third_party/nanopb/pb_encode.h ) s.files += %w( src/core/httpcli/httpcli_security_connector.c ) s.files += %w( src/core/security/base64.c ) s.files += %w( src/core/security/client_auth_filter.c ) @@ -319,6 +325,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/client_config/connector.c ) s.files += %w( src/core/client_config/default_initial_connect_string.c ) s.files += %w( src/core/client_config/initial_connect_string.c ) + s.files += %w( src/core/client_config/lb_policies/load_balancer_api.c ) s.files += %w( src/core/client_config/lb_policies/pick_first.c ) s.files += %w( src/core/client_config/lb_policies/round_robin.c ) s.files += %w( src/core/client_config/lb_policy.c ) @@ -382,6 +389,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/json/json_reader.c ) s.files += %w( src/core/json/json_string.c ) s.files += %w( src/core/json/json_writer.c ) + s.files += %w( src/core/proto/grpc/lb/v0/load_balancer.pb.c ) s.files += %w( src/core/surface/alarm.c ) s.files += %w( src/core/surface/api_trace.c ) s.files += %w( src/core/surface/byte_buffer.c ) @@ -436,6 +444,9 @@ Gem::Specification.new do |s| s.files += %w( src/core/census/operation.c ) s.files += %w( src/core/census/placeholders.c ) s.files += %w( src/core/census/tracing.c ) + s.files += %w( third_party/nanopb/pb_common.c ) + s.files += %w( third_party/nanopb/pb_decode.c ) + s.files += %w( third_party/nanopb/pb_encode.c ) s.files += %w( third_party/boringssl/crypto/aes/internal.h ) s.files += %w( third_party/boringssl/crypto/asn1/asn1_locl.h ) s.files += %w( third_party/boringssl/crypto/bio/internal.h ) diff --git a/package.json b/package.json index 1b79ecf92dc..b8f8c0a256e 100644 --- a/package.json +++ b/package.json @@ -128,6 +128,7 @@ "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -188,6 +189,7 @@ "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -229,6 +231,10 @@ "src/core/transport/transport_impl.h", "src/core/census/aggregation.h", "src/core/census/rpc_metric_id.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h", "src/core/httpcli/httpcli_security_connector.c", "src/core/security/base64.c", "src/core/security/client_auth_filter.c", @@ -265,6 +271,7 @@ "src/core/client_config/connector.c", "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", + "src/core/client_config/lb_policies/load_balancer_api.c", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/round_robin.c", "src/core/client_config/lb_policy.c", @@ -328,6 +335,7 @@ "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", "src/core/surface/alarm.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", @@ -382,6 +390,9 @@ "src/core/census/operation.c", "src/core/census/placeholders.c", "src/core/census/tracing.c", + "third_party/nanopb/pb_common.c", + "third_party/nanopb/pb_decode.c", + "third_party/nanopb/pb_encode.c", "third_party/zlib/crc32.h", "third_party/zlib/deflate.h", "third_party/zlib/gzguts.h", diff --git a/src/core/client_config/lb_policies/load_balancer_api.c b/src/core/client_config/lb_policies/load_balancer_api.c new file mode 100644 index 00000000000..a6b5785fe4e --- /dev/null +++ b/src/core/client_config/lb_policies/load_balancer_api.c @@ -0,0 +1,163 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/client_config/lb_policies/load_balancer_api.h" +#include "third_party/nanopb/pb_decode.h" +#include "third_party/nanopb/pb_encode.h" + +#include + +typedef struct decode_serverlist_arg { + int first_pass; + int i; + size_t num_servers; + grpc_grpclb_server **servers; +} decode_serverlist_arg; + +/* invoked once for every Server in ServerList */ +static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field, + void **arg) { + decode_serverlist_arg *dec_arg = *arg; + if (dec_arg->first_pass != 0) { /* first pass */ + grpc_grpclb_server server; + if (!pb_decode(stream, grpc_lb_v0_Server_fields, &server)) { + return false; + } + dec_arg->num_servers++; + } else { /* second pass */ + grpc_grpclb_server *server = gpr_malloc(sizeof(grpc_grpclb_server)); + GPR_ASSERT(dec_arg->num_servers > 0); + if (dec_arg->i == 0) { /* first iteration of second pass */ + dec_arg->servers = + gpr_malloc(sizeof(grpc_grpclb_server *) * dec_arg->num_servers); + } + if (!pb_decode(stream, grpc_lb_v0_Server_fields, server)) { + return false; + } + dec_arg->servers[dec_arg->i++] = server; + } + + return true; +} + +grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) { + grpc_grpclb_request *req = gpr_malloc(sizeof(grpc_grpclb_request)); + + req->has_client_stats = 0; /* TODO(dgq): add support for stats once defined */ + req->has_initial_request = 1; + req->initial_request.has_name = 1; + strncpy(req->initial_request.name, lb_service_name, + GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH); + return req; +} + +gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) { + size_t encoded_length; + pb_ostream_t sizestream; + pb_ostream_t outputstream; + gpr_slice slice; + memset(&sizestream, 0, sizeof(pb_ostream_t)); + pb_encode(&sizestream, grpc_lb_v0_LoadBalanceRequest_fields, request); + encoded_length = sizestream.bytes_written; + + slice = gpr_slice_malloc(encoded_length); + outputstream = + pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length); + GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v0_LoadBalanceRequest_fields, + request) != 0); + return slice; +} + +void grpc_grpclb_request_destroy(grpc_grpclb_request *request) { + gpr_free(request); +} + +grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response) { + bool status; + pb_istream_t stream = + pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response), + GPR_SLICE_LENGTH(encoded_response)); + grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response)); + memset(res, 0, sizeof(*res)); + status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res); + GPR_ASSERT(status == true); + return res; +} + +grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( + gpr_slice encoded_response) { + grpc_grpclb_serverlist *sl = gpr_malloc(sizeof(grpc_grpclb_serverlist)); + bool status; + decode_serverlist_arg arg; + pb_istream_t stream = + pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response), + GPR_SLICE_LENGTH(encoded_response)); + pb_istream_t stream_at_start = stream; + grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response)); + memset(res, 0, sizeof(*res)); + memset(&arg, 0, sizeof(decode_serverlist_arg)); + + res->server_list.servers.funcs.decode = decode_serverlist; + res->server_list.servers.arg = &arg; + arg.first_pass = 1; + status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res); + GPR_ASSERT(status == true); + GPR_ASSERT(arg.num_servers > 0); + + arg.first_pass = 0; + status = + pb_decode(&stream_at_start, grpc_lb_v0_LoadBalanceResponse_fields, res); + GPR_ASSERT(status == true); + GPR_ASSERT(arg.servers != NULL); + + sl->num_servers = arg.num_servers; + sl->servers = arg.servers; + if (res->server_list.has_expiration_interval) { + sl->expiration_interval = res->server_list.expiration_interval; + } + grpc_grpclb_response_destroy(res); + return sl; +} + +void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) { + size_t i; + for (i = 0; i < serverlist->num_servers; i++) { + gpr_free(serverlist->servers[i]); + } + gpr_free(serverlist->servers); + gpr_free(serverlist); +} + +void grpc_grpclb_response_destroy(grpc_grpclb_response *response) { + gpr_free(response); +} diff --git a/src/core/client_config/lb_policies/load_balancer_api.h b/src/core/client_config/lb_policies/load_balancer_api.h new file mode 100644 index 00000000000..4dbe1d6c224 --- /dev/null +++ b/src/core/client_config/lb_policies/load_balancer_api.h @@ -0,0 +1,85 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H +#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H + +#include + +#include "src/core/client_config/lb_policy_factory.h" +#include "src/core/proto/grpc/lb/v0/load_balancer.pb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128 + +typedef grpc_lb_v0_LoadBalanceRequest grpc_grpclb_request; +typedef grpc_lb_v0_LoadBalanceResponse grpc_grpclb_response; +typedef grpc_lb_v0_Server grpc_grpclb_server; +typedef grpc_lb_v0_Duration grpc_grpclb_duration; +typedef struct grpc_grpclb_serverlist { + grpc_grpclb_server **servers; + size_t num_servers; + grpc_grpclb_duration expiration_interval; +} grpc_grpclb_serverlist; + +/** Create a request for a gRPC LB service under \a lb_service_name */ +grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name); + +/** Protocol Buffers v3-encode \a request */ +gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request); + +/** Destroy \a request */ +void grpc_grpclb_request_destroy(grpc_grpclb_request *request); + +/** Parse (ie, decode) the bytes in \a encoded_response as a \a + * grpc_grpclb_response */ +grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response); + +/** Destroy \a serverlist */ +void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist); + +/** Parse the list of servers from an encoded \a grpc_grpclb_response */ +grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( + gpr_slice encoded_response); + +/** Destroy \a response */ +void grpc_grpclb_response_destroy(grpc_grpclb_response *response); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H */ diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.c b/src/core/proto/grpc/lb/v0/load_balancer.pb.c new file mode 100644 index 00000000000..bbb6fa82249 --- /dev/null +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.c @@ -0,0 +1,150 @@ +/* + * + * Copyright 2016, 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. + * + */ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.3.4-dev */ + +#include "src/core/proto/grpc/lb/v0/load_balancer.pb.h" + +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +const pb_field_t grpc_lb_v0_Duration_fields[3] = { + PB_FIELD(1, INT64, OPTIONAL, STATIC, FIRST, grpc_lb_v0_Duration, seconds, + seconds, 0), + PB_FIELD(2, INT32, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Duration, nanos, + seconds, 0), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_LoadBalanceRequest_fields[3] = { + PB_FIELD(1, MESSAGE, OPTIONAL, STATIC, FIRST, grpc_lb_v0_LoadBalanceRequest, + initial_request, initial_request, + &grpc_lb_v0_InitialLoadBalanceRequest_fields), + PB_FIELD(2, MESSAGE, OPTIONAL, STATIC, OTHER, grpc_lb_v0_LoadBalanceRequest, + client_stats, initial_request, &grpc_lb_v0_ClientStats_fields), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_InitialLoadBalanceRequest_fields[2] = { + PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, + grpc_lb_v0_InitialLoadBalanceRequest, name, name, 0), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_ClientStats_fields[4] = { + PB_FIELD(1, INT64, OPTIONAL, STATIC, FIRST, grpc_lb_v0_ClientStats, + total_requests, total_requests, 0), + PB_FIELD(2, INT64, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ClientStats, + client_rpc_errors, total_requests, 0), + PB_FIELD(3, INT64, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ClientStats, + dropped_requests, client_rpc_errors, 0), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_LoadBalanceResponse_fields[3] = { + PB_FIELD(1, MESSAGE, OPTIONAL, STATIC, FIRST, + grpc_lb_v0_LoadBalanceResponse, initial_response, initial_response, + &grpc_lb_v0_InitialLoadBalanceResponse_fields), + PB_FIELD(2, MESSAGE, OPTIONAL, STATIC, OTHER, + grpc_lb_v0_LoadBalanceResponse, server_list, initial_response, + &grpc_lb_v0_ServerList_fields), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_InitialLoadBalanceResponse_fields[4] = { + PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, + grpc_lb_v0_InitialLoadBalanceResponse, client_config, + client_config, 0), + PB_FIELD(2, STRING, OPTIONAL, STATIC, OTHER, + grpc_lb_v0_InitialLoadBalanceResponse, load_balancer_delegate, + client_config, 0), + PB_FIELD(3, MESSAGE, OPTIONAL, STATIC, OTHER, + grpc_lb_v0_InitialLoadBalanceResponse, + client_stats_report_interval, load_balancer_delegate, + &grpc_lb_v0_Duration_fields), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_ServerList_fields[3] = { + PB_FIELD(1, MESSAGE, REPEATED, CALLBACK, FIRST, grpc_lb_v0_ServerList, + servers, servers, &grpc_lb_v0_Server_fields), + PB_FIELD(3, MESSAGE, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ServerList, + expiration_interval, servers, &grpc_lb_v0_Duration_fields), + PB_LAST_FIELD}; + +const pb_field_t grpc_lb_v0_Server_fields[5] = { + PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, grpc_lb_v0_Server, ip_address, + ip_address, 0), + PB_FIELD(2, INT32, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, port, + ip_address, 0), + PB_FIELD(3, BYTES, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, + load_balance_token, port, 0), + PB_FIELD(4, BOOL, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, drop_request, + load_balance_token, 0), + PB_LAST_FIELD}; + +/* Check that field information fits in pb_field_t */ +#if !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_32BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in 8 or 16 bit + * field descriptors. + */ +PB_STATIC_ASSERT( + (pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 65536 && + pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 65536 && + pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 65536 && + pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 65536 && + pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, + client_stats_report_interval) < 65536 && + pb_membersize(grpc_lb_v0_ServerList, servers) < 65536 && + pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 65536), + YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) +#endif + +#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) +/* If you get an error here, it means that you need to define PB_FIELD_16BIT + * compile-time option. You can do that in pb.h or on compiler command line. + * + * The reason you need to do this is that some of your messages contain tag + * numbers or field sizes that are larger than what can fit in the default + * 8 bit descriptors. + */ +PB_STATIC_ASSERT( + (pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 256 && + pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 256 && + pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 256 && + pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 256 && + pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, + client_stats_report_interval) < 256 && + pb_membersize(grpc_lb_v0_ServerList, servers) < 256 && + pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 256), + YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) +#endif diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.h b/src/core/proto/grpc/lb/v0/load_balancer.pb.h new file mode 100644 index 00000000000..ac836658399 --- /dev/null +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.h @@ -0,0 +1,221 @@ +/* + * + * Copyright 2016, 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. + * + */ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.3.4-dev */ + +#ifndef PB_LOAD_BALANCER_PB_H_INCLUDED +#define PB_LOAD_BALANCER_PB_H_INCLUDED +#include "third_party/nanopb/pb.h" +#if PB_PROTO_HEADER_VERSION != 30 +#error Regenerate this file with the current version of nanopb generator. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Enum definitions */ +/* Struct definitions */ +typedef struct _grpc_lb_v0_ClientStats { + bool has_total_requests; + int64_t total_requests; + bool has_client_rpc_errors; + int64_t client_rpc_errors; + bool has_dropped_requests; + int64_t dropped_requests; +} grpc_lb_v0_ClientStats; + +typedef struct _grpc_lb_v0_Duration { + bool has_seconds; + int64_t seconds; + bool has_nanos; + int32_t nanos; +} grpc_lb_v0_Duration; + +typedef struct _grpc_lb_v0_InitialLoadBalanceRequest { + bool has_name; + char name[128]; +} grpc_lb_v0_InitialLoadBalanceRequest; + +typedef PB_BYTES_ARRAY_T(64) grpc_lb_v0_Server_load_balance_token_t; +typedef struct _grpc_lb_v0_Server { + bool has_ip_address; + char ip_address[46]; + bool has_port; + int32_t port; + bool has_load_balance_token; + grpc_lb_v0_Server_load_balance_token_t load_balance_token; + bool has_drop_request; + bool drop_request; +} grpc_lb_v0_Server; + +typedef struct _grpc_lb_v0_InitialLoadBalanceResponse { + bool has_client_config; + char client_config[64]; + bool has_load_balancer_delegate; + char load_balancer_delegate[64]; + bool has_client_stats_report_interval; + grpc_lb_v0_Duration client_stats_report_interval; +} grpc_lb_v0_InitialLoadBalanceResponse; + +typedef struct _grpc_lb_v0_LoadBalanceRequest { + bool has_initial_request; + grpc_lb_v0_InitialLoadBalanceRequest initial_request; + bool has_client_stats; + grpc_lb_v0_ClientStats client_stats; +} grpc_lb_v0_LoadBalanceRequest; + +typedef struct _grpc_lb_v0_ServerList { + pb_callback_t servers; + bool has_expiration_interval; + grpc_lb_v0_Duration expiration_interval; +} grpc_lb_v0_ServerList; + +typedef struct _grpc_lb_v0_LoadBalanceResponse { + bool has_initial_response; + grpc_lb_v0_InitialLoadBalanceResponse initial_response; + bool has_server_list; + grpc_lb_v0_ServerList server_list; +} grpc_lb_v0_LoadBalanceResponse; + +/* Default values for struct fields */ + +/* Initializer values for message structs */ +#define grpc_lb_v0_Duration_init_default \ + { false, 0, false, 0 } +#define grpc_lb_v0_LoadBalanceRequest_init_default \ + { \ + false, grpc_lb_v0_InitialLoadBalanceRequest_init_default, false, \ + grpc_lb_v0_ClientStats_init_default \ + } +#define grpc_lb_v0_InitialLoadBalanceRequest_init_default \ + { false, "" } +#define grpc_lb_v0_ClientStats_init_default \ + { false, 0, false, 0, false, 0 } +#define grpc_lb_v0_LoadBalanceResponse_init_default \ + { \ + false, grpc_lb_v0_InitialLoadBalanceResponse_init_default, false, \ + grpc_lb_v0_ServerList_init_default \ + } +#define grpc_lb_v0_InitialLoadBalanceResponse_init_default \ + { false, "", false, "", false, grpc_lb_v0_Duration_init_default } +#define grpc_lb_v0_ServerList_init_default \ + { \ + { \ + { NULL } \ + , NULL \ + } \ + , false, grpc_lb_v0_Duration_init_default \ + } +#define grpc_lb_v0_Server_init_default \ + { false, "", false, 0, false, {0, {0}}, false, 0 } +#define grpc_lb_v0_Duration_init_zero \ + { false, 0, false, 0 } +#define grpc_lb_v0_LoadBalanceRequest_init_zero \ + { \ + false, grpc_lb_v0_InitialLoadBalanceRequest_init_zero, false, \ + grpc_lb_v0_ClientStats_init_zero \ + } +#define grpc_lb_v0_InitialLoadBalanceRequest_init_zero \ + { false, "" } +#define grpc_lb_v0_ClientStats_init_zero \ + { false, 0, false, 0, false, 0 } +#define grpc_lb_v0_LoadBalanceResponse_init_zero \ + { \ + false, grpc_lb_v0_InitialLoadBalanceResponse_init_zero, false, \ + grpc_lb_v0_ServerList_init_zero \ + } +#define grpc_lb_v0_InitialLoadBalanceResponse_init_zero \ + { false, "", false, "", false, grpc_lb_v0_Duration_init_zero } +#define grpc_lb_v0_ServerList_init_zero \ + { \ + { \ + { NULL } \ + , NULL \ + } \ + , false, grpc_lb_v0_Duration_init_zero \ + } +#define grpc_lb_v0_Server_init_zero \ + { false, "", false, 0, false, {0, {0}}, false, 0 } + +/* Field tags (for use in manual encoding/decoding) */ +#define grpc_lb_v0_ClientStats_total_requests_tag 1 +#define grpc_lb_v0_ClientStats_client_rpc_errors_tag 2 +#define grpc_lb_v0_ClientStats_dropped_requests_tag 3 +#define grpc_lb_v0_Duration_seconds_tag 1 +#define grpc_lb_v0_Duration_nanos_tag 2 +#define grpc_lb_v0_InitialLoadBalanceRequest_name_tag 1 +#define grpc_lb_v0_Server_ip_address_tag 1 +#define grpc_lb_v0_Server_port_tag 2 +#define grpc_lb_v0_Server_load_balance_token_tag 3 +#define grpc_lb_v0_Server_drop_request_tag 4 +#define grpc_lb_v0_InitialLoadBalanceResponse_client_config_tag 1 +#define grpc_lb_v0_InitialLoadBalanceResponse_load_balancer_delegate_tag 2 +#define grpc_lb_v0_InitialLoadBalanceResponse_client_stats_report_interval_tag 3 +#define grpc_lb_v0_LoadBalanceRequest_initial_request_tag 1 +#define grpc_lb_v0_LoadBalanceRequest_client_stats_tag 2 +#define grpc_lb_v0_ServerList_servers_tag 1 +#define grpc_lb_v0_ServerList_expiration_interval_tag 3 +#define grpc_lb_v0_LoadBalanceResponse_initial_response_tag 1 +#define grpc_lb_v0_LoadBalanceResponse_server_list_tag 2 + +/* Struct field encoding specification for nanopb */ +extern const pb_field_t grpc_lb_v0_Duration_fields[3]; +extern const pb_field_t grpc_lb_v0_LoadBalanceRequest_fields[3]; +extern const pb_field_t grpc_lb_v0_InitialLoadBalanceRequest_fields[2]; +extern const pb_field_t grpc_lb_v0_ClientStats_fields[4]; +extern const pb_field_t grpc_lb_v0_LoadBalanceResponse_fields[3]; +extern const pb_field_t grpc_lb_v0_InitialLoadBalanceResponse_fields[4]; +extern const pb_field_t grpc_lb_v0_ServerList_fields[3]; +extern const pb_field_t grpc_lb_v0_Server_fields[5]; + +/* Maximum encoded size of messages (where known) */ +#define grpc_lb_v0_Duration_size 22 +#define grpc_lb_v0_LoadBalanceRequest_size 169 +#define grpc_lb_v0_InitialLoadBalanceRequest_size 131 +#define grpc_lb_v0_ClientStats_size 33 +#define grpc_lb_v0_InitialLoadBalanceResponse_size 156 +#define grpc_lb_v0_Server_size 127 + +/* Message IDs (where set with "msgid" option) */ +#ifdef PB_MSGID + +#define LOAD_BALANCER_MESSAGES + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/proto/grpc/lb/v0/load_balancer.options b/src/proto/grpc/lb/v0/load_balancer.options new file mode 100644 index 00000000000..6d4528f838a --- /dev/null +++ b/src/proto/grpc/lb/v0/load_balancer.options @@ -0,0 +1,6 @@ +grpc.lb.v0.InitialLoadBalanceRequest.name max_size:128 +grpc.lb.v0.InitialLoadBalanceResponse.client_config max_size:64 +grpc.lb.v0.InitialLoadBalanceResponse.load_balancer_delegate max_size:64 +grpc.lb.v0.Server.ip_address max_size:46 +grpc.lb.v0.Server.load_balance_token max_size:64 +load_balancer.proto no_unions:true diff --git a/src/proto/grpc/lb/v0/load_balancer.proto b/src/proto/grpc/lb/v0/load_balancer.proto new file mode 100644 index 00000000000..e88a4f8c4a7 --- /dev/null +++ b/src/proto/grpc/lb/v0/load_balancer.proto @@ -0,0 +1,144 @@ +// Copyright 2016, 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. + +syntax = "proto3"; + +package grpc.lb.v0; + +message Duration { + + // Signed seconds of the span of time. Must be from -315,576,000,000 + // to +315,576,000,000 inclusive. + int64 seconds = 1; + + // Signed fractions of a second at nanosecond resolution of the span + // of time. Durations less than one second are represented with a 0 + // `seconds` field and a positive or negative `nanos` field. For durations + // of one second or more, a non-zero value for the `nanos` field must be + // of the same sign as the `seconds` field. Must be from -999,999,999 + // to +999,999,999 inclusive. + int32 nanos = 2; +} + +service LoadBalancer { + // Bidirectional rpc to get a list of servers. + rpc BalanceLoad(stream LoadBalanceRequest) + returns (stream LoadBalanceResponse); +} + +message LoadBalanceRequest { + oneof load_balance_request_type { + // This message should be sent on the first request to the load balancer. + InitialLoadBalanceRequest initial_request = 1; + + // The client stats should be periodically reported to the load balancer + // based on the duration defined in the InitialLoadBalanceResponse. + ClientStats client_stats = 2; + } +} + +message InitialLoadBalanceRequest { + // Name of load balanced service (IE, service.grpc.gslb.google.com) + string name = 1; +} + +// Contains client level statistics that are useful to load balancing. Each +// count should be reset to zero after reporting the stats. +message ClientStats { + // The total number of requests sent by the client since the last report. + int64 total_requests = 1; + + // The number of client rpc errors since the last report. + int64 client_rpc_errors = 2; + + // The number of dropped requests since the last report. + int64 dropped_requests = 3; +} + +message LoadBalanceResponse { + oneof load_balance_response_type { + // This message should be sent on the first response to the client. + InitialLoadBalanceResponse initial_response = 1; + + // Contains the list of servers selected by the load balancer. The client + // should send requests to these servers in the specified order. + ServerList server_list = 2; + } +} + +message InitialLoadBalanceResponse { + oneof initial_response_type { + // Contains gRPC config options like RPC deadline or flow control. + // TODO(yetianx): Change to ClientConfig after it is defined. + string client_config = 1; + + // This is an application layer redirect that indicates the client should + // use the specified server for load balancing. When this field is set in + // the response, the client should open a separate connection to the + // load_balancer_delegate and call the BalanceLoad method. + string load_balancer_delegate = 2; + } + + // This interval defines how often the client should send the client stats + // to the load balancer. Stats should only be reported when the duration is + // positive. + Duration client_stats_report_interval = 3; +} + +message ServerList { + // Contains a list of servers selected by the load balancer. The list will + // be updated when server resolutions change or as needed to balance load + // across more servers. The client should consume the server list in order + // unless instructed otherwise via the client_config. + repeated Server servers = 1; + + // Indicates the amount of time that the client should consider this server + // list as valid. It may be considered stale after waiting this interval of + // time after receiving the list. If the interval is not positive, the + // client can assume the list is valid until the next list is received. + Duration expiration_interval = 3; +} + +message Server { + // A resolved address and port for the server. The IP address string may + // either be an IPv4 or IPv6 address. + string ip_address = 1; + int32 port = 2; + + // An opaque token that is passed from the client to the server in metadata. + // The server may expect this token to indicate that the request from the + // client was load balanced. + // TODO(yetianx): Not used right now, and will be used after implementing + // load report. + bytes load_balance_token = 3; + + // Indicates whether this particular request should be dropped by the client + // when this server is chosen from the list. + bool drop_request = 4; +} diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 8e90f7a61d2..60af8623055 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -109,6 +109,7 @@ CORE_SOURCE_FILES = [ 'src/core/client_config/connector.c', 'src/core/client_config/default_initial_connect_string.c', 'src/core/client_config/initial_connect_string.c', + 'src/core/client_config/lb_policies/load_balancer_api.c', 'src/core/client_config/lb_policies/pick_first.c', 'src/core/client_config/lb_policies/round_robin.c', 'src/core/client_config/lb_policy.c', @@ -172,6 +173,7 @@ CORE_SOURCE_FILES = [ 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', + 'src/core/proto/grpc/lb/v0/load_balancer.pb.c', 'src/core/surface/alarm.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', @@ -226,6 +228,9 @@ CORE_SOURCE_FILES = [ 'src/core/census/operation.c', 'src/core/census/placeholders.c', 'src/core/census/tracing.c', + 'third_party/nanopb/pb_common.c', + 'third_party/nanopb/pb_decode.c', + 'third_party/nanopb/pb_encode.c', 'src/boringssl/err_data.c', 'third_party/boringssl/crypto/aes/aes.c', 'third_party/boringssl/crypto/aes/mode_wrappers.c', diff --git a/templates/tools/run_tests/sources_and_headers.json.template b/templates/tools/run_tests/sources_and_headers.json.template index 04802772af5..78363ff1fae 100644 --- a/templates/tools/run_tests/sources_and_headers.json.template +++ b/templates/tools/run_tests/sources_and_headers.json.template @@ -12,20 +12,27 @@ out.extend(fmt % name for fmt in ['%s.grpc.pb.h', '%s.pb.h']) return out - def no_protos(src): + def no_protos_filter(src): + return os.path.splitext(src)[1] != '.proto' + + def no_third_party_filter(src): + return not src.startswith('third_party/') + + def filter_srcs(srcs, filters): out = [] - for f in src: - if os.path.splitext(f)[1] != '.proto': - out.append(f) + for s in srcs: + filter_passes = (f(s) for f in filters) + if all(filter_passes): + out.append(s) return out %> ${json.dumps([{"name": tgt.name, "language": tgt.language, "src": sorted( - no_protos(tgt.src) + - tgt.get('public_headers', []) + - tgt.get('headers', [])), + filter_srcs(tgt.src, (no_protos_filter, no_third_party_filter)) + + filter_srcs(tgt.get('public_headers', []), (no_protos_filter, no_third_party_filter)) + + filter_srcs(tgt.get('headers', []), (no_third_party_filter,))), "headers": sorted( tgt.get('public_headers', []) + tgt.get('headers', []) + diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc new file mode 100644 index 00000000000..bd4885fb4cd --- /dev/null +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -0,0 +1,133 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include "src/core/client_config/lb_policies/load_balancer_api.h" +#include "src/proto/grpc/lb/v0/load_balancer.pb.h" // C++ version + +namespace grpc { +namespace { + +using grpc::lb::v0::LoadBalanceRequest; +using grpc::lb::v0::LoadBalanceResponse; + +class GrpclbTest : public ::testing::Test {}; + +TEST_F(GrpclbTest, CreateRequest) { + const std::string service_name = "AServiceName"; + LoadBalanceRequest request; + grpc_grpclb_request* c_req = grpc_grpclb_request_create(service_name.c_str()); + gpr_slice slice = grpc_grpclb_request_encode(c_req); + const int num_bytes_written = GPR_SLICE_LENGTH(slice); + EXPECT_GT(num_bytes_written, 0); + request.ParseFromArray(GPR_SLICE_START_PTR(slice), num_bytes_written); + EXPECT_EQ(request.initial_request().name(), service_name); + gpr_slice_unref(slice); + grpc_grpclb_request_destroy(c_req); +} + +TEST_F(GrpclbTest, ParseResponse) { + LoadBalanceResponse response; + const std::string client_config_str = "I'm a client config"; + auto* initial_response = response.mutable_initial_response(); + initial_response->set_client_config(client_config_str); + auto* client_stats_report_interval = + initial_response->mutable_client_stats_report_interval(); + client_stats_report_interval->set_seconds(123); + client_stats_report_interval->set_nanos(456); + + const std::string encoded_response = response.SerializeAsString(); + gpr_slice encoded_slice = + gpr_slice_from_copied_string(encoded_response.c_str()); + grpc_grpclb_response* c_response = grpc_grpclb_response_parse(encoded_slice); + EXPECT_TRUE(c_response->has_initial_response); + EXPECT_TRUE(c_response->initial_response.has_client_config); + EXPECT_FALSE(c_response->initial_response.has_load_balancer_delegate); + EXPECT_TRUE(strcmp(c_response->initial_response.client_config, + client_config_str.c_str()) == 0); + EXPECT_EQ(c_response->initial_response.client_stats_report_interval.seconds, + 123); + EXPECT_EQ(c_response->initial_response.client_stats_report_interval.nanos, + 456); + gpr_slice_unref(encoded_slice); + grpc_grpclb_response_destroy(c_response); +} + +TEST_F(GrpclbTest, ParseResponseServerList) { + LoadBalanceResponse response; + auto* serverlist = response.mutable_server_list(); + auto* server = serverlist->add_servers(); + server->set_ip_address("127.0.0.1"); + server->set_port(12345); + server->set_drop_request(true); + server = response.mutable_server_list()->add_servers(); + server->set_ip_address("10.0.0.1"); + server->set_port(54321); + server->set_drop_request(false); + auto* expiration_interval = serverlist->mutable_expiration_interval(); + expiration_interval->set_seconds(888); + expiration_interval->set_nanos(999); + + const std::string encoded_response = response.SerializeAsString(); + gpr_slice encoded_slice = + gpr_slice_from_copied_string(encoded_response.c_str()); + grpc_grpclb_serverlist* c_serverlist = + grpc_grpclb_response_parse_serverlist(encoded_slice); + ASSERT_EQ(c_serverlist->num_servers, 2ul); + EXPECT_TRUE(c_serverlist->servers[0]->has_ip_address); + EXPECT_TRUE(strcmp(c_serverlist->servers[0]->ip_address, "127.0.0.1") == 0); + EXPECT_EQ(c_serverlist->servers[0]->port, 12345); + EXPECT_TRUE(c_serverlist->servers[0]->drop_request); + EXPECT_TRUE(c_serverlist->servers[1]->has_ip_address); + EXPECT_TRUE(strcmp(c_serverlist->servers[1]->ip_address, "10.0.0.1") == 0); + EXPECT_EQ(c_serverlist->servers[1]->port, 54321); + EXPECT_FALSE(c_serverlist->servers[1]->drop_request); + + EXPECT_TRUE(c_serverlist->expiration_interval.has_seconds); + EXPECT_EQ(c_serverlist->expiration_interval.seconds, 888); + EXPECT_TRUE(c_serverlist->expiration_interval.has_nanos); + EXPECT_EQ(c_serverlist->expiration_interval.nanos, 999); + + gpr_slice_unref(encoded_slice); + grpc_grpclb_destroy_serverlist(c_serverlist); +} + +} // namespace +} // namespace grpc + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/third_party/nanopb b/third_party/nanopb new file mode 160000 index 00000000000..5497a1dfc91 --- /dev/null +++ b/third_party/nanopb @@ -0,0 +1 @@ +Subproject commit 5497a1dfc91a86965383cdd1652e348345400435 diff --git a/tools/codegen/core/gen_load_balancing_proto.sh b/tools/codegen/core/gen_load_balancing_proto.sh new file mode 100755 index 00000000000..114dd9d70d8 --- /dev/null +++ b/tools/codegen/core/gen_load_balancing_proto.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +# Copyright 2016, 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. + +# +# Example usage: +# tools/codegen/core/gen_load_balancing_proto.sh \ +# src/proto/grpc/lb/v0/load_balancer.proto + +read -r -d '' COPYRIGHT <<'EOF' +/* + * + * Copyright , 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. + * + */ + +EOF + +# build clang-format docker image +docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format + +CURRENT_YEAR=$(date +%Y) +COPYRIGHT_FILE=$(mktemp) +echo "${COPYRIGHT//$CURRENT_YEAR}" > $COPYRIGHT_FILE + +set -ex +if [ $# -eq 0 ]; then + echo "Usage: $0 [output dir]" + exit 1 +fi + +readonly GRPC_ROOT=$PWD + +OUTPUT_DIR="$GRPC_ROOT/src/core/proto/grpc/lb/v0" +if [ $# -eq 2 ]; then + mkdir -p "$2" + if [ $? != 0 ]; then + echo "Error creating output directory $2" + exit 2 + fi + OUTPUT_DIR="$2" +fi + +readonly EXPECTED_OPTIONS_FILE_PATH="${1%.*}.options" + +if [[ ! -f "$1" ]]; then + echo "Input proto file '$1' doesn't exist." + exit 3 +fi +if [[ ! -f "${EXPECTED_OPTIONS_FILE_PATH}" ]]; then + echo "Expected nanopb options file '${EXPECTED_OPTIONS_FILE_PATH}' missing" + exit 4 +fi + +pushd "$(dirname $1)" > /dev/null + +protoc \ +--plugin=protoc-gen-nanopb="$GRPC_ROOT/third_party/nanopb/generator/protoc-gen-nanopb" \ +--nanopb_out='-T -L#include\ \"third_party/nanopb/pb.h\"'":$OUTPUT_DIR" \ +"$(basename $1)" + +readonly PROTO_BASENAME=$(basename $1 .proto) +sed -i "s:$PROTO_BASENAME.pb.h:src/core/proto/grpc/lb/v0/$PROTO_BASENAME.pb.h:g" \ + "$OUTPUT_DIR/$PROTO_BASENAME.pb.c" + +# prepend copyright +TMPFILE=$(mktemp) +cat $COPYRIGHT_FILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.c" > $TMPFILE +mv -v $TMPFILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.c" +cat $COPYRIGHT_FILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.h" > $TMPFILE +mv -v $TMPFILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.h" + +readonly MOUNTPOINT='/protos' +docker run --rm=true -v ${HOST_GIT_ROOT}/gens/src/proto/grpc/lb/v0:$MOUNTPOINT \ + -t grpc_clang_format \ + clang-format-3.6 -style="{BasedOnStyle: Google, Language: Cpp}" \ + -i $MOUNTPOINT/load_balancer.pb.c $MOUNTPOINT/load_balancer.pb.h + +popd > /dev/null diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh new file mode 100755 index 00000000000..78d3a734e96 --- /dev/null +++ b/tools/distrib/check_nanopb_output.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# Copyright 2015-2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set -ex + +apt-get install -y autoconf automake libtool curl python-virtualenv + +readonly NANOPB_TMP_OUTPUT="${LOCAL_GIT_ROOT}/gens/src/proto/grpc/lb/v0" +readonly VENV_DIR=$(mktemp -d) +# create a virtualenv for nanopb's compiler +pushd $VENV_DIR +readonly VENV_NAME="nanopb-$(date '+%Y%m%d_%H%M%S_%N')" +virtualenv $VENV_NAME +. $VENV_NAME/bin/activate +popd + +# install proto3 +pip install protobuf==3.0.0b2 + +# change to root directory +cd $(dirname $0)/../.. + +# build clang-format docker image +docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format + +# install protoc version 3 +pushd third_party/protobuf +./autogen.sh +./configure +make +make install +ldconfig +popd + +if [ ! -x "/usr/local/bin/protoc" ]; then + echo "Error: protoc not found in path" + exit 1 +fi +readonly PROTOC_PATH='/usr/local/bin' +# stack up and change to nanopb's proto generator directory +pushd third_party/nanopb/generator/proto +PATH="$PROTOC_PATH:$PATH" make + +# back to the root directory +popd + + +# nanopb-compile the proto to a temp location +PATH="$PROTOC_PATH:$PATH" ./tools/codegen/core/gen_load_balancing_proto.sh \ + src/proto/grpc/lb/v0/load_balancer.proto \ + $NANOPB_TMP_OUTPUT + +# compare outputs to checked compiled code +diff -rq $NANOPB_TMP_OUTPUT src/core/proto/grpc/lb/v0 +if [ $? != 0 ]; then + echo "Outputs differ: $NANOPB_TMP_OUTPUT vs src/core/proto/grpc/lb/v0" + exit 1 +fi +deactivate diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index b6268432335..c6f1b6ae7c2 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -801,6 +801,7 @@ src/core/channel/subchannel_call_holder.h \ src/core/client_config/client_config.h \ src/core/client_config/connector.h \ src/core/client_config/initial_connect_string.h \ +src/core/client_config/lb_policies/load_balancer_api.h \ src/core/client_config/lb_policies/pick_first.h \ src/core/client_config/lb_policies/round_robin.h \ src/core/client_config/lb_policy.h \ @@ -861,6 +862,7 @@ src/core/json/json.h \ src/core/json/json_common.h \ src/core/json/json_reader.h \ src/core/json/json_writer.h \ +src/core/proto/grpc/lb/v0/load_balancer.pb.h \ src/core/statistics/census_interface.h \ src/core/statistics/census_rpc_stats.h \ src/core/surface/api_trace.h \ @@ -902,6 +904,10 @@ src/core/transport/transport.h \ src/core/transport/transport_impl.h \ src/core/census/aggregation.h \ src/core/census/rpc_metric_id.h \ +third_party/nanopb/pb.h \ +third_party/nanopb/pb_common.h \ +third_party/nanopb/pb_decode.h \ +third_party/nanopb/pb_encode.h \ src/core/httpcli/httpcli_security_connector.c \ src/core/security/base64.c \ src/core/security/client_auth_filter.c \ @@ -938,6 +944,7 @@ src/core/client_config/client_config.c \ src/core/client_config/connector.c \ src/core/client_config/default_initial_connect_string.c \ src/core/client_config/initial_connect_string.c \ +src/core/client_config/lb_policies/load_balancer_api.c \ src/core/client_config/lb_policies/pick_first.c \ src/core/client_config/lb_policies/round_robin.c \ src/core/client_config/lb_policy.c \ @@ -1001,6 +1008,7 @@ src/core/json/json.c \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ +src/core/proto/grpc/lb/v0/load_balancer.pb.c \ src/core/surface/alarm.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ @@ -1055,6 +1063,9 @@ src/core/census/initialize.c \ src/core/census/operation.c \ src/core/census/placeholders.c \ src/core/census/tracing.c \ +third_party/nanopb/pb_common.c \ +third_party/nanopb/pb_decode.c \ +third_party/nanopb/pb_encode.c \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ diff --git a/tools/jenkins/build_docker_and_run_tests.sh b/tools/jenkins/build_docker_and_run_tests.sh index e2ac7518f09..daa29b2f94b 100755 --- a/tools/jenkins/build_docker_and_run_tests.sh +++ b/tools/jenkins/build_docker_and_run_tests.sh @@ -60,6 +60,9 @@ docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR # Choose random name for docker container CONTAINER_NAME="run_tests_$(uuidgen)" +# Git root as seen by the docker instance +docker_instance_git_root=/var/local/jenkins/grpc + # Run tests inside docker docker run \ -e "RUN_TESTS_COMMAND=$RUN_TESTS_COMMAND" \ @@ -69,9 +72,10 @@ docker run \ -e XDG_CACHE_HOME=/tmp/xdg-cache-home \ -e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \ -e HOST_GIT_ROOT=$git_root \ + -e LOCAL_GIT_ROOT=$docker_instance_git_root \ -e "BUILD_ID=$BUILD_ID" \ -i $TTY_FLAG \ - -v "$git_root:/var/local/jenkins/grpc" \ + -v "$git_root:$docker_instance_git_root" \ -v /tmp/ccache:/tmp/ccache \ -v /tmp/npm-cache:/tmp/npm-cache \ -v /tmp/xdg-cache-home:/tmp/xdg-cache-home \ diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index f49230e49aa..c08b382638f 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -44,6 +44,7 @@ cat << EOF | awk '{ print $1 }' | sort > $want_submodules 9f897b25800d2f54f5c442ef01a60721aeca6d87 third_party/boringssl (version_for_cocoapods_1.0-67-g9f897b2) 05b155ff59114735ec8cd089f669c4c3d8f59029 third_party/gflags (v2.1.0-45-g05b155f) c99458533a9b4c743ed51537e25989ea55944908 third_party/googletest (release-1.7.0) + 5497a1dfc91a86965383cdd1652e348345400435 third_party/nanopb (nanopb-0.3.3-10-g5497a1d) d5fb408ddc281ffcadeb08699e65bb694656d0bd third_party/protobuf (v3.0.0-beta-2) 50893291621658f355bc5b4d450a8d06a563053d third_party/zlib (v1.2.8) EOF diff --git a/tools/run_tests/sanity/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml index 809e6ce6454..1fc0525e029 100644 --- a/tools/run_tests/sanity/sanity_tests.yaml +++ b/tools/run_tests/sanity/sanity_tests.yaml @@ -7,3 +7,4 @@ - script: tools/distrib/check_copyright.py - script: tools/distrib/clang_format_code.sh - script: tools/distrib/check_trailing_newlines.sh +- script: tools/distrib/check_nanopb_output.sh diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 6538ddc37e1..76fa3d07764 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -1644,6 +1644,23 @@ "src/compiler/ruby_plugin.cc" ] }, + { + "deps": [ + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [ + "src/proto/grpc/lb/v0/load_balancer.grpc.pb.h", + "src/proto/grpc/lb/v0/load_balancer.pb.h" + ], + "language": "c++", + "name": "grpclb_api_test", + "src": [ + "test/cpp/grpclb/grpclb_api_test.cc" + ] + }, { "deps": [ "gpr", @@ -2983,6 +3000,7 @@ "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -3043,6 +3061,7 @@ "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/security/auth_filters.h", "src/core/security/base64.h", "src/core/security/credentials.h", @@ -3095,7 +3114,11 @@ "src/core/tsi/ssl_transport_security.h", "src/core/tsi/ssl_types.h", "src/core/tsi/transport_security.h", - "src/core/tsi/transport_security_interface.h" + "src/core/tsi/transport_security_interface.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h" ], "language": "c", "name": "grpc", @@ -3149,6 +3172,8 @@ "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.c", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.c", @@ -3273,6 +3298,8 @@ "src/core/json/json_string.c", "src/core/json/json_writer.c", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/security/auth_filters.h", "src/core/security/base64.c", "src/core/security/base64.h", @@ -3508,6 +3535,7 @@ "src/core/client_config/client_config.h", "src/core/client_config/connector.h", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.h", "src/core/client_config/lb_policy.h", @@ -3568,6 +3596,7 @@ "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -3606,7 +3635,11 @@ "src/core/transport/metadata_batch.h", "src/core/transport/static_metadata.h", "src/core/transport/transport.h", - "src/core/transport/transport_impl.h" + "src/core/transport/transport_impl.h", + "third_party/nanopb/pb.h", + "third_party/nanopb/pb_common.h", + "third_party/nanopb/pb_decode.h", + "third_party/nanopb/pb_encode.h" ], "language": "c", "name": "grpc_unsecure", @@ -3659,6 +3692,8 @@ "src/core/client_config/default_initial_connect_string.c", "src/core/client_config/initial_connect_string.c", "src/core/client_config/initial_connect_string.h", + "src/core/client_config/lb_policies/load_balancer_api.c", + "src/core/client_config/lb_policies/load_balancer_api.h", "src/core/client_config/lb_policies/pick_first.c", "src/core/client_config/lb_policies/pick_first.h", "src/core/client_config/lb_policies/round_robin.c", @@ -3782,6 +3817,8 @@ "src/core/json/json_string.c", "src/core/json/json_writer.c", "src/core/json/json_writer.h", + "src/core/proto/grpc/lb/v0/load_balancer.pb.c", + "src/core/proto/grpc/lb/v0/load_balancer.pb.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/alarm.c", diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 2c73c40d1f5..3b9bce1ec38 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -2019,6 +2019,26 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "flaky": false, + "language": "c++", + "name": "grpclb_api_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 76975322be8..4e1155f84b5 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -310,6 +310,7 @@ + @@ -370,6 +371,7 @@ + @@ -411,6 +413,10 @@ + + + + @@ -485,6 +491,8 @@ + + @@ -611,6 +619,8 @@ + + @@ -719,6 +729,12 @@ + + + + + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 4660572f979..e0cfd8295b1 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -109,6 +109,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config\lb_policies @@ -298,6 +301,9 @@ src\core\json + + src\core\proto\grpc\lb\v0 + src\core\surface @@ -460,6 +466,15 @@ src\core\census + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + @@ -587,6 +602,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config\lb_policies @@ -767,6 +785,9 @@ src\core\json + + src\core\proto\grpc\lb\v0 + src\core\statistics @@ -890,6 +911,18 @@ src\core\census + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + @@ -941,6 +974,18 @@ {e665cc0e-b994-d7c5-cc18-2007392019f0} + + {1ff04466-0905-8a5d-d6f4-7ff2df4c13b5} + + + {7c7ad0b3-bf85-5bd3-e0c8-4f5468a8e2e6} + + + {3d533dad-8100-e8a3-b7c3-1fc13a4d60da} + + + {0ffcf868-7617-5fed-b6ce-2162d9d09148} + {1d850ac6-e639-4eab-5338-4ba40272fcc9} @@ -959,6 +1004,12 @@ {0b0f9ab1-efa4-7f03-e446-6fb9b5227e84} + + {aaab30a4-2a15-732e-c141-3fbc0f0f5a7a} + + + {93d6596d-330c-1d27-6f84-3c840e57869e} + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 541000af404..3820d89968b 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -286,6 +286,7 @@ + @@ -346,6 +347,7 @@ + @@ -387,6 +389,10 @@ + + + + @@ -421,6 +427,8 @@ + + @@ -547,6 +555,8 @@ + + @@ -655,6 +665,12 @@ + + + + + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 48814f997e1..c4c957d36b2 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -49,6 +49,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config\lb_policies @@ -238,6 +241,9 @@ src\core\json + + src\core\proto\grpc\lb\v0 + src\core\surface @@ -400,6 +406,15 @@ src\core\census + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + @@ -482,6 +497,9 @@ src\core\client_config + + src\core\client_config\lb_policies + src\core\client_config\lb_policies @@ -662,6 +680,9 @@ src\core\json + + src\core\proto\grpc\lb\v0 + src\core\statistics @@ -785,6 +806,18 @@ src\core\census + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + + + third_party\nanopb + @@ -836,6 +869,18 @@ {443ffc61-1bea-2477-6e54-1ddf8c139264} + + {7f4bb22a-65ba-0f8f-6387-66b1f6677a80} + + + {9c2bd164-c317-8a13-564d-3b28b0fd79cf} + + + {2bad8e10-4fc5-d8b3-e026-4abbd0c25cda} + + + {4475c8ed-e01b-8906-47d0-8a504189c0d5} + {e084164c-a069-00e3-db35-4e0b1cd6f0b7} @@ -848,6 +893,12 @@ {5fcd6206-f774-9ae6-4b85-305d6a723843} + + {025c051e-8eba-125b-67f9-173f95176eb2} + + + {6511f77d-f28c-80e0-0889-8975e688e344} + diff --git a/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj b/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj new file mode 100644 index 00000000000..1509ece9f96 --- /dev/null +++ b/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj @@ -0,0 +1,209 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {990AF023-17D7-8DBF-EB6E-14C7C016C77E} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + grpclb_api_test + static + Debug + static + Debug + + + grpclb_api_test + static + Release + static + Release + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + + + + + + + + + + + + + {0BE77741-552A-929B-A497-4EF7ECE17A64} + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {C187A093-A0FE-489D-A40A-6E33DE0F9FEB} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj.filters b/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj.filters new file mode 100644 index 00000000000..6c57b8c162a --- /dev/null +++ b/vsprojects/vcxproj/test/grpclb_api_test/grpclb_api_test.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + src\proto\grpc\lb\v0 + + + test\cpp\grpclb + + + + + + {a31d21fb-c6ab-75ce-43dc-7d6f506765e6} + + + {10d49c90-8503-9b10-6678-eed983bc25d9} + + + {8b6be783-e071-44cc-2096-f1c476012556} + + + {2981699e-c196-c599-bc17-c177770f89ee} + + + {3d04774a-1c2f-e100-435e-08af5d539250} + + + {64736e1d-eb77-664f-34ab-6cf41263d3d8} + + + {c86e9cb1-bed4-3697-40f2-9ecff6297fa5} + + + {6b5ba83a-6cf2-5a7b-0ab8-62de31882705} + + + + From 00c48296693d8c1d4fc5c600bcb318abeb4e4c3d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 11 Feb 2016 16:20:28 -0800 Subject: [PATCH 03/32] Ignore pb.h, pb.c for clang-fmt --- src/core/proto/grpc/lb/v0/load_balancer.pb.c | 119 +++++------- src/core/proto/grpc/lb/v0/load_balancer.pb.h | 169 +++++++----------- .../codegen/core/gen_load_balancing_proto.sh | 19 +- tools/distrib/check_nanopb_output.sh | 16 -- .../clang_format_all_the_things.sh | 2 +- 5 files changed, 121 insertions(+), 204 deletions(-) diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.c b/src/core/proto/grpc/lb/v0/load_balancer.pb.c index bbb6fa82249..abd4b1cefc6 100644 --- a/src/core/proto/grpc/lb/v0/load_balancer.pb.c +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.c @@ -39,112 +39,81 @@ #error Regenerate this file with the current version of nanopb generator. #endif + + const pb_field_t grpc_lb_v0_Duration_fields[3] = { - PB_FIELD(1, INT64, OPTIONAL, STATIC, FIRST, grpc_lb_v0_Duration, seconds, - seconds, 0), - PB_FIELD(2, INT32, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Duration, nanos, - seconds, 0), - PB_LAST_FIELD}; + PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v0_Duration, seconds, seconds, 0), + PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Duration, nanos, seconds, 0), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_LoadBalanceRequest_fields[3] = { - PB_FIELD(1, MESSAGE, OPTIONAL, STATIC, FIRST, grpc_lb_v0_LoadBalanceRequest, - initial_request, initial_request, - &grpc_lb_v0_InitialLoadBalanceRequest_fields), - PB_FIELD(2, MESSAGE, OPTIONAL, STATIC, OTHER, grpc_lb_v0_LoadBalanceRequest, - client_stats, initial_request, &grpc_lb_v0_ClientStats_fields), - PB_LAST_FIELD}; + PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v0_LoadBalanceRequest, initial_request, initial_request, &grpc_lb_v0_InitialLoadBalanceRequest_fields), + PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_LoadBalanceRequest, client_stats, initial_request, &grpc_lb_v0_ClientStats_fields), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_InitialLoadBalanceRequest_fields[2] = { - PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, - grpc_lb_v0_InitialLoadBalanceRequest, name, name, 0), - PB_LAST_FIELD}; + PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_InitialLoadBalanceRequest, name, name, 0), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_ClientStats_fields[4] = { - PB_FIELD(1, INT64, OPTIONAL, STATIC, FIRST, grpc_lb_v0_ClientStats, - total_requests, total_requests, 0), - PB_FIELD(2, INT64, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ClientStats, - client_rpc_errors, total_requests, 0), - PB_FIELD(3, INT64, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ClientStats, - dropped_requests, client_rpc_errors, 0), - PB_LAST_FIELD}; + PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v0_ClientStats, total_requests, total_requests, 0), + PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ClientStats, client_rpc_errors, total_requests, 0), + PB_FIELD( 3, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ClientStats, dropped_requests, client_rpc_errors, 0), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_LoadBalanceResponse_fields[3] = { - PB_FIELD(1, MESSAGE, OPTIONAL, STATIC, FIRST, - grpc_lb_v0_LoadBalanceResponse, initial_response, initial_response, - &grpc_lb_v0_InitialLoadBalanceResponse_fields), - PB_FIELD(2, MESSAGE, OPTIONAL, STATIC, OTHER, - grpc_lb_v0_LoadBalanceResponse, server_list, initial_response, - &grpc_lb_v0_ServerList_fields), - PB_LAST_FIELD}; + PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v0_LoadBalanceResponse, initial_response, initial_response, &grpc_lb_v0_InitialLoadBalanceResponse_fields), + PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_LoadBalanceResponse, server_list, initial_response, &grpc_lb_v0_ServerList_fields), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_InitialLoadBalanceResponse_fields[4] = { - PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, - grpc_lb_v0_InitialLoadBalanceResponse, client_config, - client_config, 0), - PB_FIELD(2, STRING, OPTIONAL, STATIC, OTHER, - grpc_lb_v0_InitialLoadBalanceResponse, load_balancer_delegate, - client_config, 0), - PB_FIELD(3, MESSAGE, OPTIONAL, STATIC, OTHER, - grpc_lb_v0_InitialLoadBalanceResponse, - client_stats_report_interval, load_balancer_delegate, - &grpc_lb_v0_Duration_fields), - PB_LAST_FIELD}; + PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_InitialLoadBalanceResponse, client_config, client_config, 0), + PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, grpc_lb_v0_InitialLoadBalanceResponse, load_balancer_delegate, client_config, 0), + PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval, load_balancer_delegate, &grpc_lb_v0_Duration_fields), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_ServerList_fields[3] = { - PB_FIELD(1, MESSAGE, REPEATED, CALLBACK, FIRST, grpc_lb_v0_ServerList, - servers, servers, &grpc_lb_v0_Server_fields), - PB_FIELD(3, MESSAGE, OPTIONAL, STATIC, OTHER, grpc_lb_v0_ServerList, - expiration_interval, servers, &grpc_lb_v0_Duration_fields), - PB_LAST_FIELD}; + PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v0_ServerList, servers, servers, &grpc_lb_v0_Server_fields), + PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ServerList, expiration_interval, servers, &grpc_lb_v0_Duration_fields), + PB_LAST_FIELD +}; const pb_field_t grpc_lb_v0_Server_fields[5] = { - PB_FIELD(1, STRING, OPTIONAL, STATIC, FIRST, grpc_lb_v0_Server, ip_address, - ip_address, 0), - PB_FIELD(2, INT32, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, port, - ip_address, 0), - PB_FIELD(3, BYTES, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, - load_balance_token, port, 0), - PB_FIELD(4, BOOL, OPTIONAL, STATIC, OTHER, grpc_lb_v0_Server, drop_request, - load_balance_token, 0), - PB_LAST_FIELD}; + PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_Server, ip_address, ip_address, 0), + PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, port, ip_address, 0), + PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, load_balance_token, port, 0), + PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, drop_request, load_balance_token, 0), + PB_LAST_FIELD +}; + /* Check that field information fits in pb_field_t */ #if !defined(PB_FIELD_32BIT) /* If you get an error here, it means that you need to define PB_FIELD_32BIT * compile-time option. You can do that in pb.h or on compiler command line. - * + * * The reason you need to do this is that some of your messages contain tag * numbers or field sizes that are larger than what can fit in 8 or 16 bit * field descriptors. */ -PB_STATIC_ASSERT( - (pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 65536 && - pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 65536 && - pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 65536 && - pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 65536 && - pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, - client_stats_report_interval) < 65536 && - pb_membersize(grpc_lb_v0_ServerList, servers) < 65536 && - pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 65536), - YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) +PB_STATIC_ASSERT((pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v0_ServerList, servers) < 65536 && pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) #endif #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) /* If you get an error here, it means that you need to define PB_FIELD_16BIT * compile-time option. You can do that in pb.h or on compiler command line. - * + * * The reason you need to do this is that some of your messages contain tag * numbers or field sizes that are larger than what can fit in the default * 8 bit descriptors. */ -PB_STATIC_ASSERT( - (pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 256 && - pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 256 && - pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 256 && - pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 256 && - pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, - client_stats_report_interval) < 256 && - pb_membersize(grpc_lb_v0_ServerList, servers) < 256 && - pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 256), - YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) +PB_STATIC_ASSERT((pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v0_ServerList, servers) < 256 && pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server) #endif + + diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.h b/src/core/proto/grpc/lb/v0/load_balancer.pb.h index ac836658399..87037213998 100644 --- a/src/core/proto/grpc/lb/v0/load_balancer.pb.h +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.h @@ -47,144 +47,104 @@ extern "C" { /* Enum definitions */ /* Struct definitions */ typedef struct _grpc_lb_v0_ClientStats { - bool has_total_requests; - int64_t total_requests; - bool has_client_rpc_errors; - int64_t client_rpc_errors; - bool has_dropped_requests; - int64_t dropped_requests; + bool has_total_requests; + int64_t total_requests; + bool has_client_rpc_errors; + int64_t client_rpc_errors; + bool has_dropped_requests; + int64_t dropped_requests; } grpc_lb_v0_ClientStats; typedef struct _grpc_lb_v0_Duration { - bool has_seconds; - int64_t seconds; - bool has_nanos; - int32_t nanos; + bool has_seconds; + int64_t seconds; + bool has_nanos; + int32_t nanos; } grpc_lb_v0_Duration; typedef struct _grpc_lb_v0_InitialLoadBalanceRequest { - bool has_name; - char name[128]; + bool has_name; + char name[128]; } grpc_lb_v0_InitialLoadBalanceRequest; typedef PB_BYTES_ARRAY_T(64) grpc_lb_v0_Server_load_balance_token_t; typedef struct _grpc_lb_v0_Server { - bool has_ip_address; - char ip_address[46]; - bool has_port; - int32_t port; - bool has_load_balance_token; - grpc_lb_v0_Server_load_balance_token_t load_balance_token; - bool has_drop_request; - bool drop_request; + bool has_ip_address; + char ip_address[46]; + bool has_port; + int32_t port; + bool has_load_balance_token; + grpc_lb_v0_Server_load_balance_token_t load_balance_token; + bool has_drop_request; + bool drop_request; } grpc_lb_v0_Server; typedef struct _grpc_lb_v0_InitialLoadBalanceResponse { - bool has_client_config; - char client_config[64]; - bool has_load_balancer_delegate; - char load_balancer_delegate[64]; - bool has_client_stats_report_interval; - grpc_lb_v0_Duration client_stats_report_interval; + bool has_client_config; + char client_config[64]; + bool has_load_balancer_delegate; + char load_balancer_delegate[64]; + bool has_client_stats_report_interval; + grpc_lb_v0_Duration client_stats_report_interval; } grpc_lb_v0_InitialLoadBalanceResponse; typedef struct _grpc_lb_v0_LoadBalanceRequest { - bool has_initial_request; - grpc_lb_v0_InitialLoadBalanceRequest initial_request; - bool has_client_stats; - grpc_lb_v0_ClientStats client_stats; + bool has_initial_request; + grpc_lb_v0_InitialLoadBalanceRequest initial_request; + bool has_client_stats; + grpc_lb_v0_ClientStats client_stats; } grpc_lb_v0_LoadBalanceRequest; typedef struct _grpc_lb_v0_ServerList { - pb_callback_t servers; - bool has_expiration_interval; - grpc_lb_v0_Duration expiration_interval; + pb_callback_t servers; + bool has_expiration_interval; + grpc_lb_v0_Duration expiration_interval; } grpc_lb_v0_ServerList; typedef struct _grpc_lb_v0_LoadBalanceResponse { - bool has_initial_response; - grpc_lb_v0_InitialLoadBalanceResponse initial_response; - bool has_server_list; - grpc_lb_v0_ServerList server_list; + bool has_initial_response; + grpc_lb_v0_InitialLoadBalanceResponse initial_response; + bool has_server_list; + grpc_lb_v0_ServerList server_list; } grpc_lb_v0_LoadBalanceResponse; /* Default values for struct fields */ /* Initializer values for message structs */ -#define grpc_lb_v0_Duration_init_default \ - { false, 0, false, 0 } -#define grpc_lb_v0_LoadBalanceRequest_init_default \ - { \ - false, grpc_lb_v0_InitialLoadBalanceRequest_init_default, false, \ - grpc_lb_v0_ClientStats_init_default \ - } -#define grpc_lb_v0_InitialLoadBalanceRequest_init_default \ - { false, "" } -#define grpc_lb_v0_ClientStats_init_default \ - { false, 0, false, 0, false, 0 } -#define grpc_lb_v0_LoadBalanceResponse_init_default \ - { \ - false, grpc_lb_v0_InitialLoadBalanceResponse_init_default, false, \ - grpc_lb_v0_ServerList_init_default \ - } -#define grpc_lb_v0_InitialLoadBalanceResponse_init_default \ - { false, "", false, "", false, grpc_lb_v0_Duration_init_default } -#define grpc_lb_v0_ServerList_init_default \ - { \ - { \ - { NULL } \ - , NULL \ - } \ - , false, grpc_lb_v0_Duration_init_default \ - } -#define grpc_lb_v0_Server_init_default \ - { false, "", false, 0, false, {0, {0}}, false, 0 } -#define grpc_lb_v0_Duration_init_zero \ - { false, 0, false, 0 } -#define grpc_lb_v0_LoadBalanceRequest_init_zero \ - { \ - false, grpc_lb_v0_InitialLoadBalanceRequest_init_zero, false, \ - grpc_lb_v0_ClientStats_init_zero \ - } -#define grpc_lb_v0_InitialLoadBalanceRequest_init_zero \ - { false, "" } -#define grpc_lb_v0_ClientStats_init_zero \ - { false, 0, false, 0, false, 0 } -#define grpc_lb_v0_LoadBalanceResponse_init_zero \ - { \ - false, grpc_lb_v0_InitialLoadBalanceResponse_init_zero, false, \ - grpc_lb_v0_ServerList_init_zero \ - } -#define grpc_lb_v0_InitialLoadBalanceResponse_init_zero \ - { false, "", false, "", false, grpc_lb_v0_Duration_init_zero } -#define grpc_lb_v0_ServerList_init_zero \ - { \ - { \ - { NULL } \ - , NULL \ - } \ - , false, grpc_lb_v0_Duration_init_zero \ - } -#define grpc_lb_v0_Server_init_zero \ - { false, "", false, 0, false, {0, {0}}, false, 0 } +#define grpc_lb_v0_Duration_init_default {false, 0, false, 0} +#define grpc_lb_v0_LoadBalanceRequest_init_default {false, grpc_lb_v0_InitialLoadBalanceRequest_init_default, false, grpc_lb_v0_ClientStats_init_default} +#define grpc_lb_v0_InitialLoadBalanceRequest_init_default {false, ""} +#define grpc_lb_v0_ClientStats_init_default {false, 0, false, 0, false, 0} +#define grpc_lb_v0_LoadBalanceResponse_init_default {false, grpc_lb_v0_InitialLoadBalanceResponse_init_default, false, grpc_lb_v0_ServerList_init_default} +#define grpc_lb_v0_InitialLoadBalanceResponse_init_default {false, "", false, "", false, grpc_lb_v0_Duration_init_default} +#define grpc_lb_v0_ServerList_init_default {{{NULL}, NULL}, false, grpc_lb_v0_Duration_init_default} +#define grpc_lb_v0_Server_init_default {false, "", false, 0, false, {0, {0}}, false, 0} +#define grpc_lb_v0_Duration_init_zero {false, 0, false, 0} +#define grpc_lb_v0_LoadBalanceRequest_init_zero {false, grpc_lb_v0_InitialLoadBalanceRequest_init_zero, false, grpc_lb_v0_ClientStats_init_zero} +#define grpc_lb_v0_InitialLoadBalanceRequest_init_zero {false, ""} +#define grpc_lb_v0_ClientStats_init_zero {false, 0, false, 0, false, 0} +#define grpc_lb_v0_LoadBalanceResponse_init_zero {false, grpc_lb_v0_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v0_ServerList_init_zero} +#define grpc_lb_v0_InitialLoadBalanceResponse_init_zero {false, "", false, "", false, grpc_lb_v0_Duration_init_zero} +#define grpc_lb_v0_ServerList_init_zero {{{NULL}, NULL}, false, grpc_lb_v0_Duration_init_zero} +#define grpc_lb_v0_Server_init_zero {false, "", false, 0, false, {0, {0}}, false, 0} /* Field tags (for use in manual encoding/decoding) */ #define grpc_lb_v0_ClientStats_total_requests_tag 1 #define grpc_lb_v0_ClientStats_client_rpc_errors_tag 2 #define grpc_lb_v0_ClientStats_dropped_requests_tag 3 -#define grpc_lb_v0_Duration_seconds_tag 1 -#define grpc_lb_v0_Duration_nanos_tag 2 +#define grpc_lb_v0_Duration_seconds_tag 1 +#define grpc_lb_v0_Duration_nanos_tag 2 #define grpc_lb_v0_InitialLoadBalanceRequest_name_tag 1 -#define grpc_lb_v0_Server_ip_address_tag 1 -#define grpc_lb_v0_Server_port_tag 2 +#define grpc_lb_v0_Server_ip_address_tag 1 +#define grpc_lb_v0_Server_port_tag 2 #define grpc_lb_v0_Server_load_balance_token_tag 3 -#define grpc_lb_v0_Server_drop_request_tag 4 +#define grpc_lb_v0_Server_drop_request_tag 4 #define grpc_lb_v0_InitialLoadBalanceResponse_client_config_tag 1 #define grpc_lb_v0_InitialLoadBalanceResponse_load_balancer_delegate_tag 2 #define grpc_lb_v0_InitialLoadBalanceResponse_client_stats_report_interval_tag 3 #define grpc_lb_v0_LoadBalanceRequest_initial_request_tag 1 #define grpc_lb_v0_LoadBalanceRequest_client_stats_tag 2 -#define grpc_lb_v0_ServerList_servers_tag 1 +#define grpc_lb_v0_ServerList_servers_tag 1 #define grpc_lb_v0_ServerList_expiration_interval_tag 3 #define grpc_lb_v0_LoadBalanceResponse_initial_response_tag 1 #define grpc_lb_v0_LoadBalanceResponse_server_list_tag 2 @@ -200,17 +160,18 @@ extern const pb_field_t grpc_lb_v0_ServerList_fields[3]; extern const pb_field_t grpc_lb_v0_Server_fields[5]; /* Maximum encoded size of messages (where known) */ -#define grpc_lb_v0_Duration_size 22 -#define grpc_lb_v0_LoadBalanceRequest_size 169 +#define grpc_lb_v0_Duration_size 22 +#define grpc_lb_v0_LoadBalanceRequest_size 169 #define grpc_lb_v0_InitialLoadBalanceRequest_size 131 -#define grpc_lb_v0_ClientStats_size 33 +#define grpc_lb_v0_ClientStats_size 33 #define grpc_lb_v0_InitialLoadBalanceResponse_size 156 -#define grpc_lb_v0_Server_size 127 +#define grpc_lb_v0_Server_size 127 /* Message IDs (where set with "msgid" option) */ #ifdef PB_MSGID -#define LOAD_BALANCER_MESSAGES +#define LOAD_BALANCER_MESSAGES \ + #endif diff --git a/tools/codegen/core/gen_load_balancing_proto.sh b/tools/codegen/core/gen_load_balancing_proto.sh index 114dd9d70d8..6d974ce31b9 100755 --- a/tools/codegen/core/gen_load_balancing_proto.sh +++ b/tools/codegen/core/gen_load_balancing_proto.sh @@ -70,9 +70,6 @@ read -r -d '' COPYRIGHT <<'EOF' EOF -# build clang-format docker image -docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format - CURRENT_YEAR=$(date +%Y) COPYRIGHT_FILE=$(mktemp) echo "${COPYRIGHT//$CURRENT_YEAR}" > $COPYRIGHT_FILE @@ -106,6 +103,15 @@ if [[ ! -f "${EXPECTED_OPTIONS_FILE_PATH}" ]]; then exit 4 fi +readonly VENV_DIR=$(mktemp -d) +readonly VENV_NAME="nanopb-$(date '+%Y%m%d_%H%M%S_%N')" +pushd $VENV_DIR +virtualenv $VENV_NAME +. $VENV_NAME/bin/activate +popd + +pip install protobuf==3.0.0b2 + pushd "$(dirname $1)" > /dev/null protoc \ @@ -124,10 +130,7 @@ mv -v $TMPFILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.c" cat $COPYRIGHT_FILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.h" > $TMPFILE mv -v $TMPFILE "$OUTPUT_DIR/$PROTO_BASENAME.pb.h" -readonly MOUNTPOINT='/protos' -docker run --rm=true -v ${HOST_GIT_ROOT}/gens/src/proto/grpc/lb/v0:$MOUNTPOINT \ - -t grpc_clang_format \ - clang-format-3.6 -style="{BasedOnStyle: Google, Language: Cpp}" \ - -i $MOUNTPOINT/load_balancer.pb.c $MOUNTPOINT/load_balancer.pb.h +deactivate +rm -rf $VENV_DIR popd > /dev/null diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 78d3a734e96..3b01140996b 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -33,22 +33,6 @@ set -ex apt-get install -y autoconf automake libtool curl python-virtualenv readonly NANOPB_TMP_OUTPUT="${LOCAL_GIT_ROOT}/gens/src/proto/grpc/lb/v0" -readonly VENV_DIR=$(mktemp -d) -# create a virtualenv for nanopb's compiler -pushd $VENV_DIR -readonly VENV_NAME="nanopb-$(date '+%Y%m%d_%H%M%S_%N')" -virtualenv $VENV_NAME -. $VENV_NAME/bin/activate -popd - -# install proto3 -pip install protobuf==3.0.0b2 - -# change to root directory -cd $(dirname $0)/../.. - -# build clang-format docker image -docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format # install protoc version 3 pushd third_party/protobuf diff --git a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh index 86ba8b2e90b..af0b22a07f9 100755 --- a/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh +++ b/tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh @@ -44,7 +44,7 @@ for dir in $DIRS do for glob in $GLOB do - files="$files `find /local-code/$dir -name $glob -and -not -name *.generated.*`" + files="$files `find /local-code/$dir -name $glob -and -not -name *.generated.* -and -not -name *.pb.h -and -not -name *.pb.c`" done done From ddcc39267089a4886c420af8776e572f24714cbb Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 12 Feb 2016 09:19:05 -0800 Subject: [PATCH 04/32] Fix script --- tools/distrib/check_nanopb_output.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 3b01140996b..9cb7581d87f 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -67,4 +67,3 @@ if [ $? != 0 ]; then echo "Outputs differ: $NANOPB_TMP_OUTPUT vs src/core/proto/grpc/lb/v0" exit 1 fi -deactivate From 1cbb5673179677810bd6a5632b6faae0a9b6cef4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Feb 2016 14:27:28 -0800 Subject: [PATCH 05/32] minor tweaks to C# qpswoker --- src/csharp/Grpc.IntegrationTesting/Control.cs | 419 +++++++++++++++--- .../Grpc.IntegrationTesting/QpsWorker.cs | 13 +- .../RunnerClientServerTest.cs | 4 +- .../Grpc.IntegrationTesting/ServerRunners.cs | 2 +- .../Grpc.IntegrationTesting/Services.cs | 7 +- .../Grpc.IntegrationTesting/ServicesGrpc.cs | 71 ++- .../WorkerServiceImpl.cs | 18 + 7 files changed, 468 insertions(+), 66 deletions(-) diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs index b90243c2bd5..291bc753978 100644 --- a/src/csharp/Grpc.IntegrationTesting/Control.cs +++ b/src/csharp/Grpc.IntegrationTesting/Control.cs @@ -38,7 +38,7 @@ namespace Grpc.Testing { "LmdycGMudGVzdGluZy5EZXRlcm1pbmlzdGljUGFyYW1zSAASLAoGcGFyZXRv", "GAUgASgLMhouZ3JwYy50ZXN0aW5nLlBhcmV0b1BhcmFtc0gAQgYKBGxvYWQi", "QwoOU2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2Vy", - "dmVyX2hvc3Rfb3ZlcnJpZGUYAiABKAkirwMKDENsaWVudENvbmZpZxIWCg5z", + "dmVyX2hvc3Rfb3ZlcnJpZGUYAiABKAki1gMKDENsaWVudENvbmZpZxIWCg5z", "ZXJ2ZXJfdGFyZ2V0cxgBIAMoCRItCgtjbGllbnRfdHlwZRgCIAEoDjIYLmdy", "cGMudGVzdGluZy5DbGllbnRUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgDIAEo", "CzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIkChxvdXRzdGFuZGlu", @@ -48,24 +48,27 @@ namespace Grpc.Testing { "GAogASgLMhguZ3JwYy50ZXN0aW5nLkxvYWRQYXJhbXMSMwoOcGF5bG9hZF9j", "b25maWcYCyABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxI3ChBo", "aXN0b2dyYW1fcGFyYW1zGAwgASgLMh0uZ3JwYy50ZXN0aW5nLkhpc3RvZ3Jh", - "bVBhcmFtcyI4CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBj", - "LnRlc3RpbmcuQ2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNldBgBIAEoCCJo", - "CgpDbGllbnRBcmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50ZXN0aW5nLkNs", - "aWVudENvbmZpZ0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRlc3RpbmcuTWFy", - "a0gAQgkKB2FyZ3R5cGUi9wEKDFNlcnZlckNvbmZpZxItCgtzZXJ2ZXJfdHlw", - "ZRgBIAEoDjIYLmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUKD3NlY3VyaXR5", - "X3BhcmFtcxgCIAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIM", - "CgRob3N0GAMgASgJEgwKBHBvcnQYBCABKAUSHAoUYXN5bmNfc2VydmVyX3Ro", - "cmVhZHMYByABKAUSEgoKY29yZV9saW1pdBgIIAEoBRIzCg5wYXlsb2FkX2Nv", - "bmZpZxgJIAEoCzIbLmdycGMudGVzdGluZy5QYXlsb2FkQ29uZmlnImgKClNl", - "cnZlckFyZ3MSKwoFc2V0dXAYASABKAsyGi5ncnBjLnRlc3RpbmcuU2VydmVy", - "Q29uZmlnSAASIgoEbWFyaxgCIAEoCzISLmdycGMudGVzdGluZy5NYXJrSABC", - "CQoHYXJndHlwZSJVCgxTZXJ2ZXJTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5n", - "cnBjLnRlc3RpbmcuU2VydmVyU3RhdHMSDAoEcG9ydBgCIAEoBRINCgVjb3Jl", - "cxgDIAEoBSovCgpDbGllbnRUeXBlEg8KC1NZTkNfQ0xJRU5UEAASEAoMQVNZ", - "TkNfQ0xJRU5UEAEqLwoKU2VydmVyVHlwZRIPCgtTWU5DX1NFUlZFUhAAEhAK", - "DEFTWU5DX1NFUlZFUhABKiMKB1JwY1R5cGUSCQoFVU5BUlkQABINCglTVFJF", - "QU1JTkcQAWIGcHJvdG8z")); + "bVBhcmFtcxIRCgljb3JlX2xpc3QYDSADKAUSEgoKY29yZV9saW1pdBgOIAEo", + "BSI4CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBjLnRlc3Rp", + "bmcuQ2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNldBgBIAEoCCJoCgpDbGll", + "bnRBcmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVudENv", + "bmZpZ0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRlc3RpbmcuTWFya0gAQgkK", + "B2FyZ3R5cGUi/AEKDFNlcnZlckNvbmZpZxItCgtzZXJ2ZXJfdHlwZRgBIAEo", + "DjIYLmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUKD3NlY3VyaXR5X3BhcmFt", + "cxgCIAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIMCgRwb3J0", + "GAQgASgFEhwKFGFzeW5jX3NlcnZlcl90aHJlYWRzGAcgASgFEhIKCmNvcmVf", + "bGltaXQYCCABKAUSMwoOcGF5bG9hZF9jb25maWcYCSABKAsyGy5ncnBjLnRl", + "c3RpbmcuUGF5bG9hZENvbmZpZxIRCgljb3JlX2xpc3QYCiADKAUiaAoKU2Vy", + "dmVyQXJncxIrCgVzZXR1cBgBIAEoCzIaLmdycGMudGVzdGluZy5TZXJ2ZXJD", + "b25maWdIABIiCgRtYXJrGAIgASgLMhIuZ3JwYy50ZXN0aW5nLk1hcmtIAEIJ", + "Cgdhcmd0eXBlIlUKDFNlcnZlclN0YXR1cxIoCgVzdGF0cxgBIAEoCzIZLmdy", + "cGMudGVzdGluZy5TZXJ2ZXJTdGF0cxIMCgRwb3J0GAIgASgFEg0KBWNvcmVz", + "GAMgASgFIg0KC0NvcmVSZXF1ZXN0Ih0KDENvcmVSZXNwb25zZRINCgVjb3Jl", + "cxgBIAEoBSIGCgRWb2lkKi8KCkNsaWVudFR5cGUSDwoLU1lOQ19DTElFTlQQ", + "ABIQCgxBU1lOQ19DTElFTlQQASpJCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VS", + "VkVSEAASEAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJW", + "RVIQAiojCgdScGNUeXBlEgkKBVVOQVJZEAASDQoJU1RSRUFNSU5HEAFiBnBy", + "b3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, }, new pbr::GeneratedCodeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedCodeInfo[] { @@ -76,13 +79,16 @@ namespace Grpc.Testing { new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClosedLoopParams), global::Grpc.Testing.ClosedLoopParams.Parser, null, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson", "Uniform", "Determ", "Pareto" }, new[]{ "Load" }, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.SecurityParams), global::Grpc.Testing.SecurityParams.Parser, new[]{ "UseTestCa", "ServerHostOverride" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientStatus), global::Grpc.Testing.ClientStatus.Parser, new[]{ "Stats" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Mark), global::Grpc.Testing.Mark.Parser, new[]{ "Reset" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientArgs), global::Grpc.Testing.ClientArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Host", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerArgs), global::Grpc.Testing.ServerArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null) + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreRequest), global::Grpc.Testing.CoreRequest.Parser, null, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreResponse), global::Grpc.Testing.CoreResponse.Parser, new[]{ "Cores" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null) })); } #endregion @@ -97,6 +103,7 @@ namespace Grpc.Testing { public enum ServerType { SYNC_SERVER = 0, ASYNC_SERVER = 1, + ASYNC_GENERIC_SERVER = 2, } public enum RpcType { @@ -1097,6 +1104,8 @@ namespace Grpc.Testing { LoadParams = other.loadParams_ != null ? other.LoadParams.Clone() : null; PayloadConfig = other.payloadConfig_ != null ? other.PayloadConfig.Clone() : null; HistogramParams = other.histogramParams_ != null ? other.HistogramParams.Clone() : null; + coreList_ = other.coreList_.Clone(); + coreLimit_ = other.coreLimit_; } public ClientConfig Clone() { @@ -1219,6 +1228,28 @@ namespace Grpc.Testing { } } + /// Field number for the "core_list" field. + public const int CoreListFieldNumber = 13; + private static readonly pb::FieldCodec _repeated_coreList_codec + = pb::FieldCodec.ForInt32(106); + private readonly pbc::RepeatedField coreList_ = new pbc::RepeatedField(); + /// + /// Specify the cores we should run the client on, if desired + /// + public pbc::RepeatedField CoreList { + get { return coreList_; } + } + + /// Field number for the "core_limit" field. + public const int CoreLimitFieldNumber = 14; + private int coreLimit_; + public int CoreLimit { + get { return coreLimit_; } + set { + coreLimit_ = value; + } + } + public override bool Equals(object other) { return Equals(other as ClientConfig); } @@ -1240,6 +1271,8 @@ namespace Grpc.Testing { if (!object.Equals(LoadParams, other.LoadParams)) return false; if (!object.Equals(PayloadConfig, other.PayloadConfig)) return false; if (!object.Equals(HistogramParams, other.HistogramParams)) return false; + if(!coreList_.Equals(other.coreList_)) return false; + if (CoreLimit != other.CoreLimit) return false; return true; } @@ -1255,6 +1288,8 @@ namespace Grpc.Testing { if (loadParams_ != null) hash ^= LoadParams.GetHashCode(); if (payloadConfig_ != null) hash ^= PayloadConfig.GetHashCode(); if (histogramParams_ != null) hash ^= HistogramParams.GetHashCode(); + hash ^= coreList_.GetHashCode(); + if (CoreLimit != 0) hash ^= CoreLimit.GetHashCode(); return hash; } @@ -1300,6 +1335,11 @@ namespace Grpc.Testing { output.WriteRawTag(98); output.WriteMessage(HistogramParams); } + coreList_.WriteTo(output, _repeated_coreList_codec); + if (CoreLimit != 0) { + output.WriteRawTag(112); + output.WriteInt32(CoreLimit); + } } public int CalculateSize() { @@ -1332,6 +1372,10 @@ namespace Grpc.Testing { if (histogramParams_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(HistogramParams); } + size += coreList_.CalculateSize(_repeated_coreList_codec); + if (CoreLimit != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(CoreLimit); + } return size; } @@ -1379,6 +1423,10 @@ namespace Grpc.Testing { } HistogramParams.MergeFrom(other.HistogramParams); } + coreList_.Add(other.coreList_); + if (other.CoreLimit != 0) { + CoreLimit = other.CoreLimit; + } } public void MergeFrom(pb::CodedInputStream input) { @@ -1440,6 +1488,15 @@ namespace Grpc.Testing { input.ReadMessage(histogramParams_); break; } + case 106: + case 104: { + coreList_.AddEntriesFrom(input, _repeated_coreList_codec); + break; + } + case 112: { + CoreLimit = input.ReadInt32(); + break; + } } } } @@ -1855,11 +1912,11 @@ namespace Grpc.Testing { public ServerConfig(ServerConfig other) : this() { serverType_ = other.serverType_; SecurityParams = other.securityParams_ != null ? other.SecurityParams.Clone() : null; - host_ = other.host_; port_ = other.port_; asyncServerThreads_ = other.asyncServerThreads_; coreLimit_ = other.coreLimit_; PayloadConfig = other.payloadConfig_ != null ? other.PayloadConfig.Clone() : null; + coreList_ = other.coreList_.Clone(); } public ServerConfig Clone() { @@ -1886,19 +1943,6 @@ namespace Grpc.Testing { } } - /// Field number for the "host" field. - public const int HostFieldNumber = 3; - private string host_ = ""; - /// - /// Host on which to listen. - /// - public string Host { - get { return host_; } - set { - host_ = pb::Preconditions.CheckNotNull(value, "value"); - } - } - /// Field number for the "port" field. public const int PortFieldNumber = 4; private int port_; @@ -1929,7 +1973,7 @@ namespace Grpc.Testing { public const int CoreLimitFieldNumber = 8; private int coreLimit_; /// - /// restrict core usage, currently unused + /// Specify the number of cores to limit server to, if desired /// public int CoreLimit { get { return coreLimit_; } @@ -1941,6 +1985,9 @@ namespace Grpc.Testing { /// Field number for the "payload_config" field. public const int PayloadConfigFieldNumber = 9; private global::Grpc.Testing.PayloadConfig payloadConfig_; + /// + /// payload config, used in generic server + /// public global::Grpc.Testing.PayloadConfig PayloadConfig { get { return payloadConfig_; } set { @@ -1948,6 +1995,18 @@ namespace Grpc.Testing { } } + /// Field number for the "core_list" field. + public const int CoreListFieldNumber = 10; + private static readonly pb::FieldCodec _repeated_coreList_codec + = pb::FieldCodec.ForInt32(82); + private readonly pbc::RepeatedField coreList_ = new pbc::RepeatedField(); + /// + /// Specify the cores we should run the server on, if desired + /// + public pbc::RepeatedField CoreList { + get { return coreList_; } + } + public override bool Equals(object other) { return Equals(other as ServerConfig); } @@ -1961,11 +2020,11 @@ namespace Grpc.Testing { } if (ServerType != other.ServerType) return false; if (!object.Equals(SecurityParams, other.SecurityParams)) return false; - if (Host != other.Host) return false; if (Port != other.Port) return false; if (AsyncServerThreads != other.AsyncServerThreads) return false; if (CoreLimit != other.CoreLimit) return false; if (!object.Equals(PayloadConfig, other.PayloadConfig)) return false; + if(!coreList_.Equals(other.coreList_)) return false; return true; } @@ -1973,11 +2032,11 @@ namespace Grpc.Testing { int hash = 1; if (ServerType != global::Grpc.Testing.ServerType.SYNC_SERVER) hash ^= ServerType.GetHashCode(); if (securityParams_ != null) hash ^= SecurityParams.GetHashCode(); - if (Host.Length != 0) hash ^= Host.GetHashCode(); if (Port != 0) hash ^= Port.GetHashCode(); if (AsyncServerThreads != 0) hash ^= AsyncServerThreads.GetHashCode(); if (CoreLimit != 0) hash ^= CoreLimit.GetHashCode(); if (payloadConfig_ != null) hash ^= PayloadConfig.GetHashCode(); + hash ^= coreList_.GetHashCode(); return hash; } @@ -1994,10 +2053,6 @@ namespace Grpc.Testing { output.WriteRawTag(18); output.WriteMessage(SecurityParams); } - if (Host.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Host); - } if (Port != 0) { output.WriteRawTag(32); output.WriteInt32(Port); @@ -2014,6 +2069,7 @@ namespace Grpc.Testing { output.WriteRawTag(74); output.WriteMessage(PayloadConfig); } + coreList_.WriteTo(output, _repeated_coreList_codec); } public int CalculateSize() { @@ -2024,9 +2080,6 @@ namespace Grpc.Testing { if (securityParams_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SecurityParams); } - if (Host.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Host); - } if (Port != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Port); } @@ -2039,6 +2092,7 @@ namespace Grpc.Testing { if (payloadConfig_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(PayloadConfig); } + size += coreList_.CalculateSize(_repeated_coreList_codec); return size; } @@ -2055,9 +2109,6 @@ namespace Grpc.Testing { } SecurityParams.MergeFrom(other.SecurityParams); } - if (other.Host.Length != 0) { - Host = other.Host; - } if (other.Port != 0) { Port = other.Port; } @@ -2073,6 +2124,7 @@ namespace Grpc.Testing { } PayloadConfig.MergeFrom(other.PayloadConfig); } + coreList_.Add(other.coreList_); } public void MergeFrom(pb::CodedInputStream input) { @@ -2093,10 +2145,6 @@ namespace Grpc.Testing { input.ReadMessage(securityParams_); break; } - case 26: { - Host = input.ReadString(); - break; - } case 32: { Port = input.ReadInt32(); break; @@ -2116,6 +2164,11 @@ namespace Grpc.Testing { input.ReadMessage(payloadConfig_); break; } + case 82: + case 80: { + coreList_.AddEntriesFrom(input, _repeated_coreList_codec); + break; + } } } } @@ -2347,7 +2400,7 @@ namespace Grpc.Testing { public const int CoresFieldNumber = 3; private int cores_; /// - /// Number of cores on the server. See gpr_cpu_num_cores. + /// Number of cores available to the server /// public int Cores { get { return cores_; } @@ -2460,6 +2513,264 @@ namespace Grpc.Testing { } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class CoreRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CoreRequest()); + public static pb::MessageParser Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[14]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public CoreRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + public CoreRequest(CoreRequest other) : this() { + } + + public CoreRequest Clone() { + return new CoreRequest(this); + } + + public override bool Equals(object other) { + return Equals(other as CoreRequest); + } + + public bool Equals(CoreRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(CoreRequest other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class CoreResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CoreResponse()); + public static pb::MessageParser Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[15]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public CoreResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + public CoreResponse(CoreResponse other) : this() { + cores_ = other.cores_; + } + + public CoreResponse Clone() { + return new CoreResponse(this); + } + + /// Field number for the "cores" field. + public const int CoresFieldNumber = 1; + private int cores_; + /// + /// Number of cores available on the server + /// + public int Cores { + get { return cores_; } + set { + cores_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as CoreResponse); + } + + public bool Equals(CoreResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Cores != other.Cores) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Cores != 0) hash ^= Cores.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Cores != 0) { + output.WriteRawTag(8); + output.WriteInt32(Cores); + } + } + + public int CalculateSize() { + int size = 0; + if (Cores != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Cores); + } + return size; + } + + public void MergeFrom(CoreResponse other) { + if (other == null) { + return; + } + if (other.Cores != 0) { + Cores = other.Cores; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Cores = input.ReadInt32(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Void : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Void()); + public static pb::MessageParser Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[16]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public Void() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Void(Void other) : this() { + } + + public Void Clone() { + return new Void(this); + } + + public override bool Equals(object other) { + return Equals(other as Void); + } + + public bool Equals(Void other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(Void other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + #endregion } diff --git a/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs b/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs index 686b4843453..a7c9fa894de 100644 --- a/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs +++ b/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs @@ -85,24 +85,27 @@ namespace Grpc.IntegrationTesting } var workerServer = new QpsWorker(options); - workerServer.Run(); + workerServer.RunAsync().Wait(); } - private void Run() + private async Task RunAsync() { string host = "0.0.0.0"; int port = options.DriverPort; + var tcs = new TaskCompletionSource(); + var workerServiceImpl = new WorkerServiceImpl(() => { Task.Run(() => tcs.SetResult(null)); }); + var server = new Server { - Services = { WorkerService.BindService(new WorkerServiceImpl()) }, + Services = { WorkerService.BindService(workerServiceImpl) }, Ports = { new ServerPort(host, options.DriverPort, ServerCredentials.Insecure )} }; int boundPort = server.Ports.Single().BoundPort; Console.WriteLine("Running qps worker server on " + string.Format("{0}:{1}", host, boundPort)); server.Start(); - - server.ShutdownTask.Wait(); + await tcs.Task; + await server.ShutdownAsync(); } } } diff --git a/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs index 3dd91b79485..e87f3b7dc1b 100644 --- a/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs @@ -48,7 +48,6 @@ namespace Grpc.IntegrationTesting /// public class RunnerClientServerTest { - const string Host = "localhost"; IServerRunner serverRunner; [TestFixtureSetUp] @@ -57,7 +56,6 @@ namespace Grpc.IntegrationTesting var serverConfig = new ServerConfig { ServerType = ServerType.ASYNC_SERVER, - Host = Host, PayloadConfig = new PayloadConfig { SimpleParams = new SimpleProtoParams @@ -83,7 +81,7 @@ namespace Grpc.IntegrationTesting { var config = new ClientConfig { - ServerTargets = { string.Format("{0}:{1}", Host, serverRunner.BoundPort) }, + ServerTargets = { string.Format("{0}:{1}", "localhost", serverRunner.BoundPort) }, RpcType = RpcType.UNARY, LoadParams = new LoadParams { ClosedLoop = new ClosedLoopParams() }, PayloadConfig = new PayloadConfig diff --git a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs index e8be7758cee..d401fa82d21 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs @@ -65,7 +65,7 @@ namespace Grpc.IntegrationTesting var server = new Server { Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) }, - Ports = { new ServerPort(config.Host, config.Port, credentials) } + Ports = { new ServerPort("[::]", config.Port, credentials) } }; server.Start(); diff --git a/src/csharp/Grpc.IntegrationTesting/Services.cs b/src/csharp/Grpc.IntegrationTesting/Services.cs index 04a092ccd79..a8475c18172 100644 --- a/src/csharp/Grpc.IntegrationTesting/Services.cs +++ b/src/csharp/Grpc.IntegrationTesting/Services.cs @@ -29,11 +29,14 @@ namespace Grpc.Testing { "QmVuY2htYXJrU2VydmljZRJGCglVbmFyeUNhbGwSGy5ncnBjLnRlc3Rpbmcu", "U2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGluZy5TaW1wbGVSZXNwb25zZRJO", "Cg1TdHJlYW1pbmdDYWxsEhsuZ3JwYy50ZXN0aW5nLlNpbXBsZVJlcXVlc3Qa", - "HC5ncnBjLnRlc3RpbmcuU2ltcGxlUmVzcG9uc2UoATABMp0BCg1Xb3JrZXJT", + "HC5ncnBjLnRlc3RpbmcuU2ltcGxlUmVzcG9uc2UoATABMpcCCg1Xb3JrZXJT", "ZXJ2aWNlEkUKCVJ1blNlcnZlchIYLmdycGMudGVzdGluZy5TZXJ2ZXJBcmdz", "GhouZ3JwYy50ZXN0aW5nLlNlcnZlclN0YXR1cygBMAESRQoJUnVuQ2xpZW50", "EhguZ3JwYy50ZXN0aW5nLkNsaWVudEFyZ3MaGi5ncnBjLnRlc3RpbmcuQ2xp", - "ZW50U3RhdHVzKAEwAWIGcHJvdG8z")); + "ZW50U3RhdHVzKAEwARJCCglDb3JlQ291bnQSGS5ncnBjLnRlc3RpbmcuQ29y", + "ZVJlcXVlc3QaGi5ncnBjLnRlc3RpbmcuQ29yZVJlc3BvbnNlEjQKClF1aXRX", + "b3JrZXISEi5ncnBjLnRlc3RpbmcuVm9pZBoSLmdycGMudGVzdGluZy5Wb2lk", + "YgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.MessagesReflection.Descriptor, global::Grpc.Testing.ControlReflection.Descriptor, }, new pbr::GeneratedCodeInfo(null, null)); diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs index dd30afb427f..996439afbf1 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs @@ -114,6 +114,9 @@ namespace Grpc.Testing { static readonly Marshaller __Marshaller_ServerStatus = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ServerStatus.Parser.ParseFrom); static readonly Marshaller __Marshaller_ClientArgs = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientArgs.Parser.ParseFrom); static readonly Marshaller __Marshaller_ClientStatus = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ClientStatus.Parser.ParseFrom); + static readonly Marshaller __Marshaller_CoreRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreRequest.Parser.ParseFrom); + static readonly Marshaller __Marshaller_CoreResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.CoreResponse.Parser.ParseFrom); + static readonly Marshaller __Marshaller_Void = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); static readonly Method __Method_RunServer = new Method( MethodType.DuplexStreaming, @@ -129,6 +132,20 @@ namespace Grpc.Testing { __Marshaller_ClientArgs, __Marshaller_ClientStatus); + static readonly Method __Method_CoreCount = new Method( + MethodType.Unary, + __ServiceName, + "CoreCount", + __Marshaller_CoreRequest, + __Marshaller_CoreResponse); + + static readonly Method __Method_QuitWorker = new Method( + MethodType.Unary, + __ServiceName, + "QuitWorker", + __Marshaller_Void, + __Marshaller_Void); + // service descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor { @@ -142,6 +159,14 @@ namespace Grpc.Testing { AsyncDuplexStreamingCall RunServer(CallOptions options); AsyncDuplexStreamingCall RunClient(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); AsyncDuplexStreamingCall RunClient(CallOptions options); + global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, CallOptions options); + AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, CallOptions options); + global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, CallOptions options); + AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, CallOptions options); } // server-side interface @@ -149,6 +174,8 @@ namespace Grpc.Testing { { Task RunServer(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context); Task RunClient(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context); + Task CoreCount(global::Grpc.Testing.CoreRequest request, ServerCallContext context); + Task QuitWorker(global::Grpc.Testing.Void request, ServerCallContext context); } // client stub @@ -177,6 +204,46 @@ namespace Grpc.Testing { var call = CreateCall(__Method_RunClient, options); return Calls.AsyncDuplexStreamingCall(call); } + public global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var call = CreateCall(__Method_CoreCount, new CallOptions(headers, deadline, cancellationToken)); + return Calls.BlockingUnaryCall(call, request); + } + public global::Grpc.Testing.CoreResponse CoreCount(global::Grpc.Testing.CoreRequest request, CallOptions options) + { + var call = CreateCall(__Method_CoreCount, options); + return Calls.BlockingUnaryCall(call, request); + } + public AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var call = CreateCall(__Method_CoreCount, new CallOptions(headers, deadline, cancellationToken)); + return Calls.AsyncUnaryCall(call, request); + } + public AsyncUnaryCall CoreCountAsync(global::Grpc.Testing.CoreRequest request, CallOptions options) + { + var call = CreateCall(__Method_CoreCount, options); + return Calls.AsyncUnaryCall(call, request); + } + public global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var call = CreateCall(__Method_QuitWorker, new CallOptions(headers, deadline, cancellationToken)); + return Calls.BlockingUnaryCall(call, request); + } + public global::Grpc.Testing.Void QuitWorker(global::Grpc.Testing.Void request, CallOptions options) + { + var call = CreateCall(__Method_QuitWorker, options); + return Calls.BlockingUnaryCall(call, request); + } + public AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var call = CreateCall(__Method_QuitWorker, new CallOptions(headers, deadline, cancellationToken)); + return Calls.AsyncUnaryCall(call, request); + } + public AsyncUnaryCall QuitWorkerAsync(global::Grpc.Testing.Void request, CallOptions options) + { + var call = CreateCall(__Method_QuitWorker, options); + return Calls.AsyncUnaryCall(call, request); + } } // creates service definition that can be registered with a server @@ -184,7 +251,9 @@ namespace Grpc.Testing { { return ServerServiceDefinition.CreateBuilder(__ServiceName) .AddMethod(__Method_RunServer, serviceImpl.RunServer) - .AddMethod(__Method_RunClient, serviceImpl.RunClient).Build(); + .AddMethod(__Method_RunClient, serviceImpl.RunClient) + .AddMethod(__Method_CoreCount, serviceImpl.CoreCount) + .AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker).Build(); } // creates a new client diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs index bb2918bf463..4edd7027540 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs @@ -47,6 +47,13 @@ namespace Grpc.Testing /// public class WorkerServiceImpl : WorkerService.IWorkerService { + readonly Action stopRequestHandler; + + public WorkerServiceImpl(Action stopRequestHandler) + { + this.stopRequestHandler = Grpc.Core.Utils.Preconditions.CheckNotNull(stopRequestHandler); + } + public async Task RunServer(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) { Grpc.Core.Utils.Preconditions.CheckState(await requestStream.MoveNext()); @@ -92,5 +99,16 @@ namespace Grpc.Testing } await runner.StopAsync(); } + + public Task CoreCount(CoreRequest request, ServerCallContext context) + { + return Task.FromResult(new CoreResponse { Cores = Environment.ProcessorCount }); + } + + public Task QuitWorker(Void request, ServerCallContext context) + { + stopRequestHandler(); + return Task.FromResult(new Void()); + } } } From 13b63a0711bd32728fb45ee4352cc3a28b31c3df Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Feb 2016 14:29:32 -0800 Subject: [PATCH 06/32] fix copyrights --- src/csharp/Grpc.IntegrationTesting/QpsWorker.cs | 2 +- src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs | 2 +- src/csharp/Grpc.IntegrationTesting/ServerRunners.cs | 2 +- src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs b/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs index a7c9fa894de..e407792c4b5 100644 --- a/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs +++ b/src/csharp/Grpc.IntegrationTesting/QpsWorker.cs @@ -1,6 +1,6 @@ #region Copyright notice and license -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs index e87f3b7dc1b..06d5ee93d88 100644 --- a/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/RunnerClientServerTest.cs @@ -1,6 +1,6 @@ #region Copyright notice and license -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs index d401fa82d21..7d6f1a51794 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs @@ -1,6 +1,6 @@ #region Copyright notice and license -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs index 4edd7027540..62d03edbdde 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs @@ -1,6 +1,6 @@ #region Copyright notice and license -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without From 9c5f0b160576ac33147b7386ffe15b01a54eb4dc Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 18 Feb 2016 15:00:07 -0800 Subject: [PATCH 07/32] Move Node JUnit reports.xml to repo root --- tools/run_tests/run_node.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh index 178584ae8ed..fb84b79e7fc 100755 --- a/tools/run_tests/run_node.sh +++ b/tools/run_tests/run_node.sh @@ -44,6 +44,7 @@ root=`pwd` test_directory='src/node/test' timeout=8000 + if [ "$CONFIG" = "gcov" ] then ./node_modules/.bin/istanbul cover --dir reports/node_coverage \ @@ -58,7 +59,7 @@ then echo '' > \ ../reports/node_coverage/index.html else - JUNIT_REPORT_PATH=src/node/reports.xml JUNIT_REPORT_STACK=1 \ + JUNIT_REPORT_PATH=reports.xml JUNIT_REPORT_STACK=1 \ ./node_modules/.bin/mocha --timeout $timeout \ --reporter mocha-jenkins-reporter $test_directory fi From b46672602965727de647a720b6cc3f3dca436a11 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 18 Feb 2016 15:35:56 -0800 Subject: [PATCH 08/32] Extract reports.xml files from docker images in reports.zip --- tools/jenkins/build_docker_and_run_tests.sh | 5 ----- tools/jenkins/docker_run_tests.sh | 1 + tools/run_tests/run_node.sh | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/jenkins/build_docker_and_run_tests.sh b/tools/jenkins/build_docker_and_run_tests.sh index e2ac7518f09..0ddf261032c 100755 --- a/tools/jenkins/build_docker_and_run_tests.sh +++ b/tools/jenkins/build_docker_and_run_tests.sh @@ -82,11 +82,6 @@ docker run \ $DOCKER_IMAGE_NAME \ bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || DOCKER_FAILED="true" -if [ "$XML_REPORT" != "" ] -then - docker cp "$CONTAINER_NAME:/var/local/git/grpc/$XML_REPORT" $git_root || true -fi - docker cp "$CONTAINER_NAME:/var/local/git/grpc/reports.zip" $git_root || true unzip -o $git_root/reports.zip -d $git_root || true rm -f reports.zip diff --git a/tools/jenkins/docker_run_tests.sh b/tools/jenkins/docker_run_tests.sh index 282b8573511..578bda170ae 100755 --- a/tools/jenkins/docker_run_tests.sh +++ b/tools/jenkins/docker_run_tests.sh @@ -60,5 +60,6 @@ echo '' >> index.html cd .. zip -r reports.zip reports +find . -name reports.xml | xargs zip reports.xml exit $exit_code diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh index fb84b79e7fc..178584ae8ed 100755 --- a/tools/run_tests/run_node.sh +++ b/tools/run_tests/run_node.sh @@ -44,7 +44,6 @@ root=`pwd` test_directory='src/node/test' timeout=8000 - if [ "$CONFIG" = "gcov" ] then ./node_modules/.bin/istanbul cover --dir reports/node_coverage \ @@ -59,7 +58,7 @@ then echo '' > \ ../reports/node_coverage/index.html else - JUNIT_REPORT_PATH=reports.xml JUNIT_REPORT_STACK=1 \ + JUNIT_REPORT_PATH=src/node/reports.xml JUNIT_REPORT_STACK=1 \ ./node_modules/.bin/mocha --timeout $timeout \ --reporter mocha-jenkins-reporter $test_directory fi From 9ddd46587827cd0498b67a3972ec9c263ba393ab Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 18 Feb 2016 15:39:18 -0800 Subject: [PATCH 09/32] Fixed zip file name --- tools/jenkins/docker_run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jenkins/docker_run_tests.sh b/tools/jenkins/docker_run_tests.sh index 578bda170ae..2e40f8fd65a 100755 --- a/tools/jenkins/docker_run_tests.sh +++ b/tools/jenkins/docker_run_tests.sh @@ -60,6 +60,6 @@ echo '' >> index.html cd .. zip -r reports.zip reports -find . -name reports.xml | xargs zip reports.xml +find . -name reports.xml | xargs zip reports.zip exit $exit_code From 3b28872210fc2019eba52f310e824b1aa864f8f5 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 19 Feb 2016 00:28:28 -0800 Subject: [PATCH 10/32] 1. Adjust tsan/asan/msan slowdowns according to documentation tsan documentation says 2-20x, so set it at 20x asan documentation says 1.2-2.7x, so set it at 3x msan documentation says 2-4x, so set it at 4x This is now much less optimistic than before 2. Reactive tsan tests for qps_test 3. Set CPU load for qps_openloop_test 4. Divide qps_openloop_test Poisson rate by the slowdown factor of the configuration --- Makefile | 8 ++++---- build.yaml | 11 +++++------ test/cpp/qps/qps_openloop_test.cc | 5 +++-- tools/run_tests/configs.json | 8 ++++---- tools/run_tests/tests.json | 6 ++---- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 6c7febdabc3..445e6bcdf33 100644 --- a/Makefile +++ b/Makefile @@ -121,7 +121,7 @@ LD_asan-noleaks = clang LDXX_asan-noleaks = clang++ CPPFLAGS_asan-noleaks = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS LDFLAGS_asan-noleaks = -fsanitize=address -DEFINES_asan-noleaks += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=1.5 +DEFINES_asan-noleaks += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3 VALID_CONFIG_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 @@ -177,7 +177,7 @@ LD_asan = clang LDXX_asan = clang++ CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS LDFLAGS_asan = -fsanitize=address -DEFINES_asan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=1.5 +DEFINES_asan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3 VALID_CONFIG_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1 @@ -187,7 +187,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS LDFLAGS_tsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) -DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=2 +DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 @@ -198,7 +198,7 @@ LDXX_msan = clang++ CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) DEFINES_msan = NDEBUG -DEFINES_msan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=2 +DEFINES_msan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=4 VALID_CONFIG_mutrace = 1 CC_mutrace = $(DEFAULT_CC) diff --git a/build.yaml b/build.yaml index b639b5d21e6..e60300cbc52 100644 --- a/build.yaml +++ b/build.yaml @@ -2310,6 +2310,7 @@ targets: - linux - posix - name: qps_openloop_test + cpu_cost: 10 build: test language: c++ src: @@ -2342,8 +2343,6 @@ targets: - gpr_test_util - gpr - grpc++_test_config - exclude_configs: - - tsan platforms: - mac - linux @@ -2631,7 +2630,7 @@ configs: test_environ: ASAN_OPTIONS: detect_leaks=1:color=always LSAN_OPTIONS: suppressions=tools/lsan_suppressions.txt:report_objects=1 - timeout_multiplier: 1.5 + timeout_multiplier: 3 asan-noleaks: CC: clang CPPFLAGS: -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument @@ -2643,7 +2642,7 @@ configs: compile_the_world: true test_environ: ASAN_OPTIONS: detect_leaks=0:color=always - timeout_multiplier: 1.5 + timeout_multiplier: 3 basicprof: CPPFLAGS: -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC DEFINES: NDEBUG @@ -2682,7 +2681,7 @@ configs: -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDXX: clang++ compile_the_world: true - timeout_multiplier: 2 + timeout_multiplier: 4 mutrace: CPPFLAGS: -O0 DEFINES: _DEBUG DEBUG @@ -2704,7 +2703,7 @@ configs: compile_the_world: true test_environ: TSAN_OPTIONS: suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1 - timeout_multiplier: 2 + timeout_multiplier: 20 ubsan: CC: clang CPPFLAGS: -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 0ac41d9f963..90f21733ee2 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -35,6 +35,7 @@ #include +#include "test/core/util/test_config.h" #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" #include "test/cpp/util/benchmark_config.h" @@ -55,11 +56,11 @@ static void RunQPS() { client_config.set_async_client_threads(8); client_config.set_rpc_type(STREAMING); client_config.mutable_load_params()->mutable_poisson()->set_offered_load( - 1000.0); + 1000.0/g_fixture_slowdown_factor); ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_async_server_threads(4); + server_config.set_async_server_threads(8); const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); diff --git a/tools/run_tests/configs.json b/tools/run_tests/configs.json index 9d7b8a3c725..aacca409f7c 100644 --- a/tools/run_tests/configs.json +++ b/tools/run_tests/configs.json @@ -18,7 +18,7 @@ "environ": { "ASAN_OPTIONS": "detect_leaks=0:color=always" }, - "timeout_multiplier": 1.5 + "timeout_multiplier": 3 }, { "config": "ubsan", @@ -48,18 +48,18 @@ "ASAN_OPTIONS": "detect_leaks=1:color=always", "LSAN_OPTIONS": "suppressions=tools/lsan_suppressions.txt:report_objects=1" }, - "timeout_multiplier": 1.5 + "timeout_multiplier": 3 }, { "config": "tsan", "environ": { "TSAN_OPTIONS": "suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1" }, - "timeout_multiplier": 2 + "timeout_multiplier": 20 }, { "config": "msan", - "timeout_multiplier": 2 + "timeout_multiplier": 4 }, { "config": "mutrace" diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index ea9c129101d..6f98a2c179f 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -2104,7 +2104,7 @@ "mac", "posix" ], - "cpu_cost": 1.0, + "cpu_cost": 10, "exclude_configs": [], "flaky": false, "language": "c++", @@ -2123,9 +2123,7 @@ "posix" ], "cpu_cost": 10, - "exclude_configs": [ - "tsan" - ], + "exclude_configs": [], "flaky": false, "language": "c++", "name": "qps_test", From 2d435b9178b04a38168fc9d54d0a6dbb235baa93 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 19 Feb 2016 00:42:08 -0800 Subject: [PATCH 11/32] Fix the slowdown factor --- test/cpp/qps/qps_openloop_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 90f21733ee2..27f266b32be 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -56,7 +56,7 @@ static void RunQPS() { client_config.set_async_client_threads(8); client_config.set_rpc_type(STREAMING); client_config.mutable_load_params()->mutable_poisson()->set_offered_load( - 1000.0/g_fixture_slowdown_factor); + 1000.0 / GRPC_TEST_SLOWDOWN_FACTOR); ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); From e046f712c5ed1723972af41c1ff402a33d538e29 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 18 Feb 2016 16:06:10 -0800 Subject: [PATCH 12/32] build protoc artifacts on mac and linux --- .../grpc_artifact_protoc/Dockerfile | 70 +++++++++++++++++++ tools/run_tests/artifact_targets.py | 50 ++++++++++++- tools/run_tests/build_artifact_protoc.sh | 41 +++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 tools/dockerfile/grpc_artifact_protoc/Dockerfile create mode 100755 tools/run_tests/build_artifact_protoc.sh diff --git a/tools/dockerfile/grpc_artifact_protoc/Dockerfile b/tools/dockerfile/grpc_artifact_protoc/Dockerfile new file mode 100644 index 00000000000..0e405655718 --- /dev/null +++ b/tools/dockerfile/grpc_artifact_protoc/Dockerfile @@ -0,0 +1,70 @@ +# Copyright 2016, 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. + +# Docker file for building protoc and gRPC protoc plugin artifacts. +# forked from https://github.com/google/protobuf/blob/master/protoc-artifacts/Dockerfile + +FROM centos:6.6 + +RUN yum install -y git \ + tar \ + wget \ + make \ + autoconf \ + curl-devel \ + unzip \ + automake \ + libtool \ + glibc-static.i686 \ + glibc-devel \ + glibc-devel.i686 + +# Install Java 8 +RUN wget -q --no-cookies --no-check-certificate \ + --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz" \ + -O - | tar xz -C /var/local +ENV JAVA_HOME /var/local/jdk1.8.0_45 +ENV PATH $JAVA_HOME/bin:$PATH + +# Install Maven +RUN wget -q http://apache.cs.utah.edu/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz -O - | \ + tar xz -C /var/local +ENV PATH /var/local/apache-maven-3.3.3/bin:$PATH + +# Install GCC 4.7 to support -static-libstdc++ +RUN wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -P /etc/yum.repos.d +RUN bash -c 'echo "enabled=1" >> /etc/yum.repos.d/devtools-1.1.repo' +RUN bash -c "sed -e 's/\$basearch/i386/g' /etc/yum.repos.d/devtools-1.1.repo > /etc/yum.repos.d/devtools-i386-1.1.repo" +RUN sed -e 's/testing-/testing-i386-/g' -i /etc/yum.repos.d/devtools-i386-1.1.repo +RUN yum install -y devtoolset-1.1 \ + devtoolset-1.1-libstdc++-devel \ + devtoolset-1.1-libstdc++-devel.i686 + +# Start in devtoolset environment that uses GCC 4.7 +CMD ["scl", "enable", "devtoolset-1.1", "bash"] \ No newline at end of file diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py index 9cd02c5e432..3933564273d 100644 --- a/tools/run_tests/artifact_targets.py +++ b/tools/run_tests/artifact_targets.py @@ -79,6 +79,12 @@ def macos_arch_env(arch): raise Exception('Unsupported arch') return {'CFLAGS': arch_arg, 'LDFLAGS': arch_arg} +_MACOS_COMPAT_FLAG = '-mmacosx-version-min=10.7' + +_ARCH_FLAG_MAP = { + 'x86': '-m32', + 'x64': '-m64' +} class PythonArtifact: """Builds Python artifacts.""" @@ -190,6 +196,7 @@ class CSharpExtArtifact: def __str__(self): return self.name + node_gyp_arch_map = { 'x86': 'ia32', 'x64': 'x64' @@ -226,6 +233,43 @@ class NodeExtArtifact: self.gyp_arch]) +class ProtocArtifact: + """Builds protoc and protoc-plugin artifacts""" + + def __init__(self, platform, arch): + self.name = 'protoc_%s_%s' % (platform, arch) + self.platform = platform + self.arch = arch + self.labels = ['artifact', 'protoc', platform, arch] + + def pre_build_jobspecs(self): + return [] + + def build_jobspec(self): + if self.platform != 'windows': + cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] + ldflags = ' -static-libgcc -static-libstdc++ -s %s' % _ARCH_FLAG_MAP[self.arch] + environ={'CONFIG': 'opt', + 'CXXFLAGS': cxxflags, + 'LDFLAGS': ldflags, + 'PROTOBUF_LDFLAGS_EXTRA': ldflags} + if self.platform == 'linux': + return create_docker_jobspec(self.name, + 'tools/dockerfile/grpc_artifact_protoc', + 'tools/run_tests/build_artifact_protoc.sh', + environ=environ) + else: + environ['CXXFLAGS'] += ' %s' % _MACOS_COMPAT_FLAG + return create_jobspec(self.name, + ['tools/run_tests/build_artifact_protoc.sh'], + environ=environ) + else: + raise Exception('Not yet supported') + + def __str__(self): + return self.name + + def targets(): """Gets list of supported targets""" return ([Cls(platform, arch) @@ -237,4 +281,8 @@ def targets(): PythonArtifact('macos', 'x64'), RubyArtifact('linux', 'x86'), RubyArtifact('linux', 'x64'), - RubyArtifact('macos', 'x64')]) + RubyArtifact('macos', 'x64'), + ProtocArtifact('linux', 'x86'), + ProtocArtifact('linux', 'x64'), + ProtocArtifact('macos', 'x86'), + ProtocArtifact('macos', 'x64')]) diff --git a/tools/run_tests/build_artifact_protoc.sh b/tools/run_tests/build_artifact_protoc.sh new file mode 100755 index 00000000000..161d3a84d6e --- /dev/null +++ b/tools/run_tests/build_artifact_protoc.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Copyright 2016, 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. + +# Use devtoolset environment that has GCC 4.7 before set -ex +source scl_source enable devtoolset-1.1 + +set -ex + +cd $(dirname $0)/../.. + +make plugins + +mkdir -p artifacts +cp bins/opt/protobuf/protoc bins/opt/*_plugin artifacts/ From 2146fe8f88a06669e29a0cef2474e4063e7efe53 Mon Sep 17 00:00:00 2001 From: vjpai Date: Fri, 19 Feb 2016 10:05:57 -0800 Subject: [PATCH 13/32] Tune down multiplier for tsan to 5 --- Makefile | 2 +- build.yaml | 2 +- tools/run_tests/configs.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 445e6bcdf33..cf7af69ddca 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,7 @@ LD_tsan = clang LDXX_tsan = clang++ CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS LDFLAGS_tsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) -DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 +DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 VALID_CONFIG_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1 diff --git a/build.yaml b/build.yaml index e60300cbc52..a8646a2f37a 100644 --- a/build.yaml +++ b/build.yaml @@ -2703,7 +2703,7 @@ configs: compile_the_world: true test_environ: TSAN_OPTIONS: suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1 - timeout_multiplier: 20 + timeout_multiplier: 5 ubsan: CC: clang CPPFLAGS: -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument diff --git a/tools/run_tests/configs.json b/tools/run_tests/configs.json index aacca409f7c..cbb8ec57b61 100644 --- a/tools/run_tests/configs.json +++ b/tools/run_tests/configs.json @@ -55,7 +55,7 @@ "environ": { "TSAN_OPTIONS": "suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1" }, - "timeout_multiplier": 20 + "timeout_multiplier": 5 }, { "config": "msan", From e7b7d86fde3475978c3f7d4dfaabaf549152cd02 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 19 Feb 2016 09:49:35 -0800 Subject: [PATCH 14/32] fix protoc artifact build on mac --- tools/run_tests/artifact_targets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py index 3933564273d..5d678a561f9 100644 --- a/tools/run_tests/artifact_targets.py +++ b/tools/run_tests/artifact_targets.py @@ -248,7 +248,9 @@ class ProtocArtifact: def build_jobspec(self): if self.platform != 'windows': cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] - ldflags = ' -static-libgcc -static-libstdc++ -s %s' % _ARCH_FLAG_MAP[self.arch] + ldflags = '%s' % _ARCH_FLAG_MAP[self.arch] + if self.platform != 'macos': + ldflags += ' -static-libgcc -static-libstdc++ -s' environ={'CONFIG': 'opt', 'CXXFLAGS': cxxflags, 'LDFLAGS': ldflags, @@ -259,7 +261,7 @@ class ProtocArtifact: 'tools/run_tests/build_artifact_protoc.sh', environ=environ) else: - environ['CXXFLAGS'] += ' %s' % _MACOS_COMPAT_FLAG + environ['CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG return create_jobspec(self.name, ['tools/run_tests/build_artifact_protoc.sh'], environ=environ) From 07591a5dfcc04266410084a249b7dda53e2a9d43 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 19 Feb 2016 10:28:24 -0800 Subject: [PATCH 15/32] fix centos6.6 docker build with overlay --- .../grpc_artifact_protoc/Dockerfile | 21 +++++++------------ tools/run_tests/artifact_targets.py | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_protoc/Dockerfile b/tools/dockerfile/grpc_artifact_protoc/Dockerfile index 0e405655718..74fc96c00ed 100644 --- a/tools/dockerfile/grpc_artifact_protoc/Dockerfile +++ b/tools/dockerfile/grpc_artifact_protoc/Dockerfile @@ -45,26 +45,21 @@ RUN yum install -y git \ glibc-devel \ glibc-devel.i686 -# Install Java 8 -RUN wget -q --no-cookies --no-check-certificate \ - --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz" \ - -O - | tar xz -C /var/local -ENV JAVA_HOME /var/local/jdk1.8.0_45 -ENV PATH $JAVA_HOME/bin:$PATH - -# Install Maven -RUN wget -q http://apache.cs.utah.edu/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz -O - | \ - tar xz -C /var/local -ENV PATH /var/local/apache-maven-3.3.3/bin:$PATH - # Install GCC 4.7 to support -static-libstdc++ RUN wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo -P /etc/yum.repos.d RUN bash -c 'echo "enabled=1" >> /etc/yum.repos.d/devtools-1.1.repo' RUN bash -c "sed -e 's/\$basearch/i386/g' /etc/yum.repos.d/devtools-1.1.repo > /etc/yum.repos.d/devtools-i386-1.1.repo" RUN sed -e 's/testing-/testing-i386-/g' -i /etc/yum.repos.d/devtools-i386-1.1.repo + +# Make yum install twice to overcome docker issue when using overlay storage driver. + +# We'll get and "Rpmdb checksum is invalid: dCDPT(pkg checksums)" error caused by +# docker issue when using overlay storage driver, but all the stuff we need +# will be installed, so for now we just ignore the error. +# https://github.com/docker/docker/issues/10180 RUN yum install -y devtoolset-1.1 \ devtoolset-1.1-libstdc++-devel \ - devtoolset-1.1-libstdc++-devel.i686 + devtoolset-1.1-libstdc++-devel.i686 || true # Start in devtoolset environment that uses GCC 4.7 CMD ["scl", "enable", "devtoolset-1.1", "bash"] \ No newline at end of file diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py index 5d678a561f9..cf056ec9293 100644 --- a/tools/run_tests/artifact_targets.py +++ b/tools/run_tests/artifact_targets.py @@ -250,7 +250,7 @@ class ProtocArtifact: cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] ldflags = '%s' % _ARCH_FLAG_MAP[self.arch] if self.platform != 'macos': - ldflags += ' -static-libgcc -static-libstdc++ -s' + ldflags += ' -static-libgcc -static-libstdc++ -s' environ={'CONFIG': 'opt', 'CXXFLAGS': cxxflags, 'LDFLAGS': ldflags, From 2e8710414f34c7ff5d50f45f35fb98df9bc96ee0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 19 Feb 2016 13:57:13 -0800 Subject: [PATCH 16/32] Remove extraneous comment. --- tools/dockerfile/grpc_artifact_protoc/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/dockerfile/grpc_artifact_protoc/Dockerfile b/tools/dockerfile/grpc_artifact_protoc/Dockerfile index 74fc96c00ed..1bbc6e021bc 100644 --- a/tools/dockerfile/grpc_artifact_protoc/Dockerfile +++ b/tools/dockerfile/grpc_artifact_protoc/Dockerfile @@ -51,8 +51,6 @@ RUN bash -c 'echo "enabled=1" >> /etc/yum.repos.d/devtools-1.1.repo' RUN bash -c "sed -e 's/\$basearch/i386/g' /etc/yum.repos.d/devtools-1.1.repo > /etc/yum.repos.d/devtools-i386-1.1.repo" RUN sed -e 's/testing-/testing-i386-/g' -i /etc/yum.repos.d/devtools-i386-1.1.repo -# Make yum install twice to overcome docker issue when using overlay storage driver. - # We'll get and "Rpmdb checksum is invalid: dCDPT(pkg checksums)" error caused by # docker issue when using overlay storage driver, but all the stuff we need # will be installed, so for now we just ignore the error. @@ -62,4 +60,4 @@ RUN yum install -y devtoolset-1.1 \ devtoolset-1.1-libstdc++-devel.i686 || true # Start in devtoolset environment that uses GCC 4.7 -CMD ["scl", "enable", "devtoolset-1.1", "bash"] \ No newline at end of file +CMD ["scl", "enable", "devtoolset-1.1", "bash"] From 6d15982ce70cee38e0d26e00d52191a4d8c156ac Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 19 Feb 2016 16:03:22 -0800 Subject: [PATCH 17/32] building protoc artifacts on windows --- tools/run_tests/artifact_targets.py | 15 ++++---- tools/run_tests/build_artifact_protoc.bat | 45 +++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 tools/run_tests/build_artifact_protoc.bat diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py index cf056ec9293..2a9f248d92e 100644 --- a/tools/run_tests/artifact_targets.py +++ b/tools/run_tests/artifact_targets.py @@ -266,7 +266,12 @@ class ProtocArtifact: ['tools/run_tests/build_artifact_protoc.sh'], environ=environ) else: - raise Exception('Not yet supported') + generator = 'Visual Studio 12 Win64' if self.arch == 'x64' else 'Visual Studio 12' + vcplatform = 'x64' if self.arch == 'x64' else 'Win32' + return create_jobspec(self.name, + ['tools\\run_tests\\build_artifact_protoc.bat'], + environ={'generator': generator, + 'Platform': vcplatform}) def __str__(self): return self.name @@ -275,7 +280,7 @@ class ProtocArtifact: def targets(): """Gets list of supported targets""" return ([Cls(platform, arch) - for Cls in (CSharpExtArtifact, NodeExtArtifact) + for Cls in (CSharpExtArtifact, NodeExtArtifact, ProtocArtifact) for platform in ('linux', 'macos', 'windows') for arch in ('x86', 'x64')] + [PythonArtifact('linux', 'x86'), @@ -283,8 +288,4 @@ def targets(): PythonArtifact('macos', 'x64'), RubyArtifact('linux', 'x86'), RubyArtifact('linux', 'x64'), - RubyArtifact('macos', 'x64'), - ProtocArtifact('linux', 'x86'), - ProtocArtifact('linux', 'x64'), - ProtocArtifact('macos', 'x86'), - ProtocArtifact('macos', 'x64')]) + RubyArtifact('macos', 'x64')]) diff --git a/tools/run_tests/build_artifact_protoc.bat b/tools/run_tests/build_artifact_protoc.bat new file mode 100644 index 00000000000..1fa7f6046ae --- /dev/null +++ b/tools/run_tests/build_artifact_protoc.bat @@ -0,0 +1,45 @@ +@rem Copyright 2016, Google Inc. +@rem All rights reserved. +@rem +@rem Redistribution and use in source and binary forms, with or without +@rem modification, are permitted provided that the following conditions are +@rem met: +@rem +@rem * Redistributions of source code must retain the above copyright +@rem notice, this list of conditions and the following disclaimer. +@rem * Redistributions in binary form must reproduce the above +@rem copyright notice, this list of conditions and the following disclaimer +@rem in the documentation and/or other materials provided with the +@rem distribution. +@rem * Neither the name of Google Inc. nor the names of its +@rem contributors may be used to endorse or promote products derived from +@rem this software without specific prior written permission. +@rem +@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +mkdir artifacts + +setlocal +cd third_party/protobuf/cmake +cmake -G "%generator%" || goto :error +endlocal + +call vsprojects/build_plugins.bat || goto :error + +xcopy /Y third_party\protobuf\cmake\Release\protoc.exe artifacts\ || goto :error +xcopy /Y vsprojects\Release\*_plugin.exe artifacts\ || goto :error + +goto :EOF + +:error +exit /b 1 \ No newline at end of file From 4ad14db9960d62b57abc84723e58cd51b18f492b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 19 Feb 2016 16:33:46 -0800 Subject: [PATCH 18/32] download and extract gmock --- tools/run_tests/build_artifact_protoc.bat | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/build_artifact_protoc.bat b/tools/run_tests/build_artifact_protoc.bat index 1fa7f6046ae..e1dc032188f 100644 --- a/tools/run_tests/build_artifact_protoc.bat +++ b/tools/run_tests/build_artifact_protoc.bat @@ -30,14 +30,20 @@ mkdir artifacts setlocal -cd third_party/protobuf/cmake +cd third_party/protobuf + +powershell -Command "Invoke-WebRequest https://googlemock.googlecode.com/files/gmock-1.7.0.zip -OutFile gmock.zip" +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('gmock.zip', '.');" +rename gmock-1.7.0 gmock + +cd cmake cmake -G "%generator%" || goto :error endlocal call vsprojects/build_plugins.bat || goto :error xcopy /Y third_party\protobuf\cmake\Release\protoc.exe artifacts\ || goto :error -xcopy /Y vsprojects\Release\*_plugin.exe artifacts\ || goto :error +xcopy /Y vsprojects\Release\*_plugin.exe artifacts\ || xcopy /Y vsprojects\x64\Release\*_plugin.exe artifacts\ || goto :error goto :EOF From 6611dde2615be4853bc3cc3b8405ba67aa9dc2dd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Feb 2016 08:48:02 -0800 Subject: [PATCH 19/32] enable 64bit windows compilation of protoc plugins --- build.yaml | 2 ++ templates/vsprojects/protoc.props.template | 3 +++ 2 files changed, 5 insertions(+) diff --git a/build.yaml b/build.yaml index b639b5d21e6..761e7d537d8 100644 --- a/build.yaml +++ b/build.yaml @@ -776,6 +776,8 @@ libs: - gpr_codegen secure: false vs_project_guid: '{B6E81D84-2ACB-41B8-8781-493A944C7817}' + vs_props: + - protoc - name: interop_client_helper build: private language: c++ diff --git a/templates/vsprojects/protoc.props.template b/templates/vsprojects/protoc.props.template index a869005daec..ced6028a4be 100644 --- a/templates/vsprojects/protoc.props.template +++ b/templates/vsprojects/protoc.props.template @@ -4,6 +4,9 @@ + + 4244;4267;%(DisableSpecificWarnings) + libprotoc.lib;%(AdditionalDependencies) $(SolutionDir)\..\third_party\protobuf\cmake\$(Configuration);%(AdditionalLibraryDirectories) From a0d7ea6410d4006a23d472ad461ab0039846715d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 22 Feb 2016 08:49:14 -0800 Subject: [PATCH 20/32] generated projects --- vsprojects/protoc.props | 2 +- .../vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/vsprojects/protoc.props b/vsprojects/protoc.props index ecaf248446e..1bdc07193bc 100644 --- a/vsprojects/protoc.props +++ b/vsprojects/protoc.props @@ -1 +1 @@ - libprotoc.lib;%(AdditionalDependencies) $(SolutionDir)\..\third_party\protobuf\cmake\$(Configuration);%(AdditionalLibraryDirectories) \ No newline at end of file + 4244;4267;%(DisableSpecificWarnings) libprotoc.lib;%(AdditionalDependencies) $(SolutionDir)\..\third_party\protobuf\cmake\$(Configuration);%(AdditionalLibraryDirectories) \ No newline at end of file diff --git a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj index 89183902d74..a76c883903a 100644 --- a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj +++ b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj @@ -53,6 +53,7 @@ + From 19432c3daafd545fbf5d9cc98ad75ec1ffab7169 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 22 Feb 2016 20:58:30 -0800 Subject: [PATCH 21/32] Put a 900-sec timeout on the perf test. --- tools/jenkins/run_performance.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/jenkins/run_performance.sh b/tools/jenkins/run_performance.sh index c80685b23a0..08cc476c6fe 100755 --- a/tools/jenkins/run_performance.sh +++ b/tools/jenkins/run_performance.sh @@ -31,6 +31,11 @@ # This script is invoked by Jenkins and runs performance smoke test. set -ex +# +# Put a timeout on this test +# +((sleep 900; kill $$)&) + # Enter the gRPC repo root cd $(dirname $0)/../.. From 3c50e70c994ccc67f6cec9c1b7d80fcfb28093ba Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 22 Feb 2016 21:38:36 -0800 Subject: [PATCH 22/32] Start the timeout after the build finishes --- tools/jenkins/run_performance.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/jenkins/run_performance.sh b/tools/jenkins/run_performance.sh index 08cc476c6fe..caf0c0bc04c 100755 --- a/tools/jenkins/run_performance.sh +++ b/tools/jenkins/run_performance.sh @@ -31,11 +31,6 @@ # This script is invoked by Jenkins and runs performance smoke test. set -ex -# -# Put a timeout on this test -# -((sleep 900; kill $$)&) - # Enter the gRPC repo root cd $(dirname $0)/../.. @@ -52,6 +47,11 @@ PID1=$! bins/$config/qps_worker -driver_port 10010 & PID2=$! +# +# Put a timeout on these tests +# +((sleep 900; kill $$)&) + export QPS_WORKERS="localhost:10000,localhost:10010" # big is the size in bytes of large messages (0 is the size otherwise) From 49c5c3308c2a331a59dbcd2f2b57e3ee59d2a87f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 22 Feb 2016 21:44:33 -0800 Subject: [PATCH 23/32] Some more cleanup on timeout --- tools/jenkins/run_performance.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jenkins/run_performance.sh b/tools/jenkins/run_performance.sh index caf0c0bc04c..fbc078330f7 100755 --- a/tools/jenkins/run_performance.sh +++ b/tools/jenkins/run_performance.sh @@ -50,7 +50,7 @@ PID2=$! # # Put a timeout on these tests # -((sleep 900; kill $$)&) +((sleep 900; kill $$ && killall qps_worker && rm -f /tmp/qps-test.$$ )&) export QPS_WORKERS="localhost:10000,localhost:10010" From 023759216c4efa34440deb2e7516d1cc9e5b278f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 22 Feb 2016 22:27:28 -0800 Subject: [PATCH 24/32] Add comment --- tools/codegen/core/gen_load_balancing_proto.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/codegen/core/gen_load_balancing_proto.sh b/tools/codegen/core/gen_load_balancing_proto.sh index 6d974ce31b9..fb6a468ee0b 100755 --- a/tools/codegen/core/gen_load_balancing_proto.sh +++ b/tools/codegen/core/gen_load_balancing_proto.sh @@ -110,6 +110,8 @@ virtualenv $VENV_NAME . $VENV_NAME/bin/activate popd +# this should be the same version as the submodule we compile against +# ideally we'd update this as a template to ensure that pip install protobuf==3.0.0b2 pushd "$(dirname $1)" > /dev/null From 9f23c4a4f6d326463e50868017ad2fd10dda53d9 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Tue, 23 Feb 2016 16:22:32 +0000 Subject: [PATCH 25/32] Further improvements to Summer Of Code Ideas An introductory paragraph, addition of required skills and likely mentors, hyperlinks to other technologies, and copy edits. --- summerofcode/ideas.md | 46 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/summerofcode/ideas.md b/summerofcode/ideas.md index b14d3f7b6ad..4ccbe3b12fc 100644 --- a/summerofcode/ideas.md +++ b/summerofcode/ideas.md @@ -1,22 +1,50 @@ # gRPC Summer of Code Project Ideas -C Core: +Hello students! -1. Port gRPC to one of (Free, Net, Open) BSD platforms and create packages for them. Add kqueue support in the process. -2. Fix gRPC C-core's URI parser. The current parser does not qualify as a standard parser according to [RFC3986]( https://tools.ietf.org/html/rfc3986). Write test suites to verify this and make changes necessary to make the URI parser compliant. -3. HPACK compression efficiency evaluation - Figure out how to benchmark gRPC's compression efficiency (both in terms of bytes on the wire and cpu cycles). Implement benchmarks. Potentially extend this to other standalone implementations -- Java and Go. +We want gRPC to be the universal protocol for all computing platforms and +paradigms, so while these are our ideas of what we think would make good +projects for the summer, we're eager to hear your ideas and proposals as well. +Try us out and get to know the gRPC code and team! + +**Required skills for all projects:** git version control, collaborative +software development on github.com, and software development in at least one +of gRPC's ten languages on at least one of Linux, Mac OS X, and Windows. + +------------------------------------- + +gRPC C Core: + +1. Port gRPC to one of the major BSD platforms ([FreeBSD](https://freebsd.org), [NetBSD](https://netbsd.org), and [OpenBSD](https://openbsd.org)) and create packages for them. Add kqueue support in the process. + * **Required skills:** C programming language, BSD operating system. + * **Likely mentors:** [Craig Tiller](https://github.com/ctiller), [Nicolas Noble](https://github.com/nicolasnoble). +1. Fix gRPC C-core's URI parser. The current parser does not qualify as a standard parser according to [RFC3986]( https://tools.ietf.org/html/rfc3986). Write test suites to verify this and make changes necessary to make the URI parser compliant. + * **Required skills:** C programming language, HTTP standard compliance. + * **Likely mentors:** [Craig Tiller](https://github.com/ctiller). +1. HPACK compression efficiency evaluation - Figure out how to benchmark gRPC's compression efficiency (both in terms of bytes on the wire and cpu cycles). Implement benchmarks. Potentially extend this to other full-stack gRPC implementations (Java and Go). + * **Required skills:** C programming language, software performance benchmarking, potentially Java and Go. + * **Likely mentors:** [Craig Tiller](https://github.com/ctiller). gRPC Python: - 1. Evaluate the port of gRPC's Python implementation to PyPy. Investigate the state of [Cython support](http://docs.cython.org/src/userguide/pypy.html) to do this or potentially explore cffi - 2. Develop and test Python 3.5 Support for gRPC. Make necessary changes to port gRPC and package it for supported platforms. +1. Port gRPC Python to [PyPy](http://pypy.org). Investigate the state of [Cython support](http://docs.cython.org/src/userguide/pypy.html) to do this or potentially explore [cffi](https://cffi.readthedocs.org/en/latest/). + * **Required skills:** Python programming language, PyPy Python interpreter. + * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm). +1. Develop and test Python 3.5 Support for gRPC. Make necessary changes to port gRPC and package it for supported platforms. + * **Required skills:** Python programming language, PyPy Python interpreter. + * **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm). gRPC Ruby/Java: -1. jRuby support for gRPC. Develop a jRuby wrapper for gRPC based on grpc-java and ensure that it is API compatible with the existing Ruby implementation and passes all tests. +1. [jRuby](http://jruby.org) support for gRPC. Develop a jRuby wrapper for gRPC based on grpc-java and ensure that it is API compatible with the existing Ruby implementation and passes all tests. + * **Required skills:** Java programming language, Ruby programming language. + * **Likely mentors:** [Michael Lumish](https://github.com/murgatroid99), [Eric Anderson](https://github.com/ejona86). -Other: +gRPC Wire Protocol: -1. Develop a Wireshark plugin for the gRPC protocol. Provide documentation and tutorials for this plugin. Bonus: consider set-up and use with the mobile clients. +1. Develop a [Wireshark](https://wireshark.org) plugin for the gRPC protocol. Provide documentation and tutorials for this plugin. + * **Bonus:** consider set-up and use with mobile clients. + * **Required skills:** Wireshark software. + * **Likely mentors:** [Nicolas Noble](https://github.com/nicolasnoble). From 368a66dcbed0472e8a36e14351b6d89d618bbf20 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Tue, 23 Feb 2016 17:17:05 +0000 Subject: [PATCH 26/32] More ideas page tweaks One copy edit, two links. --- summerofcode/ideas.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/summerofcode/ideas.md b/summerofcode/ideas.md index 4ccbe3b12fc..c7f368e7cc2 100644 --- a/summerofcode/ideas.md +++ b/summerofcode/ideas.md @@ -2,10 +2,12 @@ Hello students! -We want gRPC to be the universal protocol for all computing platforms and -paradigms, so while these are our ideas of what we think would make good -projects for the summer, we're eager to hear your ideas and proposals as well. -Try us out and get to know the gRPC code and team! +We want gRPC to be the universal remote procedure call protocol for all +computing platforms and paradigms, so while these are our ideas of what we +think would make good projects for the summer, we're eager to hear your ideas +and proposals as well. +[Try us out](https://github.com/grpc/grpc/blob/master/CONTRIBUTING.md) and get +to know the gRPC code and team! **Required skills for all projects:** git version control, collaborative software development on github.com, and software development in at least one @@ -15,7 +17,7 @@ of gRPC's ten languages on at least one of Linux, Mac OS X, and Windows. gRPC C Core: -1. Port gRPC to one of the major BSD platforms ([FreeBSD](https://freebsd.org), [NetBSD](https://netbsd.org), and [OpenBSD](https://openbsd.org)) and create packages for them. Add kqueue support in the process. +1. Port gRPC to one of the major BSD platforms ([FreeBSD](https://freebsd.org), [NetBSD](https://netbsd.org), and [OpenBSD](https://openbsd.org)) and create packages for them. Add [kqueue](https://www.freebsd.org/cgi/man.cgi?query=kqueue) support in the process. * **Required skills:** C programming language, BSD operating system. * **Likely mentors:** [Craig Tiller](https://github.com/ctiller), [Nicolas Noble](https://github.com/nicolasnoble). 1. Fix gRPC C-core's URI parser. The current parser does not qualify as a standard parser according to [RFC3986]( https://tools.ietf.org/html/rfc3986). Write test suites to verify this and make changes necessary to make the URI parser compliant. From a49335326cf674b1d74fde8777e410aa588ddc1f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 23 Feb 2016 10:45:58 -0800 Subject: [PATCH 27/32] fix C# build --- src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs index ad0c53a3251..cab299a1373 100644 --- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceImpl.cs @@ -51,7 +51,7 @@ namespace Grpc.Testing public WorkerServiceImpl(Action stopRequestHandler) { - this.stopRequestHandler = Grpc.Core.Utils.Preconditions.CheckNotNull(stopRequestHandler); + this.stopRequestHandler = GrpcPreconditions.CheckNotNull(stopRequestHandler); } public async Task RunServer(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) From 6d5abcb3418d57bbe972d9a1c5e69ede95e6d138 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 23 Feb 2016 13:51:29 -0800 Subject: [PATCH 28/32] cleanup gens/ directory after nanopb check --- tools/distrib/check_nanopb_output.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 9cb7581d87f..99fd6806c49 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -67,3 +67,5 @@ if [ $? != 0 ]; then echo "Outputs differ: $NANOPB_TMP_OUTPUT vs src/core/proto/grpc/lb/v0" exit 1 fi + +rm -Rf $NANOPB_TMP_OUTPUT From 07b4c1cb8d4769c7ea33d5bdff71eb2d0521e095 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 23 Feb 2016 15:13:29 -0800 Subject: [PATCH 29/32] update nanopb version --- third_party/nanopb | 2 +- tools/run_tests/sanity/check_submodules.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/nanopb b/third_party/nanopb index 5497a1dfc91..f8ac4637662 160000 --- a/third_party/nanopb +++ b/third_party/nanopb @@ -1 +1 @@ -Subproject commit 5497a1dfc91a86965383cdd1652e348345400435 +Subproject commit f8ac463766281625ad710900479130c7fcb4d63b diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index c08b382638f..3c6dbb9ea1f 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -44,7 +44,7 @@ cat << EOF | awk '{ print $1 }' | sort > $want_submodules 9f897b25800d2f54f5c442ef01a60721aeca6d87 third_party/boringssl (version_for_cocoapods_1.0-67-g9f897b2) 05b155ff59114735ec8cd089f669c4c3d8f59029 third_party/gflags (v2.1.0-45-g05b155f) c99458533a9b4c743ed51537e25989ea55944908 third_party/googletest (release-1.7.0) - 5497a1dfc91a86965383cdd1652e348345400435 third_party/nanopb (nanopb-0.3.3-10-g5497a1d) + f8ac463766281625ad710900479130c7fcb4d63b third_party/nanopb (nanopb-0.3.4-29-gf8ac463) d5fb408ddc281ffcadeb08699e65bb694656d0bd third_party/protobuf (v3.0.0-beta-2) 50893291621658f355bc5b4d450a8d06a563053d third_party/zlib (v1.2.8) EOF From 4f6683c395a030fe2d9c189817a4265a4ae9a694 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 23 Feb 2016 15:17:58 -0800 Subject: [PATCH 30/32] remove the whole gens/ --- tools/distrib/check_nanopb_output.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 99fd6806c49..241a3a5ce3a 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -68,4 +68,4 @@ if [ $? != 0 ]; then exit 1 fi -rm -Rf $NANOPB_TMP_OUTPUT +rm -Rf "${LOCAL_GIT_ROOT}/gens" From 0d2df65c4120aebbe63f84cd316fc7b8068cf067 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 23 Feb 2016 17:37:47 -0800 Subject: [PATCH 31/32] updated generated lb proto code to latest nanopb version --- src/core/proto/grpc/lb/v0/load_balancer.pb.c | 2 +- src/core/proto/grpc/lb/v0/load_balancer.pb.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.c b/src/core/proto/grpc/lb/v0/load_balancer.pb.c index abd4b1cefc6..59aae30cff9 100644 --- a/src/core/proto/grpc/lb/v0/load_balancer.pb.c +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.c @@ -31,7 +31,7 @@ * */ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.4-dev */ +/* Generated by nanopb-0.3.5-dev */ #include "src/core/proto/grpc/lb/v0/load_balancer.pb.h" diff --git a/src/core/proto/grpc/lb/v0/load_balancer.pb.h b/src/core/proto/grpc/lb/v0/load_balancer.pb.h index 87037213998..3599f881bb1 100644 --- a/src/core/proto/grpc/lb/v0/load_balancer.pb.h +++ b/src/core/proto/grpc/lb/v0/load_balancer.pb.h @@ -31,7 +31,7 @@ * */ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.4-dev */ +/* Generated by nanopb-0.3.5-dev */ #ifndef PB_LOAD_BALANCER_PB_H_INCLUDED #define PB_LOAD_BALANCER_PB_H_INCLUDED @@ -44,7 +44,6 @@ extern "C" { #endif -/* Enum definitions */ /* Struct definitions */ typedef struct _grpc_lb_v0_ClientStats { bool has_total_requests; @@ -164,6 +163,7 @@ extern const pb_field_t grpc_lb_v0_Server_fields[5]; #define grpc_lb_v0_LoadBalanceRequest_size 169 #define grpc_lb_v0_InitialLoadBalanceRequest_size 131 #define grpc_lb_v0_ClientStats_size 33 +#define grpc_lb_v0_LoadBalanceResponse_size (165 + grpc_lb_v0_ServerList_size) #define grpc_lb_v0_InitialLoadBalanceResponse_size 156 #define grpc_lb_v0_Server_size 127 From e86b4573fefc73f90c4136ebde9395bd15346276 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 23 Feb 2016 17:38:01 -0800 Subject: [PATCH 32/32] fixed check nanopb sanity script --- tools/distrib/check_nanopb_output.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/distrib/check_nanopb_output.sh b/tools/distrib/check_nanopb_output.sh index 241a3a5ce3a..5f49ebb93e6 100755 --- a/tools/distrib/check_nanopb_output.sh +++ b/tools/distrib/check_nanopb_output.sh @@ -32,7 +32,7 @@ set -ex apt-get install -y autoconf automake libtool curl python-virtualenv -readonly NANOPB_TMP_OUTPUT="${LOCAL_GIT_ROOT}/gens/src/proto/grpc/lb/v0" +readonly NANOPB_TMP_OUTPUT="$(mktemp -d)" # install protoc version 3 pushd third_party/protobuf @@ -62,10 +62,7 @@ PATH="$PROTOC_PATH:$PATH" ./tools/codegen/core/gen_load_balancing_proto.sh \ $NANOPB_TMP_OUTPUT # compare outputs to checked compiled code -diff -rq $NANOPB_TMP_OUTPUT src/core/proto/grpc/lb/v0 -if [ $? != 0 ]; then +if ! diff -r $NANOPB_TMP_OUTPUT src/core/proto/grpc/lb/v0; then echo "Outputs differ: $NANOPB_TMP_OUTPUT vs src/core/proto/grpc/lb/v0" - exit 1 + exit 2 fi - -rm -Rf "${LOCAL_GIT_ROOT}/gens"