Sha256: e502b01192dff51b5f5d30863284c1f6f110ba5939c145327775cfcfe552c97f

Contents?: true

Size: 1.29 KB

Versions: 39

Compression:

Stored size: 1.29 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'ruby-jmeter'

class Test
  def initialize options = {}
    @users    = options[:users]
    @ramp     = options[:ramp]
    @duration = options[:duration]
    @region   = options[:region] || 'ap-southeast-2'
    @name     = options[:name]
  end

  def flood domain
    @domain = domain
    test_plan.grid ENV['FLOOD_IO_KEY'], region: @region, name: @name
  end

  def jmeter domain
    @domain = domain
    test_plan.run path: '/usr/share/jmeter/bin/', gui:true
  end

  def test_plan
    test do
      grab_dsl self
      defaults domain: @domain,
        protocol: 'http',
        image_parser: true,
        concurrentDwn: true,
        concurrentPool: 4

      cookies

      plan
    end
  end

  def plan
    threads @users, {ramp_time: @ramp, duration: @duration, scheduler: true, continue_forever: true} do
      random_timer 5000, 10000

      transaction '01_GET_home_page' do
        visit '/'
      end
    end
  end

  def grab_dsl dsl
    @dsl = dsl
  end

  def method_missing method, *args, &block
    @dsl.__send__ method, *args, &block
  end
end

test = Test.new users:10, ramp: 30, duration: 30, name: 'Test Number 1'

# test locally with JMeter
test.jmeter 'google.com'

# test distributed with flood
# test.flood 'google.com'

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ruby-jmeter-2.13.10 examples/basic_meta_fu.rb
ruby-jmeter-2.13.9 examples/basic_meta_fu.rb
ruby-jmeter-2.13.8 examples/basic_meta_fu.rb
ruby-jmeter-2.13.7 examples/basic_meta_fu.rb
ruby-jmeter-2.13.6 examples/basic_meta_fu.rb
ruby-jmeter-2.13.5 examples/basic_meta_fu.rb
ruby-jmeter-2.13.4 examples/basic_meta_fu.rb
ruby-jmeter-2.13.3 examples/basic_meta_fu.rb
ruby-jmeter-2.13.2 examples/basic_meta_fu.rb
ruby-jmeter-2.13.1 examples/basic_meta_fu.rb
ruby-jmeter-2.13.0 examples/basic_meta_fu.rb
ruby-jmeter-2.12.5 examples/basic_meta_fu.rb
ruby-jmeter-2.12.4 examples/basic_meta_fu.rb
ruby-jmeter-2.12.3 examples/basic_meta_fu.rb
ruby-jmeter-2.12.2 examples/basic_meta_fu.rb
ruby-jmeter-2.12.1 examples/basic_meta_fu.rb
ruby-jmeter-2.12.0 examples/basic_meta_fu.rb
ruby-jmeter-2.11.22 examples/basic_meta_fu.rb
ruby-jmeter-2.11.21 examples/basic_meta_fu.rb
ruby-jmeter-2.11.20 examples/basic_meta_fu.rb