Description:
load test reads site_url from command line
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r315:faf1f66729ca - - 5 files changed: 28 inserted, 182 deleted
@@ -3,5 +3,5 | |||
|
3 | 3 | |
|
4 | 4 | Load test for front page: |
|
5 | 5 | |
|
6 |
- ruby runner.rb common_visitors.rb FirstPageViewer |
|
|
6 | + ruby runner.rb common_visitors.rb FirstPageViewer 20 -t 10 --site_url=http://localhost/cafe | |
|
7 | 7 |
@@ -1,7 +1,8 | |||
|
1 | - visitor "FirstPageViewer" do | |
|
2 | - stores_cookies | |
|
1 | + if !defined? VISITOR_OPTION_LIST | |
|
2 | + VISITOR_OPTION_LIST = {} | |
|
3 | + end | |
|
3 | 4 | |
|
4 | - site_url "http://localhost:3000" | |
|
5 | - | |
|
5 | + visitor "FirstPageViewer", VISITOR_OPTION_LIST do | |
|
6 | + stores_cookies | |
|
6 | 7 | get "/" |
|
7 | 8 | end |
@@ -130,13 +130,13 | |||
|
130 | 130 | end |
|
131 | 131 | |
|
132 | 132 | visitor_file = ARGV.shift |
|
133 | - require visitor_file | |
|
134 | 133 | |
|
135 | 134 | load_time = 60 |
|
136 | 135 | dry_run = false |
|
137 | 136 | |
|
138 | - #build visitor list | |
|
137 | + #build visitor/option list | |
|
139 | 138 | visitor_list = {} |
|
139 | + visitor_option_list = {} | |
|
140 | 140 | while ARGV.length>0 |
|
141 | 141 | key = ARGV.shift |
|
142 | 142 | |
@@ -147,11 +147,21 | |||
|
147 | 147 | num = ARGV.shift.to_i |
|
148 | 148 | load_time = num |
|
149 | 149 | else |
|
150 | - num = ARGV.shift.to_i | |
|
151 | - visitor_list[key] = num | |
|
150 | + if key =~ /--(\w+)=(.*)/ | |
|
151 | + # options | |
|
152 | + lm = Regexp.last_match | |
|
153 | + visitor_option_list[lm[1]] = lm[2] | |
|
154 | + else | |
|
155 | + # new visitor | |
|
156 | + num = ARGV.shift.to_i | |
|
157 | + visitor_list[key] = num | |
|
158 | + end | |
|
152 | 159 | end |
|
153 | 160 | end |
|
154 | 161 | |
|
162 | + VISITOR_OPTION_LIST = visitor_option_list | |
|
163 | + require visitor_file | |
|
164 | + | |
|
155 | 165 | initialize_temp_dir |
|
156 | 166 | runner visitor_list, load_time, {:dry_run => dry_run} |
|
157 | 167 |
@@ -120,6 +120,12 | |||
|
120 | 120 | :options => options } |
|
121 | 121 | end |
|
122 | 122 | |
|
123 | + def self.process_options(options) | |
|
124 | + if options.has_key? "site_url" | |
|
125 | + self.base_url = options["site_url"] | |
|
126 | + end | |
|
127 | + end | |
|
128 | + | |
|
123 | 129 | def substitute_id(st) |
|
124 | 130 | return st if !(st.is_a? String) |
|
125 | 131 | st.gsub(/(()|(\$))\$\{id\}/) do |s| |
@@ -270,7 +276,7 | |||
|
270 | 276 | end |
|
271 | 277 | end |
|
272 | 278 | |
|
273 | - def visitor(cname,&blk) | |
|
279 | + def visitor(cname,options={},&blk) | |
|
274 | 280 | c = Class.new(Visitor) |
|
275 | 281 | begin |
|
276 | 282 | Object.const_set(cname,c) |
@@ -281,5 +287,6 | |||
|
281 | 287 | ERROR |
|
282 | 288 | exit(0) |
|
283 | 289 | end |
|
290 | + c.process_options(options) | |
|
284 | 291 | c.instance_eval(&blk) |
|
285 | 292 | end |
deleted file |
You need to be logged in to leave comments.
Login now