Description:
added first page load test on localhost
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r314:933be61bc431 - - 4 files changed: 28 inserted, 4 deleted
@@ -0,0 +1,7 | |||||
|
|
1 | + How to call | ||
|
|
2 | + =========== | ||
|
|
3 | + | ||
|
|
4 | + Load test for front page: | ||
|
|
5 | + | ||
|
|
6 | + ruby runner.rb common_visitors.rb FirstPageViewer 10 -t 10 | ||
|
|
7 | + |
@@ -0,0 +1,7 | |||||
|
|
1 | + visitor "FirstPageViewer" do | ||
|
|
2 | + stores_cookies | ||
|
|
3 | + | ||
|
|
4 | + site_url "http://localhost:3000" | ||
|
|
5 | + | ||
|
|
6 | + get "/" | ||
|
|
7 | + end |
@@ -17,33 +17,41 | |||||
|
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 | # 02110-1301, USA. |
|
18 | # 02110-1301, USA. |
|
19 | # |
|
19 | # |
|
20 |
|
20 | ||
|
21 | require 'visitor_curl_cli' |
|
21 | require 'visitor_curl_cli' |
|
22 |
|
22 | ||
|
|
23 | + TEMP_DIR = './tmp' | ||
|
|
24 | + | ||
|
23 | def show_usage |
|
25 | def show_usage |
|
24 | puts <<USAGE |
|
26 | puts <<USAGE |
|
25 | using: ruby runner.rb <visitor_file> [<type> <number>] [<type> <number>] ... [options] |
|
27 | using: ruby runner.rb <visitor_file> [<type> <number>] [<type> <number>] ... [options] |
|
26 | * visitor_file : your visitor definition file, (with or without .rb) |
|
28 | * visitor_file : your visitor definition file, (with or without .rb) |
|
27 | * type, number : the type and the number of visitors of that type |
|
29 | * type, number : the type and the number of visitors of that type |
|
28 | * options : any of the following |
|
30 | * options : any of the following |
|
29 | -t <sec> specify how long (in seconds) |
|
31 | -t <sec> specify how long (in seconds) |
|
30 | -d dry-run: run, but make no real http requests |
|
32 | -d dry-run: run, but make no real http requests |
|
31 | USAGE |
|
33 | USAGE |
|
32 | end |
|
34 | end |
|
33 |
|
35 | ||
|
|
36 | + def initialize_temp_dir | ||
|
|
37 | + if !FileTest.exists? TEMP_DIR | ||
|
|
38 | + Dir.mkdir TEMP_DIR | ||
|
|
39 | + end | ||
|
|
40 | + end | ||
|
|
41 | + | ||
|
34 | def runner(visitor_lists, load_time=60, options={}) |
|
42 | def runner(visitor_lists, load_time=60, options={}) |
|
35 | visitors = [] |
|
43 | visitors = [] |
|
36 | vcount = 0 |
|
44 | vcount = 0 |
|
37 |
|
45 | ||
|
38 | visitor_lists.each do |cname, num| |
|
46 | visitor_lists.each do |cname, num| |
|
39 | begin |
|
47 | begin |
|
40 | c = Kernel.const_get(cname) |
|
48 | c = Kernel.const_get(cname) |
|
41 |
|
49 | ||
|
42 | num.times do |
|
50 | num.times do |
|
43 | - visitors[vcount] = c.new(vcount+1) |
|
51 | + visitors[vcount] = c.new(vcount+1, TEMP_DIR) |
|
44 | visitors[vcount].talkative = true |
|
52 | visitors[vcount].talkative = true |
|
45 | vcount += 1 |
|
53 | vcount += 1 |
|
46 | end |
|
54 | end |
|
47 | rescue NameError |
|
55 | rescue NameError |
|
48 | puts "Can't find class #{cname}" |
|
56 | puts "Can't find class #{cname}" |
|
49 | show_usage |
|
57 | show_usage |
@@ -141,8 +149,9 | |||||
|
141 | else |
|
149 | else |
|
142 | num = ARGV.shift.to_i |
|
150 | num = ARGV.shift.to_i |
|
143 | visitor_list[key] = num |
|
151 | visitor_list[key] = num |
|
144 | end |
|
152 | end |
|
145 | end |
|
153 | end |
|
146 |
|
154 | ||
|
|
155 | + initialize_temp_dir | ||
|
147 | runner visitor_list, load_time, {:dry_run => dry_run} |
|
156 | runner visitor_list, load_time, {:dry_run => dry_run} |
|
148 |
|
157 |
@@ -29,29 +29,30 | |||||
|
29 | attr_accessor :commands |
|
29 | attr_accessor :commands |
|
30 | attr_accessor :base_url |
|
30 | attr_accessor :base_url |
|
31 | attr_accessor :cookies_stored |
|
31 | attr_accessor :cookies_stored |
|
32 | end |
|
32 | end |
|
33 |
|
33 | ||
|
34 | def get_cookie_fname |
|
34 | def get_cookie_fname |
|
35 | - "cookies.#{@id}" |
|
35 | + "#{@base_dir}/cookies.#{@id}" |
|
36 | end |
|
36 | end |
|
37 |
|
37 | ||
|
38 | def get_output_fname |
|
38 | def get_output_fname |
|
39 | - "output.#{@id}" |
|
39 | + "#{@base_dir}/output.#{@id}" |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | def id |
|
42 | def id |
|
43 | @id |
|
43 | @id |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
46 | - def initialize(id=0) |
|
46 | + def initialize(id=0, base_dir='.') |
|
47 | # initialize nil class variable |
|
47 | # initialize nil class variable |
|
48 | self.class.base_url = "" if (self.class.base_url) == nil |
|
48 | self.class.base_url = "" if (self.class.base_url) == nil |
|
49 | self.class.cookies_stored = false if self.class.cookies_stored == nil |
|
49 | self.class.cookies_stored = false if self.class.cookies_stored == nil |
|
50 |
|
50 | ||
|
51 | @id = id |
|
51 | @id = id |
|
|
52 | + @base_dir = base_dir | ||
|
52 | @cookies_fname = get_cookie_fname |
|
53 | @cookies_fname = get_cookie_fname |
|
53 | @output_fname = get_output_fname |
|
54 | @output_fname = get_output_fname |
|
54 | @statistics = Array.new |
|
55 | @statistics = Array.new |
|
55 | @talkative = false |
|
56 | @talkative = false |
|
56 |
|
57 | ||
|
57 | @stopped = false |
|
58 | @stopped = false |
You need to be logged in to leave comments.
Login now