Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 1 | #!/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 | # smoke test for a grpc-using app that receives and |
| 33 | # handles process-ending signals |
| 34 | |
Alexander Polcyn | f8dc32e | 2017-03-15 00:04:33 -0700 | [diff] [blame] | 35 | require_relative './end2end_common' |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 36 | |
| 37 | def main |
Alexander Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 38 | STDERR.puts 'start server' |
Alexander Polcyn | 077f890 | 2017-03-24 09:53:40 -0700 | [diff] [blame] | 39 | server_runner = ServerRunner.new(EchoServerImpl) |
Alexander Polcyn | f8dc32e | 2017-03-15 00:04:33 -0700 | [diff] [blame] | 40 | server_port = server_runner.run |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 41 | |
| 42 | sleep 1 |
| 43 | |
Alexander Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 44 | STDERR.puts 'start client' |
| 45 | control_stub, client_pid = start_client('sig_handling_client.rb', server_port) |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 46 | |
| 47 | sleep 1 |
| 48 | |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 49 | count = 0 |
| 50 | while count < 5 |
Alexander Polcyn | 4e60675 | 2017-03-19 23:32:54 -0700 | [diff] [blame] | 51 | control_stub.do_echo_rpc( |
| 52 | ClientControl::DoEchoRpcRequest.new(request: 'hello')) |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 53 | Process.kill('SIGTERM', client_pid) |
| 54 | Process.kill('SIGINT', client_pid) |
| 55 | count += 1 |
| 56 | end |
| 57 | |
Alexander Polcyn | 16d97ed | 2017-03-15 10:01:13 -0700 | [diff] [blame] | 58 | cleanup(control_stub, client_pid, server_runner) |
Alexander Polcyn | c44c16e | 2017-03-14 17:44:21 -0700 | [diff] [blame] | 59 | end |
| 60 | |
| 61 | main |