loadaboy 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,14 +16,12 @@ LoadaBoy requires Erlang and RubyGems.
16
16
 
17
17
  * Write a custom generator in Loadafile.rb:
18
18
 
19
- * The generator should return a hash with the requests names as keys and the urls as values.
19
+ Write a generator containing each request a worker needs to perform per job.
20
+ The request order is respected.
21
+ You can optionally give a name to the generator if you want to test different load profiles.
20
22
 
21
- * The generated request order is respected when the load test is running.
22
-
23
- * One set of requests returned by the generator represents one job.
24
-
25
- * run:
26
- loadaboy domain-name number-of-workers number-of-jobs-per-worker
23
+ * In the same folder as your Loadafile.rb, run:
24
+ loadaboy domain-name number-of-workers number-of-jobs-per-worker (generator-name)
27
25
 
28
26
  == Example
29
27
 
@@ -39,17 +37,24 @@ LoadaBoy requires Erlang and RubyGems.
39
37
  end
40
38
 
41
39
  LoadaBoy.generator do
42
- {
43
- :first => "/static",
44
- :second => "/dynamic/#{rand(3)}?random_string=#{random_string}&keywords=#{random_keywords}"
45
- }
40
+ request :static, "/static"
41
+ request :dynamic, "/dynamic/#{rand(3)}?random_string=#{random_string}&keywords=#{random_keywords}"
42
+ end
43
+
44
+ LoadaBoy.generator :only_dynamic do
45
+ request :dynamic, "/dynamic/#{rand(3)}?random_string=#{random_string}&keywords=#{random_keywords}"
46
46
  end
47
-
48
-
49
47
 
50
48
  === Run:
51
49
  loadaboy http://localhost:3000 10 10
52
50
 
51
+ or
52
+ loadaboy http://localhost:3000 10 10 only_dynamic
53
+
54
+ == TODO
55
+
56
+ * Add options to request to customize timeout, disable keepalive etc...
57
+
53
58
  == Note on Patches/Pull Requests
54
59
 
55
60
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -4,15 +4,25 @@ module LoadaBoy
4
4
 
5
5
  class << self
6
6
  def generator(service = 'default', &block)
7
- define_method "generate_#{service}", &block
7
+ define_method "generate_#{service}" do
8
+ @urls = {}
9
+ block.call
10
+ @urls
11
+ end
8
12
  end
9
13
  def set_generator(name)
10
14
  alias_method(:generate, "generate_#{name}")
11
15
  end
12
16
  end
13
17
 
18
+ def request(name, url, options={})
19
+ @urls[name] = url
20
+ end
21
+
14
22
  def generate_default
15
- { :default => "/" }
23
+ @urls = {}
24
+ request :default, "/"
25
+ @urls
16
26
  end
17
27
 
18
28
  alias_method :generate, :generate_default
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{loadaboy}
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jell"]
12
- s.date = %q{2010-11-17}
12
+ s.date = %q{2011-02-27}
13
13
  s.default_executable = %q{loadaboy}
14
14
  s.description = %q{LoadaBoy is a load testing gem.}
15
15
  s.email = %q{jean-louis@icehouse.se}
@@ -6,15 +6,17 @@ class TestLoadaboy < Test::Unit::TestCase
6
6
  context ".generator" do
7
7
  should "define a generate function running the given block" do
8
8
  LoadaBoy.generator do
9
- "custom generator"
9
+ raise "block ran"
10
10
  end
11
- assert_equal "custom generator", generate_default
11
+ exception = assert_raise(RuntimeError){ generate_test }
12
+ assert_match /block ran/, exception.message
12
13
  end
13
14
  should "define a generate function running the given block with proper name" do
14
15
  LoadaBoy.generator :test do
15
- "custom generator"
16
+ raise "block ran"
16
17
  end
17
- assert_equal "custom generator", generate_test
18
+ exception = assert_raise(RuntimeError){ generate_test }
19
+ assert_match /block ran/, exception.message
18
20
  end
19
21
  end
20
22
 
@@ -31,10 +33,10 @@ class TestLoadaboy < Test::Unit::TestCase
31
33
  end
32
34
  should "set proper generator" do
33
35
  LoadaBoy.generator :test do
34
- "custom generator"
36
+ request :request, "custom request"
35
37
  end
36
- generate_requests(2, 1, :test)
37
- assert_equal "custom generator", generate
38
+ generate_requests(1, 1, :test)
39
+ assert_equal "custom request", @urls[:request]
38
40
  end
39
41
  end
40
42
 
@@ -45,4 +47,12 @@ class TestLoadaboy < Test::Unit::TestCase
45
47
  end
46
48
  end
47
49
 
50
+ context "#request" do
51
+ should "add request to url list" do
52
+ @urls = {}
53
+ request :test, "test"
54
+ assert_equal "test", @urls[:test]
55
+ end
56
+ end
57
+
48
58
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jell
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-17 00:00:00 +01:00
18
+ date: 2011-02-27 00:00:00 +01:00
19
19
  default_executable: loadaboy
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency