Kouhei Sutou
null+****@clear*****
Mon Apr 24 11:06:53 JST 2017
Kouhei Sutou 2017-04-24 11:06:53 +0900 (Mon, 24 Apr 2017) New Revision: 88ea45a38506ab2032f0bb94c46e47ec9885e331 https://github.com/groonga/groonga-query-log/commit/88ea45a38506ab2032f0bb94c46e47ec9885e331 Message: run-regression-test: restart groonga per 100 commands It's caused only when --cache-base-path option is used. Modified files: lib/groonga/query-log/command/run-regression-test.rb lib/groonga/query-log/command/verify-server.rb lib/groonga/query-log/server-verifier.rb Modified: lib/groonga/query-log/command/run-regression-test.rb (+18 -18) =================================================================== --- lib/groonga/query-log/command/run-regression-test.rb 2017-04-24 11:05:13 +0900 (2bd05a3) +++ lib/groonga/query-log/command/run-regression-test.rb 2017-04-24 11:06:53 +0900 (11ce0d8) @@ -228,7 +228,7 @@ module Groonga retry end - yield + yield if block_given? end def ensure_database @@ -273,14 +273,6 @@ module Groonga Process.waitpid(@pid) end - def restart - self.shutdown - run_thread = Thread.new do - self.run{} - end - run_thread.join - end - private def find_unused_port server = TCPServer.new(@host, 0) @@ -372,16 +364,24 @@ module Groonga puts("Running test against query log...: #{query_log_path}") end begin - verify_server(log_path, query_log_path) + if****@old*****_persistent_cache? or****@new*****_persistent_cache? + callback = lambda do + if****@old*****_persistent_cache? + @old.shutdown + @old.run + end + if****@new*****_persistent_cache? + @new.shutdown + @new.run + end + end + else + callback = nil + end + verify_server(log_path, query_log_path, &callback) rescue Interrupt puts("Interrupt: #{query_log_path}") end - if****@new*****_persistent_cache? - @new.restart - end - if****@old*****_persistent_cache? - @old.restart - end end old_thread = Thread.new do @@ -396,7 +396,7 @@ module Groonga true end - def verify_server(test_log_path, query_log_path) + def verify_server(test_log_path, query_log_path, &callback) command_line = [ "--n-clients=#{@n_clients}", "--groonga1-host=#{@old.host}", @@ -413,7 +413,7 @@ module Groonga command_line << "--verify-cache" end verify_server = VerifyServer.new - verify_server.run(command_line) + verify_server.run(command_line, &callback) end def query_log_paths Modified: lib/groonga/query-log/command/verify-server.rb (+3 -3) =================================================================== --- lib/groonga/query-log/command/verify-server.rb 2017-04-24 11:05:13 +0900 (d575c2f) +++ lib/groonga/query-log/command/verify-server.rb 2017-04-24 11:06:53 +0900 (2f0c654) @@ -26,15 +26,15 @@ module Groonga @options = ServerVerifier::Options.new end - def run(command_line) + def run(command_line, &callback) input_paths = create_parser.parse(command_line) verifier = ServerVerifier.new(@options) if input_paths.empty? - verifier.verify($stdin) + verifier.verify($stdin, &callback) else input_paths.each do |input_path| File.open(input_path) do |input| - verifier.verify(input) + verifier.verify(input, &callback) end end end Modified: lib/groonga/query-log/server-verifier.rb (+18 -5) =================================================================== --- lib/groonga/query-log/server-verifier.rb 2017-04-24 11:05:13 +0900 (3b1b17c) +++ lib/groonga/query-log/server-verifier.rb 2017-04-24 11:06:53 +0900 (45b5097) @@ -31,29 +31,42 @@ module Groonga @different_results = Queue.new end - def verify(input) - producer = run_producer(input) - consumers = run_consumers + def verify(input, &callback) + producer = run_producer(input, &callback) reporter = run_reporter producer.join - consumers.each(&:join) @different_results.push(nil) reporter.join end private - def run_producer(input) + def run_producer(input, &callback) Thread.new do + consumers = run_consumers + parser = Parser.new + n_commands = 0 + callback_per_n_commands = 100 parser.parse(input) do |statistic| command = statistic.command next if command.nil? next unless target_command?(command) + n_commands += 1 @queue.push(statistic) + + if callback and (n_commands % callback_per_n_commands).zero? + @options.n_clients.times do + @queue.push(nil) + end + consumers.each(&:join) + callback.call + consumers = run_consumers + end end @options.n_clients.times do @queue.push(nil) end + consumers.each(&:join) end end -------------- next part -------------- HTML����������������������������... Télécharger