-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test for successful cancellation #70
Changes from 2 commits
60ef92d
ac4051f
e322f1b
db675ca
993245d
b9d0c86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -67,6 +67,8 @@ def initialize | |||||
@debug_rewrite = false | ||||||
@omit_rate = 0.0 | ||||||
@max_limit = -1 | ||||||
@verify_cancel = false | ||||||
@cancel_max_wait = 5.0 | ||||||
|
||||||
@care_order = true | ||||||
@ignored_drilldown_keys = [] | ||||||
|
@@ -426,6 +428,20 @@ def create_option_parser | |||||
"(#{@notifier_options[:mail_only_on_failure]})") do |boolean| | ||||||
@notifier_options[:mail_only_on_failure] = boolean | ||||||
end | ||||||
parser.on("--[no-]verify-cancel", | ||||||
"Verify cancellation", | ||||||
"(#{@verify_cancel})") do |boolean| | ||||||
@verify_cancel = boolean | ||||||
end | ||||||
parser.on("--cancel-max-wait=SECONDS", Float, | ||||||
"Used with `--verify_cancel`." + | ||||||
"You can specify the maximum number of seconds to wait " + | ||||||
"before sending `request_cancel`." + | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"For example, if you specify 5.0 in this option, " + | ||||||
"wait randomly between 0~5.0 seconds before sending `request_cancel`.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"(#{@cancel_max_wait})") do |seconds| | ||||||
@cancel_max_wait = seconds | ||||||
end | ||||||
parser | ||||||
end | ||||||
|
||||||
|
@@ -478,6 +494,8 @@ def tester_options | |||||
:verify_performance => @verify_performance, | ||||||
:performance_verfifier_options => @performance_verfifier_options, | ||||||
:read_timeout => @read_timeout, | ||||||
:verify_cancel => @verify_cancel, | ||||||
:cancel_max_wait => @cancel_max_wait, | ||||||
} | ||||||
directory_options.merge(options) | ||||||
end | ||||||
|
@@ -945,6 +963,11 @@ def verify_server(test_log_path, query_log_path, &callback) | |||||
command_line << "--read-timeout" | ||||||
command_line << @options[:read_timeout].to_s | ||||||
end | ||||||
if @options[:verify_cancel] | ||||||
command_line << "--verify_cancel" | ||||||
command_line << "--cancel-max-wait" | ||||||
command_line << @options[:cancel_max_wait].to_s | ||||||
end | ||||||
verify_server = VerifyServer.new | ||||||
same = verify_server.run(command_line, &callback) | ||||||
@n_executed_commands = verify_server.n_executed_commands | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -287,6 +287,22 @@ def create_parser | |||||
@options.max_limit = limit | ||||||
end | ||||||
|
||||||
parser.on("--[no-]verify-cancel", | ||||||
"Verify cancellation", | ||||||
"(#{@options.verify_cancel?})") do |boolean| | ||||||
@options.verify_cancel = boolean | ||||||
end | ||||||
|
||||||
parser.on("--cancel-max-wait=SECONDS", Float, | ||||||
"Used with `--verify_cancel`." + | ||||||
"You can specify the maximum number of seconds to wait " + | ||||||
"before sending `request_cancel`." + | ||||||
"For example, if you specify 5.0 in this option, " + | ||||||
"wait randomly between 0~5.0 seconds before sending `request_cancel`.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"(#{@options.cancel_max_wait})") do |seconds| | ||||||
@options.cancel_max_wait = seconds | ||||||
end | ||||||
|
||||||
create_parser_performance(parser) | ||||||
|
||||||
parser.separator("") | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,6 +33,7 @@ def initialize(options) | |||||
@queue = SizedQueue.new(@options.request_queue_size) | ||||||
@events = Queue.new | ||||||
@n_executed_commands = 0 | ||||||
@request_id_counter = 0 | ||||||
end | ||||||
|
||||||
def verify(input, &callback) | ||||||
|
@@ -167,9 +168,15 @@ def stop? | |||||
@options.stop_on_failure? and failed? | ||||||
end | ||||||
|
||||||
def generate_request_id | ||||||
(@request_id_counter += 1).to_s | ||||||
end | ||||||
|
||||||
def verify_command(groonga1_client, groonga2_client, command) | ||||||
command["cache"] = "no" if @options.disable_cache? | ||||||
command["cache"] = "no" if @options.verify_performance? | ||||||
command["request_id"] = generate_request_id if @options.verify_cancel? | ||||||
|
||||||
if @options.max_limit >= 0 and command["limit"] | ||||||
limit = command["limit"].to_i | ||||||
if limit >= 0 | ||||||
|
@@ -181,8 +188,26 @@ def verify_command(groonga1_client, groonga2_client, command) | |||||
command["output_type"] = "json" | ||||||
rewrite_filter(command, "filter") | ||||||
rewrite_filter(command, "scorer") | ||||||
|
||||||
response1 = groonga1_client.execute(command) | ||||||
response2 = groonga2_client.execute(command) | ||||||
# `groonga2` is new Groonga. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
response2 = nil | ||||||
if @options.verify_cancel? | ||||||
request = groonga2_client.execute(command) do |response| | ||||||
response2 = response | ||||||
end | ||||||
# Randomize timing of sending `request_cancel` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
sleep(rand(0..@options.cancel_max_wait)) | ||||||
@options.groonga2.create_client do |cancel_client| | ||||||
cancel_client.execute("request_cancel", id: command.request_id) | ||||||
end | ||||||
request.wait | ||||||
|
||||||
return if response2.return_code == -77 # GRN_CANCEL | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
else | ||||||
response2 = groonga2_client.execute(command) | ||||||
end | ||||||
|
||||||
compare_options = { | ||||||
:care_order => @options.care_order, | ||||||
:ignored_drilldown_keys => @options.ignored_drilldown_keys, | ||||||
|
@@ -326,6 +351,8 @@ class Options | |||||
attr_writer :debug_rewrite | ||||||
attr_writer :omit_rate | ||||||
attr_accessor :max_limit | ||||||
attr_writer :verify_cancel | ||||||
attr_writer :cancel_max_wait | ||||||
def initialize | ||||||
@groonga1 = GroongaOptions.new | ||||||
@groonga2 = GroongaOptions.new | ||||||
|
@@ -361,6 +388,8 @@ def initialize | |||||
@debug_rewrite = false | ||||||
@omit_rate = 0.0 | ||||||
@max_limit = -1 | ||||||
@verify_cancel = false | ||||||
@cancel_max_wait = 5.0 | ||||||
end | ||||||
|
||||||
def request_queue_size | ||||||
|
@@ -460,6 +489,14 @@ def debug_rewrite? | |||||
def omit_rate | ||||||
@omit_rate | ||||||
end | ||||||
|
||||||
def verify_cancel? | ||||||
@verify_cancel | ||||||
end | ||||||
|
||||||
def cancel_max_wait | ||||||
@cancel_max_wait | ||||||
end | ||||||
end | ||||||
|
||||||
class GroongaOptions | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use Markdown: