Sha256: 8e0083e51df65b307dd4e125847f06de7f0d8173274123e0cba95bcea1d1bdc3

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents


class Stella::CLI < Drydock::Command
  
  def init
    @conf = Stella::Config.refresh
  end
  
  def verify_valid?
    create_testplan
  end
  
  def verify
    opts = {}
    opts[:hosts] = @hosts
    opts[:benchmark] = true if @option.benchmark
    Stella::Engine::Functional.run @testplan, opts
  end
  
  def load_valid?
    create_testplan
  end
  
  def load
    opts = {}
    opts[:hosts] = @hosts
    [:benchmark, :users, :repetitions, :delay, :time].each do |opt|
      opts[opt] = @option.send(opt) unless @option.send(opt).nil?
    end
    Stella::Engine::Load.run @testplan, opts
  end
  
  def preview_valid?
    create_testplan
  end
  
  def preview
    Stella.li2 "file: #{@option.testplan} (#{@testplan.digest})"
    Stella.li @testplan.pretty
  end


  private
  def create_testplan
    @hosts = @argv.collect { |uri|; URI.parse uri; }
    if @option.testplan
      @testplan = Stella::Testplan.load_file @option.testplan
    else
      @testplan = Stella::Testplan.new
      usecase = Stella::Testplan::Usecase.new
      @argv.each do |uri|
        uri = URI.parse uri
        uri.path = '/' if uri.path.empty?
        req = usecase.add_request :get, uri.path
        req.wait = @option.delay if @option.delay
      end
      @testplan.add_usecase usecase
    end
    @testplan.check!  # raise errors, update usecase ratios
    Stella.ld "PLANHASH: #{@testplan.digest}"
    true
  end
  
  
  
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
solutious-stella-0.7.0.001 lib/stella/cli.rb
solutious-stella-0.7.0.002 lib/stella/cli.rb
solutious-stella-0.7.0.003 lib/stella/cli.rb
stella-0.7.0.003 lib/stella/cli.rb
stella-0.7.0.002 lib/stella/cli.rb