diff --git a/BUILD b/BUILD index 3e54e873562..cc5fd3eb47a 100644 --- a/BUILD +++ b/BUILD @@ -745,7 +745,7 @@ grpc_cc_library( "grpc_transport_chttp2_server_insecure", "grpc_workaround_cronet_compression_filter", "grpc_server_backward_compatibility", - ] + ], ) grpc_cc_library( @@ -1400,22 +1400,22 @@ GRPCXX_PUBLIC_HDRS = [ grpc_cc_library( name = "grpc++_base", - hdrs = GRPCXX_HDRS, srcs = GRPCXX_SRCS, - public_hdrs = GRPCXX_PUBLIC_HDRS, + hdrs = GRPCXX_HDRS, language = "c++", + public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ - "grpc++_codegen_base", "grpc", + "grpc++_codegen_base", ], ) grpc_cc_library( name = "grpc++_base_unsecure", - hdrs = GRPCXX_HDRS, srcs = GRPCXX_SRCS, - public_hdrs = GRPCXX_PUBLIC_HDRS, + hdrs = GRPCXX_HDRS, language = "c++", + public_hdrs = GRPCXX_PUBLIC_HDRS, deps = [ "grpc++_codegen_base", "grpc_unsecure", @@ -1539,5 +1539,4 @@ grpc_cc_library( ], ) - grpc_generate_one_off_targets() diff --git a/build.yaml b/build.yaml index 2c540557151..a095ab72729 100644 --- a/build.yaml +++ b/build.yaml @@ -4628,7 +4628,6 @@ php_config_m4: deps: - grpc - gpr - - ares - boringssl headers: - src/php/ext/grpc/byte_buffer.h diff --git a/config.m4 b/config.m4 index 7b5cf952222..ec463b2243f 100644 --- a/config.m4 +++ b/config.m4 @@ -8,8 +8,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/cares) LIBS="-lpthread $LIBS" @@ -23,10 +21,8 @@ if test "$PHP_GRPC" != "no"; then case $host in *darwin*) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/config_darwin) ;; *) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/config_linux) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; @@ -641,58 +637,9 @@ if test "$PHP_GRPC" != "no"; then third_party/boringssl/ssl/tls13_server.c \ third_party/boringssl/ssl/tls_method.c \ third_party/boringssl/ssl/tls_record.c \ - third_party/cares/cares/ares__close_sockets.c \ - third_party/cares/cares/ares__get_hostent.c \ - third_party/cares/cares/ares__read_line.c \ - third_party/cares/cares/ares__timeval.c \ - third_party/cares/cares/ares_cancel.c \ - third_party/cares/cares/ares_create_query.c \ - third_party/cares/cares/ares_data.c \ - third_party/cares/cares/ares_destroy.c \ - third_party/cares/cares/ares_expand_name.c \ - third_party/cares/cares/ares_expand_string.c \ - third_party/cares/cares/ares_fds.c \ - third_party/cares/cares/ares_free_hostent.c \ - third_party/cares/cares/ares_free_string.c \ - third_party/cares/cares/ares_getenv.c \ - third_party/cares/cares/ares_gethostbyaddr.c \ - third_party/cares/cares/ares_gethostbyname.c \ - third_party/cares/cares/ares_getnameinfo.c \ - third_party/cares/cares/ares_getopt.c \ - third_party/cares/cares/ares_getsock.c \ - third_party/cares/cares/ares_init.c \ - third_party/cares/cares/ares_library_init.c \ - third_party/cares/cares/ares_llist.c \ - third_party/cares/cares/ares_mkquery.c \ - third_party/cares/cares/ares_nowarn.c \ - third_party/cares/cares/ares_options.c \ - third_party/cares/cares/ares_parse_a_reply.c \ - third_party/cares/cares/ares_parse_aaaa_reply.c \ - third_party/cares/cares/ares_parse_mx_reply.c \ - third_party/cares/cares/ares_parse_naptr_reply.c \ - third_party/cares/cares/ares_parse_ns_reply.c \ - third_party/cares/cares/ares_parse_ptr_reply.c \ - third_party/cares/cares/ares_parse_soa_reply.c \ - third_party/cares/cares/ares_parse_srv_reply.c \ - third_party/cares/cares/ares_parse_txt_reply.c \ - third_party/cares/cares/ares_platform.c \ - third_party/cares/cares/ares_process.c \ - third_party/cares/cares/ares_query.c \ - third_party/cares/cares/ares_search.c \ - third_party/cares/cares/ares_send.c \ - third_party/cares/cares/ares_strcasecmp.c \ - third_party/cares/cares/ares_strdup.c \ - third_party/cares/cares/ares_strerror.c \ - third_party/cares/cares/ares_timeout.c \ - third_party/cares/cares/ares_version.c \ - third_party/cares/cares/ares_writev.c \ - third_party/cares/cares/bitncmp.c \ - third_party/cares/cares/inet_net_pton.c \ - third_party/cares/cares/inet_ntop.c \ - third_party/cares/cares/windows_port.c \ , $ext_shared, , -fvisibility=hidden \ -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN \ - -D_HAS_EXCEPTIONS=0 -DNOMINMAX) + -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0) PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc) @@ -792,6 +739,5 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509v3) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl) - PHP_ADD_BUILD_DIR($ext_builddir/third_party/cares/cares) PHP_ADD_BUILD_DIR($ext_builddir/third_party/nanopb) fi diff --git a/package.json b/package.json index e1499a089cd..1ed182ced93 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "lodash": "^4.15.0", "nan": "^2.0.0", "node-pre-gyp": "^0.6.0", - "protobufjs": "^6.7.0" + "protobufjs": "^5.0.0" }, "devDependencies": { "async": "^2.0.1", diff --git a/package.xml b/package.xml index bb8617f6d6e..380a47073ff 100644 --- a/package.xml +++ b/package.xml @@ -10,7 +10,7 @@ grpc-packages@google.com yes - 2017-03-01 + 2017-05-05 1.4.0dev @@ -22,8 +22,7 @@ BSD -- Added arg info macros #9751 -- Updated codegen to be consistent with protobuf #9492 +- Fixed some memory leaks #9559, #10996 @@ -1057,79 +1056,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1442,6 +1369,22 @@ Update to wrap gRPC C Core version 0.10.0 BSD - Added arg info macros #9751 +- Updated codegen to be consistent with protobuf #9492 + + + + + 1.2.0 + 1.2.0 + + + stable + stable + + 2017-03-20 + BSD + +- Added arg info macros #9751 - Updated codegen to be consistent with protobuf #9492 diff --git a/src/core/lib/iomgr/tcp_server_uv.c b/src/core/lib/iomgr/tcp_server_uv.c index e9246948f5b..d446e5312ad 100644 --- a/src/core/lib/iomgr/tcp_server_uv.c +++ b/src/core/lib/iomgr/tcp_server_uv.c @@ -56,6 +56,8 @@ struct grpc_tcp_listener { int port; /* linked list */ struct grpc_tcp_listener *next; + + bool closed; }; struct grpc_tcp_server { @@ -77,6 +79,8 @@ struct grpc_tcp_server { /* shutdown callback */ grpc_closure *shutdown_complete; + bool shutdown; + grpc_resource_quota *resource_quota; }; @@ -109,6 +113,7 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx, s->shutdown_starting.head = NULL; s->shutdown_starting.tail = NULL; s->shutdown_complete = shutdown_complete; + s->shutdown = false; *server = s; return GRPC_ERROR_NONE; } @@ -125,6 +130,7 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s, } static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { + GPR_ASSERT(s->shutdown); if (s->shutdown_complete != NULL) { grpc_closure_sched(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE); } @@ -144,21 +150,31 @@ static void handle_close_callback(uv_handle_t *handle) { grpc_tcp_listener *sp = (grpc_tcp_listener *)handle->data; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; sp->server->open_ports--; - if (sp->server->open_ports == 0) { + if (sp->server->open_ports == 0 && sp->server->shutdown) { finish_shutdown(&exec_ctx, sp->server); } grpc_exec_ctx_finish(&exec_ctx); } +static void close_listener(grpc_tcp_listener *sp) { + if (!sp->closed) { + sp->closed = true; + uv_close((uv_handle_t *)sp->handle, handle_close_callback); + } +} + static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) { int immediately_done = 0; grpc_tcp_listener *sp; + GPR_ASSERT(!s->shutdown); + s->shutdown = true; + if (s->open_ports == 0) { immediately_done = 1; } for (sp = s->head; sp; sp = sp->next) { - uv_close((uv_handle_t *)sp->handle, handle_close_callback); + close_listener(sp); } if (immediately_done) { @@ -196,9 +212,14 @@ static void on_connect(uv_stream_t *server, int status) { int err; if (status < 0) { - gpr_log(GPR_INFO, "Skipping on_accept due to error: %s", - uv_strerror(status)); - return; + switch (status) { + case UV_EINTR: + case UV_EAGAIN: + return; + default: + close_listener(sp); + return; + } } client = gpr_malloc(sizeof(uv_tcp_t)); @@ -287,6 +308,7 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, uv_tcp_t *handle, sp->handle = handle; sp->port = port; sp->port_index = port_index; + sp->closed = false; handle->data = sp; s->open_ports++; GPR_ASSERT(sp->handle); diff --git a/src/core/lib/iomgr/tcp_uv.c b/src/core/lib/iomgr/tcp_uv.c index e7157537f6d..dc23e4f5211 100644 --- a/src/core/lib/iomgr/tcp_uv.c +++ b/src/core/lib/iomgr/tcp_uv.c @@ -88,12 +88,12 @@ static void tcp_free(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { #ifdef GRPC_TCP_REFCOUNT_DEBUG #define TCP_UNREF(exec_ctx, tcp, reason) \ tcp_unref((exec_ctx), (tcp), (reason), __FILE__, __LINE__) -#define TCP_REF(tcp, reason) \ - tcp_ref((exec_ctx), (tcp), (reason), __FILE__, __LINE__) +#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__) static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp, const char *reason, const char *file, int line) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "TCP unref %p : %s %d -> %d", tcp, - reason, tcp->refcount.count, tcp->refcount.count - 1); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "TCP unref %p : %s %" PRIiPTR " -> %" PRIiPTR, tcp, reason, + tcp->refcount.count, tcp->refcount.count - 1); if (gpr_unref(&tcp->refcount)) { tcp_free(exec_ctx, tcp); } @@ -101,8 +101,9 @@ static void tcp_unref(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp, static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file, int line) { - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "TCP ref %p : %s %d -> %d", tcp, - reason, tcp->refcount.count, tcp->refcount.count + 1); + gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, + "TCP ref %p : %s %" PRIiPTR " -> %" PRIiPTR, tcp, reason, + tcp->refcount.count, tcp->refcount.count + 1); gpr_ref(&tcp->refcount); } #else @@ -311,6 +312,7 @@ static void uv_endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, tcp->shutting_down = true; uv_shutdown_t *req = &tcp->shutdown_req; uv_shutdown(req, (uv_stream_t *)tcp->handle, shutdown_callback); + grpc_resource_user_shutdown(exec_ctx, tcp->resource_user); } GRPC_ERROR_UNREF(why); } diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index aa8a8d3b17b..d823942be52 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -51,11 +51,11 @@ powershell -Command "cp -r ..\..\platform=*\artifacts\protoc_* protoc_plugins" @rem To be able to build, we also need to put grpc_csharp_ext to its normal location xcopy /Y /I nativelibs\csharp_ext_windows_x64\grpc_csharp_ext.dll ..\..\cmake\build\x64\Release\ -%DOTNET% pack --configuration Release Grpc.Core --output ..\..\..\artifacts || goto :error -%DOTNET% pack --configuration Release Grpc.Core.Testing --output ..\..\..\artifacts || goto :error -%DOTNET% pack --configuration Release Grpc.Auth --output ..\..\..\artifacts || goto :error -%DOTNET% pack --configuration Release Grpc.HealthCheck --output ..\..\..\artifacts || goto :error -%DOTNET% pack --configuration Release Grpc.Reflection --output ..\..\..\artifacts || goto :error +%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Core --output ..\..\..\artifacts || goto :error +%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Core.Testing --output ..\..\..\artifacts || goto :error +%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Auth --output ..\..\..\artifacts || goto :error +%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.HealthCheck --output ..\..\..\artifacts || goto :error +%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Reflection --output ..\..\..\artifacts || goto :error %NUGET% pack Grpc.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts || goto :error %NUGET% pack Grpc.Tools.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index d33923845c1..f79c97fbbcd 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -48,11 +48,11 @@ dotnet restore Grpc.sln mkdir -p ../../libs/opt cp nativelibs/csharp_ext_linux_x64/libgrpc_csharp_ext.so ../../libs/opt -dotnet pack --configuration Release Grpc.Core --output ../../../artifacts -dotnet pack --configuration Release Grpc.Core.Testing --output ../../../artifacts -dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts -dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts -dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts +dotnet pack --configuration Release --include-symbols --include-source Grpc.Core --output ../../../artifacts +dotnet pack --configuration Release --include-symbols --include-source Grpc.Core.Testing --output ../../../artifacts +dotnet pack --configuration Release --include-symbols --include-source Grpc.Auth --output ../../../artifacts +dotnet pack --configuration Release --include-symbols --include-source Grpc.HealthCheck --output ../../../artifacts +dotnet pack --configuration Release --include-symbols --include-source Grpc.Reflection --output ../../../artifacts nuget pack Grpc.nuspec -Version "1.4.0-dev" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "1.4.0-dev" -OutputDirectory ../../artifacts diff --git a/src/node/index.js b/src/node/index.js index 0da3440eb77..2da77c3eaee 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -70,8 +70,6 @@ grpc.setDefaultRootsPem(fs.readFileSync(SSL_ROOTS_PATH, 'ascii')); * Buffers. Defaults to false * - longsAsStrings: deserialize long values as strings instead of objects. * Defaults to true - * - enumsAsStrings: deserialize enum values as strings instead of numbers. - * Defaults to true * - deprecatedArgumentOrder: Use the beta method argument order for client * methods, with optional arguments after the callback. Defaults to false. * This option is only a temporary stopgap measure to smooth an API breakage. @@ -105,10 +103,6 @@ exports.loadObject = function loadObject(value, options) { switch (protobufjsVersion) { case 6: return protobuf_js_6_common.loadObject(value, options); case 5: - var deprecation_message = 'Calling grpc.loadObject with an object ' + - 'generated by ProtoBuf.js 5 is deprecated. Please upgrade to ' + - 'ProtoBuf.js 6.'; - common.log(grpc.logVerbosity.INFO, deprecation_message); return protobuf_js_5_common.loadObject(value, options); default: throw new Error('Unrecognized protobufjsVersion', protobufjsVersion); @@ -117,19 +111,6 @@ exports.loadObject = function loadObject(value, options) { var loadObject = exports.loadObject; -function applyProtoRoot(filename, root) { - if (_.isString(filename)) { - return filename; - } - filename.root = path.resolve(filename.root) + '/'; - root.resolvePath = function(originPath, importPath, alreadyNormalized) { - return ProtoBuf.util.path.resolve(filename.root, - importPath, - alreadyNormalized); - }; - return filename.file; -} - /** * Load a gRPC object from a .proto file. The options object can provide the * following options: @@ -139,8 +120,6 @@ function applyProtoRoot(filename, root) { * Buffers. Defaults to false * - longsAsStrings: deserialize long values as strings instead of objects. * Defaults to true - * - enumsAsStrings: deserialize enum values as strings instead of numbers. - * Defaults to true * - deprecatedArgumentOrder: Use the beta method argument order for client * methods, with optional arguments after the callback. Defaults to false. * This option is only a temporary stopgap measure to smooth an API breakage. @@ -152,17 +131,31 @@ function applyProtoRoot(filename, root) { * @return {Object} The resulting gRPC object */ exports.load = function load(filename, format, options) { - /* Note: format is currently unused, because the API for loading a proto - file or a JSON file is identical in Protobuf.js 6. In the future, there is - still the possibility of adding other formats that would be loaded - differently */ options = _.defaults(options, common.defaultGrpcOptions); - options.protobufjs_version = 6; - var root = new ProtoBuf.Root(); - var parse_options = {keepCase: !options.convertFieldsToCamelCase}; - return loadObject(root.loadSync(applyProtoRoot(filename, root), - parse_options), - options); + options.protobufjsVersion = 5; + if (!format) { + format = 'proto'; + } + var convertFieldsToCamelCaseOriginal = ProtoBuf.convertFieldsToCamelCase; + if(options && options.hasOwnProperty('convertFieldsToCamelCase')) { + ProtoBuf.convertFieldsToCamelCase = options.convertFieldsToCamelCase; + } + var builder; + try { + switch(format) { + case 'proto': + builder = ProtoBuf.loadProtoFile(filename); + break; + case 'json': + builder = ProtoBuf.loadJsonFile(filename); + break; + default: + throw new Error('Unrecognized format "' + format + '"'); + } + } finally { + ProtoBuf.convertFieldsToCamelCase = convertFieldsToCamelCaseOriginal; + } + return loadObject(builder.ns, options); }; var log_template = _.template( diff --git a/src/node/src/protobuf_js_5_common.js b/src/node/src/protobuf_js_5_common.js index 62cf2f4acaa..4041e05390f 100644 --- a/src/node/src/protobuf_js_5_common.js +++ b/src/node/src/protobuf_js_5_common.js @@ -45,8 +45,7 @@ var client = require('./client'); * objects. Defaults to true * @return {function(Buffer):cls} The deserialization function */ -exports.deserializeCls = function deserializeCls(cls, binaryAsBase64, - longsAsStrings) { +exports.deserializeCls = function deserializeCls(cls, options) { /** * Deserialize a buffer to a message object * @param {Buffer} arg_buf The buffer to deserialize @@ -55,7 +54,8 @@ exports.deserializeCls = function deserializeCls(cls, binaryAsBase64, return function deserialize(arg_buf) { // Convert to a native object with binary fields as Buffers (first argument) // and longs as strings (second argument) - return cls.decode(arg_buf).toRaw(binaryAsBase64, longsAsStrings); + return cls.decode(arg_buf).toRaw(options.binaryAsBase64, + options.longsAsStrings); }; }; @@ -128,10 +128,10 @@ exports.getProtobufServiceAttrs = function getProtobufServiceAttrs(service, responseType: method.resolvedResponseType, requestSerialize: serializeCls(method.resolvedRequestType.build()), requestDeserialize: deserializeCls(method.resolvedRequestType.build(), - binaryAsBase64, longsAsStrings), + options), responseSerialize: serializeCls(method.resolvedResponseType.build()), responseDeserialize: deserializeCls(method.resolvedResponseType.build(), - binaryAsBase64, longsAsStrings) + options) }; })); }; diff --git a/src/node/src/server.js b/src/node/src/server.js index 08417a74c1e..75426a62c17 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -781,6 +781,11 @@ Server.prototype.addService = function(service, implementation) { }); }; +var logAddProtoServiceDeprecationOnce = _.once(function() { + common.log(grpc.logVerbosity.INFO, + 'Server#addProtoService is deprecated. Use addService instead'); +}); + /** * Add a proto service to the server, with a corresponding implementation * @deprecated Use grpc.load and Server#addService instead @@ -792,8 +797,7 @@ Server.prototype.addProtoService = function(service, implementation) { var options; var protobuf_js_5_common = require('./protobuf_js_5_common'); var protobuf_js_6_common = require('./protobuf_js_6_common'); - common.log(constants.logVerbosity.INFO, - 'Server#addProtoService is deprecated. Use addService instead'); + logAddProtoServiceDeprecationOnce(); if (protobuf_js_5_common.isProbablyProtobufJs5(service)) { options = _.defaults(service.grpc_options, common.defaultGrpcOptions); this.addService( diff --git a/src/node/test/common_test.js b/src/node/test/common_test.js index e1ce864f975..b7c2c6a8d66 100644 --- a/src/node/test/common_test.js +++ b/src/node/test/common_test.js @@ -37,16 +37,15 @@ var assert = require('assert'); var _ = require('lodash'); var common = require('../src/common'); -var protobuf_js_6_common = require('../src/protobuf_js_6_common'); +var protobuf_js_5_common = require('../src/protobuf_js_5_common'); -var serializeCls = protobuf_js_6_common.serializeCls; -var deserializeCls = protobuf_js_6_common.deserializeCls; +var serializeCls = protobuf_js_5_common.serializeCls; +var deserializeCls = protobuf_js_5_common.deserializeCls; var ProtoBuf = require('protobufjs'); -var messages_proto = new ProtoBuf.Root(); -messages_proto = messages_proto.loadSync( - __dirname + '/test_messages.proto', {keepCase: true}).resolveAll(); +var messages_proto = ProtoBuf.loadProtoFile( + __dirname + '/test_messages.proto').build(); var default_options = common.defaultGrpcOptions; @@ -101,6 +100,7 @@ describe('Proto message long int serialize and deserialize', function() { var longNumDeserialize = deserializeCls(messages_proto.LongValues, num_options); var serialized = longSerialize({int_64: pos_value}); + console.log(longDeserialize(serialized)); assert.strictEqual(typeof longDeserialize(serialized).int_64, 'string'); /* With the longsAsStrings option disabled, long values are represented as * objects with 3 keys: low, high, and unsigned */ @@ -136,7 +136,8 @@ describe('Proto message bytes serialize and deserialize', function() { var serialized = sequenceSerialize({repeated_field: [10]}); assert.strictEqual(expected_serialize.compare(serialized), 0); }); - it('should deserialize packed or unpacked repeated', function() { + // This tests a bug that was fixed in Protobuf.js 6 + it.skip('should deserialize packed or unpacked repeated', function() { var expectedDeserialize = { bytes_field: new Buffer(''), repeated_field: [10] @@ -155,7 +156,8 @@ describe('Proto message bytes serialize and deserialize', function() { assert.deepEqual(unpackedDeserialized, expectedDeserialize); }); }); -describe('Proto message oneof serialize and deserialize', function() { +// This tests a bug that was fixed in Protobuf.js 6 +describe.skip('Proto message oneof serialize and deserialize', function() { var oneofSerialize = serializeCls(messages_proto.OneOfValues); var oneofDeserialize = deserializeCls( messages_proto.OneOfValues, default_options); @@ -193,7 +195,8 @@ describe('Proto message enum serialize and deserialize', function() { assert.deepEqual(enumDeserialize(nameSerialized), enumDeserialize(numberSerialized)); }); - it('Should deserialize as a string the enumsAsStrings option', function() { + // This tests a bug that was fixed in Protobuf.js 6 + it.skip('Should correctly handle the enumsAsStrings option', function() { var serialized = enumSerialize({enum_value: 'TWO'}); var nameDeserialized = enumDeserialize(serialized); var numberDeserialized = enumIntDeserialize(serialized); diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index 783028fa99f..d2f0511af2d 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -43,9 +43,8 @@ var ProtoBuf = require('protobufjs'); var grpc = require('..'); -var math_proto = new ProtoBuf.Root(); -math_proto = math_proto.loadSync(__dirname + - '/../../proto/math/math.proto', {keepCase: true}); +var math_proto = ProtoBuf.loadProtoFile(__dirname + + '/../../proto/math/math.proto'); var mathService = math_proto.lookup('math.Math'); var mathServiceAttrs = grpc.loadObject( @@ -332,9 +331,7 @@ describe('Echo service', function() { var server; var client; before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/echo_service.proto', - {keepCase: true}); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto'); var echo_service = test_proto.lookup('EchoService'); var Client = grpc.loadObject(echo_service); server = new grpc.Server(); @@ -357,6 +354,13 @@ describe('Echo service', function() { done(); }); }); + it('Should convert an undefined argument to default values', function(done) { + client.echo(undefined, function(error, response) { + assert.ifError(error); + assert.deepEqual(response, {value: '', value2: 0}); + done(); + }); + }); }); describe('Generic client and server', function() { function toString(val) { @@ -457,9 +461,7 @@ describe('Echo metadata', function() { var server; var metadata; before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/test_service.proto', - {keepCase: true}); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); var test_service = test_proto.lookup('TestService'); var Client = grpc.loadObject(test_service); server = new grpc.Server(); @@ -560,9 +562,7 @@ describe('Client malformed response handling', function() { var client; var badArg = new Buffer([0xFF]); before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/test_service.proto', - {keepCase: true}); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); var test_service = test_proto.lookup('TestService'); var malformed_test_service = { unary: { @@ -669,9 +669,7 @@ describe('Server serialization failure handling', function() { var client; var server; before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/test_service.proto', - {keepCase: true}); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); var test_service = test_proto.lookup('TestService'); var malformed_test_service = { unary: { @@ -772,16 +770,13 @@ describe('Server serialization failure handling', function() { }); }); describe('Other conditions', function() { - var test_service; var Client; var client; var server; var port; before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/test_service.proto', - {keepCase: true}); - test_service = test_proto.lookup('TestService'); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); + var test_service = test_proto.lookup('TestService'); Client = grpc.loadObject(test_service); server = new grpc.Server(); var trailer_metadata = new grpc.Metadata(); @@ -1121,15 +1116,12 @@ describe('Call propagation', function() { var proxy; var proxy_impl; - var test_service; var Client; var client; var server; before(function() { - var test_proto = new ProtoBuf.Root(); - test_proto = test_proto.loadSync(__dirname + '/test_service.proto', - {keepCase: true}); - test_service = test_proto.lookup('TestService'); + var test_proto = ProtoBuf.loadProtoFile(__dirname + '/test_service.proto'); + var test_service = test_proto.lookup('TestService'); server = new grpc.Server(); Client = grpc.loadObject(test_service); server.addService(Client.service, { diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index d3fd88416b4..94e0b73a498 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -125,7 +125,12 @@ zval *grpc_parse_metadata_array(grpc_metadata_array php_grpc_add_next_index_stringl(inner_array, str_val, GRPC_SLICE_LENGTH(elem->value), false); add_assoc_zval(array, str_key, inner_array); + PHP_GRPC_FREE_STD_ZVAL(inner_array); } + efree(str_key); +#if PHP_MAJOR_VERSION >= 7 + efree(str_val); +#endif } return array; } @@ -256,8 +261,6 @@ PHP_METHOD(Call, startBatch) { object_init(result); php_grpc_ulong index; zval *recv_status; - PHP_GRPC_MAKE_STD_ZVAL(recv_status); - object_init(recv_status); zval *value; zval *inner_value; zval *message_value; @@ -439,7 +442,7 @@ PHP_METHOD(Call, startBatch) { grpc_completion_queue_pluck(completion_queue, call->wrapped, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); #if PHP_MAJOR_VERSION >= 7 - zval recv_md; + zval *recv_md; #endif for (int i = 0; i < op_num; i++) { switch(ops[i].op) { @@ -460,8 +463,10 @@ PHP_METHOD(Call, startBatch) { array = grpc_parse_metadata_array(&recv_metadata TSRMLS_CC); add_property_zval(result, "metadata", array); #else - recv_md = *grpc_parse_metadata_array(&recv_metadata); - add_property_zval(result, "metadata", &recv_md); + recv_md = grpc_parse_metadata_array(&recv_metadata); + add_property_zval(result, "metadata", recv_md); + zval_ptr_dtor(recv_md); + PHP_GRPC_FREE_STD_ZVAL(recv_md); #endif PHP_GRPC_DELREF(array); break; @@ -475,12 +480,16 @@ PHP_METHOD(Call, startBatch) { } break; case GRPC_OP_RECV_STATUS_ON_CLIENT: + PHP_GRPC_MAKE_STD_ZVAL(recv_status); + object_init(recv_status); #if PHP_MAJOR_VERSION < 7 array = grpc_parse_metadata_array(&recv_trailing_metadata TSRMLS_CC); add_property_zval(recv_status, "metadata", array); #else - recv_md = *grpc_parse_metadata_array(&recv_trailing_metadata); - add_property_zval(recv_status, "metadata", &recv_md); + recv_md = grpc_parse_metadata_array(&recv_trailing_metadata); + add_property_zval(recv_status, "metadata", recv_md); + zval_ptr_dtor(recv_md); + PHP_GRPC_FREE_STD_ZVAL(recv_md); #endif PHP_GRPC_DELREF(array); add_property_long(recv_status, "code", status); @@ -489,6 +498,9 @@ PHP_METHOD(Call, startBatch) { true); gpr_free(status_details_text); add_property_zval(result, "status", recv_status); +#if PHP_MAJOR_VERSION >= 7 + zval_ptr_dtor(recv_status); +#endif PHP_GRPC_DELREF(recv_status); PHP_GRPC_FREE_STD_ZVAL(recv_status); break; diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c index 625c0c62ae3..da7100f24a5 100644 --- a/src/php/ext/grpc/call_credentials.c +++ b/src/php/ext/grpc/call_credentials.c @@ -172,34 +172,54 @@ void plugin_get_metadata(void *ptr, grpc_auth_metadata_context context, object_init(arg); php_grpc_add_property_string(arg, "service_url", context.service_url, true); php_grpc_add_property_string(arg, "method_name", context.method_name, true); - zval *retval; - PHP_GRPC_MAKE_STD_ZVAL(retval); + zval *retval = NULL; #if PHP_MAJOR_VERSION < 7 zval **params[1]; params[0] = &arg; state->fci->params = params; state->fci->retval_ptr_ptr = &retval; #else + PHP_GRPC_MAKE_STD_ZVAL(retval); state->fci->params = arg; state->fci->retval = retval; #endif state->fci->param_count = 1; + PHP_GRPC_DELREF(arg); + /* call the user callback function */ zend_call_function(state->fci, state->fci_cache TSRMLS_CC); grpc_status_code code = GRPC_STATUS_OK; grpc_metadata_array metadata; + bool cleanup = true; if (Z_TYPE_P(retval) != IS_ARRAY) { + cleanup = false; code = GRPC_STATUS_INVALID_ARGUMENT; } else if (!create_metadata_array(retval, &metadata)) { - grpc_metadata_array_destroy(&metadata); code = GRPC_STATUS_INVALID_ARGUMENT; } + if (retval != NULL) { +#if PHP_MAJOR_VERSION < 7 + zval_ptr_dtor(&retval); +#else + zval_ptr_dtor(arg); + zval_ptr_dtor(retval); + PHP_GRPC_FREE_STD_ZVAL(arg); + PHP_GRPC_FREE_STD_ZVAL(retval); +#endif + } + /* Pass control back to core */ cb(user_data, metadata.metadata, metadata.count, code, NULL); + if (cleanup) { + for (int i = 0; i < metadata.count; i++) { + grpc_slice_unref(metadata.metadata[i].value); + } + grpc_metadata_array_destroy(&metadata); + } } /* Cleanup function for plugin creds API */ @@ -207,8 +227,10 @@ void plugin_destroy_state(void *ptr) { plugin_state *state = (plugin_state *)ptr; efree(state->fci); efree(state->fci_cache); +#if PHP_MAJOR_VERSION < 7 PHP_GRPC_FREE_STD_ZVAL(state->fci->params); PHP_GRPC_FREE_STD_ZVAL(state->fci->retval); +#endif efree(state); } diff --git a/templates/config.m4.template b/templates/config.m4.template index 8bcbb47319a..a6357b7fb1b 100644 --- a/templates/config.m4.template +++ b/templates/config.m4.template @@ -10,8 +10,6 @@ PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/cares) LIBS="-lpthread $LIBS" @@ -25,10 +23,8 @@ case $host in *darwin*) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/config_darwin) ;; *) - PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/cares/config_linux) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt) ;; @@ -47,7 +43,7 @@ % endfor , $ext_shared, , -fvisibility=hidden ${"\\"} -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"} - -D_HAS_EXCEPTIONS=0 -DNOMINMAX) + -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0) PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc) <% diff --git a/templates/package.json.template b/templates/package.json.template index 3bae8fde430..551c25f0423 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -36,7 +36,7 @@ "lodash": "^4.15.0", "nan": "^2.0.0", "node-pre-gyp": "^0.6.0", - "protobufjs": "^6.7.0" + "protobufjs": "^5.0.0" }, "devDependencies": { "async": "^2.0.1", diff --git a/templates/package.xml.template b/templates/package.xml.template index 8655cfa1d94..394b8154eea 100644 --- a/templates/package.xml.template +++ b/templates/package.xml.template @@ -12,7 +12,7 @@ grpc-packages@google.com yes - 2017-03-01 + 2017-05-05 ${settings.php_version.php()} @@ -24,8 +24,7 @@ BSD - - Added arg info macros #9751 - - Updated codegen to be consistent with protobuf #9492 + - Fixed some memory leaks #9559, #10996 @@ -43,6 +42,7 @@ % endfor % endif % endfor + @@ -355,6 +355,22 @@ BSD - Added arg info macros #9751 + - Updated codegen to be consistent with protobuf #9492 + + + + + 1.2.0 + 1.2.0 + + + stable + stable + + 2017-03-20 + BSD + + - Added arg info macros #9751 - Updated codegen to be consistent with protobuf #9492 diff --git a/templates/src/csharp/build_packages_dotnetcli.bat.template b/templates/src/csharp/build_packages_dotnetcli.bat.template index 3db1e0ac3de..8624c34782b 100755 --- a/templates/src/csharp/build_packages_dotnetcli.bat.template +++ b/templates/src/csharp/build_packages_dotnetcli.bat.template @@ -53,11 +53,11 @@ @rem To be able to build, we also need to put grpc_csharp_ext to its normal location xcopy /Y /I nativelibs\csharp_ext_windows_x64\grpc_csharp_ext.dll ..\..\cmake\build\x64\Release${"\\"} - %%DOTNET% pack --configuration Release Grpc.Core --output ..\..\..\artifacts || goto :error - %%DOTNET% pack --configuration Release Grpc.Core.Testing --output ..\..\..\artifacts || goto :error - %%DOTNET% pack --configuration Release Grpc.Auth --output ..\..\..\artifacts || goto :error - %%DOTNET% pack --configuration Release Grpc.HealthCheck --output ..\..\..\artifacts || goto :error - %%DOTNET% pack --configuration Release Grpc.Reflection --output ..\..\..\artifacts || goto :error + %%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Core --output ..\..\..\artifacts || goto :error + %%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Core.Testing --output ..\..\..\artifacts || goto :error + %%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Auth --output ..\..\..\artifacts || goto :error + %%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.HealthCheck --output ..\..\..\artifacts || goto :error + %%DOTNET% pack --configuration Release --include-symbols --include-source Grpc.Reflection --output ..\..\..\artifacts || goto :error %%NUGET% pack Grpc.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts || goto :error %%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts diff --git a/templates/src/csharp/build_packages_dotnetcli.sh.template b/templates/src/csharp/build_packages_dotnetcli.sh.template index 65afec55c4d..bff497c85a4 100755 --- a/templates/src/csharp/build_packages_dotnetcli.sh.template +++ b/templates/src/csharp/build_packages_dotnetcli.sh.template @@ -50,11 +50,11 @@ mkdir -p ../../libs/opt cp nativelibs/csharp_ext_linux_x64/libgrpc_csharp_ext.so ../../libs/opt - dotnet pack --configuration Release Grpc.Core --output ../../../artifacts - dotnet pack --configuration Release Grpc.Core.Testing --output ../../../artifacts - dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts - dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts - dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts + dotnet pack --configuration Release --include-symbols --include-source Grpc.Core --output ../../../artifacts + dotnet pack --configuration Release --include-symbols --include-source Grpc.Core.Testing --output ../../../artifacts + dotnet pack --configuration Release --include-symbols --include-source Grpc.Auth --output ../../../artifacts + dotnet pack --configuration Release --include-symbols --include-source Grpc.HealthCheck --output ../../../artifacts + dotnet pack --configuration Release --include-symbols --include-source Grpc.Reflection --output ../../../artifacts nuget pack Grpc.nuspec -Version "${settings.csharp_version}" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "${settings.csharp_version}" -OutputDirectory ../../artifacts diff --git a/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile b/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile new file mode 100644 index 00000000000..b085dd00dbf --- /dev/null +++ b/tools/dockerfile/grpc_artifact_linux_armv6/Dockerfile @@ -0,0 +1,39 @@ +# Copyright 2017, 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 gRPC Raspbian binaries + +FROM quay.io/grpc/raspbian_armv6 + +# Place any extra build instructions between these commands +# Recommend modifying upstream docker image (quay.io/grpc/raspbian_armv6) +# for build steps because running them under QEMU is very slow +# (https://github.com/kpayson64/armv7hf-debian-qemu) +# RUN [ "cross-build-start" ] +# RUN [ "cross-build-end" ] diff --git a/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile b/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile new file mode 100644 index 00000000000..d7759a6c503 --- /dev/null +++ b/tools/dockerfile/grpc_artifact_linux_armv7/Dockerfile @@ -0,0 +1,39 @@ +# Copyright 2017, 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 gRPC Raspbian binaries + +FROM quay.io/grpc/raspbian_armv7 + +# Place any extra build instructions between these commands +# Recommend modifying upstream docker image (quay.io/grpc/raspbian_armv7) +# for build steps because running them under QEMU is very slow +# (https://github.com/kpayson64/armv7hf-debian-qemu) +# RUN [ "cross-build-start" ] +# RUN [ "cross-build-end" ] diff --git a/tools/run_tests/artifacts/artifact_targets.py b/tools/run_tests/artifacts/artifact_targets.py index 5a71b96f9e2..e3658acbf65 100644 --- a/tools/run_tests/artifacts/artifact_targets.py +++ b/tools/run_tests/artifacts/artifact_targets.py @@ -41,7 +41,7 @@ import python_utils.jobset as jobset def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, flake_retries=0, timeout_retries=0, timeout_seconds=30*60, - docker_base_image=None): + docker_base_image=None, extra_docker_args=None): """Creates jobspec for a task running under docker.""" environ = environ.copy() environ['RUN_COMMAND'] = shell_command @@ -56,6 +56,8 @@ def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, if docker_base_image is not None: docker_env['DOCKER_BASE_IMAGE'] = docker_base_image + if extra_docker_args is not None: + docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args jobspec = jobset.JobSpec( cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args, environ=docker_env, @@ -115,7 +117,22 @@ class PythonArtifact: def build_jobspec(self): environ = {} - if self.platform == 'linux': + if self.platform == 'linux_extra': + # Raspberry Pi build + environ['PYTHON'] = '/usr/local/bin/python{}'.format(self.py_version) + environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version) + # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9 + # A QEMU bug causes submodule update to hang, so we copy directly + environ['RELATIVE_COPY_PATH'] = '.' + extra_args = ' --entrypoint=/usr/bin/qemu-arm-static ' + return create_docker_jobspec(self.name, + 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), + 'tools/run_tests/artifacts/build_artifact_python.sh', + environ=environ, + timeout_seconds=60*60*5, + docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch), + extra_docker_args=extra_args) + elif self.platform == 'linux': if self.arch == 'x86': environ['SETARCH_CMD'] = 'linux32' # Inside the manylinux container, the python installations are located in @@ -349,6 +366,14 @@ def targets(): PythonArtifact('linux', 'x86', 'cp34-cp34m'), PythonArtifact('linux', 'x86', 'cp35-cp35m'), PythonArtifact('linux', 'x86', 'cp36-cp36m'), + PythonArtifact('linux_extra', 'armv7', '2.7'), + PythonArtifact('linux_extra', 'armv7', '3.4'), + PythonArtifact('linux_extra', 'armv7', '3.5'), + PythonArtifact('linux_extra', 'armv7', '3.6'), + PythonArtifact('linux_extra', 'armv6', '2.7'), + PythonArtifact('linux_extra', 'armv6', '3.4'), + PythonArtifact('linux_extra', 'armv6', '3.5'), + PythonArtifact('linux_extra', 'armv6', '3.6'), PythonArtifact('linux', 'x64', 'cp27-cp27m'), PythonArtifact('linux', 'x64', 'cp27-cp27mu'), PythonArtifact('linux', 'x64', 'cp34-cp34m'), diff --git a/tools/run_tests/dockerize/build_and_run_docker.sh b/tools/run_tests/dockerize/build_and_run_docker.sh index 8c25c861c1a..6189e9a5c02 100755 --- a/tools/run_tests/dockerize/build_and_run_docker.sh +++ b/tools/run_tests/dockerize/build_and_run_docker.sh @@ -74,8 +74,9 @@ docker run \ -v "$git_root:/var/local/jenkins/grpc:ro" \ -w /var/local/git/grpc \ --name=$CONTAINER_NAME \ + $EXTRA_DOCKER_ARGS \ $DOCKER_IMAGE_NAME \ - bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || FAILED="true" + /bin/bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || FAILED="true" # Copy output artifacts if [ "$OUTPUT_DIR" != "" ]