loadaboy 0.1.0 → 0.1.1
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.
- data/.gitignore +3 -1
- data/README.rdoc +36 -29
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/elib/worker.erl +3 -3
- data/lib/erlang_interface.rb +3 -2
- data/lib/loadaboy.rb +25 -5
- data/loadaboy.gemspec +3 -4
- metadata +9 -5
- data/lib/generator.rb +0 -5
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -1,47 +1,54 @@
|
|
1
|
-
=
|
1
|
+
= LoadaBoy
|
2
2
|
|
3
|
-
|
3
|
+
== Synopsis
|
4
4
|
|
5
|
-
|
5
|
+
A Load Tester that allows you to generate dynamic requests.
|
6
6
|
|
7
|
-
|
7
|
+
== Requirements
|
8
8
|
|
9
|
-
|
9
|
+
LoadaBoy requires Erlang and RubyGems.
|
10
10
|
|
11
|
-
|
12
|
-
* run loadaboy domain workers requests-per-worker
|
11
|
+
== Installation
|
13
12
|
|
14
|
-
|
13
|
+
gem install loadaboy
|
15
14
|
|
16
|
-
|
17
|
-
AD_SIZES = [{width: 250, height:360}, {width: 300, height:250}, {width: 336, height:280}, {width: 480, height:280}]
|
15
|
+
== How it works
|
18
16
|
|
19
|
-
|
20
|
-
AD_SIZES[rand(AD_SIZES.length)]
|
21
|
-
end
|
17
|
+
* Write a custom generator in Loadafile.rb:
|
22
18
|
|
23
|
-
|
24
|
-
(1..n).map{ ('a'..'z').to_a[rand(26)] }.join
|
25
|
-
end
|
19
|
+
* The generator should return a hash with the requests names as keys and the urls as values.
|
26
20
|
|
27
|
-
|
28
|
-
(1..n).map{random_string(5+rand(20))}.join("+")
|
29
|
-
end
|
21
|
+
* The generated request order is respected when the load test is running.
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
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
|
27
|
+
|
28
|
+
== Example
|
39
29
|
|
30
|
+
=== Loadafile.rb:
|
31
|
+
require 'loadaboy'
|
32
|
+
|
33
|
+
def random_string(n = 10)
|
34
|
+
(1..n).map{ ('a'..'z').to_a[rand(26)] }.join
|
35
|
+
end
|
36
|
+
|
37
|
+
def random_keywords(n = 20)
|
38
|
+
(1..n).map{random_string(5+rand(20))}.join("+")
|
39
|
+
end
|
40
|
+
|
41
|
+
LoadaBoy.generator do
|
42
|
+
{
|
43
|
+
:first => "/static",
|
44
|
+
:second => "/dynamic/#{rand(3)}?random_string=#{random_string}&keywords=#{random_keywords}"
|
45
|
+
}
|
46
|
+
end
|
40
47
|
|
41
48
|
|
42
|
-
== run:
|
43
49
|
|
44
|
-
|
50
|
+
=== Run:
|
51
|
+
loadaboy http://localhost:3000 10 10
|
45
52
|
|
46
53
|
== Note on Patches/Pull Requests
|
47
54
|
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ begin
|
|
14
14
|
gem.name = "loadaboy"
|
15
15
|
gem.executables = %W(loadaboy)
|
16
16
|
gem.summary = %Q{LoadaBoy - Load Test Gem to the Rescue!}
|
17
|
-
gem.description = %Q{LoadaBoy
|
17
|
+
gem.description = %Q{LoadaBoy is a load testing gem.}
|
18
18
|
gem.email = "jean-louis@icehouse.se"
|
19
19
|
gem.homepage = "http://github.com/Jell/loadaboy"
|
20
20
|
gem.authors = ["Jell"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/elib/worker.erl
CHANGED
@@ -28,13 +28,13 @@ fetch_url(Url) ->
|
|
28
28
|
Time = time_to_ms(Tac) - time_to_ms(Tic),
|
29
29
|
case Result of
|
30
30
|
timeout ->
|
31
|
-
[
|
31
|
+
[{"HTTP/1.1", 408, "Request Timeout"}, Time];
|
32
32
|
{Header, _Params, _Body} ->
|
33
33
|
[Header, Time]
|
34
34
|
end
|
35
35
|
catch
|
36
36
|
_:_ ->
|
37
|
-
[
|
37
|
+
[{"HTTP/1.1", 400, "Bad Request"}, 0]
|
38
38
|
end.
|
39
39
|
|
40
40
|
time_to_ms({Mega, Sec, Micro})->
|
@@ -46,6 +46,6 @@ get_over_http(Url) ->
|
|
46
46
|
{http, {RequestId, Result}} ->
|
47
47
|
Result
|
48
48
|
after
|
49
|
-
|
49
|
+
10000 ->
|
50
50
|
timeout
|
51
51
|
end.
|
data/lib/erlang_interface.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
LOADABOY_EXEC_DIR = `echo $LOADABOY_EXEC_DIR`.chomp
|
2
|
-
|
3
1
|
require 'rubygems'
|
4
2
|
require 'erlectricity'
|
5
3
|
require 'loadaboy'
|
6
4
|
|
7
5
|
extend LoadaBoy
|
8
6
|
|
7
|
+
LOADABOY_EXEC_DIR = `echo $LOADABOY_EXEC_DIR`.chomp
|
8
|
+
require "#{LOADABOY_EXEC_DIR}/Loadafile" if File.exist? "#{LOADABOY_EXEC_DIR}/Loadafile.rb"
|
9
|
+
|
9
10
|
receive do |f|
|
10
11
|
f.when([:prepare, Array]) do |array|
|
11
12
|
f.send!([:result, generate_requests(array[0], array[1])])
|
data/lib/loadaboy.rb
CHANGED
@@ -1,11 +1,31 @@
|
|
1
|
-
require '
|
2
|
-
require "#{LOADABOY_EXEC_DIR}/Loadafile" if File.exist? "#{LOADABOY_EXEC_DIR}/Loadafile.rb"
|
1
|
+
require 'enumerator'
|
3
2
|
|
4
3
|
module LoadaBoy
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def generator(&block)
|
7
|
+
define_method :generate, &block
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def generate
|
14
|
+
{ :default => "/" }
|
15
|
+
end
|
16
|
+
|
5
17
|
def generate_requests(workers_count, jobs_count)
|
6
|
-
generator = Generator.new
|
7
18
|
(1..workers_count).map do |i|
|
8
|
-
["worker#{i}".to_sym, (
|
19
|
+
["worker#{i}".to_sym, generate_urls(jobs_count)]
|
9
20
|
end
|
10
21
|
end
|
11
|
-
|
22
|
+
|
23
|
+
def generate_urls(jobs_count)
|
24
|
+
urls = []
|
25
|
+
(1..jobs_count).map { generate.to_a }.flatten.each_slice(2) do |slice|
|
26
|
+
urls << slice
|
27
|
+
end
|
28
|
+
urls
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/loadaboy.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{loadaboy}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
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-10-
|
12
|
+
s.date = %q{2010-10-26}
|
13
13
|
s.default_executable = %q{loadaboy}
|
14
|
-
s.description = %q{LoadaBoy
|
14
|
+
s.description = %q{LoadaBoy is a load testing gem.}
|
15
15
|
s.email = %q{jean-louis@icehouse.se}
|
16
16
|
s.executables = ["loadaboy"]
|
17
17
|
s.extensions = ["ext/extconf.rb", "ext/extconf.rb"]
|
@@ -33,7 +33,6 @@ Gem::Specification.new do |s|
|
|
33
33
|
"ext/Makefile",
|
34
34
|
"ext/extconf.rb",
|
35
35
|
"lib/erlang_interface.rb",
|
36
|
-
"lib/generator.rb",
|
37
36
|
"lib/loadaboy.rb",
|
38
37
|
"loadaboy.gemspec",
|
39
38
|
"test/helper.rb",
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadaboy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jell
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-26 00:00:00 +02:00
|
18
19
|
default_executable: loadaboy
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
version: "0"
|
@@ -38,6 +40,7 @@ dependencies:
|
|
38
40
|
requirements:
|
39
41
|
- - ~>
|
40
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 17
|
41
44
|
segments:
|
42
45
|
- 1
|
43
46
|
- 1
|
@@ -45,7 +48,7 @@ dependencies:
|
|
45
48
|
version: 1.1.1
|
46
49
|
type: :runtime
|
47
50
|
version_requirements: *id002
|
48
|
-
description: LoadaBoy
|
51
|
+
description: LoadaBoy is a load testing gem.
|
49
52
|
email: jean-louis@icehouse.se
|
50
53
|
executables:
|
51
54
|
- loadaboy
|
@@ -69,7 +72,6 @@ files:
|
|
69
72
|
- ext/Makefile
|
70
73
|
- ext/extconf.rb
|
71
74
|
- lib/erlang_interface.rb
|
72
|
-
- lib/generator.rb
|
73
75
|
- lib/loadaboy.rb
|
74
76
|
- loadaboy.gemspec
|
75
77
|
- test/helper.rb
|
@@ -88,6 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
90
|
requirements:
|
89
91
|
- - ">="
|
90
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
91
94
|
segments:
|
92
95
|
- 0
|
93
96
|
version: "0"
|
@@ -96,6 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
99
|
requirements:
|
97
100
|
- - ">="
|
98
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
99
103
|
segments:
|
100
104
|
- 0
|
101
105
|
version: "0"
|