nethttp_ab 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Gemfile +9 -0
- data/Manifest +8 -0
- data/README +12 -3
- data/Rakefile +1 -1
- data/bin/nethttp_ab +12 -13
- data/lib/requester.rb +7 -1
- data/nethttp_ab.gemspec +4 -4
- data/test/nethttp_ab_test.rb +22 -10
- data/test/resources/index.html +6 -1
- data/test/resources/links.html +15 -0
- data/test/resources/links1.html +8 -0
- data/test/resources/links2.html +8 -0
- data/test/resources/links3.html +8 -0
- data/test/resources/links4.html +8 -0
- data/test/resources/links5.html +8 -0
- data/test/url_regexp_test.rb +21 -0
- metadata +11 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v0.0.3 fixed a bug in url regexp and added a test suite to cover it, also added a test suite for --follow-links option, changed the way options are parsed - now it's possible to specify both "-n100 -c20" and "-n 100 -c 25"
|
2
|
+
|
1
3
|
v0.0.2 deleted trollop gem as a requirement, added nokogiri dependency to gemspec, added MIT license file, fixed small issue with benchmarked site's url, added wrong site address handling [06-04-2011]
|
2
4
|
|
3
5
|
v0.0.1. first release [05-04-2011]
|
data/Gemfile
ADDED
data/Manifest
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
CHANGELOG
|
2
|
+
Gemfile
|
2
3
|
LICENSE
|
3
4
|
Manifest
|
4
5
|
README
|
@@ -12,4 +13,11 @@ nethttp_ab.gemspec
|
|
12
13
|
test/nethttp_ab_test.rb
|
13
14
|
test/requests_queue_test.rb
|
14
15
|
test/resources/index.html
|
16
|
+
test/resources/links.html
|
17
|
+
test/resources/links1.html
|
18
|
+
test/resources/links2.html
|
19
|
+
test/resources/links3.html
|
20
|
+
test/resources/links4.html
|
21
|
+
test/resources/links5.html
|
15
22
|
test/simple_requests_queue_test.rb
|
23
|
+
test/url_regexp_test.rb
|
data/README
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
Simple tool to benchmark sites (rpm, response time, etc)
|
2
2
|
|
3
|
-
|
3
|
+
EXAMPLES:
|
4
|
+
|
4
5
|
3 concurrent threads and 100 total requests:
|
5
|
-
nethttp_ab -
|
6
|
+
nethttp_ab -n100 -c3 http://www.yoursite.com
|
6
7
|
|
7
|
-
OR simulate user and follow all local links on the page:
|
8
|
+
OR simulate one user and follow all local links on the page:
|
8
9
|
nethttp_ab -f http://localhost:3000
|
10
|
+
|
11
|
+
simulate 3 users (all local links on the page will be visited once)
|
12
|
+
nethttp_ab --follow_links -c3 http://localhost:3000
|
13
|
+
|
14
|
+
Issue tracker: https://github.com/german/nethttp_ab/issues
|
15
|
+
|
16
|
+
|
17
|
+
Copyright © 2011 Dmitrii Samoilov, released under the MIT license
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('nethttp_ab', '0.0.
|
5
|
+
Echoe.new('nethttp_ab', '0.0.3') do |p|
|
6
6
|
p.description = "Simple tool to test and benchmark sites"
|
7
7
|
p.url = "http://github.com/german/nethttp_ab"
|
8
8
|
p.author = "Dmitrii Samoilov"
|
data/bin/nethttp_ab
CHANGED
@@ -4,10 +4,13 @@ require File.dirname(File.expand_path(__FILE__)) + '/../lib/requester.rb'
|
|
4
4
|
|
5
5
|
# SIMPLE USAGE:
|
6
6
|
# 3 concurrent threads and 100 total requests
|
7
|
-
# nethttp_ab -
|
7
|
+
# nethttp_ab -n100 -c3 http://www.yoursite.com
|
8
8
|
#
|
9
|
-
# OR simulate user and follow all local links on the page
|
9
|
+
# OR simulate one user and follow all local links on the page
|
10
10
|
# nethttp_ab -f http://localhost:3000
|
11
|
+
#
|
12
|
+
# simulate 3 users (all local links on the page will be visited once)
|
13
|
+
# nethttp_ab --follow_links -c3 http://localhost:3000
|
11
14
|
|
12
15
|
opts = {}
|
13
16
|
|
@@ -17,27 +20,23 @@ else
|
|
17
20
|
opts[:follow_links] = false
|
18
21
|
end
|
19
22
|
|
20
|
-
if ARGV.
|
21
|
-
opts[:concurrent_threads] =
|
22
|
-
ARGV.delete('-c')
|
23
|
-
ARGV.delete(opts[:concurrent_threads])
|
23
|
+
if ARGV.join.match(/-c\s*(\d*)/)
|
24
|
+
opts[:concurrent_threads] = $1.to_i
|
24
25
|
else
|
25
|
-
opts[:concurrent_threads] =
|
26
|
+
opts[:concurrent_threads] = 1
|
26
27
|
end
|
27
28
|
|
28
|
-
if ARGV.
|
29
|
-
opts[:requests] =
|
30
|
-
ARGV.delete('-n')
|
31
|
-
ARGV.delete(opts[:requests])
|
29
|
+
if ARGV.join.match(/-n\s*(\d*)/)
|
30
|
+
opts[:requests] = $1.to_i
|
32
31
|
else
|
33
32
|
opts[:requests] = 10
|
34
33
|
end
|
35
34
|
|
36
35
|
url_to_benchmark = "http://localhost:3000/"
|
37
36
|
|
38
|
-
# search for the url to perform benchmarking on
|
37
|
+
# search in ARGV for the url to perform benchmarking on
|
39
38
|
ARGV.each do |arg|
|
40
|
-
url_to_benchmark = arg if arg =~
|
39
|
+
url_to_benchmark = arg if arg =~ NethttpAb::Requester::URL_REGEXP
|
41
40
|
end
|
42
41
|
|
43
42
|
url_to_benchmark = "http://" + url_to_benchmark if url_to_benchmark !~ /^https?:\/\//
|
data/lib/requester.rb
CHANGED
@@ -12,6 +12,8 @@ module NethttpAb
|
|
12
12
|
attr_accessor :successfull_requests
|
13
13
|
attr_accessor :failed_requests
|
14
14
|
|
15
|
+
URL_REGEXP = /^(https?:\/\/)?(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/
|
16
|
+
|
15
17
|
def initialize
|
16
18
|
@response_length = 0
|
17
19
|
@total_time = 0.0
|
@@ -100,7 +102,7 @@ module NethttpAb
|
|
100
102
|
puts "The url you provided is wrong, please check is it really ssl encrypted"
|
101
103
|
exit
|
102
104
|
rescue Errno::ECONNREFUSED => e
|
103
|
-
puts "Connection error, please check your internet connection or make sure the server is
|
105
|
+
puts "Connection error, please check your internet connection or make sure the server is responding"
|
104
106
|
exit
|
105
107
|
rescue SocketError => e
|
106
108
|
puts e.message
|
@@ -118,9 +120,13 @@ module NethttpAb
|
|
118
120
|
Net::HTTP::Get.new(@url.path)
|
119
121
|
end
|
120
122
|
|
123
|
+
# TODO
|
124
|
+
#req.add_field "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"
|
125
|
+
|
121
126
|
@total_time += Benchmark.realtime do
|
122
127
|
begin
|
123
128
|
response = http_opened_session.request(req)
|
129
|
+
|
124
130
|
@mutex.synchronize do
|
125
131
|
@response_length += response.body.length
|
126
132
|
@successfull_requests += 1
|
data/nethttp_ab.gemspec
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{nethttp_ab}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dmitrii Samoilov"]
|
9
|
-
s.date = %q{2011-04-
|
9
|
+
s.date = %q{2011-04-12}
|
10
10
|
s.default_executable = %q{nethttp_ab}
|
11
11
|
s.description = %q{Simple tool to test and benchmark sites}
|
12
12
|
s.email = %q{germaninthetown@gmail.com}
|
13
13
|
s.executables = ["nethttp_ab"]
|
14
14
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/nethttp_ab", "lib/net.rb", "lib/requester.rb", "lib/requests_queue.rb", "lib/simple_requests_queue.rb"]
|
15
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/nethttp_ab", "lib/net.rb", "lib/requester.rb", "lib/requests_queue.rb", "lib/simple_requests_queue.rb", "nethttp_ab.gemspec", "test/nethttp_ab_test.rb", "test/requests_queue_test.rb", "test/resources/index.html", "test/simple_requests_queue_test.rb"]
|
15
|
+
s.files = ["CHANGELOG", "Gemfile", "LICENSE", "Manifest", "README", "Rakefile", "bin/nethttp_ab", "lib/net.rb", "lib/requester.rb", "lib/requests_queue.rb", "lib/simple_requests_queue.rb", "nethttp_ab.gemspec", "test/nethttp_ab_test.rb", "test/requests_queue_test.rb", "test/resources/index.html", "test/resources/links.html", "test/resources/links1.html", "test/resources/links2.html", "test/resources/links3.html", "test/resources/links4.html", "test/resources/links5.html", "test/simple_requests_queue_test.rb", "test/url_regexp_test.rb"]
|
16
16
|
s.homepage = %q{http://github.com/german/nethttp_ab}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Nethttp_ab", "--main", "README"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{nethttp_ab}
|
20
20
|
s.rubygems_version = %q{1.6.2}
|
21
21
|
s.summary = %q{Simple tool to test and benchmark sites}
|
22
|
-
s.test_files = ["test/nethttp_ab_test.rb", "test/requests_queue_test.rb", "test/simple_requests_queue_test.rb"]
|
22
|
+
s.test_files = ["test/url_regexp_test.rb", "test/nethttp_ab_test.rb", "test/requests_queue_test.rb", "test/simple_requests_queue_test.rb"]
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
25
25
|
s.specification_version = 3
|
data/test/nethttp_ab_test.rb
CHANGED
@@ -15,19 +15,31 @@ class OpenSession
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class NetHttpAbTest < Test::Unit::TestCase
|
18
|
-
def
|
18
|
+
def setup
|
19
19
|
Net::HTTP.any_instance.stubs(:start).returns(OpenSession.new)
|
20
|
-
|
21
|
-
|
20
|
+
@requester = NethttpAb::Requester.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_simple
|
24
|
+
@requester.url = "http://localhost/index.html"
|
25
|
+
@requester.concurrent_users = 3
|
26
|
+
@requester.num_of_requests = 10
|
27
|
+
@requester.follow_links = false
|
28
|
+
|
29
|
+
@requester.proceed
|
30
|
+
|
31
|
+
assert_equal 10, @requester.successfull_requests
|
32
|
+
assert_equal 0, @requester.failed_requests
|
33
|
+
end
|
22
34
|
|
23
|
-
|
24
|
-
requester.
|
25
|
-
requester.
|
26
|
-
requester.follow_links =
|
35
|
+
def test_follow_links
|
36
|
+
@requester.url = "http://localhost/links.html"
|
37
|
+
@requester.concurrent_users = 3
|
38
|
+
@requester.follow_links = true
|
27
39
|
|
28
|
-
requester.proceed
|
40
|
+
@requester.proceed
|
29
41
|
|
30
|
-
assert_equal
|
31
|
-
assert_equal 0, requester.failed_requests
|
42
|
+
assert_equal 5, @requester.successfull_requests
|
43
|
+
assert_equal 0, @requester.failed_requests
|
32
44
|
end
|
33
45
|
end
|
data/test/resources/index.html
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Follow links test</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<h3>Follow links test</h3>
|
7
|
+
<ul>
|
8
|
+
<li><a href="links1.html">Link #1</a></li>
|
9
|
+
<li><a href="links2.html">Link #2</a></li>
|
10
|
+
<li><a href="links3.html">Link #3</a></li>
|
11
|
+
<li><a href="links4.html">Link #4</a></li>
|
12
|
+
<li><a href="links5.html">Link #5</a></li>
|
13
|
+
</ul>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname(File.expand_path(__FILE__)) + '/../lib/requester.rb'
|
4
|
+
|
5
|
+
class UrlRegexpTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@fail_urls = %w{www./yandex.ru yandex.123ru germaninthetown@gmail.com abcde}
|
8
|
+
|
9
|
+
@correct_urls = %w{www.google.com google.com http://google.com http://mail.ya.ru mail.ya.ru/ mail.ya.ru/test http://www.my-site.org/articles/2011/04/12/123-nethttpab-is-great}
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_url_regexp
|
13
|
+
@correct_urls.each do |correct_url|
|
14
|
+
assert(correct_url =~ NethttpAb::Requester::URL_REGEXP)
|
15
|
+
end
|
16
|
+
|
17
|
+
@fail_urls.each do |fail_url|
|
18
|
+
assert(fail_url !~ NethttpAb::Requester::URL_REGEXP)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nethttp_ab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-04-
|
12
|
+
date: 2011-04-12 00:00:00.000000000 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: Simple tool to test and benchmark sites
|
@@ -28,6 +28,7 @@ extra_rdoc_files:
|
|
28
28
|
- lib/simple_requests_queue.rb
|
29
29
|
files:
|
30
30
|
- CHANGELOG
|
31
|
+
- Gemfile
|
31
32
|
- LICENSE
|
32
33
|
- Manifest
|
33
34
|
- README
|
@@ -41,7 +42,14 @@ files:
|
|
41
42
|
- test/nethttp_ab_test.rb
|
42
43
|
- test/requests_queue_test.rb
|
43
44
|
- test/resources/index.html
|
45
|
+
- test/resources/links.html
|
46
|
+
- test/resources/links1.html
|
47
|
+
- test/resources/links2.html
|
48
|
+
- test/resources/links3.html
|
49
|
+
- test/resources/links4.html
|
50
|
+
- test/resources/links5.html
|
44
51
|
- test/simple_requests_queue_test.rb
|
52
|
+
- test/url_regexp_test.rb
|
45
53
|
has_rdoc: true
|
46
54
|
homepage: http://github.com/german/nethttp_ab
|
47
55
|
licenses: []
|
@@ -74,6 +82,7 @@ signing_key:
|
|
74
82
|
specification_version: 3
|
75
83
|
summary: Simple tool to test and benchmark sites
|
76
84
|
test_files:
|
85
|
+
- test/url_regexp_test.rb
|
77
86
|
- test/nethttp_ab_test.rb
|
78
87
|
- test/requests_queue_test.rb
|
79
88
|
- test/simple_requests_queue_test.rb
|