Skip to content

Commit 505ca15

Browse files
committed
run-regression-test: add an option for retry when Groonga doesn't response
1 parent 59088e2 commit 505ca15

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/groonga-query-log/command/run-regression-test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def initialize
5252
@skip_finished_queries = false
5353
@output_query_log = false
5454
@stop_on_failure = false
55+
@retry_on_no_response = false
5556
@rewrite_vector_equal = false
5657
@rewrite_vector_not_equal_empty_string = false
5758
@vector_accessors = []
@@ -199,6 +200,11 @@ def create_option_parser
199200
"(#{@stop_on_failure})") do |boolean|
200201
@stop_on_failure = boolean
201202
end
203+
parser.on("--[no-]retry-on-no-response",
204+
"Retry execution when the no response",
205+
"(#{@retry_on_no_response})") do |boolean|
206+
@retry_on_no_response = boolean
207+
end
202208
parser.on("--[no-]rewrite-vector-equal",
203209
"Rewrite 'vector == ...' with 'vector @ ...'",
204210
"(#{@rewrite_vector_equal})") do |boolean|
@@ -379,6 +385,7 @@ def tester_options
379385
:skip_finished_queries => @skip_finished_queries,
380386
:ignored_drilldown_keys => @ignored_drilldown_keys,
381387
:stop_on_failure => @stop_on_failure,
388+
:retry_on_no_response => @retry_on_no_response,
382389
:rewrite_vector_equal => @rewrite_vector_equal,
383390
:rewrite_vector_not_equal_empty_string =>
384391
@rewrite_vector_not_equal_empty_string,
@@ -602,6 +609,7 @@ def initialize(old, new, options)
602609
options[:results_directory] || (@working_directory + "results")
603610
@n_clients = options[:n_clients] || 1
604611
@stop_on_failure = options[:stop_on_failure]
612+
@retry_on_no_response = options[:retry_on_no_response]
605613
@options = options
606614
@n_ready_waits = 2
607615
end
@@ -699,6 +707,9 @@ def verify_server(test_log_path, query_log_path, &callback)
699707
if @stop_on_failure
700708
command_line << "--stop-on-failure"
701709
end
710+
if @retry_on_no_response
711+
command_line << "--retry-on-no-response"
712+
end
702713
if @options[:rewrite_vector_equal]
703714
command_line << "--rewrite-vector-equal"
704715
end

lib/groonga-query-log/command/verify-server.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ def create_parser
201201
@options.stop_on_failure = boolean
202202
end
203203

204+
parser.on("--[no-]retry-on-no-response",
205+
"Retry execution when the no response",
206+
"(#{@options.retry_on_no_response?})") do |boolean|
207+
@options.retry_on_no_response = boolean
208+
end
209+
204210
parser.on("--[no-]rewrite-vector-equal",
205211
"Rewrite 'vector == ...' with 'vector @ ...'",
206212
"(#{@options.rewrite_vector_equal?})") do |boolean|

lib/groonga-query-log/server-verifier.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (C) 2013-2018 Kouhei Sutou <[email protected]>
2+
# Copyright (C) 2019 Horimoto Yasuhiro <[email protected]>
23
#
34
# This library is free software; you can redistribute it and/or
45
# modify it under the terms of the GNU Lesser General Public
@@ -170,8 +171,15 @@ def verify_command(groonga1_client, groonga2_client, command)
170171
command["output_type"] = "json"
171172
rewrite_filter(command, "filter")
172173
rewrite_filter(command, "scorer")
173-
response1 = groonga1_client.execute(command)
174-
response2 = groonga2_client.execute(command)
174+
175+
response1, response2 = ""
176+
n_tries = 3
177+
n_tries.times do
178+
response1 = groonga1_client.execute(command)
179+
response2 = groonga2_client.execute(command)
180+
break unless @options.retry_on_no_response?
181+
break if (!response1.nil? && !response2.nil?)
182+
end
175183
compare_options = {
176184
:care_order => @options.care_order,
177185
:ignored_drilldown_keys => @options.ignored_drilldown_keys,
@@ -271,6 +279,7 @@ class Options
271279
attr_writer :verify_cache
272280
attr_accessor :ignored_drilldown_keys
273281
attr_writer :stop_on_failure
282+
attr_writer :retry_on_no_response
274283
attr_writer :rewrite_vector_equal
275284
attr_writer :rewrite_vector_not_equal_empty_string
276285
attr_accessor :vector_accessors
@@ -303,6 +312,7 @@ def initialize
303312
@verify_cache = false
304313
@ignored_drilldown_keys = []
305314
@stop_on_failure = false
315+
@retry_on_no_response = false
306316
@rewrite_vector_equal = false
307317
@rewrite_vector_not_equal_empty_string = false
308318
@vector_accessors = []
@@ -330,6 +340,10 @@ def stop_on_failure?
330340
@stop_on_failure
331341
end
332342

343+
def retry_on_no_response?
344+
@retry_on_no_response
345+
end
346+
333347
def rewrite_vector_equal?
334348
@rewrite_vector_equal
335349
end

0 commit comments

Comments
 (0)