cleanup test

pull/11054/head
Alexander Polcyn 8 years ago
parent 7b3629e6c2
commit fd4cbb7077
  1. 57
      src/ruby/end2end/grpc_class_init_client.rb
  2. 14
      src/ruby/end2end/grpc_class_init_driver.rb

@ -60,6 +60,27 @@ def run_gc_stress_test(test_proc)
construct_many(test_proc)
end
def run_concurrency_stress_test(test_proc)
test_proc.call
thds = []
100.times do
thds << Thread.new do
test_proc.call
end
end
raise "something"
end
# default (no gc_stress and no concurrency_stress)
def run_default_test(test_proc)
thd = Thread.new do
test_proc.call
end
test_proc.call
end
def get_test_proc(grpc_class)
case grpc_class
when 'channel'
@ -89,36 +110,34 @@ end
def main
grpc_class = ''
gc_stress = false
stress_test = ''
OptionParser.new do |opts|
opts.on('--grpc_class=P', String) do |p|
grpc_class = p
end
opts.on('--gc_stress=P') do |p|
gc_stress = p
opts.on('--stress_test=P') do |p|
stress_test = p
end
end.parse!
test_proc = get_test_proc(grpc_class)
if gc_stress == 'true'
# the different test configs need to be ran
# in separate processes, since each one tests
# clean shutdown in a different way
case stress_test
when 'gc'
p 'run gc stress'
run_gc_stress_test(test_proc)
return
end
# test_proc.call
thds = []
100.times do
thds << Thread.new do
test_proc.call
sleep 10
end
when 'concurrency'
p 'run concurrency stress'
run_concurrency_stress_test(test_proc)
when ''
p 'run default'
run_default_test(test_proc)
else
fail "bad --stress_test=#{stress_test} param"
end
#test_proc.call
raise "something"
thds.each(&:join)
end
main

@ -39,17 +39,17 @@ def main
compression_options )
# there is room for false positives in this test,
# do 10 runs for each config to reduce these.
[true, false].each do |gc_stress|
10.times do
native_grpc_classes.each do |grpc_class|
# do a few runs for each config
4.times do
native_grpc_classes.each do |grpc_class|
['', 'gc', 'concurrency'].each do |stress_test_type|
STDERR.puts 'start client'
this_dir = File.expand_path(File.dirname(__FILE__))
client_path = File.join(this_dir, 'grpc_class_init_client.rb')
client_pid = Process.spawn(RbConfig.ruby,
client_path,
"--grpc_class=#{grpc_class}",
"--gc_stress=#{gc_stress}")
"--stress_test=#{stress_test_type}")
begin
Timeout.timeout(10) do
Process.wait(client_pid)
@ -65,7 +65,9 @@ def main
end
client_exit_code = $CHILD_STATUS
if client_exit_code != 0
# concurrency stress test type is expected to exit with a
# non-zero status due to an exception being raised
if client_exit_code != 0 and stress_test_type != 'concurrency'
fail "client failed, exit code #{client_exit_code}"
end
end

Loading…
Cancel
Save