class GroongaQueryLog::Command::RunRegressionTest::Tester
Attributes
new[R]
old[R]
Public Class Methods
new(old, new, options)
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 795 def initialize(old, new, options) @old = old @new = new @input_directory = options[:input_directory] || Pathname.new(".") @working_directory = options[:working_directory] || Pathname.new(".") @results_directory = options[:results_directory] || (@working_directory + "results") @n_clients = options[:n_clients] || 1 @stop_on_failure = options[:stop_on_failure] @options = options @n_executed_commands = 0 end
Public Instance Methods
n_executed_commands()
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 850 def n_executed_commands @n_executed_commands end
run()
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 808 def run @old.ensure_database @new.ensure_database ready_queue = Thread::Queue.new wait_queue = Thread::Queue.new old_thread = Thread.new do @old.run begin ready_queue.push(true) wait_queue.pop true ensure @old.shutdown end end new_thread = Thread.new do @new.run begin ready_queue.push(true) wait_queue.pop true ensure @new.shutdown end end test_thread = Thread.new do ready_queue.pop ready_queue.pop success = run_test wait_queue.push(true) wait_queue.push(true) success end old_thread_success = old_thread.value new_thread_success = new_thread.value test_thread_success = test_thread.value old_thread_success and new_thread_success and test_thread_success end
Private Instance Methods
query_log_paths()
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 977 def query_log_paths Pathname.glob("#{@input_directory}/query-logs/**/*.{log,tar.gz}").sort end
run_test()
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 855 def run_test success = true query_log_paths.each do |query_log_path| log_path = test_log_path(query_log_path) if @options[:skip_finished_queries] and log_path.exist? puts("Skip query log: #{query_log_path}") next else puts("Running test against query log...: #{query_log_path}") end begin if use_persistent_cache? callback = lambda do if @old.use_persistent_cache? @old.shutdown @old.run end if @new.use_persistent_cache? @new.shutdown @new.run end end else callback = nil end unless verify_server(log_path, query_log_path, &callback) success = false break if @stop_on_failure end rescue Interrupt puts("Interrupt: #{query_log_path}") end end success end
test_log_path(query_log_path)
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 981 def test_log_path(query_log_path) @results_directory + "#{query_log_path.basename}.log" end
use_persistent_cache?()
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 985 def use_persistent_cache? @old.use_persistent_cache? or @new.use_persistent_cache? end
verify_server(test_log_path, query_log_path, &callback)
click to toggle source
# File lib/groonga-query-log/command/run-regression-test.rb, line 891 def verify_server(test_log_path, query_log_path, &callback) command_line = [ "--n-clients=#{@n_clients}", "--groonga1-host=#{@old.host}", "--groonga1-port=#{@old.port}", "--groonga1-protocol=http", "--groonga2-host=#{@new.host}", "--groonga2-port=#{@new.port}", "--groonga2-protocol=http", "--output", test_log_path.to_s, ] command_line << "--no-care-order" if @options[:care_order] == false @options[:ignored_drilldown_keys].each do |key| command_line.concat(["--ignore-drilldown-key", key]) end command_line << query_log_path.to_s if use_persistent_cache? command_line << "--verify-cache" end if @stop_on_failure command_line << "--stop-on-failure" end if @options[:debug_rewrite] command_line << "--debug-rewrite" end if @options[:rewrite_vector_equal] command_line << "--rewrite-vector-equal" end if @options[:rewrite_vector_not_equal_empty_string] command_line << "--rewrite-vector-not-equal-empty-string" end accessors = @options[:vector_accessors] || [] accessors.each do |accessor| command_line << "--vector-accessor" command_line << accessor end if @options[:rewrite_nullable_reference_number] command_line << "--rewrite-nullable-reference-number" end accessors = @options[:nullable_reference_number_accessors] || [] accessors.each do |accessor| command_line << "--nullable-reference-number-accessor" command_line << accessor end if @options[:rewrite_not_or_regular_expression] command_line << "--rewrite-not-or-regular-expression" end if @options[:rewrite_and_not_operator] command_line << "--rewrite-and-not-operator" end if @options[:debug_rewrite] command_line << "--debug-rewrite" end if @options[:omit_rate] < 1.0 command_line << "--omit-rate" command_line << @options[:omit_rate].to_s end if @options[:max_limit] >= 0 command_line << "--max-limit" command_line << @options[:max_limit].to_s end if @options[:target_command_names] command_line << "--target-command-names" command_line << @options[:target_command_names].join(",") end if @options[:verify_performance] command_line << "--verify-performance" command_line << "--performance-choose-strategy" options = @options[:performance_verfifier_options] command_line << options.choose_strategy.to_s end if @options[:read_timeout] 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 same end