blob: 6691464dc69a50bff29502d0ee60a5d20aa76681 [file] [log] [blame]
Alexander Polcync44c16e2017-03-14 17:44:21 -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# smoke test for a grpc-using app that receives and
33# handles process-ending signals
34
Alexander Polcynf8dc32e2017-03-15 00:04:33 -070035require_relative './end2end_common'
Alexander Polcync44c16e2017-03-14 17:44:21 -070036
37def main
Alexander Polcyn4e606752017-03-19 23:32:54 -070038 STDERR.puts 'start server'
Alexander Polcyn077f8902017-03-24 09:53:40 -070039 server_runner = ServerRunner.new(EchoServerImpl)
Alexander Polcynf8dc32e2017-03-15 00:04:33 -070040 server_port = server_runner.run
Alexander Polcync44c16e2017-03-14 17:44:21 -070041
42 sleep 1
43
Alexander Polcyn4e606752017-03-19 23:32:54 -070044 STDERR.puts 'start client'
45 control_stub, client_pid = start_client('sig_handling_client.rb', server_port)
Alexander Polcync44c16e2017-03-14 17:44:21 -070046
47 sleep 1
48
Alexander Polcync44c16e2017-03-14 17:44:21 -070049 count = 0
50 while count < 5
Alexander Polcyn4e606752017-03-19 23:32:54 -070051 control_stub.do_echo_rpc(
52 ClientControl::DoEchoRpcRequest.new(request: 'hello'))
Alexander Polcync44c16e2017-03-14 17:44:21 -070053 Process.kill('SIGTERM', client_pid)
54 Process.kill('SIGINT', client_pid)
55 count += 1
56 end
57
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070058 cleanup(control_stub, client_pid, server_runner)
Alexander Polcync44c16e2017-03-14 17:44:21 -070059end
60
61main