Kouhei Sutou
null+****@clear*****
Tue Jan 8 18:11:07 JST 2013
Kouhei Sutou 2013-01-08 18:11:07 +0900 (Tue, 08 Jan 2013) New Revision: 865dff07973255043216c9a021e8771a6e336436 https://github.com/groonga/groonga/commit/865dff07973255043216c9a021e8771a6e336436 Log: Remove a test for removed file Removed files: test/unit/tools/test-query-log-analyzer.rb Modified files: test/unit/run-test.rb Modified: test/unit/run-test.rb (+0 -1) =================================================================== --- test/unit/run-test.rb 2013-01-08 18:06:45 +0900 (45c8aad) +++ test/unit/run-test.rb 2013-01-08 18:11:07 +0900 (3366e01) @@ -18,7 +18,6 @@ test_lib_dir = File.expand_path(File.join(build_dir, "..", "lib")) FileUtils.mkdir_p(test_lib_dir) $LOAD_PATH.unshift(File.join(base_dir, "lib", "ruby")) -$LOAD_PATH.unshift(File.expand_path(File.join(base_dir, "..", "..", "tools"))) require 'groonga-test-utils' require 'groonga-http-test-utils' Deleted: test/unit/tools/test-query-log-analyzer.rb (+0 -180) 100644 =================================================================== --- test/unit/tools/test-query-log-analyzer.rb 2013-01-08 18:06:45 +0900 (d49a46c) +++ /dev/null @@ -1,180 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011 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. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -load "groonga-query-log-analyzer" -require "stringio" - -module QueryLogAalyzerTest - module CommandParseTestUtils - private - def command(name, parameters) - GroongaQueryLogAnalyzer::Command.new(name, parameters) - end - - def parse_http_path(command, parameters) - path = "/d/#{command}.json?" - path << parameters.collect do |key, value| - [CGI.escape(key.to_s), CGI.escape(value.to_s)].join("=") - end.join("&") - GroongaQueryLogAnalyzer::Command.parse(path) - end - - def parse_command_line(command, parameters) - command_line = "#{command} --output_type json" - parameters.each do |key, value| - if /"| / =~ value - escaped_value = '"' + value.gsub(/"/, '\"') + '"' - else - escaped_value = value - end - command_line << " --#{key} #{escaped_value}" - end - GroongaQueryLogAnalyzer::Command.parse(command_line) - end - end - - module HTTPCommandParseTestUtils - private - def parse(command, parameters) - parse_http_path(command, parameters) - end - end - - module CommandLineCommandParseTestUtils - private - def parse(command, parameters) - parse_command_line(command, parameters) - end - end - - module SelectCommandParseTests - include CommandParseTestUtils - - def test_parameters - select = parse("select", - :table => "Users", - :filter => "age<=30") - assert_equal(command("select", - "table" => "Users", - "filter" => "age<=30", - "output_type" => "json"), - select) - end - - def test_scorer - select = parse("select", - :table => "Users", - :filter => "age<=30", - :scorer => "_score = random()") - assert_equal("_score = random()", select.scorer) - end - end - - module SelectCommandParseFilterTests - include CommandParseTestUtils - - def test_parenthesis - filter = 'geo_in_rectangle(location,' + - '"35.73360x139.7394","62614x139.7714") && ' + - '((type == "たいやき" || type == "和菓子")) && ' + - 'keyword @ "たいやき" &! keyword @ "白" &! keyword @ "養殖"' - select = parse("select", - :table => "Users", - :filter => filter) - assert_equal(['geo_in_rectangle(location,' + - '"35.73360x139.7394","62614x139.7714")', - 'type == "たいやき"', - 'type == "和菓子"', - 'keyword @ "たいやき"', - 'keyword @ "白"', - 'keyword @ "養殖"'], - select.conditions) - end - end - - class HTTPSelectCommandParseTest < Test::Unit::TestCase - include SelectCommandParseTests - include SelectCommandParseFilterTests - include HTTPCommandParseTestUtils - end - - class CommandLineSelecCommandParseTest < Test::Unit::TestCase - include SelectCommandParseTests - include SelectCommandParseFilterTests - include CommandLineCommandParseTestUtils - end - - class StatisticOperationParseTest < Test::Unit::TestCase - def test_context - operations = statistics.first.operations.collect do |operation| - [operation[:name], operation[:context]] - end - expected = [ - ["filter", "local_name @ \"gsub\""], - ["filter", "description @ \"string\""], - ["select", nil], - ["sort", "_score"], - ["output", "_key"], - ["drilldown", "name"], - ["drilldown", "class"], - ] - assert_equal(expected, operations) - end - - def test_n_records - operations = statistics.first.operations.collect do |operation| - [operation[:name], operation[:n_records]] - end - expected = [ - ["filter", 15], - ["filter", 13], - ["select", 13], - ["sort", 10], - ["output", 10], - ["drilldown", 3], - ["drilldown", 2], - ] - assert_equal(expected, operations) - end - - private - def log - <<-EOL -2011-06-02 16:27:04.731685|5091e5c0|>/d/select.join?table=Entries&filter=local_name+%40+%22gsub%22+%26%26+description+%40+%22string%22&sortby=_score&output_columns=_key&drilldown=name,class -2011-06-02 16:27:04.733539|5091e5c0|:000000001849451 filter(15) -2011-06-02 16:27:04.734978|5091e5c0|:000000003293459 filter(13) -2011-06-02 16:27:04.735012|5091e5c0|:000000003327415 select(13) -2011-06-02 16:27:04.735096|5091e5c0|:000000003411824 sort(10) -2011-06-02 16:27:04.735232|5091e5c0|:000000003547265 output(10) -2011-06-02 16:27:04.735606|5091e5c0|:000000003921419 drilldown(3) -2011-06-02 16:27:04.735762|5091e5c0|:000000004077552 drilldown(2) -2011-06-02 16:27:04.735808|5091e5c0|<000000004123726 rc=0 -EOL - end - - def statistics - statistics = GroongaQueryLogAnalyzer::SizedStatistics.new - statistics.apply_options(:n_entries => 100, - :order => "-elapsed") - parser = GroongaQueryLogAnalyzer::QueryLogParser.new - parser.parse(StringIO.new(log)) do |statistic| - statistics << statistic - end - statistics - end - end -end -------------- next part -------------- HTML����������������������������...Download