tourbus 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -4
- data/lib/tourist.rb +20 -19
- data/lib/webrat_headers_patch.rb +17 -0
- metadata +101 -75
data/README.rdoc
CHANGED
@@ -46,7 +46,7 @@ better name, these are called Tours.
|
|
46
46
|
it write:
|
47
47
|
|
48
48
|
class Simple < Tourist
|
49
|
-
def
|
49
|
+
def tour_homepage
|
50
50
|
visit "http://#{@host}/"
|
51
51
|
assert_contain "My Home Page"
|
52
52
|
end
|
@@ -55,9 +55,12 @@ better name, these are called Tours.
|
|
55
55
|
* Files in ./tours should have classes that match their names. E.g.
|
56
56
|
"class BigHairyTest < Tourist" belongs in ./tours/big_hairy_test.rb
|
57
57
|
|
58
|
-
*
|
59
|
-
setup() and teardown()
|
60
|
-
times.
|
58
|
+
* Like how Test::Unit finds test_* methods automagically, TourBus will
|
59
|
+
make each tourist run any tour_* methods. setup() and teardown()
|
60
|
+
methods will be executed at the appropriate times.
|
61
|
+
|
62
|
+
* Two more magic methods: +before_tours+ and +after_tours+ will be run
|
63
|
+
before any tours and after all tours, respectively.
|
61
64
|
|
62
65
|
=== Example TourBus Run
|
63
66
|
|
data/lib/tourist.rb
CHANGED
@@ -3,6 +3,7 @@ require 'monitor'
|
|
3
3
|
require 'common'
|
4
4
|
require 'webrat'
|
5
5
|
require 'webrat/adapters/mechanize'
|
6
|
+
require 'webrat_headers_patch' # must come after webrat requires
|
6
7
|
require 'test/unit/assertions'
|
7
8
|
|
8
9
|
# A tourist is essentially a test suite file. A Tourist subclass
|
@@ -21,30 +22,30 @@ class Tourist
|
|
21
22
|
include Webrat::Matchers
|
22
23
|
include Webrat::SaveAndOpenPage
|
23
24
|
include Test::Unit::Assertions
|
24
|
-
|
25
|
+
|
25
26
|
attr_reader :host, :tours, :number, :tour_type, :tourist_id
|
26
|
-
|
27
|
+
|
27
28
|
def initialize(host, tours, number, tourist_id)
|
28
29
|
@host, @tours, @number, @tourist_id = host, tours, number, tourist_id
|
29
30
|
@tour_type = self.send(:class).to_s
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
# before_tour runs once per tour, before any tours get run
|
33
34
|
def before_tours; end
|
34
|
-
|
35
|
+
|
35
36
|
# after_tour runs once per tour, after all the tours have run
|
36
37
|
def after_tours; end
|
37
|
-
|
38
|
+
|
38
39
|
def setup
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
def teardown
|
42
43
|
end
|
43
|
-
|
44
|
+
|
44
45
|
def wait(time)
|
45
46
|
sleep time.to_i
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
# Lists tourists in tours folder. If a string is given, filters the
|
49
50
|
# list by that string. If an array of filter strings is given,
|
50
51
|
# returns items that match ANY filter string in the array.
|
@@ -57,28 +58,28 @@ class Tourist
|
|
57
58
|
# 3. If you passed in any filters, these basenames are rejected unless they match at least one filter
|
58
59
|
# 4. The filenames remaining are then checked to see if they define a class of the same name that inherits from Tourist
|
59
60
|
Dir[File.join('.', 'tours', '**', '*.rb')].map {|fn| File.basename(fn, ".rb")}.select {|fn| filter.size.zero? || filter.any?{|f| fn =~ /#{f}/}}.select {|tour| Tourist.tourist? tour }
|
60
|
-
end
|
61
|
-
|
61
|
+
end
|
62
|
+
|
62
63
|
def self.tours(tourist_name)
|
63
64
|
Tourist.make_tourist(tourist_name).tours
|
64
65
|
end
|
65
|
-
|
66
|
+
|
66
67
|
# Returns true if the given tourist name can be found in the tours folder, and defines a similarly-named subclass of Tourist
|
67
68
|
def self.tourist?(tourist_name)
|
68
69
|
Object.const_defined?(tourist_name.classify) && tourist_name.classify.constantize.ancestors.include?(Tourist)
|
69
70
|
end
|
70
|
-
|
71
|
+
|
71
72
|
# Factory method, creates the named child class instance
|
72
73
|
def self.make_tourist(tourist_name,host="http://localhost:3000",tours=[],number=1,tourist_id=nil)
|
73
74
|
tourist_name.classify.constantize.new(host,tours,number,tourist_id)
|
74
75
|
end
|
75
|
-
|
76
|
+
|
76
77
|
# Returns list of tours this tourist knows about. (Meant to be run on a subclass
|
77
78
|
# instance; returns the list of tours available).
|
78
79
|
def tours
|
79
|
-
methods.grep(/^tour_/).map {|m| m.sub(/^tour_/,'')}
|
80
|
+
methods.map(&:to_s).grep(/^tour_/).map {|m| m.sub(/^tour_/,'')}
|
80
81
|
end
|
81
|
-
|
82
|
+
|
82
83
|
def run_tour(tour_name)
|
83
84
|
@current_tour = "tour_#{tour_name}"
|
84
85
|
raise TourBusException.new("run_tour couldn't run tour '#{tour_name}' because this tourist did not respond to :#{@current_tour}") unless respond_to? @current_tour
|
@@ -86,16 +87,16 @@ class Tourist
|
|
86
87
|
send @current_tour
|
87
88
|
teardown
|
88
89
|
end
|
89
|
-
|
90
|
+
|
90
91
|
protected
|
91
|
-
|
92
|
+
|
92
93
|
def session
|
93
94
|
@session ||= Webrat::MechanizeSession.new
|
94
95
|
end
|
95
|
-
|
96
|
+
|
96
97
|
def log(message)
|
97
98
|
puts "#{Time.now.strftime('%F %H:%M:%S')} Tourist ##{@tourist_id}: (#{@current_tour}) #{message}"
|
98
99
|
end
|
99
|
-
|
100
|
+
|
100
101
|
end
|
101
102
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Webrat::MechanizeAdapter
|
2
|
+
# Replace the Webrat version of get with one that doesn't drop the
|
3
|
+
# headers param. Headers can be set using Webrat::Session#header
|
4
|
+
# (#header is available in your Tourist sublasses). For example:
|
5
|
+
#
|
6
|
+
# class MyTests < Tourist
|
7
|
+
# def before_tours
|
8
|
+
# header 'X-My-Header', 'something'
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
def get_with_headers(url, data, headers = nil)
|
12
|
+
@response = mechanize.get({url: url, headers: headers}, data)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :get_without_headers, :get
|
16
|
+
alias_method :get, :get_with_headers
|
17
|
+
end
|
metadata
CHANGED
@@ -1,101 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tourbus
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.2
|
4
5
|
prerelease:
|
5
|
-
version: 2.0.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- David Brady
|
9
9
|
- James Britt
|
10
10
|
- JT Zemp
|
11
11
|
- Tim Harper
|
12
12
|
- Joe Tanner
|
13
|
+
- Chris Bailey
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
21
20
|
name: mechanize
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
24
22
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
28
26
|
version: 1.0.0
|
29
27
|
type: :runtime
|
30
|
-
version_requirements: *id001
|
31
|
-
- !ruby/object:Gem::Dependency
|
32
|
-
name: trollop
|
33
28
|
prerelease: false
|
34
|
-
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: trollop
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
35
38
|
none: false
|
36
|
-
requirements:
|
37
|
-
- -
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
40
43
|
type: :runtime
|
41
|
-
version_requirements: *id002
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: faker
|
44
44
|
prerelease: false
|
45
|
-
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version:
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: faker
|
53
|
+
requirement: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
51
59
|
type: :runtime
|
52
|
-
version_requirements: *id003
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: hpricot
|
55
60
|
prerelease: false
|
56
|
-
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: hpricot
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
57
70
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version:
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
62
75
|
type: :runtime
|
63
|
-
version_requirements: *id004
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: webrat
|
66
76
|
prerelease: false
|
67
|
-
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webrat
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
68
86
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
72
90
|
version: 0.7.0
|
73
91
|
type: :runtime
|
74
|
-
version_requirements: *id005
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: activesupport
|
77
92
|
prerelease: false
|
78
|
-
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 0.7.0
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: activesupport
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
79
102
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
83
106
|
version: 3.0.0
|
84
107
|
type: :runtime
|
85
|
-
|
86
|
-
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 3.0.0
|
115
|
+
description: TourBus, a web load-testing tool that combines complex 'tour' definitions
|
116
|
+
with scalable, concurrent testing
|
87
117
|
email: github@shinybit.com
|
88
|
-
executables:
|
118
|
+
executables:
|
89
119
|
- tourbus
|
90
120
|
- tourwatch
|
91
121
|
- tourproxy
|
92
122
|
extensions: []
|
93
|
-
|
94
|
-
extra_rdoc_files:
|
123
|
+
extra_rdoc_files:
|
95
124
|
- README.rdoc
|
96
125
|
- MIT-LICENSE
|
97
126
|
- examples/contact_app/README.rdoc
|
98
|
-
files:
|
127
|
+
files:
|
99
128
|
- bin/tourbus
|
100
129
|
- bin/tourproxy
|
101
130
|
- bin/tourwatch
|
@@ -111,42 +140,39 @@ files:
|
|
111
140
|
- lib/tour_rat.rb
|
112
141
|
- lib/tour_watch.rb
|
113
142
|
- lib/tourist.rb
|
143
|
+
- lib/webrat_headers_patch.rb
|
114
144
|
- spec/lib/tourproxy_spec.rb
|
115
145
|
- spec/spec_helper.rb
|
116
146
|
- README.rdoc
|
117
147
|
- MIT-LICENSE
|
118
|
-
has_rdoc: true
|
119
148
|
homepage: http://github.com/dbrady/tourbus/
|
120
149
|
licenses: []
|
121
|
-
|
122
150
|
post_install_message:
|
123
|
-
rdoc_options:
|
151
|
+
rdoc_options:
|
124
152
|
- --line-numbers
|
125
153
|
- --inline-source
|
126
154
|
- --main
|
127
155
|
- README.rdoc
|
128
156
|
- --title
|
129
157
|
- Tourbus - Web Load Testing in Ruby
|
130
|
-
require_paths:
|
158
|
+
require_paths:
|
131
159
|
- lib
|
132
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
161
|
none: false
|
134
|
-
requirements:
|
135
|
-
- -
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version:
|
138
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
167
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version:
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
144
172
|
requirements: []
|
145
|
-
|
146
173
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.
|
174
|
+
rubygems_version: 1.8.24
|
148
175
|
signing_key:
|
149
176
|
specification_version: 3
|
150
177
|
summary: TourBus web stress-testing tool
|
151
178
|
test_files: []
|
152
|
-
|