Skip to content
Snippets Groups Projects
Commit fd4cbb70 authored by Alexander Polcyn's avatar Alexander Polcyn
Browse files

cleanup test

parent 7b3629e6
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,27 @@ def run_gc_stress_test(test_proc) ...@@ -60,6 +60,27 @@ def run_gc_stress_test(test_proc)
construct_many(test_proc) construct_many(test_proc)
end 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) def get_test_proc(grpc_class)
case grpc_class case grpc_class
when 'channel' when 'channel'
...@@ -89,36 +110,34 @@ end ...@@ -89,36 +110,34 @@ end
def main def main
grpc_class = '' grpc_class = ''
gc_stress = false stress_test = ''
OptionParser.new do |opts| OptionParser.new do |opts|
opts.on('--grpc_class=P', String) do |p| opts.on('--grpc_class=P', String) do |p|
grpc_class = p grpc_class = p
end end
opts.on('--gc_stress=P') do |p| opts.on('--stress_test=P') do |p|
gc_stress = p stress_test = p
end end
end.parse! end.parse!
test_proc = get_test_proc(grpc_class) 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) run_gc_stress_test(test_proc)
return when 'concurrency'
end p 'run concurrency stress'
run_concurrency_stress_test(test_proc)
# test_proc.call when ''
p 'run default'
thds = [] run_default_test(test_proc)
100.times do else
thds << Thread.new do fail "bad --stress_test=#{stress_test} param"
test_proc.call
sleep 10
end
end end
#test_proc.call
raise "something"
thds.each(&:join)
end end
main main
...@@ -39,17 +39,17 @@ def main ...@@ -39,17 +39,17 @@ def main
compression_options ) compression_options )
# there is room for false positives in this test, # there is room for false positives in this test,
# do 10 runs for each config to reduce these. # do a few runs for each config
[true, false].each do |gc_stress| 4.times do
10.times do native_grpc_classes.each do |grpc_class|
native_grpc_classes.each do |grpc_class| ['', 'gc', 'concurrency'].each do |stress_test_type|
STDERR.puts 'start client' STDERR.puts 'start client'
this_dir = File.expand_path(File.dirname(__FILE__)) this_dir = File.expand_path(File.dirname(__FILE__))
client_path = File.join(this_dir, 'grpc_class_init_client.rb') client_path = File.join(this_dir, 'grpc_class_init_client.rb')
client_pid = Process.spawn(RbConfig.ruby, client_pid = Process.spawn(RbConfig.ruby,
client_path, client_path,
"--grpc_class=#{grpc_class}", "--grpc_class=#{grpc_class}",
"--gc_stress=#{gc_stress}") "--stress_test=#{stress_test_type}")
begin begin
Timeout.timeout(10) do Timeout.timeout(10) do
Process.wait(client_pid) Process.wait(client_pid)
...@@ -65,7 +65,9 @@ def main ...@@ -65,7 +65,9 @@ def main
end end
client_exit_code = $CHILD_STATUS 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}" fail "client failed, exit code #{client_exit_code}"
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment