run_distrib_test.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # Copyright 2015 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -ex
  16. cd "$(dirname "$0")"
  17. function die {
  18. echo "$1"
  19. exit 1
  20. }
  21. ARCH="$1"
  22. PLATFORM="$2"
  23. PACKAGE_TYPE="$3"
  24. echo "$EXTERNAL_GIT_ROOT"
  25. GRPC_VERSION="$(ruby -e 'require ENV["EXTERNAL_GIT_ROOT"] + "/src/ruby/lib/grpc/version.rb"; puts GRPC::VERSION')"
  26. if [[ "$PACKAGE_TYPE" == "source" ]]; then
  27. GEM_NAME="grpc-${GRPC_VERSION}.gem"
  28. else
  29. [[ "$PACKAGE_TYPE" == "binary" ]] || die "unexpeced package type: $PACKAGE_TYPE"
  30. GEM_NAME="grpc-${GRPC_VERSION}-${ARCH}-${PLATFORM}.gem"
  31. fi
  32. # Create an indexed local gem source with gRPC gems to test
  33. GEM_SOURCE=../../../gem_source
  34. mkdir -p "${GEM_SOURCE}/gems"
  35. cp "${EXTERNAL_GIT_ROOT}/input_artifacts/${GEM_NAME}" "${GEM_SOURCE}/gems"
  36. # TODO: rewrite the following line to be shellcheck-compliant
  37. # shellcheck disable=SC2010
  38. if [[ "$(ls "${GEM_SOURCE}/gems" | grep -c grpc)" != 1 ]]; then
  39. echo "Sanity check failed. Copied over more than one grpc gem into the gem source directory."
  40. exit 1
  41. fi;
  42. gem install builder
  43. gem generate_index --directory "${GEM_SOURCE}"
  44. bundle install
  45. bundle exec ./distribtest.rb
  46. [[ "$PACKAGE_TYPE" == "source" ]] && exit 0
  47. # Attempt to repro https://github.com/protocolbuffers/protobuf/issues/4210.
  48. # This sanity check only works for linux-based distrib tests and for
  49. # binary gRPC packages.
  50. INSTALLATION_DIR="$(gem env | grep '\- INSTALLATION DIRECTORY' | awk '{ print $4 }')"
  51. if [[ "$(find "$INSTALLATION_DIR" -name 'grpc_c.so' | wc -l)" == 0 ]]; then
  52. echo "Sanity check failed. The gRPC package is not installed in $INSTALLATION_DIR."
  53. exit 1
  54. fi
  55. LIBRUBY_DEPENDENCY_EXISTS="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'libruby')" || true
  56. if [[ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ]]; then
  57. echo "A grpc_c.so file in this binary gRPC package is dynamically linked to libruby."
  58. fi
  59. DEPENDENCY_NOT_FOUND="$(find "$INSTALLATION_DIR" -name 'grpc_c.so' -exec ldd {} \; | grep -c 'not found')" || true
  60. if [[ "$DEPENDENCY_NOT_FOUND" != 0 ]]; then
  61. echo "A grpc_c.so file in this binary gRPC package has an non-portable dependency."
  62. fi
  63. if [ "$LIBRUBY_DEPENDENCY_EXISTS" != 0 ] || [ "$DEPENDENCY_NOT_FOUND" != 0 ]; then
  64. exit 1
  65. fi