1#!/usr/bin/env ruby 2 3# Copyright 2016 gRPC authors. 4# 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 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 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. 16 17require_relative './end2end_common' 18 19def main 20 native_grpc_classes = %w( channel 21 server 22 channel_credentials 23 xds_channel_credentials 24 server_credentials 25 xds_server_credentials 26 call_credentials 27 compression_options ) 28 29 # there is room for false positives in this test, 30 # do a few runs for each config 31 4.times do 32 native_grpc_classes.each do |grpc_class| 33 # TODO(b/266212253): re-enable the "concurrency" mode 34 # of this test after the "Bus error" flakes of this 35 # test are fixed. 36 ['', 'gc'].each do |stress_test_type| 37 STDERR.puts 'start client' 38 this_dir = File.expand_path(File.dirname(__FILE__)) 39 client_path = File.join(this_dir, 'grpc_class_init_client.rb') 40 client_pid = Process.spawn(RbConfig.ruby, 41 client_path, 42 "--grpc_class=#{grpc_class}", 43 "--stress_test=#{stress_test_type}") 44 begin 45 Timeout.timeout(120) do 46 Process.wait(client_pid) 47 end 48 rescue Timeout::Error 49 STDERR.puts "timeout waiting for client pid #{client_pid}" 50 Process.kill('SIGKILL', client_pid) 51 Process.wait(client_pid) 52 STDERR.puts 'killed client child' 53 raise 'Timed out waiting for client process. ' \ 54 'It likely freezes when the first constructed gRPC object has ' \ 55 "type: #{grpc_class}" 56 end 57 58 client_exit_code = $CHILD_STATUS 59 # concurrency stress test type is expected to exit with a 60 # non-zero status due to an exception being raised 61 if client_exit_code != 0 && stress_test_type != 'concurrency' 62 fail "client failed, exit code #{client_exit_code}" 63 end 64 end 65 end 66 end 67end 68 69main 70