blob: 291bf29424c30bd6ed1c290b4938c9f3e23a72e2 [file] [log] [blame]
Alexander Polcync44c16e2017-03-14 17:44:21 -07001#!/usr/bin/env ruby
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# Copyright 2016 gRPC authors.
Alexander Polcync44c16e2017-03-14 17:44:21 -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 Polcync44c16e2017-03-14 17:44:21 -07008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# http://www.apache.org/licenses/LICENSE-2.0
Alexander Polcync44c16e2017-03-14 17:44:21 -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 Polcync44c16e2017-03-14 17:44:21 -070016
17# smoke test for a grpc-using app that receives and
18# handles process-ending signals
19
Alexander Polcynf8dc32e2017-03-15 00:04:33 -070020require_relative './end2end_common'
Alexander Polcync44c16e2017-03-14 17:44:21 -070021
22def main
Alexander Polcyn4e606752017-03-19 23:32:54 -070023 STDERR.puts 'start server'
Alexander Polcyn077f8902017-03-24 09:53:40 -070024 server_runner = ServerRunner.new(EchoServerImpl)
Alexander Polcynf8dc32e2017-03-15 00:04:33 -070025 server_port = server_runner.run
Alexander Polcync44c16e2017-03-14 17:44:21 -070026
27 sleep 1
28
Alexander Polcyn4e606752017-03-19 23:32:54 -070029 STDERR.puts 'start client'
30 control_stub, client_pid = start_client('sig_handling_client.rb', server_port)
Alexander Polcync44c16e2017-03-14 17:44:21 -070031
32 sleep 1
33
Alexander Polcync44c16e2017-03-14 17:44:21 -070034 count = 0
35 while count < 5
Alexander Polcyn4e606752017-03-19 23:32:54 -070036 control_stub.do_echo_rpc(
37 ClientControl::DoEchoRpcRequest.new(request: 'hello'))
Alexander Polcync44c16e2017-03-14 17:44:21 -070038 Process.kill('SIGTERM', client_pid)
39 Process.kill('SIGINT', client_pid)
40 count += 1
41 end
42
Alexander Polcyn16d97ed2017-03-15 10:01:13 -070043 cleanup(control_stub, client_pid, server_runner)
Alexander Polcync44c16e2017-03-14 17:44:21 -070044end
45
46main