celluloid-benchmark 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/bin/celluloid-benchmark +11 -6
- data/lib/celluloid_benchmark/runner.rb +17 -15
- data/lib/celluloid_benchmark/target.rb +45 -0
- data/lib/celluloid_benchmark/version.rb +1 -1
- data/lib/celluloid_benchmark/visitor.rb +3 -1
- data/lib/celluloid_benchmark/visitor_group.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f324f0d80da8c02cbf069d16c6d9149ec54a78
|
4
|
+
data.tar.gz: 4cf506f01001f0f1c4deaedd9c63370c2126e7b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c77eb8790651fa84cc0aef9fe3f836a866babe4c82f46761148136d2613f476296c856d472d1f6163b3434c2e1031e32a7282902146b419be975114dbe9a9081
|
7
|
+
data.tar.gz: 723c251d7190fd5746f665ac53cd00979b310cba9d75935ec8c4f7b86ac9fe15b4fb1cce137f7d93b26a5683f49857e0dabacf6fbd0c9d70b05f8c16edfc3645
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Getting Started
|
|
8
8
|
gem install celluloid-benchmark
|
9
9
|
echo "benchmark :home_page, 1
|
10
10
|
get 'https://github.com/scottwillson/celluloid-benchmark'" > session.rb
|
11
|
-
celluloid-benchmark
|
11
|
+
celluloid-benchmark -d 1
|
12
12
|
|
13
13
|
Congrats! You just load-tested the project's Github page.
|
14
14
|
|
@@ -64,8 +64,12 @@ JSON requests (e.g., a mobile app API)
|
|
64
64
|
{ "Content-Type" => "application/json" }
|
65
65
|
)
|
66
66
|
|
67
|
+
Options
|
68
|
+
-------
|
69
|
+
celluloid-benchmark --help
|
70
|
+
|
67
71
|
Test data
|
68
|
-
|
72
|
+
=========
|
69
73
|
Because test scenarios are plain Ruby, you can drive tests in many different ways. The
|
70
74
|
[Faker gem](http://rubydoc.info/github/stympy/faker/master/frames) is handy
|
71
75
|
for random, realistic test data:
|
@@ -87,7 +91,7 @@ Celluloid Benchmark can also pull random test data from CSV files. For example:
|
|
87
91
|
`random_data(:post_zone)` pulls a random line from tmp/data/post_zones.csv
|
88
92
|
|
89
93
|
Extending session DSL
|
90
|
-
|
94
|
+
=====================
|
91
95
|
The DSL is simple and will change in early releases. To add custom DSL methods, add methods to Visitor
|
92
96
|
module CelluloidBenchmark
|
93
97
|
class Visitor
|
data/bin/celluloid-benchmark
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
require "slop"
|
4
4
|
|
5
|
-
|
5
|
+
opts = Slop.parse(help: true) do
|
6
|
+
banner "Usage: celluloid-benchmark [options]"
|
6
7
|
|
7
|
-
duration
|
8
|
-
|
9
|
-
|
8
|
+
on "d", "duration", "Start new visitors for :duration seconds. Default: 20.", argument: :optional
|
9
|
+
on "s", "session", "Session file path. Default: session.rb.", argument: :optional
|
10
|
+
on "t", "target", "Target server/environment, site. Default: local.", argument: :optional
|
11
|
+
on "v", "visitors", "Number of concurrent visitors. Default: CPU cores - 2 (minimum 1).", argument: :optional
|
10
12
|
end
|
11
13
|
|
12
|
-
|
14
|
+
require_relative "../lib/celluloid_benchmark"
|
15
|
+
require_relative "../lib/celluloid_benchmark/visitor"
|
16
|
+
|
17
|
+
benchmark_run = CelluloidBenchmark::Runner.run opts.to_hash
|
13
18
|
|
14
19
|
p benchmark_run
|
15
20
|
puts
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "celluloid"
|
2
2
|
require_relative "session"
|
3
|
+
require_relative "target"
|
3
4
|
require_relative "visitor_group"
|
4
5
|
|
5
6
|
Celluloid.logger = nil
|
@@ -7,44 +8,45 @@ Celluloid.logger = nil
|
|
7
8
|
module CelluloidBenchmark
|
8
9
|
# Run a scenario in several Visitors and return a BenchmarkRun
|
9
10
|
class Runner
|
10
|
-
def self.run(
|
11
|
-
|
12
|
-
|
11
|
+
def self.run(args)
|
12
|
+
session = args[:session] || "session.rb"
|
13
|
+
visitors = args[:visitors] || visitors_count(args[:visitors])
|
14
|
+
duration = (args[:duration] || 20).to_f
|
15
|
+
target = args[:target]
|
13
16
|
|
14
|
-
require
|
17
|
+
require File.expand_path(session)
|
15
18
|
|
16
19
|
VisitorGroup.run!
|
17
|
-
set_visitor_pool_size visitors
|
18
|
-
visitors = visitors_count(visitors)
|
19
20
|
|
21
|
+
visitors = visitors_count(visitors)
|
20
22
|
benchmark_run = Celluloid::Actor[:benchmark_run]
|
21
23
|
benchmark_run.visitors = visitors
|
22
24
|
|
23
25
|
benchmark_run.mark_start
|
24
|
-
futures = run_sessions(benchmark_run, duration, visitors)
|
26
|
+
futures = run_sessions(benchmark_run, duration, visitors, Target.new_from_key(target))
|
25
27
|
futures.map(&:value)
|
28
|
+
|
26
29
|
benchmark_run.mark_end
|
27
30
|
|
28
31
|
benchmark_run
|
29
32
|
end
|
30
33
|
|
31
|
-
def self.run_sessions(benchmark_run, duration, visitors)
|
34
|
+
def self.run_sessions(benchmark_run, duration, visitors, target)
|
32
35
|
pool = Celluloid::Actor[:visitor_pool]
|
33
36
|
futures = []
|
34
37
|
visitors.times do
|
35
|
-
futures << pool.future.run_session(benchmark_run, duration)
|
38
|
+
futures << pool.future.run_session(benchmark_run, duration, target)
|
36
39
|
end
|
37
40
|
futures
|
38
41
|
end
|
39
42
|
|
40
|
-
def self.
|
41
|
-
if
|
42
|
-
|
43
|
+
def self.visitors_count(count)
|
44
|
+
if count
|
45
|
+
count = count.to_i
|
46
|
+
else
|
47
|
+
count = Visitor.pool.size - 2
|
43
48
|
end
|
44
|
-
end
|
45
49
|
|
46
|
-
def self.visitors_count(count)
|
47
|
-
count = count || (Visitor.pool.size - 2)
|
48
50
|
if count > 1
|
49
51
|
count
|
50
52
|
else
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CelluloidBenchmark
|
2
|
+
class Target
|
3
|
+
attr_reader :http_auth_password
|
4
|
+
attr_reader :http_auth_username
|
5
|
+
attr_reader :key
|
6
|
+
attr_reader :uri
|
7
|
+
|
8
|
+
def self.new_from_key(key, config_file_path = nil)
|
9
|
+
if key.nil? && config_file_path.nil?
|
10
|
+
return default_target
|
11
|
+
end
|
12
|
+
|
13
|
+
key ||= "local"
|
14
|
+
config_file_path ||= "config/targets.yml"
|
15
|
+
|
16
|
+
configs = YAML.load_file(config_file_path)
|
17
|
+
config = configs[key]
|
18
|
+
|
19
|
+
unless config
|
20
|
+
raise ArgumentError, "No target for '#{key}'"
|
21
|
+
end
|
22
|
+
|
23
|
+
if config["http_auth"]
|
24
|
+
Target.new(key, config["uri"], config["http_auth"]["username"], config["http_auth"]["password"])
|
25
|
+
else
|
26
|
+
Target.new(key, config["uri"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.default_target
|
31
|
+
Target.new("local", "http://localhost")
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(key, uri, http_auth_username = nil, http_auth_password = nil)
|
35
|
+
@http_auth_password = http_auth_password
|
36
|
+
@http_auth_username = http_auth_username
|
37
|
+
@key = key
|
38
|
+
@uri = uri
|
39
|
+
end
|
40
|
+
|
41
|
+
def http_auth?
|
42
|
+
http_auth_username && http_auth_password
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -20,9 +20,11 @@ module CelluloidBenchmark
|
|
20
20
|
attr_accessor :current_request_threshold
|
21
21
|
attr_accessor :request_start_time
|
22
22
|
attr_accessor :request_end_time
|
23
|
+
attr_reader :target
|
23
24
|
|
24
|
-
def run_session(benchmark_run, duration)
|
25
|
+
def run_session(benchmark_run, duration, target = nil)
|
25
26
|
@benchmark_run = benchmark_run
|
27
|
+
@target = target
|
26
28
|
|
27
29
|
elapsed_time = 0
|
28
30
|
started_at = benchmark_run.started_at
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid-benchmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Willson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-23 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: celluloid
|
@@ -62,6 +62,14 @@ dependencies:
|
|
62
62
|
version: "1.25"
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: *id005
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: slop
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- *id006
|
71
|
+
type: :runtime
|
72
|
+
version_requirements: *id007
|
65
73
|
description: |-
|
66
74
|
Celluloid Benchmark realistically load tests websites. Write expressive, concise load tests in Ruby. Use Rubinius and Celluloid
|
67
75
|
forpec high concurrency. Use Mechanize for a realistic (albeit non-JavaScript) browser client.
|
@@ -82,6 +90,7 @@ files:
|
|
82
90
|
- lib/celluloid_benchmark/data_sources.rb
|
83
91
|
- lib/celluloid_benchmark/runner.rb
|
84
92
|
- lib/celluloid_benchmark/session.rb
|
93
|
+
- lib/celluloid_benchmark/target.rb
|
85
94
|
- lib/celluloid_benchmark/version.rb
|
86
95
|
- lib/celluloid_benchmark/visitor.rb
|
87
96
|
- lib/celluloid_benchmark/visitor_group.rb
|