blob: 84d039bf19da574cd8a65bc7050cd066d9b50a8c [file] [log] [blame]
Alexander Polcynea282e92017-03-20 20:53:34 -07001#!/usr/bin/env ruby
2
3# Copyright 2016, Google Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above
13# copyright notice, this list of conditions and the following disclaimer
14# in the documentation and/or other materials provided with the
15# distribution.
16# * Neither the name of Google Inc. nor the names of its
17# contributors may be used to endorse or promote products derived from
18# this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32# abruptly end a process that has active calls to
33# Channel.watch_connectivity_state
34
35require_relative './end2end_common'
36
37def main
38 STDERR.puts 'start server'
39 server_runner = ServerRunner.new
40 server_port = server_runner.run
41
42 sleep 1
43
44 STDERR.puts 'start client'
45 _, client_pid = start_client('sig_int_during_channel_watch_client.rb',
46 server_port)
47
48 # give time for the client to get into the middle
49 # of a channel state watch call
50 sleep 1
51 Process.kill('SIGINT', client_pid)
52
53 begin
54 Timeout.timeout(10) do
55 Process.wait(client_pid)
56 end
57 rescue Timeout::Error
58 STDERR.puts "timeout wait for client pid #{client_pid}"
59 Process.kill('SIGKILL', client_pid)
60 Process.wait(client_pid)
61 STDERR.puts 'killed client child'
62 raise 'Timed out waiting for client process. It likely hangs when a ' \
63 'SIGINT is sent while there is an active connectivity_state call'
64 end
Alexander Polcyn02d131b2017-03-22 15:12:32 -070065
66 server_runner.stop
Alexander Polcynea282e92017-03-20 20:53:34 -070067end
68
69main