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 17# make sure that the client doesn't freeze when process ended abruptly 18 19require_relative './end2end_common' 20 21def main 22 STDERR.puts 'start server' 23 server_runner = ServerRunner.new(EchoServerImpl) 24 server_port = server_runner.run 25 STDERR.puts 'start client' 26 client_controller = ClientController.new( 27 'channel_state_client.rb', server_port) 28 # sleep to allow time for the client to get into 29 # the middle of a "watch connectivity state" call 30 sleep 3 31 Process.kill('SIGTERM', client_controller.client_pid) 32 33 begin 34 Timeout.timeout(120) { Process.wait(client_controller.client_pid) } 35 rescue Timeout::Error 36 STDERR.puts "timeout wait for client pid #{client_controller.client_pid}" 37 Process.kill('SIGKILL', client_controller.client_pid) 38 Process.wait(client_controller.client_pid) 39 STDERR.puts 'killed client child' 40 raise 'Timed out waiting for client process. ' \ 41 'It likely freezes when ended abruptly' 42 end 43 44 # The interrupt in the child process should cause it to 45 # exit a non-zero status, so don't check it here. 46 # This test mainly tries to catch deadlock. 47 server_runner.stop 48end 49 50main 51