Kouhei Sutou
null+****@clear*****
Tue Nov 21 15:47:27 JST 2017
Kouhei Sutou 2017-11-21 15:47:27 +0900 (Tue, 21 Nov 2017) New Revision: 3cc150856c20699f94a0bfa1f849531762a8f3d3 https://github.com/groonga/groonga-query-log/commit/3cc150856c20699f94a0bfa1f849531762a8f3d3 Message: Change namespace to Groonga::QueryLog to GroongaQueryLog Groonga::QueryLog is deprecated but still usable with warning. Copied files: lib/groonga-query-log.rb (from lib/groonga/query-log/version.rb) lib/groonga-query-log/command/analyzer.rb (from lib/groonga/query-log/command/analyzer.rb) lib/groonga-query-log/command/check-command-version-compatibility.rb (from lib/groonga/query-log/command/check-command-version-compatibility.rb) lib/groonga-query-log/command/detect-memory-leak.rb (from lib/groonga/query-log/command/detect-memory-leak.rb) lib/groonga-query-log/command/extract.rb (from lib/groonga/query-log/command/extract.rb) lib/groonga-query-log/command/format-regression-test-logs.rb (from lib/groonga/query-log/command/format-regression-test-logs.rb) lib/groonga-query-log/command/run-regression-test.rb (from lib/groonga/query-log/command/run-regression-test.rb) lib/groonga-query-log/command/show-running-queries.rb (from lib/groonga/query-log/command/show-running-queries.rb) lib/groonga-query-log/command/verify-server.rb (from lib/groonga/query-log/command/verify-server.rb) lib/groonga-query-log/version.rb (from lib/groonga/query-log/version.rb) Modified files: lib/groonga/query-log.rb lib/groonga/query-log/command/analyzer.rb lib/groonga/query-log/command/check-command-version-compatibility.rb lib/groonga/query-log/command/detect-memory-leak.rb lib/groonga/query-log/command/extract.rb lib/groonga/query-log/command/format-regression-test-logs.rb lib/groonga/query-log/command/run-regression-test.rb lib/groonga/query-log/command/show-running-queries.rb lib/groonga/query-log/command/verify-server.rb test/command/test-analyzer.rb test/command/test-extract.rb test/command/test-format-regression-test-logs.rb test/helper.rb test/test-incompatibility-detector.rb test/test-parser.rb test/test-replayer.rb test/test-response-comparer.rb Renamed files: lib/groonga-query-log/command-line-utils.rb (from lib/groonga/query-log/command-line-utils.rb) lib/groonga-query-log/command-version-compatibility-checker.rb (from lib/groonga/query-log/command-version-compatibility-checker.rb) lib/groonga-query-log/command/analyzer/reporter.rb (from lib/groonga/query-log/command/analyzer/reporter.rb) lib/groonga-query-log/command/analyzer/reporter/console.rb (from lib/groonga/query-log/command/analyzer/reporter/console.rb) lib/groonga-query-log/command/analyzer/reporter/html.rb (from lib/groonga/query-log/command/analyzer/reporter/html.rb) lib/groonga-query-log/command/analyzer/reporter/json-stream.rb (from lib/groonga/query-log/command/analyzer/reporter/json-stream.rb) lib/groonga-query-log/command/analyzer/reporter/json.rb (from lib/groonga/query-log/command/analyzer/reporter/json.rb) lib/groonga-query-log/command/analyzer/sized-grouped-operations.rb (from lib/groonga/query-log/command/analyzer/sized-grouped-operations.rb) lib/groonga-query-log/command/analyzer/sized-statistics.rb (from lib/groonga/query-log/command/analyzer/sized-statistics.rb) lib/groonga-query-log/command/analyzer/streamer.rb (from lib/groonga/query-log/command/analyzer/streamer.rb) lib/groonga-query-log/command/replay.rb (from lib/groonga/query-log/command/replay.rb) lib/groonga-query-log/incompatibility-detector.rb (from lib/groonga/query-log/incompatibility-detector.rb) lib/groonga-query-log/memory-leak-detector.rb (from lib/groonga/query-log/memory-leak-detector.rb) lib/groonga-query-log/parser.rb (from lib/groonga/query-log/parser.rb) lib/groonga-query-log/replayer.rb (from lib/groonga/query-log/replayer.rb) lib/groonga-query-log/response-comparer.rb (from lib/groonga/query-log/response-comparer.rb) lib/groonga-query-log/server-verifier.rb (from lib/groonga/query-log/server-verifier.rb) lib/groonga-query-log/statistic.rb (from lib/groonga/query-log/statistic.rb) lib/groonga/query-log/command/reply.rb (from lib/groonga/query-log/version.rb) Copied: lib/groonga-query-log.rb (+22 -3) 53% =================================================================== --- lib/groonga/query-log/version.rb 2017-11-21 15:18:27 +0900 (0883a43) +++ lib/groonga-query-log.rb 2017-11-21 15:47:27 +0900 (82eae24) @@ -14,8 +14,27 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog - VERSION = "1.2.9" +require "groonga-query-log/version" +require "groonga-query-log/parser" +require "groonga-query-log/replayer" +require "groonga-query-log/server-verifier" +require "groonga-query-log/command-version-compatibility-checker" + +module GroongaQueryLog + module AnalyzerNamespaceBackwardCompatibility + def const_missing(name) + case name + when :Analyzer + warn("GroongaQueryLog::Analyzer is deprecated. " + + "Use GroongaQueryLog::Command::Analyzer instead:\n" + + caller.join("\n")) + require "groonga-query-log/command/analyzer" + const_set(name, Command::Analyzer) + else + super + end + end end + + extend AnalyzerNamespaceBackwardCompatibility end Renamed: lib/groonga-query-log/command-line-utils.rb (+2 -6) 87% =================================================================== --- lib/groonga/query-log/command-line-utils.rb 2017-11-21 15:18:27 +0900 (471b688) +++ lib/groonga-query-log/command-line-utils.rb 2017-11-21 15:47:27 +0900 (2c8e359) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> +# Copyright (C) 2012-2017 Haruka Yoshihara <yoshihara �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -15,8 +13,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -module Groonga - module QueryLog +module GroongaQueryLog module CommandLineUtils def log_via_stdin? stdin_with_pipe? or stdin_with_redirect? @@ -30,5 +27,4 @@ module Groonga not File.select([$stdin], [], [], 0).nil? end end - end end Renamed: lib/groonga-query-log/command-version-compatibility-checker.rb (+3 -5) 95% =================================================================== --- lib/groonga/query-log/command-version-compatibility-checker.rb 2017-11-21 15:18:27 +0900 (887f1aa) +++ lib/groonga-query-log/command-version-compatibility-checker.rb 2017-11-21 15:47:27 +0900 (75f2e5a) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,10 +14,9 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/incompatibility-detector" +require "groonga-query-log/incompatibility-detector" -module Groonga - module QueryLog +module GroongaQueryLog class CommandVersionCompatibilityChecker def initialize(options) @options = options @@ -96,5 +95,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/analyzer.rb (+13 -15) 92% =================================================================== --- lib/groonga/query-log/command/analyzer.rb 2017-11-21 15:18:27 +0900 (ae69c1f) +++ lib/groonga-query-log/command/analyzer.rb 2017-11-21 15:47:27 +0900 (e2010ea) @@ -17,18 +17,17 @@ require "optparse" require "json" -require "groonga/query-log/command-line-utils" -require "groonga/query-log/parser" -require "groonga/query-log/command/analyzer/streamer" -require "groonga/query-log/command/analyzer/sized-statistics" -require "groonga/query-log/command/analyzer/reporter/console" -require "groonga/query-log/command/analyzer/reporter/html" -require "groonga/query-log/command/analyzer/reporter/json" -require "groonga/query-log/command/analyzer/reporter/json-stream" +require "groonga-query-log/command-line-utils" +require "groonga-query-log/parser" +require "groonga-query-log/command/analyzer/streamer" +require "groonga-query-log/command/analyzer/sized-statistics" +require "groonga-query-log/command/analyzer/reporter/console" +require "groonga-query-log/command/analyzer/reporter/html" +require "groonga-query-log/command/analyzer/reporter/json" +require "groonga-query-log/command/analyzer/reporter/json-stream" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer include CommandLineUtils @@ -45,11 +44,11 @@ module Groonga setup_options end - # Executes analyzer for groonga's query logs. + # Executes analyzer for Groonga's query logs. # "groonga-query-log-analyze" command run this method. # # @example - # analyzer = Groonga::QueryLog::Analyzer.new + # analyzer = GroongaQueryLog::Command::Analyzer.new # analyzer.run("--output", "statistics.html", # "--reporter", "html", # "query.log") @@ -243,7 +242,7 @@ module Groonga end def parse(log_paths, &process_statistic) - parser = Groonga::QueryLog::Parser.new(@options) + parser = Parser.new(@options) if log_paths.empty? unless log_via_stdin? raise(NoInputError, "Error: Please specify input log files.") @@ -258,6 +257,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/reporter.rb (+3 -7) 95% =================================================================== --- lib/groonga/query-log/command/analyzer/reporter.rb 2017-11-21 15:18:27 +0900 (b6cb5f1) +++ lib/groonga-query-log/command/analyzer/reporter.rb 2017-11-21 15:47:27 +0900 (517946d) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011-2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2017 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> # # This library is free software; you can redistribute it and/or @@ -17,9 +15,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class Reporter include Enumerable @@ -107,6 +104,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/reporter/console.rb (+3 -5) 98% =================================================================== --- lib/groonga/query-log/command/analyzer/reporter/console.rb 2017-11-21 15:18:27 +0900 (f47c14c) +++ lib/groonga-query-log/command/analyzer/reporter/console.rb 2017-11-21 15:47:27 +0900 (69a1511) @@ -15,11 +15,10 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/command/analyzer/reporter" +require "groonga-query-log/command/analyzer/reporter" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class ConsoleReporter < Reporter class Color @@ -294,6 +293,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/reporter/html.rb (+3 -5) 98% =================================================================== --- lib/groonga/query-log/command/analyzer/reporter/html.rb 2017-11-21 15:18:27 +0900 (624b98c) +++ lib/groonga-query-log/command/analyzer/reporter/html.rb 2017-11-21 15:47:27 +0900 (c6748e9) @@ -16,11 +16,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA require "erb" -require "groonga/query-log/command/analyzer/reporter" +require "groonga-query-log/command/analyzer/reporter" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class HTMLReporter < Reporter include ERB::Util @@ -337,6 +336,5 @@ td.name end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/reporter/json-stream.rb (+3 -5) 91% =================================================================== --- lib/groonga/query-log/command/analyzer/reporter/json-stream.rb 2017-11-21 15:18:27 +0900 (c569139) +++ lib/groonga-query-log/command/analyzer/reporter/json-stream.rb 2017-11-21 15:47:27 +0900 (4270eae) @@ -14,11 +14,10 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/command/analyzer/reporter" +require "groonga-query-log/command/analyzer/reporter" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class JSONStreamReporter < Reporter def report_statistic(statistic) @@ -44,6 +43,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/reporter/json.rb (+3 -5) 92% =================================================================== --- lib/groonga/query-log/command/analyzer/reporter/json.rb 2017-11-21 15:18:27 +0900 (5adb195) +++ lib/groonga-query-log/command/analyzer/reporter/json.rb 2017-11-21 15:47:27 +0900 (3e8f411) @@ -15,11 +15,10 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/command/analyzer/reporter" +require "groonga-query-log/command/analyzer/reporter" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class JSONReporter < Reporter def report_statistic(statistic) @@ -49,6 +48,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/sized-grouped-operations.rb (+2 -4) 97% =================================================================== --- lib/groonga/query-log/command/analyzer/sized-grouped-operations.rb 2017-11-21 15:18:27 +0900 (8a9faa3) +++ lib/groonga-query-log/command/analyzer/sized-grouped-operations.rb 2017-11-21 15:47:27 +0900 (413917f) @@ -15,9 +15,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class SizedGroupedOperations < Array def initialize @@ -79,6 +78,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/sized-statistics.rb (+3 -5) 97% =================================================================== --- lib/groonga/query-log/command/analyzer/sized-statistics.rb 2017-11-21 15:18:27 +0900 (b120923) +++ lib/groonga-query-log/command/analyzer/sized-statistics.rb 2017-11-21 15:47:27 +0900 (91b6b99) @@ -15,11 +15,10 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/command/analyzer/sized-grouped-operations" +require "groonga-query-log/command/analyzer/sized-grouped-operations" -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class SizedStatistics < Array attr_reader :n_responses, :n_slow_responses, :n_slow_operations @@ -155,6 +154,5 @@ module Groonga end end end - end end end Renamed: lib/groonga-query-log/command/analyzer/streamer.rb (+2 -4) 95% =================================================================== --- lib/groonga/query-log/command/analyzer/streamer.rb 2017-11-21 15:18:27 +0900 (316773b) +++ lib/groonga-query-log/command/analyzer/streamer.rb 2017-11-21 15:47:27 +0900 (7791695) @@ -15,9 +15,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog - module Command +module GroongaQueryLog + module Command class Analyzer class Streamer def initialize(reporter) @@ -37,6 +36,5 @@ module Groonga end end end - end end end Copied: lib/groonga-query-log/command/check-command-version-compatibility.rb (+3 -5) 94% =================================================================== --- lib/groonga/query-log/command/check-command-version-compatibility.rb 2017-11-21 15:18:27 +0900 (4b2d6e3) +++ lib/groonga-query-log/command/check-command-version-compatibility.rb 2017-11-21 15:47:27 +0900 (4225704) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,10 +16,9 @@ require "optparse" -require "groonga/query-log" +require "groonga-query-log" -module Groonga - module QueryLog +module GroongaQueryLog module Command class CheckCommandVersionCompatibility def initialize @@ -67,5 +66,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/detect-memory-leak.rb (+4 -8) 93% =================================================================== --- lib/groonga/query-log/command/detect-memory-leak.rb 2017-11-21 15:18:27 +0900 (eddf0fb) +++ lib/groonga-query-log/command/detect-memory-leak.rb 2017-11-21 15:47:27 +0900 (d75864f) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,11 +16,10 @@ require "optparse" -require "groonga/query-log/version" -require "groonga/query-log/memory-leak-detector" +require "groonga-query-log/version" +require "groonga-query-log/memory-leak-detector" -module Groonga - module QueryLog +module GroongaQueryLog module Command class DetectMemoryLeak def initialize @@ -89,5 +86,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/extract.rb (+7 -11) 94% =================================================================== --- lib/groonga/query-log/command/extract.rb 2017-11-21 15:18:27 +0900 (8894729) +++ lib/groonga-query-log/command/extract.rb 2017-11-21 15:47:27 +0900 (e85c024) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2017 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> # # This library is free software; you can redistribute it and/or @@ -20,11 +18,10 @@ require "ostruct" require "optparse" require "pathname" -require "groonga/query-log" -require "groonga/query-log/command-line-utils" +require "groonga-query-log" +require "groonga-query-log/command-line-utils" -module Groonga - module QueryLog +module GroongaQueryLog module Command class Extract include CommandLineUtils @@ -41,11 +38,11 @@ module Groonga setup_options end - # Executes extractor for groonga's query logs. + # Executes extractor for Groonga's query logs. # "groonga-query-log-extract" command runs this method. # # @example - # extractor = Groonga::QueryLog::Command::Extract.new + # extractor = GroongaQueryLog::Command::Extract.new # extractor.run("--output", "commands.output", # "--command", "select", # "query.log") @@ -154,7 +151,7 @@ module Groonga end def extract_command(log, output) - parser = Groonga::QueryLog::Parser.new + parser = Parser.new parser.parse(log) do |statistic| command = statistic.command next unless target?(command) @@ -188,5 +185,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/format-regression-test-logs.rb (+3 -5) 97% =================================================================== --- lib/groonga/query-log/command/format-regression-test-logs.rb 2017-11-21 15:18:27 +0900 (669def0) +++ lib/groonga-query-log/command/format-regression-test-logs.rb 2017-11-21 15:47:27 +0900 (669b06b) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -23,10 +23,9 @@ require "json" require "groonga/command/parser" -require "groonga/query-log/version" +require "groonga-query-log/version" -module Groonga - module QueryLog +module GroongaQueryLog module Command class FormatRegressionTestLogs def initialize @@ -141,5 +140,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/command/replay.rb (+4 -8) 95% =================================================================== --- lib/groonga/query-log/command/replay.rb 2017-11-21 15:18:27 +0900 (2029559) +++ lib/groonga-query-log/command/replay.rb 2017-11-21 15:47:27 +0900 (ea7260b) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,11 +16,10 @@ require "optparse" -require "groonga/query-log/version" -require "groonga/query-log/replayer" +require "groonga-query-log/version" +require "groonga-query-log/replayer" -module Groonga - module QueryLog +module GroongaQueryLog module Command class Replay def initialize @@ -116,5 +113,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/run-regression-test.rb (+3 -5) 99% =================================================================== --- lib/groonga/query-log/command/run-regression-test.rb 2017-11-21 15:18:27 +0900 (f6763d9) +++ lib/groonga-query-log/command/run-regression-test.rb 2017-11-21 15:47:27 +0900 (363da6b) @@ -21,11 +21,10 @@ require "fileutils" require "pathname" require "net/http" -require "groonga/query-log" -require "groonga/query-log/command/verify-server" +require "groonga-query-log" +require "groonga-query-log/command/verify-server" -module Groonga - module QueryLog +module GroongaQueryLog module Command class RunRegressionTest def initialize @@ -430,5 +429,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/show-running-queries.rb (+4 -6) 93% =================================================================== --- lib/groonga/query-log/command/show-running-queries.rb 2017-11-21 15:18:27 +0900 (d602356) +++ lib/groonga-query-log/command/show-running-queries.rb 2017-11-21 15:47:27 +0900 (9ceaa46) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,11 +17,10 @@ require "optparse" require "time" -require "groonga/query-log/version" -require "groonga/query-log/parser" +require "groonga-query-log/version" +require "groonga-query-log/parser" -module Groonga - module QueryLog +module GroongaQueryLog module Command class ShowRunningQueries def initialize @@ -76,5 +75,4 @@ module Groonga end end end - end end Copied: lib/groonga-query-log/command/verify-server.rb (+2 -4) 98% =================================================================== --- lib/groonga/query-log/command/verify-server.rb 2017-11-21 15:18:27 +0900 (2f0c654) +++ lib/groonga-query-log/command/verify-server.rb 2017-11-21 15:47:27 +0900 (3818411) @@ -16,10 +16,9 @@ require "optparse" -require "groonga/query-log" +require "groonga-query-log" -module Groonga - module QueryLog +module GroongaQueryLog module Command class VerifyServer def initialize @@ -149,5 +148,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/incompatibility-detector.rb (+3 -5) 95% =================================================================== --- lib/groonga/query-log/incompatibility-detector.rb 2017-11-21 15:18:27 +0900 (2b2fd0e) +++ lib/groonga-query-log/incompatibility-detector.rb 2017-11-21 15:47:27 +0900 (a824e6e) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,10 +16,9 @@ require "fileutils" -require "groonga/query-log/parser" +require "groonga-query-log/parser" -module Groonga - module QueryLog +module GroongaQueryLog class IncompatibilityDetector attr_reader :version def initialize(version) @@ -94,5 +93,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/memory-leak-detector.rb (+3 -7) 95% =================================================================== --- lib/groonga/query-log/memory-leak-detector.rb 2017-11-21 15:18:27 +0900 (078290b) +++ lib/groonga-query-log/memory-leak-detector.rb 2017-11-21 15:47:27 +0900 (60c7a6c) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,10 +18,9 @@ require "time" require "groonga/client" -require "groonga/query-log/parser" +require "groonga-query-log/parser" -module Groonga - module QueryLog +module GroongaQueryLog class MemoryLeakDetector def initialize(options) @options = options @@ -122,5 +119,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/parser.rb (+5 -7) 93% =================================================================== --- lib/groonga/query-log/parser.rb 2017-11-21 15:18:27 +0900 (c0017b2) +++ lib/groonga-query-log/parser.rb 2017-11-21 15:47:27 +0900 (c8dd10f) @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2016 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,10 +16,9 @@ require "English" -require "groonga/query-log/statistic" +require "groonga-query-log/statistic" -module Groonga - module QueryLog +module GroongaQueryLog class Parser def initialize(options={}) @options = options @@ -31,13 +30,13 @@ module Groonga end # Parses query-log file as stream to - # {Groonga::QueryLog::Analyzer::Statistics} including some + # {GroongaQueryLog::Analyzer::Statistic}s including some # informations for each query. # # @param [IO] input IO for input query log file. # @yield [statistics] if a block is specified, it is called # every time a query is finished parsing. - # @yieldparam [Groonga::QueryLog::Analyzer::Statistic] statistic + # @yieldparam [GroongaQueryLog::Statistic] statistic # statistics of each query in log files. def parse(input, &block) input.each_line do |line| @@ -121,5 +120,4 @@ module Groonga true end end - end end Renamed: lib/groonga-query-log/replayer.rb (+3 -7) 97% =================================================================== --- lib/groonga/query-log/replayer.rb 2017-11-21 15:18:27 +0900 (c5a37de) +++ lib/groonga-query-log/replayer.rb 2017-11-21 15:47:27 +0900 (3c68dad) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -21,10 +19,9 @@ require "thread" require "groonga/client" -require "groonga/query-log/parser" +require "groonga-query-log/parser" -module Groonga - module QueryLog +module GroongaQueryLog class Replayer def initialize(options) @options = options @@ -201,5 +198,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/response-comparer.rb (+3 -5) 97% =================================================================== --- lib/groonga/query-log/response-comparer.rb 2017-11-21 15:18:27 +0900 (291dbf4) +++ lib/groonga-query-log/response-comparer.rb 2017-11-21 15:47:27 +0900 (91320d2) @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,8 +14,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog +module GroongaQueryLog class ResponseComparer def initialize(command, response1, response2, options={}) @command = command @@ -46,7 +45,7 @@ module Groonga private def error_response?(response) - response.is_a?(Client::Response::Error) + response.is_a?(Groonga::Client::Response::Error) end def same_error_response? @@ -211,5 +210,4 @@ module Groonga map end end - end end Renamed: lib/groonga-query-log/server-verifier.rb (+3 -5) 98% =================================================================== --- lib/groonga/query-log/server-verifier.rb 2017-11-21 15:18:27 +0900 (4d6ab94) +++ lib/groonga-query-log/server-verifier.rb 2017-11-21 15:47:27 +0900 (5410f6b) @@ -19,11 +19,10 @@ require "thread" require "groonga/client" -require "groonga/query-log/parser" -require "groonga/query-log/response-comparer" +require "groonga-query-log/parser" +require "groonga-query-log/response-comparer" -module Groonga - module QueryLog +module GroongaQueryLog class ServerVerifier def initialize(options) @options = options @@ -246,5 +245,4 @@ module Groonga end end end - end end Renamed: lib/groonga-query-log/statistic.rb (+1 -3) 99% =================================================================== --- lib/groonga/query-log/statistic.rb 2017-11-21 15:18:27 +0900 (f4954a5) +++ lib/groonga-query-log/statistic.rb 2017-11-21 15:47:27 +0900 (4897396) @@ -16,8 +16,7 @@ require "groonga/command/parser" -module Groonga - module QueryLog +module GroongaQueryLog class Statistic DEFAULT_SLOW_OPERATION_THRESHOLD = 0.1 DEFAULT_SLOW_RESPONSE_THRESHOLD = 0.2 @@ -188,5 +187,4 @@ module Groonga elapsed >= @slow_operation_threshold end end - end end Copied: lib/groonga-query-log/version.rb (+1 -3) 95% =================================================================== --- lib/groonga/query-log/version.rb 2017-11-21 15:18:27 +0900 (0883a43) +++ lib/groonga-query-log/version.rb 2017-11-21 15:47:27 +0900 (030517b) @@ -14,8 +14,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog +module GroongaQueryLog VERSION = "1.2.9" - end end Modified: lib/groonga/query-log.rb (+21 -6) =================================================================== --- lib/groonga/query-log.rb 2017-11-21 15:18:27 +0900 (ef735ee) +++ lib/groonga/query-log.rb 2017-11-21 15:47:27 +0900 (8639f34) @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,8 +14,23 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/version" -require "groonga/query-log/parser" -require "groonga/query-log/replayer" -require "groonga/query-log/server-verifier" -require "groonga/query-log/command-version-compatibility-checker" +require "groonga-query-log" + +module GroongaQueryLog + module NamespaceBackwardCompatibility + def const_missing(name) + case name + when :QueryLog + warn("Groonga::QueryLog is deprecated. Use GroongaQueryLog instead:\n" + + caller.join("\n")) + const_set(name, GroongaQueryLog) + else + super + end + end + end +end + +module Groonga + extend GroongaQueryLog::NamespaceBackwardCompatibility +end Modified: lib/groonga/query-log/command/analyzer.rb (+3 -248) =================================================================== --- lib/groonga/query-log/command/analyzer.rb 2017-11-21 15:18:27 +0900 (ae69c1f) +++ lib/groonga/query-log/command/analyzer.rb 2017-11-21 15:47:27 +0900 (13ce9ca) @@ -1,5 +1,4 @@ -# Copyright (C) 2011-2017 Kouhei Sutou <kou �� clear-code.com> -# Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -15,249 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "optparse" -require "json" -require "groonga/query-log/command-line-utils" -require "groonga/query-log/parser" -require "groonga/query-log/command/analyzer/streamer" -require "groonga/query-log/command/analyzer/sized-statistics" -require "groonga/query-log/command/analyzer/reporter/console" -require "groonga/query-log/command/analyzer/reporter/html" -require "groonga/query-log/command/analyzer/reporter/json" -require "groonga/query-log/command/analyzer/reporter/json-stream" - -module Groonga - module QueryLog - module Command - class Analyzer - include CommandLineUtils - - class Error < StandardError - end - - class NoInputError < Error - end - - class UnsupportedReporter < Error - end - - def initialize - setup_options - end - - # Executes analyzer for groonga's query logs. - # "groonga-query-log-analyze" command run this method. - # - # @example - # analyzer = Groonga::QueryLog::Analyzer.new - # analyzer.run("--output", "statistics.html", - # "--reporter", "html", - # "query.log") - # - # If only paths of query log files are specified, - # this method prints a result of them to console with coloring. - # - # @param [Array<String>] arguments arguments for - # groonga-query-log-analyze. Please execute - # "groonga-query-log-analyze --help" or see #setup_options. - def run(arguments) - log_paths = @option_parser.parse!(arguments) - - stream = @options[:stream] - dynamic_sort = @options[:dynamic_sort] - statistics = SizedStatistics.new - statistics.apply_options(@options) - if stream - reporter = create_reporter(statistics) - reporter.apply_options(@options) - streamer = Streamer.new(reporter) - streamer.start - process_statistic = lambda do |statistic| - streamer << statistic - end - elsif dynamic_sort - process_statistic = lambda do |statistic| - statistics << statistic - end - else - full_statistics = [] - process_statistic = lambda do |statistic| - full_statistics << statistic - end - end - - begin - parse(log_paths, &process_statistic) - rescue Interrupt - raise unless stream - end - - if stream - streamer.finish - else - statistics.replace(full_statistics) unless dynamic_sort - - reporter = create_reporter(statistics) - reporter.apply_options(@options) - reporter.report - end - - true - end - - private - def setup_options - @options = {} - @options[:n_entries] = 10 - @options[:order] = "-elapsed" - @options[:color] = :auto - @options[:output] = "-" - @options[:slow_operation_threshold] = 0.1 - @options[:slow_response_threshold] = 0.2 - @options[:target_commands] = nil - @options[:target_tables] = nil - @options[:reporter] = "console" - @options[:dynamic_sort] = true - @options[:stream] = false - @options[:report_summary] = true - - @option_parser = OptionParser.new do |parser| - parser.version = VERSION - parser.banner += " LOG1 ..." - - parser.on("-n", "--n-entries=N", - Integer, - "Show top N entries", - "(#{@options[:n_entries]})") do |n| - @options[:n_entries] = n - end - - available_orders = ["elapsed", "-elapsed", "start-time", "-start-time"] - parser.on("--order=ORDER", - available_orders, - "Sort by ORDER", - "available values: [#{available_orders.join(', ')}]", - "(#{@options[:order]})") do |order| - @options[:order] = order - end - - color_options = [ - [:auto, :auto], - ["-", false], - ["no", false], - ["false", false], - ["+", true], - ["yes", true], - ["true", true], - ] - parser.on("--[no-]color=[auto]", - color_options, - "Enable color output", - "(#{@options[:color]})") do |color| - if color.nil? - @options[:color] = true - else - @options[:color] = color - end - end - - parser.on("--output=PATH", - "Output to PATH.", - "'-' PATH means standard output.", - "(#{@options[:output]})") do |output| - @options[:output] = output - end - - parser.on("--slow-operation-threshold=THRESHOLD", - Float, - "Use THRESHOLD seconds to detect slow operations.", - "(#{@options[:slow_operation_threshold]})") do |threshold| - @options[:slow_operation_threshold] = threshold - end - - parser.on("--slow-response-threshold=THRESHOLD", - Float, - "Use THRESHOLD seconds to detect slow responses.", - "(#{@options[:slow_response_threshold]})") do |threshold| - @options[:slow_response_threshold] = threshold - end - - parser.on("--target-commands=COMMAND1,COMMAND2,...", - Array, - "Process only COMMANDS.", - "Example: --target-commands=select,logical_select", - "Process all commands by default") do |commands| - @options[:target_commands] = commands - end - - parser.on("--target-tables=TABLE1,TABLE2,...", - Array, - "Process only TABLES.", - "Example: --target-tables=Items,Users", - "Process all tables by default") do |tables| - @options[:target_tables] = tables - end - - available_reporters = ["console", "json", "json-stream", "html"] - parser.on("--reporter=REPORTER", - available_reporters, - "Reports statistics by REPORTER.", - "available values: [#{available_reporters.join(', ')}]", - "(#{@options[:reporter]})") do |reporter| - @options[:reporter] = reporter - end - - parser.on("--[no-]dynamic-sort", - "Sorts dynamically.", - "Memory and CPU usage reduced for large query log.", - "(#{@options[:dynamic_sort]})") do |sort| - @options[:dynamic_sort] = sort - end - - parser.on("--[no-]stream", - "Outputs analyzed query on the fly.", - "NOTE: --n-entries and --order are ignored.", - "(#{@options[:stream]})") do |stream| - @options[:stream] = stream - end - - parser.on("--[no-]report-summary", - "Reports summary at the end.", - "(#{@options[:report_summary]})") do |report_summary| - @options[:report_summary] = report_summary - end - end - end - - def create_reporter(statistics) - case @options[:reporter] - when "json" - JSONReporter.new(statistics) - when "json-stream" - JSONStreamReporter.new(statistics) - when "html" - HTMLReporter.new(statistics) - else - ConsoleReporter.new(statistics) - end - end - - def parse(log_paths, &process_statistic) - parser = Groonga::QueryLog::Parser.new(@options) - if log_paths.empty? - unless log_via_stdin? - raise(NoInputError, "Error: Please specify input log files.") - end - parser.parse($stdin, &process_statistic) - end - - log_paths.each do |log_path| - File.open(log_path) do |log| - parser.parse(log, &process_statistic) - end - end - end - end - end - end -end +require "groonga/query-log" +require "groonga-query-log/command/analyzer" Modified: lib/groonga/query-log/command/check-command-version-compatibility.rb (+2 -55) =================================================================== --- lib/groonga/query-log/command/check-command-version-compatibility.rb 2017-11-21 15:18:27 +0900 (4b2d6e3) +++ lib/groonga/query-log/command/check-command-version-compatibility.rb 2017-11-21 15:47:27 +0900 (5319e4b) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,58 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "optparse" - require "groonga/query-log" - -module Groonga - module QueryLog - module Command - class CheckCommandVersionCompatibility - def initialize - @options = CommandVersionCompatibilityChecker::Options.new - end - - def run(command_line) - input_paths = create_parser.parse(command_line) - checker = CommandVersionCompatibilityChecker.new(@options) - checker.start do - compatible = true - if input_paths.empty? - compatible = false unless checker.check($stdin) - else - input_paths.each do |input_path| - File.open(input_path) do |input| - compatible = false unless checker.check(input) - end - end - end - compatible - end - end - - private - def create_parser - parser = OptionParser.new - parser.version = VERSION - parser.banner += " QUERY_LOG1 QUERY_LOG2 ..." - - parser.separator("") - parser.separator("Options:") - - parser.on("--target-version=VERSION", Integer, - "Check incompatibility against command version VERSION", - "[#{@options.target_version}]") do |version| - @options.target_version = version - end - - parser.on("--output=PATH", - "Output results to PATH", - "[stdout]") do |path| - @options.output_path = path - end - end - end - end - end -end +require "groonga-query-log/command/check-command-version-compatibility" Modified: lib/groonga/query-log/command/detect-memory-leak.rb (+3 -78) =================================================================== --- lib/groonga/query-log/command/detect-memory-leak.rb 2017-11-21 15:18:27 +0900 (eddf0fb) +++ lib/groonga/query-log/command/detect-memory-leak.rb 2017-11-21 15:47:27 +0900 (85996f2) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2013-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,78 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "optparse" - -require "groonga/query-log/version" -require "groonga/query-log/memory-leak-detector" - -module Groonga - module QueryLog - module Command - class DetectMemoryLeak - def initialize - @options = MemoryLeakDetector::Options.new - end - - def run(command_line) - input_paths = create_parser.parse(command_line) - detector = MemoryLeakDetector.new(@options) - input_paths.each do |input_path| - File.open(input_path) do |input| - detector.detect(input) - end - end - true - end - - private - def create_parser - parser = OptionParser.new - parser.version = VERSION - parser.banner += " QUERY_LOG" - - parser.separator("") - parser.separator("Options:") - - parser.on("--host=HOST", - "Host name or IP address of groonga server", - "[#{@options.host}]") do |host| - @options.host = host - end - - parser.on("--port=PORT", Integer, - "Port number of groonga server", - "[#{@options.port}]") do |port| - @options.port = port - end - - available_protocols = [:gqtp, :http] - available_protocols_label = "[#{available_protocols.join(', ')}]" - parser.on("--protocol=PROTOCOL", available_protocols, - "Protocol of groonga server", - available_protocols_label) do |protocol| - @options.protocol = protocol - end - - parser.on("--pid=PID", - "The PID of groonga server", - "[#{@options.pid}]") do |pid| - @options.pid = pid - end - - parser.on("--n-tries=N", Integer, - "The number of the same request tries", - "[#{@options.n_tries}]") do |n| - @options.n_tries = n - end - - parser.on("--[no-]force-disable-cache", - "Force disable cache of select command by cache=no parameter", - "[#{@options.force_disable_cache?}]") do |boolean| - @options.force_disable_cache = boolean - end - end - end - end - end -end +require "groonga/query-log" +require "groonga-query-log/command/detect-memory-leak" Modified: lib/groonga/query-log/command/extract.rb (+5 -179) =================================================================== --- lib/groonga/query-log/command/extract.rb 2017-11-21 15:18:27 +0900 (8894729) +++ lib/groonga/query-log/command/extract.rb 2017-11-21 15:47:27 +0900 (ce98c50) @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011 Kouhei Sutou <kou �� clear-code.com> -# Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public -# License version 2.1 as published by the Free Software Foundation. +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,179 +12,7 @@ # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -require "ostruct" -require "optparse" -require "pathname" +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA require "groonga/query-log" -require "groonga/query-log/command-line-utils" - -module Groonga - module QueryLog - module Command - class Extract - include CommandLineUtils - - class Error < StandardError - end - - attr_accessor :options - attr_reader :option_parser - - def initialize - @options = nil - @option_parser = nil - setup_options - end - - # Executes extractor for groonga's query logs. - # "groonga-query-log-extract" command runs this method. - # - # @example - # extractor = Groonga::QueryLog::Command::Extract.new - # extractor.run("--output", "commands.output", - # "--command", "select", - # "query.log") - # - # If only paths of query log files are specified, - # this method prints command(s) of them to console. - # - # @param [Array<String>] arguments arguments for - # groonga-query-log-extract. Please execute - # "groonga-query-log-extract --help" or see #setup_options. - def run(arguments) - begin - log_paths = @option_parser.parse!(arguments) - rescue OptionParser::ParseError - $stderr.puts($!.message) - return false - end - - if log_paths.empty? - unless log_via_stdin? - $stderr.puts("Error: Please specify input log files.") - return false - end - log = $stdin - else - log = log_paths - end - - if****@optio*****_path - File.open(@options.output_path, "w") do |output| - extract(log, output) - end - else - extract(log, $stdout) - end - - true - end - - private - def setup_options - @options = OpenStruct.new - @options.unify_format = nil - @options.commands = [] - @options.exclude_commands = [] - @options.output_path = nil - @option_parser = OptionParser.new do |parser| - parser.version = VERSION - parser.banner += " QUERY_LOG1 ..." - - available_formats = ["uri", "command"] - parser.on("--unify-format=FORMAT", - available_formats, - "Unify command format to FORMAT.", - "(#{available_formats.join(', ')})", - "[not unify]") do |format| - @options.unify_format = format - end - - parser.on("--command=COMMAND", - "Extract only COMMAND.", - "To extract one or more commands,", - "specify this command a number of times.", - "Use /.../ as COMMAND to match command with regular expression.", - "[all commands]") do |command| - case command - when /\A\/(.*)\/(i)?\z/ - @options.commands << Regexp.new($1, $2 == "i") - when - @options.commands << command - end - end - - parser.on("--exclude-command=COMMAND", - "Don't extract COMMAND.", - "To ignore one or more commands,", - "specify this command a number of times.", - "Use /.../ as COMMAND to match command with regular expression.", - "[no commands]") do |command| - case command - when /\A\/(.*)\/(i)?\z/ - @options.exclude_commands << Regexp.new($1, $2 == "i") - when - @options.exclude_commands << command - end - end - - parser.on("--output=PATH", - "Output to PATH.", - "[standard output]") do |path| - @options.output_path = path - end - end - end - - def extract(log, output) - if log.instance_of?(Array) - log.each do |log_path| - File.open(log_path) do |log_file| - extract_command(log_file, output) - end - end - else - extract_command(log, output) - end - end - - def extract_command(log, output) - parser = Groonga::QueryLog::Parser.new - parser.parse(log) do |statistic| - command = statistic.command - next unless target?(command) - command_text = nil - case****@optio*****_format - when "uri" - command_text = command.to_uri_format - when "command" - command_text = command.to_command_format - else - command_text = statistic.raw_command - end - output.puts(command_text) - end - end - - def target?(command) - name = command.command_name - target_commands =****@optio***** - exclude_commands =****@optio*****_commands - - unless target_commands.empty? - return target_commands.any? {|target_command| target_command === name} - end - - unless exclude_commands.empty? - return (not exclude_commands.any? {|exclude_command| exclude_command === name}) - end - - true - end - end - end - end -end +require "groonga-query-log/command/extract" Modified: lib/groonga/query-log/command/format-regression-test-logs.rb (+3 -130) =================================================================== --- lib/groonga/query-log/command/format-regression-test-logs.rb 2017-11-21 15:18:27 +0900 (669def0) +++ lib/groonga/query-log/command/format-regression-test-logs.rb 2017-11-21 15:47:27 +0900 (d47ba37) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,132 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "English" -require "find" -require "tempfile" -require "pp" -require "optparse" -require "json" - -require "groonga/command/parser" - -require "groonga/query-log/version" - -module Groonga - module QueryLog - module Command - class FormatRegressionTestLogs - def initialize - end - - def run(command_line) - parser = OptionParser.new - parser.banner += " PATH1 PATH2 ..." - parser.version = VERSION - paths = parser.parse!(command_line) - - if paths.empty? - format_log($stdin, "-") - else - paths.each do |path| - if File.directory?(path) - Find.find(path) do |sub_path| - next unless File.file?(sub_path) - File.open(sub_path) do |file| - format_log(file, sub_path) - end - end - else - File.open(path) do |file| - format_log(file, path) - end - end - end - end - true - end - - private - def format_log(input, path) - command = nil - response_old = nil - response_new = nil - - input.each_line do |line| - unless line.valid_encoding? - puts("invalid encoding line") - puts("#{path}:#{input.lineno}:#{line}") - next - end - case line - when /\Acommand: / - command = $POSTMATCH.chomp - when /\Aresponse1: / - response_old = $POSTMATCH.chomp - when /\Aresponse2: / - response_new = $POSTMATCH.chomp - next unless valid_entry?(command, response_old, response_new) - report_diff(command, response_old, response_new) - end - end - end - - def valid_entry?(command, response_old, response_new) - valid = true - - begin - JSON.parse(response_old) - rescue JSON::ParserError - puts(command) - puts("failed to parse old response: #{$!.message}") - puts(response_old) - valid = false - end - - begin - JSON.parse(response_new) - rescue JSON::ParserError - puts(command) - puts("failed to parse new response: #{$!.message}") - puts(response_new) - valid = false - end - - valid - end - - def report_diff(command, response_old, response_new) - return if response_old == response_new - - Tempfile.open("response-old") do |response_old_file| - PP.pp(JSON.parse(response_old), response_old_file) - response_old_file.flush - Tempfile.open("response-new") do |response_new_file| - PP.pp(JSON.parse(response_new), response_new_file) - response_new_file.flush - report_command(command) - system("diff", - "--label=old", - "--label=new", - "-u", - response_old_file.path, response_new_file.path) - end - end - end - - def report_command(command) - puts(command) - parsed_command = Groonga::Command::Parser.parse(command) - puts("Name: #{parsed_command.name}") - puts("Arguments:") - sorted_arguments = parsed_command.arguments.sort_by do |key, value| - key - end - sorted_arguments.each do |key, value| - puts(" #{key}: #{value}") - end - end - end - end - end -end +require "groonga/query-log" +require "groonga-query-log/command/format-regression-test-logs" Renamed: lib/groonga/query-log/command/reply.rb (+3 -6) 85% =================================================================== --- lib/groonga/query-log/version.rb 2017-11-21 15:18:27 +0900 (0883a43) +++ lib/groonga/query-log/command/reply.rb 2017-11-21 15:47:27 +0900 (b8e34a9) @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,8 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -module Groonga - module QueryLog - VERSION = "1.2.9" - end -end +require "groonga/query-log" +require "groonga-query-log/command/reply" Modified: lib/groonga/query-log/command/run-regression-test.rb (+2 -418) =================================================================== --- lib/groonga/query-log/command/run-regression-test.rb 2017-11-21 15:18:27 +0900 (f6763d9) +++ lib/groonga/query-log/command/run-regression-test.rb 2017-11-21 15:47:27 +0900 (c095aa8) @@ -1,4 +1,4 @@ -# Copyright (C) 2014-2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,421 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "rbconfig" -require "optparse" -require "socket" -require "fileutils" -require "pathname" -require "net/http" - require "groonga/query-log" -require "groonga/query-log/command/verify-server" - -module Groonga - module QueryLog - module Command - class RunRegressionTest - def initialize - @input_directory = Pathname.new(".") - @working_directory = Pathname.new(".") - - @old_groonga = "groonga" - @old_database = "db.old/db" - @old_groonga_options = [] - - @new_groonga = "groonga" - @new_database = "db.new/db" - @new_groonga_options = [] - - @recreate_database = false - @load_data = true - @run_queries = true - @skip_finished_queries = false - @output_query_log = false - @care_order = true - @verify_cachehit_mode = false - end - - def run(command_line) - option_parser = create_option_parser - begin - option_parser.parse!(command_line) - rescue OptionParser::ParseError => error - $stderr.puts(error.message) - return false - end - - tester = Tester.new(old_groonga_server, - new_groonga_server, - tester_options) - tester.run - end - - private - def create_option_parser - parser = OptionParser.new - parser.version = VERSION - - parser.separator("") - parser.separator("Path:") - parser.on("--input-directory=DIRECTORY", - "Load schema and data from DIRECTORY.", - "(#{@input_directory})") do |directory| - @input_directory = Pathname.new(directory) - end - parser.on("--working-directory=DIRECTORY", - "Use DIRECTORY as working directory.", - "(#{@working_directory})") do |directory| - @working_directory = Pathname.new(directory) - end - - parser.separator("") - parser.separator("Throughput:") - parser.on("--n-clients=N", Integer, - "Use N clients concurrently.", - "(#{@n_clients})") do |n| - @n_clients = n - end - - parser.separator("") - parser.separator("Old Groonga:") - parser.on("--old-groonga=GROONGA", - "Old groonga command", - "(#{@old_groonga})") do |groonga| - @old_groonga = groonga - end - - parser.on("--old-groonga-option=OPTION", - "Add an additional old groonga option", - "You can specify this option multiple times to specify multiple groonga options", - "(no options)") do |groonga_option| - @old_groonga_options << groonga_option - end - - parser.separator("") - parser.separator("New Groonga:") - parser.on("--new-groonga=GROONGA", - "New groonga command", - "(#{@new_groonga})") do |groonga| - @new_groonga = groonga - end - - parser.on("--new-groonga-option=OPTION", - "Add an additional new groonga option", - "You can specify this option multiple times to specify multiple groonga options", - "(no options)") do |groonga_option| - @new_groonga_options << groonga_option - end - - parser.separator("") - parser.separator("Operations:") - parser.on("--recreate-database", - "Always recreate Groonga database") do - @recreate_database = true - end - parser.on("--no-load-data", - "Don't load data. Just loads schema to Groonga database") do - @load_data = false - end - parser.on("--no-run-queries", - "Don't run queries. Just creates Groonga database") do - @run_queries = false - end - parser.on("--skip-finished-queries", - "Don't run finished query logs.") do - @skip_finished_queries = true - end - parser.on("--output-query-log", - "Output query log in verified target Groonga servers") do - @output_query_log = true - end - parser.on("--no-care-order", - "Don't care order of select response records") do - @care_order = false - end - - parser - end - - def directory_options - { - :input_directory => @input_directory, - :working_directory => @working_directory, - } - end - - def server_options - options = { - :load_data => @load_data, - :run_queries => @run_queries, - :recreate_database => @recreate_database, - :output_query_log => @output_query_log, - } - directory_options.merge(options) - end - - def tester_options - options = { - :n_clients => @n_clients, - :care_order => @care_order, - :skip_finished_queries => @skip_finished_queries, - } - directory_options.merge(options) - end - - def old_groonga_server - GroongaServer.new(@old_groonga, - @old_groonga_options, - @old_database, - server_options) - end - - def new_groonga_server - GroongaServer.new(@new_groonga, - @new_groonga_options, - @new_database, - server_options) - end - - class GroongaServer - attr_reader :host, :port - def initialize(groonga, groonga_options, database_path, options) - @input_directory = options[:input_directory] || Pathname.new(".") - @working_directory = options[:working_directory] || Pathname.new(".") - @groonga = groonga - @groonga_options = groonga_options - @database_path = @working_directory + database_path - @host = "127.0.0.1" - @port = find_unused_port - @options = options - end - - def run - return unless @options[:run_queries] - - arguments = @groonga_options.dup - arguments.concat(["--bind-address", @host]) - arguments.concat(["--port", @port.to_s]) - arguments.concat(["--protocol", "http"]) - arguments.concat(["--log-path", log_path.to_s]) - if @options[:output_query_log] - arguments.concat(["--query-log-path", query_log_path.to_s]) - end - arguments << "-s" - arguments << @database_path.to_s - @pid = spawn(@groonga, *arguments) - - n_retries = 10 - begin - send_command("status") - rescue SystemCallError - sleep(1) - n_retries -= 1 - raise if n_retries.zero? - retry - end - - yield if block_given? - end - - def ensure_database - if @options[:recreate_database] - FileUtils.rm_rf(@database_path.dirname.to_s) - end - - return if @database_path.exist? - FileUtils.mkdir_p(@database_path.dirname.to_s) - system(@groonga, "-n", @database_path.to_s, "quit") - grn_files.each do |grn_file| - command = [ - @groonga, - "--log-path", log_path.to_s, - "--file", grn_file.to_s, - @database_path.to_s, - ] - command_line = command.join(" ") - puts("Running...: #{command_line}") - pid = spawn(*command) - begin - pid, status = Process.waitpid2(pid) - rescue Interrupt - Process.kill(:TERM, pid) - pid, status = Process.waitpid2(pid) - end - unless status.success? - raise "Failed to run: #{command_line}" - end - end - end - - def use_persistent_cache? - @groonga_options.include?("--cache-base-path") - end - - def shutdown - begin - send_command("shutdown") - rescue SystemCallError - end - Process.waitpid(@pid) - end - - private - def find_unused_port - server = TCPServer.new(@host, 0) - begin - server.addr[1] - ensure - server.close - end - end - - def log_path - @database_path.dirname + "groonga.log" - end - - def query_log_path - @database_path.dirname + "query.log" - end - - def send_command(name) - Net::HTTP.start(@host, @port) do |http| - response = http.get("/d/#{name}") - response.body - end - end - - def grn_files - files = schema_files - files += data_files if @options[:load_data] - files += index_files - files - end - - def schema_files - Pathname.glob("#{@input_directory}/schema/**/*.grn").sort - end - - def index_files - Pathname.glob("#{@input_directory}/indexes/**/*.grn").sort - end - - def data_files - Pathname.glob("#{@input_directory}/data/**/*.grn").sort - end - end - - class Tester - def initialize(old, new, options) - @old = old - @new = new - @input_directory = options[:input_directory] || Pathname.new(".") - @working_directory = options[:working_directory] || Pathname.new(".") - @n_clients = options[:n_clients] || 1 - @options = options - @n_ready_waits = 2 - end - - def run - @old.ensure_database - @new.ensure_database - - old_thread = Thread.new do - @old.run do - run_test - end - end - new_thread = Thread.new do - @new.run do - run_test - end - end - - old_thread_success = old_thread.value - new_thread_success = new_thread.value - - old_thread_success and new_thread_success - end - - private - def run_test - @n_ready_waits -= 1 - return true unless @n_ready_waits.zero? - - 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*****_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 - end - - old_thread = Thread.new do - @old.shutdown - end - new_thread = Thread.new do - @new.shutdown - end - old_thread.join - new_thread.join - - true - end - - 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 - command_line << query_log_path.to_s - if use_persistent_cache? - command_line << "--verify-cache" - end - verify_server = VerifyServer.new - verify_server.run(command_line, &callback) - end - - def query_log_paths - Pathname.glob("#{@input_directory}/query-logs/**/*.log").sort - end - - def test_log_path(query_log_path) - @working_directory + "results" + query_log_path.basename - end - - def use_persistent_cache? - @old.use_persistent_cache? or****@new*****_persistent_cache? - end - end - end - end - end -end +require "groonga-query-log/command/run-regression-test" Modified: lib/groonga/query-log/command/show-running-queries.rb (+3 -65) =================================================================== --- lib/groonga/query-log/command/show-running-queries.rb 2017-11-21 15:18:27 +0900 (d602356) +++ lib/groonga/query-log/command/show-running-queries.rb 2017-11-21 15:47:27 +0900 (bd6d202) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,67 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "optparse" -require "time" - -require "groonga/query-log/version" -require "groonga/query-log/parser" - -module Groonga - module QueryLog - module Command - class ShowRunningQueries - def initialize - @base_time = nil - end - - def run(command_line) - input_paths = create_parser.parse(command_line) - each_parsing_statistic(input_paths) do |statistic| - timestamp = statistic.start_time.strftime("%Y-%m-%d %H:%M:%S.%6N") - puts("#{timestamp}:#{statistic.raw_command}") - end - true - end - - private - def create_parser - parser = OptionParser.new - parser.version = VERSION - parser.banner += " QUERY_LOG" - - parser.separator("") - parser.separator("Options:") - - parser.on("--base-time=TIME", - "Show running queries at TIME", - "You can use popular time format for TIME such as W3C-DTF", - "(now)") do |base_time| - @base_time = Time.parse(base_time) - end - end - - def each_parsing_statistic(input_paths) - parser = Parser.new - catch do |tag| - input_paths.each do |input_path| - File.open(input_path) do |input| - parser.parse(input) do |statistic| - next if @base_time.nil? - next if statistic.start_time < @base_time - if statistic.start_time == @base_time - yield(statistic) - end - throw(tag) - end - end - end - end - parser.parsing_statistics.each do |statistic| - yield(statistic) - end - end - end - end - end -end +require "groonga/query-log" +require "groonga-query-log/command/show-running-queries" Modified: lib/groonga/query-log/command/verify-server.rb (+2 -137) =================================================================== --- lib/groonga/query-log/command/verify-server.rb 2017-11-21 15:18:27 +0900 (2f0c654) +++ lib/groonga/query-log/command/verify-server.rb 2017-11-21 15:47:27 +0900 (54683d8) @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,140 +14,5 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "optparse" - require "groonga/query-log" - -module Groonga - module QueryLog - module Command - class VerifyServer - def initialize - @options = ServerVerifier::Options.new - end - - def run(command_line, &callback) - input_paths = create_parser.parse(command_line) - verifier = ServerVerifier.new(@options) - if input_paths.empty? - verifier.verify($stdin, &callback) - else - input_paths.each do |input_path| - File.open(input_path) do |input| - verifier.verify(input, &callback) - end - end - end - true - end - - private - def create_parser - parser = OptionParser.new - parser.version = VERSION - parser.banner += " QUERY_LOG1 QUERY_LOG2 ..." - - parser.separator("") - parser.separator("Options:") - - available_protocols = [:gqtp, :http] - available_protocols_label = "[#{available_protocols.join(', ')}]" - - parser.on("--groonga1-host=HOST", - "Host name or IP address of Groonga server 1", - "[#{@options.groonga1.host}]") do |host| - @options.groonga1.host = host - end - - parser.on("--groonga1-port=PORT", Integer, - "Port number of Groonga server 1", - "[#{@options.groonga1.port}]") do |port| - @options.groonga1.port = port - end - - parser.on("--groonga1-protocol=PROTOCOL", available_protocols, - "Protocol of Groonga server 1", - available_protocols_label) do |protocol| - @options.groonga1.protocol = protocol - end - - parser.on("--groonga2-host=HOST", - "Host name or IP address of Groonga server 2", - "[#{@options.groonga2.host}]") do |host| - @options.groonga2.host = host - end - - parser.on("--groonga2-port=PORT", Integer, - "Port number of Groonga server 2", - "[#{@options.groonga2.port}]") do |port| - @options.groonga2.port = port - end - - parser.on("--groonga2-protocol=PROTOCOL", available_protocols, - "Protocol of Groonga server 2", - available_protocols_label) do |protocol| - @options.groonga2.protocol = protocol - end - - parser.on("--n-clients=N", Integer, - "The max number of concurrency", - "[#{@options.n_clients}]") do |n_clients| - @options.n_clients = n_clients - end - - parser.on("--request-queue-size=SIZE", Integer, - "The size of request queue", - "[auto]") do |size| - @options.request_queue_size = size - end - - parser.on("--disable-cache", - "Add 'cache=no' parameter to request", - "[#{@options.disable_cache?}]") do - @options.disable_cache = true - end - - parser.on("--target-command-name=NAME", - "Add NAME to target command names", - "You can specify this option zero or more times", - "See also --target-command-names") do |name| - @options.target_command_names << name - end - - target_command_names_label =****@optio*****_command_names.join(", ") - parser.on("--target-command-names=NAME1,NAME2,...", Array, - "Replay only NAME1,NAME2,... commands", - "You can use glob to choose command name", - "[#{target_command_names_label}]") do |names| - @options.target_command_names = names - end - - parser.on("--no-care-order", - "Don't care order of select response records") do - @options.care_order = false - end - - parser.on("--output=PATH", - "Output results to PATH", - "[stdout]") do |path| - @options.output_path = path - end - - parser.on("--[no-]verify-cache", - "Verify cache for each query.", - "[#{@options.verify_cache?}]") do |verify_cache| - @options.verify_cache = verify_cache - end - - parser.separator("Debug options:") - parser.separator("") - - parser.on("--abort-on-exception", - "Abort on exception in threads") do - Thread.abort_on_exception = true - end - end - end - end - end -end +require "groonga-query-log/command/verify-server" Modified: test/command/test-analyzer.rb (+3 -3) =================================================================== --- test/command/test-analyzer.rb 2017-11-21 15:18:27 +0900 (2e1f3a8) +++ test/command/test-analyzer.rb 2017-11-21 15:47:27 +0900 (7fa4590) @@ -17,7 +17,7 @@ require "tempfile" require "pathname" -require "groonga/query-log/command/analyzer" +require "groonga-query-log/command/analyzer" class AnalyzerCommandTest < Test::Unit::TestCase setup @@ -27,7 +27,7 @@ class AnalyzerCommandTest < Test::Unit::TestCase end def setup - @analyzer = Groonga::QueryLog::Command::Analyzer.new + @analyzer = GroongaQueryLog::Command::Analyzer.new end class TestInputFile < self @@ -40,7 +40,7 @@ class AnalyzerCommandTest < Test::Unit::TestCase end def test_no_specified - assert_raise(Groonga::QueryLog::Command::Analyzer::NoInputError) do + assert_raise(GroongaQueryLog::Command::Analyzer::NoInputError) do run_analyzer end end Modified: test/command/test-extract.rb (+2 -2) =================================================================== --- test/command/test-extract.rb 2017-11-21 15:18:27 +0900 (1fc1e95) +++ test/command/test-extract.rb 2017-11-21 15:47:27 +0900 (c58c100) @@ -19,7 +19,7 @@ require "stringio" require "groonga/command" -require "groonga/query-log/command/extract" +require "groonga-query-log/command/extract" class ExtractCommandTest < Test::Unit::TestCase setup @@ -29,7 +29,7 @@ class ExtractCommandTest < Test::Unit::TestCase end def setup - @extract_command = Groonga::QueryLog::Command::Extract.new + @extract_command = GroongaQueryLog::Command::Extract.new end class TestInputFile < self Modified: test/command/test-format-regression-test-logs.rb (+2 -2) =================================================================== --- test/command/test-format-regression-test-logs.rb 2017-11-21 15:18:27 +0900 (47f8b06) +++ test/command/test-format-regression-test-logs.rb 2017-11-21 15:47:27 +0900 (7d2b752) @@ -16,13 +16,13 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "groonga/query-log/command/format-regression-test-logs" +require "groonga-query-log/command/format-regression-test-logs" class FormatRegressionTestLogsCommandTest < Test::Unit::TestCase include Path def setup - @command = Groonga::QueryLog::Command::FormatRegressionTestLogs.new + @command = GroongaQueryLog::Command::FormatRegressionTestLogs.new end def run_command(command_line) Modified: test/helper.rb (+2 -4) =================================================================== --- test/helper.rb 2017-11-21 15:18:27 +0900 (5074588) +++ test/helper.rb 2017-11-21 15:47:27 +0900 (5c95fbf) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011-2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2017 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -21,7 +19,7 @@ require "stringio" require "groonga/command" -require "groonga/query-log" +require "groonga-query-log" module Path def fixture_path(*components) Modified: test/test-incompatibility-detector.rb (+3 -3) =================================================================== --- test/test-incompatibility-detector.rb 2017-11-21 15:18:27 +0900 (eb5e1da) +++ test/test-incompatibility-detector.rb 2017-11-21 15:47:27 +0900 (fe0d286) @@ -25,7 +25,7 @@ class IncompatibilityDetectorTest < Test::Unit::TestCase end def parse_query_log(query_log) - parser = Groonga::QueryLog::Parser.new + parser = GroongaQueryLog::Parser.new parser.parse(query_log) do |statistic| return statistic end @@ -33,13 +33,13 @@ class IncompatibilityDetectorTest < Test::Unit::TestCase sub_test_case("version1") do def setup - @detector = Groonga::QueryLog::IncompatibilityDetector::Version1.new + @detector = GroongaQueryLog::IncompatibilityDetector::Version1.new end end sub_test_case("version2") do def setup - @detector = Groonga::QueryLog::IncompatibilityDetector::Version2.new + @detector = GroongaQueryLog::IncompatibilityDetector::Version2.new end sub_test_case("select") do Modified: test/test-parser.rb (+1 -1) =================================================================== --- test/test-parser.rb 2017-11-21 15:18:27 +0900 (c8f1c5e) +++ test/test-parser.rb 2017-11-21 15:47:27 +0900 (39f70dd) @@ -48,7 +48,7 @@ class ParserTest < Test::Unit::TestCase private def parse(log) statistics = [] - parser = Groonga::QueryLog::Parser.new + parser = GroongaQueryLog::Parser.new parser.parse(StringIO.new(log)) do |statistic| statistics << statistic end Modified: test/test-replayer.rb (+3 -3) =================================================================== --- test/test-replayer.rb 2017-11-21 15:18:27 +0900 (1cb11c2) +++ test/test-replayer.rb 2017-11-21 15:47:27 +0900 (2279b83) @@ -20,7 +20,7 @@ class ReplayerTest < Test::Unit::TestCase class OptionTest < self class ClientTest < self def setup - @options = Groonga::QueryLog::Replayer::Options.new + @options = GroongaQueryLog::Replayer::Options.new @options.n_clients = 1 end @@ -40,7 +40,7 @@ class ReplayerTest < Test::Unit::TestCase private def replay - replayer = Groonga::QueryLog::Replayer.new(@options) + replayer = GroongaQueryLog::Replayer.new(@options) replayer.replay(StringIO.new("")) end @@ -60,7 +60,7 @@ class ReplayerTest < Test::Unit::TestCase class TargetCommandNameTest < self def setup - @options = Groonga::QueryLog::Replayer::Options.new + @options = GroongaQueryLog::Replayer::Options.new end def test_default Modified: test/test-response-comparer.rb (+2 -2) =================================================================== --- test/test-response-comparer.rb 2017-11-21 15:18:27 +0900 (d802b2e) +++ test/test-response-comparer.rb 2017-11-21 15:47:27 +0900 (81746c6) @@ -19,8 +19,8 @@ class ResponseComparerTest < Test::Unit::TestCase def comparer(response1, response2, options={}) response1 = normalize_response(response1) response2 = normalize_response(response2) - Groonga::QueryLog::ResponseComparer.new(@command, response1, response2, - options) + GroongaQueryLog::ResponseComparer.new(@command, response1, response2, + options) end def same?(response1, response2, options={})