Included modules
Public instance methods
run
(testrun, opts={})
[show source]
# File lib/stella/engine.rb, line 40 def run testrun, opts={} opts = parse_opts testrun.options, opts Stella.ld "testrun opts: #{opts.inspect}" threads = [] testrun.stime = Stella.now testrun.running! opts[:concurrency].times do threads << Thread.new do client = Stella::Client.new opts Benelux.current_track "client_#{client.clientid.shorten}" begin opts[:repetitions].times do |idx| Stella.li '%-61s %s' % [testrun.plan.desc, testrun.plan.planid.shorten(12)] if Stella.noise >= 2 && !Stella.quiet? testrun.plan.usecases.each_with_index do |uc,i| if opts[:usecases].nil? || opts[:usecases].member?(uc.class) Benelux.current_track.add_tags :usecase => uc.id Stella.rescue { Stella.li ' %-60s %s' % [uc.desc, uc.ucid.shorten(12)] if Stella.noise >= 1 && !Stella.quiet? client.execute uc do |session| Stella.li ' %3d %-4s %-76s' % [session.status, session.http_method.upcase, session.uri] if Stella.noise >= 1 && !Stella.quiet? if Stella.noise >= 2 && !Stella.quiet? Stella.li ' %s' % [session.req.header.dump.split(/\n/).join("\n ")] Stella.li Stella.li ' %s' % [session.res.header.dump.split(/\n/).join("\n ")] Stella.li '' end end } if client.exception if Stella.noise >= 1 Stella.li ' %4s %s (%s)' % ['', client.exception.message, client.exception.class] end # TODO: use a throw. This won't stop the next repetition. break if Stella::TestplanQuit === client.exception end else #Stella.li ' %-60s %s' % ["#{uc.desc} (skipped)", uc.ucid.shorten(12)] if Stella.noise >= 2 end Benelux.current_track.remove_tags :usecase end end rescue Interrupt Stella.li "Skipping..." testrun.etime = Stella.now testrun.fubar! exit 1 rescue => ex Stella.li ex.message Stella.li ex.backtrace if Stella.debug? end end end begin threads.each { |thread| thread.join } timeline = Benelux.merge_tracks rescue Interrupt Stella.li "Skipping..." testrun.etime = Stella.now testrun.fubar! exit 1 end begin testrun.etime = Stella.now testrun.report = Stella::Report.new timeline, testrun.runid testrun.report.process testrun.report.fubars? ? testrun.fubar! : testrun.done! rescue Interrupt Stella.li "Exiting..." testrun.etime = Stella.now testrun.fubar! exit 1 rescue => ex Stella.li ex.message Stella.li ex.backtrace if Stella.debug? testrun.etime = Stella.now testrun.fubar! end Benelux.reset # If we run again, the old stats still remain testrun end