Kouhei Sutou
null+****@clear*****
Fri Aug 14 11:13:18 JST 2015
Kouhei Sutou 2015-08-14 11:13:18 +0900 (Fri, 14 Aug 2015) New Revision: cf758d80d600c84cb2650132f9d482f7e4fd1b53 https://github.com/groonga/groonga-query-log/commit/cf758d80d600c84cb2650132f9d482f7e4fd1b53 Message: verify-server, run-regression-test: add --no-care-order Modified files: lib/groonga/query-log/command/run-regression-test.rb lib/groonga/query-log/command/verify-server.rb lib/groonga/query-log/response-comparer.rb lib/groonga/query-log/server-verifier.rb test/test-response-comparer.rb Modified: lib/groonga/query-log/command/run-regression-test.rb (+10 -3) =================================================================== --- lib/groonga/query-log/command/run-regression-test.rb 2015-08-12 18:45:49 +0900 (9bd0fa8) +++ lib/groonga/query-log/command/run-regression-test.rb 2015-08-14 11:13:18 +0900 (2afd645) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2015 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 @@ -43,6 +43,7 @@ module Groonga @run_queries = true @skip_finished_queries = false @output_query_log = false + @care_order = true end def run(command_line) @@ -124,6 +125,10 @@ module Groonga "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 @@ -148,7 +153,8 @@ module Groonga def tester_options options = { - :n_clients => @n_clients, + :n_clients => @n_clients, + :care_order => @care_order, } directory_options.merge(options) end @@ -372,8 +378,9 @@ module Groonga "--groonga2-protocol=http", "--target-command-name=select", "--output", test_log_path.to_s, - query_log_path.to_s, ] + command_line << "--no-care-order" if @otions[:care_order] == false + command_line << query_log_path.to_s verify_serer = VerifyServer.new verify_serer.run(command_line) end Modified: lib/groonga/query-log/command/verify-server.rb (+6 -1) =================================================================== --- lib/groonga/query-log/command/verify-server.rb 2015-08-12 18:45:49 +0900 (bb95601) +++ lib/groonga/query-log/command/verify-server.rb 2015-08-14 11:13:18 +0900 (276bf95) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2013-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2015 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 @@ -124,6 +124,11 @@ module Groonga @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| Modified: lib/groonga/query-log/response-comparer.rb (+19 -8) =================================================================== --- lib/groonga/query-log/response-comparer.rb 2015-08-12 18:45:49 +0900 (546625d) +++ lib/groonga/query-log/response-comparer.rb 2015-08-14 11:13:18 +0900 (4d7f9fa) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2015 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,10 +17,12 @@ module Groonga module QueryLog class ResponseComparer - def initialize(command, response1, response2) + def initialize(command, response1, response2, options={}) @command = command @response1 = response1 @response2 = response2 + @options = options + @options[:care_order] = true if @options[:care_order].nil? end def same? @@ -56,15 +58,24 @@ module Groonga end def same_select_response? - if random_sort? - same_random_sort_response? - elsif all_output_columns? - same_all_output_columns? + if care_order? + if all_output_columns? + same_all_output_columns? + else + same_response? + end else - same_response? + same_size_response? end end + def care_order? + return false unless @options[:care_order] + return false if random_sort? + + true + end + def random_score? @command.scorer == "_score=rand()" end @@ -81,7 +92,7 @@ module Groonga normalized_sort_items.include?("_score") end - def same_random_sort_response? + def same_size_response? records_result1 =****@respo*****[0] || [] records_result2 =****@respo*****[0] || [] return false if records_result1.size != records_result2.size Modified: lib/groonga/query-log/server-verifier.rb (+8 -2) =================================================================== --- lib/groonga/query-log/server-verifier.rb 2015-08-12 18:45:49 +0900 (d020ff5) +++ lib/groonga/query-log/server-verifier.rb 2015-08-14 11:13:18 +0900 (8f83b04) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2013-2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2015 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 @@ -108,7 +108,11 @@ module Groonga command["output_type"] = :json response1 = groonga1_client.execute(command) response2 = groonga2_client.execute(command) - comparer = ResponseComparer.new(command, response1, response2) + compare_options = { + :care_order => @options.care_order, + } + comparer = ResponseComparer.new(command, response1, response2, + compare_options) unless comparer.same? @different_results.push([command, response1, response2]) end @@ -141,6 +145,7 @@ module Groonga attr_writer :disable_cache attr_accessor :target_command_names attr_accessor :output_path + attr_accessor :care_order def initialize @groonga1 = GroongaOptions.new @groonga2 = GroongaOptions.new @@ -149,6 +154,7 @@ module Groonga @disable_cache = false @output_path = nil @target_command_names = ["select"] + @care_order = true end def request_queue_size Modified: test/test-response-comparer.rb (+15 -5) =================================================================== --- test/test-response-comparer.rb 2015-08-12 18:45:49 +0900 (b7456fa) +++ test/test-response-comparer.rb 2015-08-14 11:13:18 +0900 (53c8d2b) @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2014-2015 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,14 +16,15 @@ class ResponseComparerTest < Test::Unit::TestCase private - def comparer(response1, response2) + def comparer(response1, response2, options={}) response1 = normalize_response(response1) response2 = normalize_response(response2) - Groonga::QueryLog::ResponseComparer.new(@command, response1, response2) + Groonga::QueryLog::ResponseComparer.new(@command, response1, response2, + options) end - def same?(response1, response2) - comparer(response1, response2).same? + def same?(response1, response2, options={}) + comparer(response1, response2, options).same? end def response(body) @@ -229,6 +230,15 @@ class ResponseComparerTest < Test::Unit::TestCase end end + class ForceNoCareOrderTest < self + def test_different_order + @command["output_columns"] = "_id" + assert_true(same?([[[3], [["_id", "UInt32"]], [1], [2], [3]]], + [[[3], [["_id", "UInt32"]], [3], [2], [1]]], + :care_order => false)) + end + end + class ErrorTest < self def test_with_location response1_header = [ -------------- next part -------------- HTML����������������������������... Download