grpc_class_init_driver.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env ruby
  2. # Copyright 2016, Google Inc.
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are
  7. # met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above
  12. # copyright notice, this list of conditions and the following disclaimer
  13. # in the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Google Inc. nor the names of its
  16. # contributors may be used to endorse or promote products derived from
  17. # this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. require_relative './end2end_common'
  31. def main
  32. native_grpc_classes = %w( channel
  33. server
  34. channel_credentials
  35. call_credentials
  36. compression_options )
  37. # there is room for false positives in this test,
  38. # do a few runs for each config
  39. 4.times do
  40. native_grpc_classes.each do |grpc_class|
  41. ['', 'gc', 'concurrency'].each do |stress_test_type|
  42. STDERR.puts 'start client'
  43. this_dir = File.expand_path(File.dirname(__FILE__))
  44. client_path = File.join(this_dir, 'grpc_class_init_client.rb')
  45. client_pid = Process.spawn(RbConfig.ruby,
  46. client_path,
  47. "--grpc_class=#{grpc_class}",
  48. "--stress_test=#{stress_test_type}")
  49. begin
  50. Timeout.timeout(10) do
  51. Process.wait(client_pid)
  52. end
  53. rescue Timeout::Error
  54. STDERR.puts "timeout waiting for client pid #{client_pid}"
  55. Process.kill('SIGKILL', client_pid)
  56. Process.wait(client_pid)
  57. STDERR.puts 'killed client child'
  58. raise 'Timed out waiting for client process. ' \
  59. 'It likely hangs when the first constructed gRPC object has ' \
  60. "type: #{grpc_class}"
  61. end
  62. client_exit_code = $CHILD_STATUS
  63. # concurrency stress test type is expected to exit with a
  64. # non-zero status due to an exception being raised
  65. if client_exit_code != 0 && stress_test_type != 'concurrency'
  66. fail "client failed, exit code #{client_exit_code}"
  67. end
  68. end
  69. end
  70. end
  71. end
  72. main