lib/stella/testplan.rb in stella-0.7.0.003 vs lib/stella/testplan.rb in stella-0.7.0.004

- old
+ new

@@ -5,21 +5,32 @@ class Testplan include Gibbler::Complex class WackyRatio < Stella::Error end - attr_accessor :usecases attr_accessor :base_path attr_accessor :desc attr_reader :stats - def initialize + def initialize(uris=[], opts={}) @desc, @usecases = "Stella's plan", [] @testplan_current_ratio = 0 @stats = Stella::Testplan::Stats.new + + unless uris.empty? + usecase = Stella::Testplan::Usecase.new + usecase.ratio = 1.0 + uris.each do |uri| + uri = URI.parse uri + uri.path = '/' if uri.path.empty? + req = usecase.add_request :get, uri.path + req.wait = opts[:delay] if opts[:delay] + end + self.add_usecase usecase + end end def self.load_file(path) conf = File.read path plan = Stella::Testplan.new @@ -27,10 +38,16 @@ # eval so the DSL code can be executed in this namespace. plan.instance_eval conf plan end + # Were there any errors in any of the usecases? + def errors? + Stella.ld "TODO: tally use case errors" + false + end + def check! # Adjust ratios if necessary needy = @usecases.select { |u| u.ratio == -1 } needy.each do |u| u.ratio = (remaining_ratio / needy.size).to_f @@ -72,10 +89,10 @@ def pretty str = [] str << " %-50s ".att(:reverse) % [@desc] @usecases.each_with_index do |uc,i| description = uc.desc || "Usecase ##{i+1}" - str << " %s (%s)".bright % [description, uc.ratio] + str << " %s (%s%%)".bright % [description, uc.ratio_pretty] requests = uc.requests.each do |r| str << " %-35s %s" % ["#{r.desc}:", r] if Stella.loglev > 2 [:wait].each { |i| str << " %s: %s" % [i, r.send(i)] } end