Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 1 | #!/usr/bin/env ruby |
| 2 | |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | # Copyright 2016 gRPC authors. |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 4 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 10 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 16 | |
| 17 | require_relative './end2end_common' |
| 18 | |
| 19 | def main |
| 20 | native_grpc_classes = %w( channel |
| 21 | server |
| 22 | channel_credentials |
| 23 | call_credentials |
| 24 | compression_options ) |
| 25 | |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 26 | # there is room for false positives in this test, |
Alexander Polcyn | fd4cbb7 | 2017-05-17 09:57:25 -0700 | [diff] [blame] | 27 | # do a few runs for each config |
| 28 | 4.times do |
| 29 | native_grpc_classes.each do |grpc_class| |
| 30 | ['', 'gc', 'concurrency'].each do |stress_test_type| |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 31 | STDERR.puts 'start client' |
| 32 | this_dir = File.expand_path(File.dirname(__FILE__)) |
| 33 | client_path = File.join(this_dir, 'grpc_class_init_client.rb') |
| 34 | client_pid = Process.spawn(RbConfig.ruby, |
| 35 | client_path, |
| 36 | "--grpc_class=#{grpc_class}", |
Alexander Polcyn | fd4cbb7 | 2017-05-17 09:57:25 -0700 | [diff] [blame] | 37 | "--stress_test=#{stress_test_type}") |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 38 | begin |
| 39 | Timeout.timeout(10) do |
| 40 | Process.wait(client_pid) |
| 41 | end |
| 42 | rescue Timeout::Error |
| 43 | STDERR.puts "timeout waiting for client pid #{client_pid}" |
| 44 | Process.kill('SIGKILL', client_pid) |
| 45 | Process.wait(client_pid) |
| 46 | STDERR.puts 'killed client child' |
| 47 | raise 'Timed out waiting for client process. ' \ |
| 48 | 'It likely hangs when the first constructed gRPC object has ' \ |
| 49 | "type: #{grpc_class}" |
| 50 | end |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 51 | |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 52 | client_exit_code = $CHILD_STATUS |
Alexander Polcyn | 5c6dda8 | 2017-05-17 13:08:34 -0700 | [diff] [blame] | 53 | # concurrency stress test type is expected to exit with a |
| 54 | # non-zero status due to an exception being raised |
| 55 | if client_exit_code != 0 && stress_test_type != 'concurrency' |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 56 | fail "client failed, exit code #{client_exit_code}" |
| 57 | end |
| 58 | end |
| 59 | end |
Alexander Polcyn | 4736e01 | 2017-04-14 17:32:00 -0700 | [diff] [blame] | 60 | end |
| 61 | end |
| 62 | |
| 63 | main |