blob: 98339baebeb231214291e999ec396887ba6a2812 [file] [log] [blame]
Alexander Polcyn16d97ed2017-03-15 10:01:13 -07001#!/usr/bin/env ruby
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# Copyright 2016 gRPC authors.
Alexander Polcyn16d97ed2017-03-15 10:01:13 -07004#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005# 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 Polcyn16d97ed2017-03-15 10:01:13 -07008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# http://www.apache.org/licenses/LICENSE-2.0
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070010#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011# 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 Polcyn16d97ed2017-03-15 10:01:13 -070016
Alexander Polcynf3147b32017-03-15 11:34:08 -070017# make sure that the client doesn't hang when process ended abruptly
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070018
19require_relative './end2end_common'
20
21def main
Alexander Polcyn4e606752017-03-19 23:32:54 -070022 STDERR.puts 'start server'
Alexander Polcyn077f8902017-03-24 09:53:40 -070023 server_runner = ServerRunner.new(EchoServerImpl)
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070024 server_port = server_runner.run
25
26 sleep 1
27
Alexander Polcyn4e606752017-03-19 23:32:54 -070028 STDERR.puts 'start client'
29 _, client_pid = start_client('channel_state_client.rb', server_port)
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070030
31 sleep 3
32
33 Process.kill('SIGTERM', client_pid)
34
35 begin
36 Timeout.timeout(10) { Process.wait(client_pid) }
37 rescue Timeout::Error
38 STDERR.puts "timeout wait for client pid #{client_pid}"
39 Process.kill('SIGKILL', client_pid)
40 Process.wait(client_pid)
Alexander Polcyn4e606752017-03-19 23:32:54 -070041 STDERR.puts 'killed client child'
42 raise 'Timed out waiting for client process. ' \
43 'It likely hangs when ended abruptly'
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070044 end
45
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070046 # The interrupt in the child process should cause it to
47 # exit a non-zero status, so don't check it here.
48 # This test mainly tries to catch deadlock.
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070049 server_runner.stop
50end
51
52main