blob: b054f0f5f31d3a22d5827cbd31aec28ed80d5798 [file] [log] [blame]
Alexander Polcynea282e92017-03-20 20:53:34 -07001#!/usr/bin/env ruby
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# Copyright 2016 gRPC authors.
Alexander Polcynea282e92017-03-20 20:53:34 -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 Polcynea282e92017-03-20 20:53:34 -07008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# http://www.apache.org/licenses/LICENSE-2.0
Alexander Polcynea282e92017-03-20 20:53:34 -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 Polcynea282e92017-03-20 20:53:34 -070016
17# abruptly end a process that has active calls to
18# Channel.watch_connectivity_state
19
20require_relative './end2end_common'
21
22def main
23 STDERR.puts 'start server'
Alexander Polcyn077f8902017-03-24 09:53:40 -070024 server_runner = ServerRunner.new(EchoServerImpl)
Alexander Polcynea282e92017-03-20 20:53:34 -070025 server_port = server_runner.run
26
27 sleep 1
28
29 STDERR.puts 'start client'
30 _, client_pid = start_client('sig_int_during_channel_watch_client.rb',
31 server_port)
32
33 # give time for the client to get into the middle
34 # of a channel state watch call
35 sleep 1
36 Process.kill('SIGINT', client_pid)
37
38 begin
39 Timeout.timeout(10) do
40 Process.wait(client_pid)
41 end
42 rescue Timeout::Error
43 STDERR.puts "timeout wait 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. It likely hangs when a ' \
48 'SIGINT is sent while there is an active connectivity_state call'
49 end
Alexander Polcyn02d131b2017-03-22 15:12:32 -070050
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070051 client_exit_code = $CHILD_STATUS
52 if client_exit_code != 0
53 fail "sig_int_during_channel_watch_client failed: #{client_exit_code}"
54 end
55
Alexander Polcyn02d131b2017-03-22 15:12:32 -070056 server_runner.stop
Alexander Polcynea282e92017-03-20 20:53:34 -070057end
58
59main