Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env ruby |
| 2 | |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | # Copyright 2016 gRPC authors. |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 4 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 10 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 16 | |
Alexander Polcyn | f3147b3 | 2017-03-15 11:34:08 -0700 | [diff] [blame] | 17 | # make sure that the client doesn't hang when process ended abruptly |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 18 | |
| 19 | require_relative './end2end_common' |
| 20 | |
| 21 | def main |
Alexander Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 22 | STDERR.puts 'start server' |
Alexander Polcyn | 077f890 | 2017-03-24 09:53:40 -0700 | [diff] [blame] | 23 | server_runner = ServerRunner.new(EchoServerImpl) |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 24 | server_port = server_runner.run |
| 25 | |
| 26 | sleep 1 |
| 27 | |
Alexander Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 28 | STDERR.puts 'start client' |
| 29 | _, client_pid = start_client('channel_state_client.rb', server_port) |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 30 | |
| 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 Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 41 | STDERR.puts 'killed client child' |
| 42 | raise 'Timed out waiting for client process. ' \ |
| 43 | 'It likely hangs when ended abruptly' |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 44 | end |
| 45 | |
Alexander Polcyn | b2c0b7b | 2017-04-27 00:26:25 -0700 | [diff] [blame] | 46 | # 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 Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 49 | server_runner.stop |
| 50 | end |
| 51 | |
| 52 | main |