Kouhei Sutou
null+****@clear*****
Tue Dec 17 19:16:45 JST 2013
Kouhei Sutou 2013-12-17 19:16:45 +0900 (Tue, 17 Dec 2013) New Revision: 393ec7dd0ce8e4b8c41f2617dddc50d3c4f6b5a6 https://github.com/droonga/drntest/commit/393ec7dd0ce8e4b8c41f2617dddc50d3c4f6b5a6 Message: Run requests async while logging is disabled It may break f-p-d tests... I will fix them later... Modified files: lib/drntest/test-executor.rb Renamed files: lib/drntest/response-normalizer.rb (from lib/drntest/request-executor.rb) Renamed: lib/drntest/response-normalizer.rb (+17 -33) 59% =================================================================== --- lib/drntest/request-executor.rb 2013-12-17 18:17:39 +0900 (58b893c) +++ lib/drntest/response-normalizer.rb 2013-12-17 19:16:45 +0900 (494c30b) @@ -13,48 +13,32 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -require "droonga/client" - module Drntest - class RequestExecutor - attr_reader :owner, :request - - def initialize(owner, request) - @owner = owner + class ResponseNormalizer + def initialize(request, response) @request = request + @response = response end - def execute - normalize_result(execute_command) - end + def normalize + return @response if****@respo*****? - private - def execute_command - Droonga::Client.open(tag: owner.tag, - port: owner.port, - connect_timeout: 1) do |client| - client.connection.send(request, :response => :one) - end + normalized_response =****@respo***** + normalize_envelope!(normalized_response) + normalize_body!(normalized_response) + normalized_response end - def normalize_result(result) - return result if result.nil? - - normalized_result = result.dup - normalize_envelope!(normalized_result) - normalize_body!(normalized_result) - normalized_result - end - - def normalize_envelope!(normalized_result) + private + def normalize_envelope!(normalized_response) normalized_start_time = 0 - normalized_result[1] = normalized_start_time + normalized_response[1] = normalized_start_time end - def normalize_body!(normalized_result) + def normalize_body!(normalized_response) return unless groonga_command? begin - normalize_groonga_command_result!(normalized_result[2]) + normalize_groonga_command_response!(normalized_response[2]) rescue StandardError => error p error end @@ -66,11 +50,11 @@ module Drntest "select", ] def groonga_command? - GROONGA_COMMANDS.include?(request["type"]) + GROONGA_COMMANDS.include?(@request["type"]) end - def normalize_groonga_command_result!(result) - normalize_groonga_command_header!(result["body"][0]) + def normalize_groonga_command_response!(response) + normalize_groonga_command_header!(response["body"][0]) end def normalize_groonga_command_header!(header) Modified: lib/drntest/test-executor.rb (+36 -13) =================================================================== --- lib/drntest/test-executor.rb 2013-12-17 18:17:39 +0900 (ac22710) +++ lib/drntest/test-executor.rb 2013-12-17 19:16:45 +0900 (baf2b40) @@ -13,8 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +require "droonga/client" + require "drntest/json-loader" -require "drntest/request-executor" +require "drntest/response-normalizer" module Drntest class TestExecutor @@ -28,19 +30,35 @@ module Drntest def execute actuals = [] logging = true - requests.each do |request| - if request.is_a?(Directive) - case request.type - when :enable_logging - logging = true - when :disable_logging - logging = false + client = Droonga::Client.open(tag: owner.tag, + port: owner.port) do |client| + requests = [] + test_commands.each do |test_command| + if test_command.is_a?(Directive) + case test_command.type + when :enable_logging + logging = true + requests.each do |request| + request.wait + end + requests.clear + when :disable_logging + logging = false + end + next + end + if logging + response = client.connection.execute(test_command) + actuals << normalize_response(test_command, response) + else + requests << client.connection.execute(test_command, + :connect_timeout => 2) do + end end - next end - executor = RequestExecutor.new(@owner, request) - response = executor.execute - actuals << response if logging + requests.each do |request| + request.wait + end end actuals end @@ -52,7 +70,12 @@ module Drntest Pathname(path).expand_path(@owner.base_path) end - def requests + def normalize_response(request, response) + normalizer = ResponseNormalizer.new(request, response) + normalizer.normalize + end + + def test_commands load_jsons(@test_path) end -------------- next part -------------- HTML����������������������������... 下载