blob: 4ffc5719c68449b6b12b06b86d8cb9389a2082b1 [file] [log] [blame]
Alexander Polcyn4736e012017-04-14 17:32:00 -07001#!/usr/bin/env ruby
2
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# Copyright 2016 gRPC authors.
Alexander Polcyn4736e012017-04-14 17:32:00 -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 Polcyn4736e012017-04-14 17:32:00 -07008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# http://www.apache.org/licenses/LICENSE-2.0
Alexander Polcyn4736e012017-04-14 17:32:00 -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 Polcyn4736e012017-04-14 17:32:00 -070016
17require_relative './end2end_common'
18
19def main
20 native_grpc_classes = %w( channel
21 server
22 channel_credentials
23 call_credentials
24 compression_options )
25
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070026 # there is room for false positives in this test,
Alexander Polcynfd4cbb72017-05-17 09:57:25 -070027 # do a few runs for each config
28 4.times do
29 native_grpc_classes.each do |grpc_class|
30 ['', 'gc', 'concurrency'].each do |stress_test_type|
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070031 STDERR.puts 'start client'
32 this_dir = File.expand_path(File.dirname(__FILE__))
33 client_path = File.join(this_dir, 'grpc_class_init_client.rb')
34 client_pid = Process.spawn(RbConfig.ruby,
35 client_path,
36 "--grpc_class=#{grpc_class}",
Alexander Polcynfd4cbb72017-05-17 09:57:25 -070037 "--stress_test=#{stress_test_type}")
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070038 begin
39 Timeout.timeout(10) do
40 Process.wait(client_pid)
41 end
42 rescue Timeout::Error
43 STDERR.puts "timeout waiting for client pid #{client_pid}"
44 Process.kill('SIGKILL', client_pid)
45 Process.wait(client_pid)
46 STDERR.puts 'killed client child'
47 raise 'Timed out waiting for client process. ' \
48 'It likely hangs when the first constructed gRPC object has ' \
49 "type: #{grpc_class}"
50 end
Alexander Polcyn4736e012017-04-14 17:32:00 -070051
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070052 client_exit_code = $CHILD_STATUS
Alexander Polcyn5c6dda82017-05-17 13:08:34 -070053 # concurrency stress test type is expected to exit with a
54 # non-zero status due to an exception being raised
55 if client_exit_code != 0 && stress_test_type != 'concurrency'
Alexander Polcynb2c0b7b2017-04-27 00:26:25 -070056 fail "client failed, exit code #{client_exit_code}"
57 end
58 end
59 end
Alexander Polcyn4736e012017-04-14 17:32:00 -070060 end
61end
62
63main