YUKI Hiroshi
null+****@clear*****
Tue Apr 14 20:49:28 JST 2015
YUKI Hiroshi 2015-04-14 20:49:28 +0900 (Tue, 14 Apr 2015) New Revision: c6c87df3a803b48b0287189bcbb77cc00e4e7264 https://github.com/droonga/drntest/commit/c6c87df3a803b48b0287189bcbb77cc00e4e7264 Message: Support "Nmessages" type parameter for subscribe-until directive Modified files: lib/drntest/directive.rb lib/drntest/test-executor.rb lib/drntest/test-loader.rb Modified: lib/drntest/directive.rb (+15 -6) =================================================================== --- lib/drntest/directive.rb 2015-04-14 20:00:32 +0900 (a166469) +++ lib/drntest/directive.rb 2015-04-14 20:49:28 +0900 (0a731bb) @@ -69,21 +69,30 @@ module Drntest end class SubscribeUntil < Directive - attr_reader :timeout_seconds + attr_reader :max_messages, :timeout_seconds DEFAULT_TIMEOUT_SECONDS = 1 ONE_MINUTE_IN_SECONDS = 60 ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 60 - def initialize(timeout) - if timeout =~ /\A(\d+\.?|\.\d+|\d+\.\d+)s(?:ec(?:onds?)?)?\z/ + def initialize(parameters) + @max_messages = nil + @timeout_seconds = nil + + parameters.each do |parameter| + if parameter =~ /\A(\d+)(?:messages|msg)?\z/ + @max_messages = $1.to_i + elsif parameter =~ /\A(\d+\.?|\.\d+|\d+\.\d+)s(?:ec(?:onds?)?)?\z/ @timeout_seconds = $1.to_f - elsif timeout =~ /\A(\d+\.?|\.\d+|\d+\.\d+)m(?:inutes?)?\z/ + elsif parameter =~ /\A(\d+\.?|\.\d+|\d+\.\d+)m(?:inutes?)?\z/ @timeout_seconds = $1.to_f * ONE_MINUTE_IN_SECONDS - elsif timeout =~ /\A(\d+\.?|\.\d+|\d+\.\d+)h(?:ours?)?\z/ + elsif parameter =~ /\A(\d+\.?|\.\d+|\d+\.\d+)h(?:ours?)?\z/ @timeout_seconds = $1.to_f * ONE_HOUR_IN_SECONDS - else + end + end + + if @max_messages.nil? and @timeout_seconds.nil? @timeout_seconds = DEFAULT_TIMEOUT_SECONDS end end Modified: lib/drntest/test-executor.rb (+3 -1) =================================================================== --- lib/drntest/test-executor.rb 2015-04-14 20:00:32 +0900 (ab0fee5) +++ lib/drntest/test-executor.rb 2015-04-14 20:49:28 +0900 (a9b338d) @@ -111,6 +111,7 @@ module Drntest when SubscribeUntil @subscribe = true @timeout_seconds = directive.timeout_seconds + @max_messages = directive.max_messages end end @@ -122,7 +123,8 @@ module Drntest if @logging responses = [] if @subscribe - options[:timeout_seconds] = @timeout_seconds + options[:subscription_timeout] = @timeout_seconds + options[:max_messages] = @max_messages request_process =****@clien*****(request, options) do |raw_response| responses << clean_response(request, raw_response) end Modified: lib/drntest/test-loader.rb (+1 -1) =================================================================== --- lib/drntest/test-loader.rb 2015-04-14 20:00:32 +0900 (8f04eb6) +++ lib/drntest/test-loader.rb 2015-04-14 20:49:28 +0900 (192d458) @@ -100,7 +100,7 @@ module Drntest when :disable_validation DisableValidationDirective.new when :subscribe_until - SubscribeUntil.new(options.first) + SubscribeUntil.new(options) else UnknownDirective.new(type, options) end -------------- next part -------------- HTML����������������������������...Download