stella 0.7.3.002 → 0.7.4.001

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.
@@ -8,26 +8,25 @@ module Stella::Engine
8
8
  opts = process_options! plan, opts
9
9
 
10
10
  Stella.ld "OPTIONS: #{opts.inspect}"
11
- Stella.li2 "Hosts: " << opts[:hosts].join(', ') if !opts[:hosts].empty?
11
+ Stella.stdout.info2 "Hosts: " << opts[:hosts].join(', ') if !opts[:hosts].empty?
12
12
 
13
13
  client = Stella::Client.new opts[:hosts].first
14
14
  client.add_observer(self)
15
15
 
16
16
  client.enable_nowait_mode if opts[:nowait]
17
17
 
18
- Stella.li2 $/, "Starting test...", $/
19
- Stella.lflush
18
+ Stella.stdout.info2 $/, "Starting test...", $/
20
19
  sleep 0.3
21
20
 
22
21
  # Identify this thread to Benelux
23
22
  Benelux.current_track :functional
24
23
 
25
- dig = Stella.loglev > 1 ? plan.digest_cache : plan.digest_cache.shorter
26
- Stella.li " %-65s ".att(:reverse) % ["#{plan.desc} (#{dig})"]
24
+ dig = Stella.stdout.lev > 1 ? plan.digest_cache : plan.digest_cache.shorter
25
+ Stella.stdout.info " %-65s ".att(:reverse) % ["#{plan.desc} (#{dig})"]
27
26
  plan.usecases.each_with_index do |uc,i|
28
27
  desc = (uc.desc || "Usecase ##{i+1}")
29
- dig = Stella.loglev > 1 ? uc.digest_cache : uc.digest_cache.shorter
30
- Stella.li ' %-65s '.att(:reverse).bright % ["#{desc} (#{dig}) "]
28
+ dig = Stella.stdout.lev > 1 ? uc.digest_cache : uc.digest_cache.shorter
29
+ Stella.stdout.info ' %-65s '.att(:reverse).bright % ["#{desc} (#{dig}) "]
31
30
  Stella.rescue { client.execute uc }
32
31
  end
33
32
 
@@ -38,49 +37,49 @@ module Stella::Engine
38
37
 
39
38
  def update_prepare_request(client_id, usecase, req, counter)
40
39
  notice = "repeat: #{counter-1}" if counter > 1
41
- dig = Stella.loglev > 1 ? req.digest_cache : req.digest_cache.shorter
40
+ dig = Stella.stdout.lev > 1 ? req.digest_cache : req.digest_cache.shorter
42
41
  desc = "#{req.desc} (#{dig}) "
43
- Stella.li2 " %-46s %16s ".bright % [desc, notice]
42
+ Stella.stdout.info2 " %-46s %16s ".bright % [desc, notice]
44
43
  end
45
44
 
46
- def update_receive_response(client_id, usecase, uri, req, params, counter, container)
45
+ def update_receive_response(client_id, usecase, uri, req, params, headers, counter, container)
47
46
  msg = ' %-6s %-53s ' % [req.http_method, uri]
48
- msg << container.status.to_s if Stella.loglev == 1
49
- Stella.li msg
47
+ msg << container.status.to_s if Stella.stdout.lev == 1
48
+ Stella.stdout.info msg
50
49
 
51
- Stella.li2 $/, " Params:"
50
+ Stella.stdout.info2 $/, " Params:"
52
51
  params.each do |pair|
53
- Stella.li2 " %s: %s" % pair
52
+ Stella.stdout.info2 " %s: %s" % pair
54
53
  end
55
54
 
56
- Stella.li2 $/, ' ' << container.response.request.header.send(:request_line)
55
+ Stella.stdout.info2 $/, ' ' << container.response.request.header.send(:request_line)
57
56
 
58
57
  container.response.request.header.all.each do |pair|
59
- Stella.li2 " %s: %s" % pair
58
+ Stella.stdout.info2 " %s: %s" % pair
60
59
  end
61
60
 
62
61
  if req.http_method == 'POST'
63
62
  cont = container.response.request.body.content
64
63
  if String === cont
65
- Stella.li2 (' ' << cont.split($/).join("#{$/} "))
64
+ Stella.stdout.info3 (' ' << cont.split($/).join("#{$/} "))
66
65
  elsif HTTP::Message::Body::Parts === cont
67
66
  cont.parts.each do |part|
68
67
  if File === part
69
- Stella.li2 "<#{part.path}>"
68
+ Stella.stdout.info3 "<#{part.path}>"
70
69
  else
71
- Stella.li2 part
70
+ Stella.stdout.info3 part
72
71
  end
73
72
  end
74
73
  end
75
74
  end
76
75
 
77
76
  resh = container.response.header
78
- Stella.li2 $/, ' HTTP/%s %3d %s' % [resh.http_version, resh.status_code, resh.reason_phrase]
77
+ Stella.stdout.info2 $/, ' HTTP/%s %3d %s' % [resh.http_version, resh.status_code, resh.reason_phrase]
79
78
  container.headers.all.each do |pair|
80
- Stella.li2 " %s: %s" % pair
79
+ Stella.stdout.info2 " %s: %s" % pair
81
80
  end
82
- Stella.li4 container.body.empty? ? ' [empty]' : container.body
83
- Stella.li2 $/
81
+ Stella.stdout.info3 container.body.empty? ? ' [empty]' : container.body
82
+ Stella.stdout.info2 $/
84
83
  end
85
84
 
86
85
  def update_execute_response_handler(client_id, req, container)
@@ -91,24 +90,32 @@ module Stella::Engine
91
90
  Stella.ld ex.backtrace
92
91
  end
93
92
 
94
- def update_request_error(client_id, usecase, uri, req, params, ex)
93
+ def update_request_unhandled_exception(client_id, usecase, uri, req, params, ex)
95
94
  desc = "#{usecase.desc} > #{req.desc}"
96
95
  Stella.le ' Client-%s %-45s %s' % [client_id.short, desc, ex.message]
97
96
  Stella.ld ex.backtrace
98
97
  end
99
98
 
100
- def update_quit_usecase client_id, msg
101
- Stella.li " QUIT %s" % [msg]
99
+ def update_usecase_quit client_id, msg, req, container
100
+ Stella.stdout.info " QUIT %s" % [msg]
102
101
  end
103
102
 
104
- def update_fail_request client_id, msg
105
- Stella.li " FAILED %s" % [msg]
103
+ def update_request_fail client_id, msg, req, container
104
+ Benelux.thread_timeline.add_count :failed, 1
105
+ Stella.stdout.info " FAILED %s" % [msg]
106
106
  end
107
107
 
108
- def update_repeat_request client_id, counter, total
109
- Stella.li3 " Client-%s REPEAT %d of %d" % [client_id.shorter, counter, total]
108
+ def update_request_error client_id, msg, req, container
109
+ Stella.stdout.info " ERROR %s" % [msg]
110
110
  end
111
111
 
112
+ def update_request_repeat client_id, counter, total, req, container
113
+ Stella.stdout.info3 " Client-%s REPEAT %d of %d" % [client_id.shorter, counter, total]
114
+ end
115
+
116
+ def update_authenticate client_id, usecase, req, kind, domain, user, pass
117
+ Stella.stdout.info " AUTH (#{kind}) #{domain} (#{user}/#{pass})"
118
+ end
112
119
  end
113
120
  end
114
121
 
@@ -5,6 +5,8 @@ module Stella::Engine
5
5
  extend Stella::Engine::Load
6
6
  extend self
7
7
 
8
+ CREATE_THREAD_SLEEP = 0.001
9
+ CHECK_THREAD_SLEEP = 0.0005
8
10
 
9
11
  def execute_test_plan(packages, reps=1, duration=0)
10
12
  @mode = :rolling
@@ -13,14 +15,14 @@ module Stella::Engine
13
15
 
14
16
  (1..reps).to_a.each { |rep|
15
17
  @real_reps += 1 # Increments when duration is specified.
16
- Stella.li3 "*** REPETITION #{@real_reps} of #{reps} ***"
18
+ Stella.stdout.info3 "*** REPETITION #{@real_reps} of #{reps} ***"
17
19
  packages.each { |package|
18
20
  if running_threads.size <= packages.size
19
21
  @threads << Thread.new do
20
22
  c, uc = package.client, package.usecase
21
23
  msg = "THREAD START: client %s: " % [c.digest.short]
22
24
  msg << "%s:%s (rep: %d)" % [uc.desc, uc.digest.short, @real_reps]
23
- Stella.li4 $/, "======== " << msg
25
+ Stella.stdout.info4 $/, "======== " << msg
24
26
  # This thread will stay on this one track.
25
27
  Benelux.current_track c.digest
26
28
  Benelux.add_thread_tags :usecase => uc.digest_cache
@@ -28,14 +30,14 @@ module Stella::Engine
28
30
  Benelux.add_thread_tags :rep => @real_reps
29
31
  Stella::Engine::Load.rescue(c.digest_cache) {
30
32
  break if Stella.abort?
31
- print '.' if Stella.loglev == 2
33
+ print '.' if Stella.stdout.lev == 2
32
34
  stats = c.execute uc
33
35
  }
34
36
  Benelux.remove_thread_tags :rep
35
37
  Benelux.remove_thread_tags :usecase
36
38
 
37
39
  end
38
- Stella.sleep :create_thread
40
+ Stella.sleep CREATE_THREAD_SLEEPx
39
41
  end
40
42
 
41
43
  if running_threads.size > @max_clients
@@ -45,9 +47,9 @@ module Stella::Engine
45
47
  if @mode == :rolling
46
48
  tries = 0
47
49
  while (reps > 1 || duration > 0) && running_threads.size >= packages.size
48
- Stella.sleep :check_threads
50
+ Stella.sleep CHECK_THREAD_SLEEP
49
51
  msg = "#{running_threads.size} (max: #{@max_clients})"
50
- Stella.li3 "*** RUNNING THREADS: #{msg} ***"
52
+ Stella.stdout.info3 "*** RUNNING THREADS: #{msg} ***"
51
53
  (tries += 1)
52
54
  end
53
55
  end
@@ -55,7 +57,7 @@ module Stella::Engine
55
57
 
56
58
  if @mode != :rolling && running_threads.size > 0
57
59
  args = [running_threads.size, @max_clients]
58
- Stella.li3 "*** WAITING FOR %d THREADS TO FINISH (max: %d) ***" % args
60
+ Stella.stdout.info3 "*** WAITING FOR %d THREADS TO FINISH (max: %d) ***" % args
59
61
  @threads.each { |t| t.join } # wait
60
62
  end
61
63
 
@@ -66,7 +68,7 @@ module Stella::Engine
66
68
  if duration > 0
67
69
  time_elapsed = (Time.now - time_started).to_i
68
70
  msg = "#{time_elapsed} of #{duration} (threads: %d)" % running_threads.size
69
- Stella.li3 "*** TIME ELAPSED: #{msg} ***"
71
+ Stella.stdout.info3 "*** TIME ELAPSED: #{msg} ***"
70
72
  redo if time_elapsed <= duration
71
73
  break if time_elapsed >= duration
72
74
  end
@@ -74,10 +76,10 @@ module Stella::Engine
74
76
  }
75
77
 
76
78
  if @mode == :rolling && running_threads.size > 0
77
- Stella.li3 "*** WAITING FOR THREADS TO FINISH ***"
79
+ Stella.stdout.info3 "*** WAITING FOR THREADS TO FINISH ***"
78
80
  @threads.each { |t| t.join } # wait
79
81
  end
80
- Stella.li2 $/, $/
82
+ Stella.stdout.info2 $/, $/
81
83
  end
82
84
 
83
85
  Benelux.add_timer Stella::Engine::LoadCreate, :execute_test_plan
@@ -5,7 +5,6 @@ module Stella::Engine
5
5
  extend Stella::Engine::Load
6
6
  extend self
7
7
 
8
-
9
8
  def execute_test_plan(packages, reps=1,duration=0)
10
9
  require 'threadify'
11
10
 
@@ -19,18 +18,18 @@ module Stella::Engine
19
18
  Benelux.add_thread_tags :rep => rep
20
19
  Stella::Engine::Load.rescue(package.client.digest_cache) {
21
20
  break if Stella.abort?
22
- print '.' if Stella.loglev == 2
21
+ print '.' if Stella.stdout.lev == 2
23
22
  stats = package.client.execute package.usecase
24
23
  }
25
24
  Benelux.remove_thread_tags :rep
26
- Stella.sleep :check_threads
25
+ Stella.sleep CHECK_THREAD_SLEEP
27
26
  end
28
27
 
29
28
  Benelux.remove_thread_tags :usecase
30
29
 
31
30
  end
32
31
 
33
- Stella.li2 $/, $/
32
+ Stella.stdout.info2 $/, $/
34
33
  end
35
34
 
36
35
  Benelux.add_timer Stella::Engine::LoadPackage, :execute_test_plan
@@ -20,7 +20,7 @@ module Stella::Engine
20
20
  Thread.current[:real_reps] = 0
21
21
  Thread.current[:real_uctime] = Benelux::Stats::Calculator.new
22
22
  c, uc = package.client, package.usecase
23
- Stella.li4 $/, "======== THREAD %s: START" % [c.digest.short]
23
+ Stella.stdout.info4 $/, "======== THREAD %s: START" % [c.digest.short]
24
24
 
25
25
  # This thread will stay on this one track.
26
26
  Benelux.current_track c.digest
@@ -32,13 +32,13 @@ module Stella::Engine
32
32
  break if Stella.abort?
33
33
  Thread.current[:real_reps] += 1
34
34
  args = [c.digest.short, uc.desc, uc.digest.short, Thread.current[:real_reps]]
35
- Stella.li4 $/, "======== THREAD %s: %s:%s (rep: %d)" % args
35
+ Stella.stdout.info4 $/, "======== THREAD %s: %s:%s (rep: %d)" % args
36
36
 
37
37
  Benelux.add_thread_tags :rep => rep
38
- #Stella.li [package.client.gibbler.shorter, package.usecase.gibbler.shorter, rep].inspect
38
+ #Stella.stdout.info [package.client.gibbler.shorter, package.usecase.gibbler.shorter, rep].inspect
39
39
  Stella::Engine::Load.rescue(c.digest_cache) {
40
40
  break if Stella.abort?
41
- print '.' if Stella.loglev == 1
41
+ Stella.stdout.print! 2, '.'
42
42
  stats = c.execute uc
43
43
  }
44
44
  Benelux.remove_thread_tags :rep
@@ -48,10 +48,9 @@ module Stella::Engine
48
48
 
49
49
  if (Time.now - prev_ptime).to_i >= ROTATE_TIMELINE
50
50
  prev_ptime, ruct = Time.now, Thread.current[:real_uctime]
51
- if Stella.loglev >= 2 && Thread.current == @threads.first
51
+ if Stella.stdout.lev >= 2 && Thread.current == @threads.first
52
52
  args = [time_elapsed.to_i, ruct.n, ruct.mean, ruct.sd]
53
- Stella.li2 $/, "REAL UC TIME: %ds (reps: %d): %.4fs %.4f(SD)" % args
54
- Stella.lflush
53
+ Stella.stdout.info2 $/, "REAL UC TIME: %ds (reps: %d): %.4fs %.4f(SD)" % args
55
54
  end
56
55
 
57
56
  Thread.current.rotate_timeline
@@ -73,37 +72,19 @@ module Stella::Engine
73
72
  unless arrival.nil?
74
73
  # Create 1 second / users per second
75
74
  args = [1/arrival, @threads.size, packages.size]
76
- Stella.li2 $/, "======== ARRIVAL (%s): %s of %s" % args
75
+ Stella.stdout.info2 $/, "======== ARRIVAL (%s): %s of %s" % args
77
76
  sleep 1/arrival
78
77
  end
79
78
  }
80
79
 
81
- data_dumper = Thread.new do
82
- prev_ptime = Time.now
83
- loop do
84
- break if Stella.abort?
85
- break if @threads.select { |t| (!t.nil? && t.status) }.empty?
86
- if (Time.now - prev_ptime).to_i >= (ROTATE_TIMELINE * 4)
87
- Benelux.update_global_timeline
88
- Stella.li $/, [:logger, (Time.now - prev_ptime).to_i, Benelux.timeline.size].inspect
89
- prev_ptime = Time.now
90
- ##TODO: Dump to file
91
- ##Benelux.timeline.clear
92
- end
93
- sleep 5
94
- end
95
-
96
- end
97
- data_dumper.join
98
-
99
80
  repscalc = Benelux::Stats::Calculator.new
100
81
  @threads.each { |t| t.join } # wait
101
82
  @threads.each { |t| repscalc.sample(t[:real_reps]) }
102
83
  @real_reps = repscalc.mean.to_i
103
84
 
104
- #Stella.li "*** REPETITION #{@real_reps} of #{reps} ***"
85
+ #Stella.stdout.info "*** REPETITION #{@real_reps} of #{reps} ***"
105
86
 
106
- Stella.li2 $/, $/
87
+ Stella.stdout.info2 $/, $/
107
88
  end
108
89
 
109
90
  Benelux.add_timer Stella::Engine::LoadQueue, :execute_test_plan
@@ -6,16 +6,51 @@ module Stella::Engine
6
6
 
7
7
  @timers = [:do_request]
8
8
  @counts = [:response_content_size]
9
+ @reqlog = nil
9
10
 
10
11
  class << self
11
12
  attr_accessor :timers, :counts
12
13
  end
13
14
 
14
15
  def run(plan, opts={})
16
+
15
17
  opts = process_options! plan, opts
16
18
  @threads, @max_clients, @real_reps = [], 0, 0
17
19
 
18
- if Stella.loglev > 2
20
+ d = log_dir(plan)
21
+ latest = File.join(File.dirname(d), 'latest')
22
+ Stella.stdout.info "Logging to #{d}", $/
23
+
24
+ if Stella.sysinfo.os == :unix
25
+ File.unlink latest if File.exists? latest
26
+ FileUtils.ln_sf File.basename(d), latest
27
+ end
28
+
29
+ @reqlog = Stella::Logger.new log_path(plan, 'requests')
30
+ @failog = Stella::Logger.new log_path(plan, 'requests-exceptions')
31
+ @sumlog = Stella::Logger.new log_path(plan, 'summary')
32
+ @optlog = Stella::Logger.new log_path(plan, 'options')
33
+ @authlog = Stella::Logger.new log_path(plan, 'requests-auth')
34
+
35
+ @syslog = Stella::Logger.new log_path(plan, 'sysinfo')
36
+ @syslog.info(Stella.sysinfo.dump(:yaml)) and @syslog.close
37
+
38
+ @plalog = Stella::Logger.new log_path(plan, 'plan')
39
+ @plalog.info(plan.pretty.noansi) and @plalog.close
40
+
41
+
42
+ Stella.stdout.add_template :head1, '%s (%s)'
43
+ Stella.stdout.add_template :head2, ' %s: %s'
44
+ Stella.stdout.add_template :status, "#{$/}%s..."
45
+
46
+ @sumlog.add_template :dsummary, '%20s: %8d'
47
+ @sumlog.add_template :fsummary, '%20s: %8.2f'
48
+ @optlog.add_template :head, '%10s: %s'
49
+ @failog.add_template :request, '%s %s'
50
+
51
+ @dumper = prepare_dumper(plan, opts)
52
+
53
+ if Stella.stdout.lev > 2
19
54
  Load.timers += [:query, :connect, :socket_gets_first_byte, :get_body]
20
55
  Load.counts = [:request_header_size, :request_content_size]
21
56
  Load.counts += [:response_headers_size, :response_content_size]
@@ -23,54 +58,76 @@ module Stella::Engine
23
58
 
24
59
  counts = calculate_usecase_clients plan, opts
25
60
 
26
- Stella.li $/, "Preparing #{counts[:total]} virtual clients...", $/
27
- Stella.lflush
61
+ @optlog.head 'RUNID', runid(plan)
62
+ @optlog.head 'OPTIONS', opts.inspect
63
+
28
64
  packages = build_thread_package plan, opts, counts
29
65
 
30
66
  if opts[:duration] > 0
31
- msg = "for #{opts[:duration].seconds}s"
67
+ timing = "#{opts[:duration].seconds.to_i} seconds"
32
68
  else
33
- msg = "for #{opts[:repetitions]} reps"
69
+ timing = "#{opts[:repetitions]} repetitions"
34
70
  end
35
71
 
36
- Stella.li "Generating requests #{msg}...", $/
37
- Stella.lflush
72
+ Stella.stdout.head1 plan.desc, plan.digest.short
73
+ Stella.stdout.head2 'Clients', counts[:total]
74
+ Stella.stdout.head2 'Limit', timing
38
75
 
39
- bt = Benelux.timeline
76
+ @dumper.start
40
77
 
41
- begin
78
+ begin
79
+ @optlog.head "START", Time.now.to_s
80
+ Stella.stdout.status "Running"
42
81
  execute_test_plan packages, opts[:repetitions], opts[:duration], opts[:arrival]
82
+ Stella.stdout.info "Done"
43
83
  rescue Interrupt
44
- Stella.li "Stopping test...", $/
84
+ Stella.stdout.nstatus "Stopping test"
45
85
  Stella.abort!
46
86
  @threads.each { |t| t.join } unless @threads.nil? || @threads.empty? # wait
47
- ensure
48
- Stella.li "Processing statistics...", $/
49
- Stella.lflush
50
-
51
- Benelux.update_global_timeline
52
-
53
- tt = Benelux.thread_timeline
54
-
55
- test_time = tt.stats.group(:execute_test_plan).mean
56
- generate_report plan, test_time
57
- report_time = tt.stats.group(:generate_report).mean
58
-
59
- # Here is the calcualtion for the number of
60
- # Benelux assets created for each request:
61
- #
62
- # [5*2*REQ+6, 5*1*REQ+3, 13*REQ]
63
- #
64
-
65
- Stella.li "Summary: "
66
- Stella.li " max clients: %d" % @max_clients
67
- Stella.li " repetitions: %d" % @real_reps
68
- Stella.li " test time: %10.2fs" % test_time
69
- Stella.li " post time: %10.2fs" % report_time
70
- Stella.li $/
87
+ rescue => ex
88
+ STDERR.puts "Unhandled exception: #{ex.message}"
89
+ STDERR.puts ex.backtrace if Stella.debug? || Stella.stdout.lev >= 3
71
90
  end
72
91
 
73
- bt.stats.group(:failed).merge.n == 0
92
+ @optlog.head "END", Time.now.to_s
93
+ @optlog.flush
94
+
95
+ @dumper.stop
96
+
97
+ Stella.stdout.status "Processing"
98
+
99
+ Benelux.update_global_timeline
100
+
101
+ bt = Benelux.timeline
102
+ tt = Benelux.thread_timeline
103
+
104
+ test_time = tt.stats.group(:execute_test_plan).mean
105
+ generate_report @sumlog, plan, test_time
106
+ report_time = tt.stats.group(:generate_report).mean
107
+
108
+ # Here is the calcualtion for the number of
109
+ # Benelux assets created for each request:
110
+ #
111
+ # [5*2*REQ+6, 5*1*REQ+3, 13*REQ]
112
+ #
113
+
114
+ failed = bt.stats.group(:failed).merge
115
+ total = bt.stats.group(:do_request).merge
116
+
117
+ @sumlog.info $/, "Summary: "
118
+ @sumlog.dsummary 'successful req', total.n
119
+ @sumlog.dsummary "failed req", failed.n
120
+ @sumlog.dsummary "max clients", @max_clients
121
+ @sumlog.dsummary "repetitions", @real_reps
122
+ @sumlog.fsummary "test time", test_time
123
+ @sumlog.fsummary "reporting time", report_time
124
+ @sumlog.flush
125
+
126
+ Stella.stdout.info File.read(@sumlog.path)
127
+ # DNE:
128
+ #p [@real_reps, total.n]
129
+
130
+ failed.n == 0
74
131
  end
75
132
 
76
133
  protected
@@ -83,6 +140,21 @@ module Stella::Engine
83
140
  end
84
141
  end
85
142
 
143
+ def prepare_dumper(plan, opts)
144
+ Stella::Hand.new(15.seconds, 2.seconds) do
145
+ Benelux.update_global_timeline
146
+ #reqlog.info [Time.now, Benelux.timeline.size].inspect
147
+ @reqlog.info Benelux.timeline.messages.filter(:kind => :request)
148
+ @failog.info Benelux.timeline.messages.filter(:kind => :exception)
149
+ @failog.info Benelux.timeline.messages.filter(:kind => :timeout)
150
+ @authlog.info Benelux.timeline.messages.filter(:kind => :authentication)
151
+ @reqlog.clear and @failog.clear and @authlog.clear
152
+ #generate_runtime_report(plan)
153
+ Benelux.timeline.clear if opts[:"disable-stats"]
154
+ end
155
+
156
+ end
157
+
86
158
  def calculate_usecase_clients(plan, opts)
87
159
  counts = { :total => 0 }
88
160
  plan.usecases.each_with_index do |usecase,i|
@@ -115,7 +187,7 @@ module Stella::Engine
115
187
  client = Stella::Client.new opts[:hosts].first, index+1, copts
116
188
  client.add_observer(self)
117
189
  client.enable_nowait_mode if opts[:nowait]
118
- Stella.li4 "Created client #{client.digest.short}"
190
+ Stella.stdout.info4 "Created client #{client.digest.short}"
119
191
  ThreadPackage.new(index+1, client, usecase)
120
192
  end
121
193
  pointer += count
@@ -130,7 +202,27 @@ module Stella::Engine
130
202
  def running_threads
131
203
  @threads.select { |t| t.status } # non-false status are still running
132
204
  end
133
- def generate_report(plan,test_time)
205
+
206
+ def generate_runtime_report(plan)
207
+ gt = Benelux.timeline
208
+ gstats = gt.stats.group(:do_request).merge
209
+
210
+ plan.usecases.uniq.each_with_index do |uc,i|
211
+ uc.requests.each do |req|
212
+ filter = [uc.digest_cache, req.digest_cache]
213
+
214
+ Load.timers.each do |sname|
215
+ stats = gt.stats.group(sname)[filter].merge
216
+ #Stella.stdout.info stats.inspect
217
+ puts [sname, stats.min, stats.mean, stats.max, stats.sd, stats.n].join('; ')
218
+ end
219
+
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ def generate_report(sumlog,plan,test_time)
134
226
  #Benelux.update_all_track_timelines
135
227
  global_timeline = Benelux.timeline
136
228
  global_stats = global_timeline.stats.group(:do_request).merge
@@ -139,7 +231,7 @@ module Stella::Engine
139
231
  return
140
232
  end
141
233
 
142
- Stella.li $/, " %-72s ".att(:reverse) % ["#{plan.desc} (#{plan.digest_cache.shorter})"]
234
+ @sumlog.info " %-72s ".att(:reverse) % ["#{plan.desc} (#{plan.digest_cache.shorter})"]
143
235
  plan.usecases.uniq.each_with_index do |uc,i|
144
236
 
145
237
  # TODO: Create Ranges object, like Stats object
@@ -150,24 +242,24 @@ module Stella::Engine
150
242
  desc = uc.desc || "Usecase ##{i+1} "
151
243
  desc << " (#{uc.digest_cache.shorter}) "
152
244
  str = ' ' << " %-66s %s %d%% ".bright.att(:reverse)
153
- Stella.li str % [desc, '', uc.ratio_pretty]
245
+ @sumlog.info str % [desc, '', uc.ratio_pretty]
154
246
 
155
247
  uc.requests.each do |req|
156
248
  filter = [uc.digest_cache, req.digest_cache]
157
249
  desc = req.desc
158
- Stella.li " %-72s ".bright % ["#{req.desc} (#{req.digest_cache.shorter})"]
159
- Stella.li " %s" % [req.to_s]
250
+ @sumlog.info " %-72s ".bright % ["#{req.desc} (#{req.digest_cache.shorter})"]
251
+ @sumlog.info " %s" % [req.to_s]
160
252
  Load.timers.each do |sname|
161
253
  stats = global_timeline.stats.group(sname)[filter].merge
162
- # Stella.li stats.inspect
254
+ # Stella.stdout.info stats.inspect
163
255
  str = ' %-30s %.3f <= ' << '%.3fs' << ' >= %.3f; %.3f(SD) %d(N)'
164
- Stella.li str % [sname, stats.min, stats.mean, stats.max, stats.sd, stats.n]
165
- Stella.lflush
256
+ @sumlog.info str % [sname, stats.min, stats.mean, stats.max, stats.sd, stats.n]
257
+ @sumlog.flush
166
258
  end
167
- Stella.li $/
259
+ @sumlog.info $/
168
260
  end
169
261
 
170
- Stella.li " Sub Total:".bright
262
+ @sumlog.info " Sub Total:".bright
171
263
 
172
264
  stats = global_timeline.stats.group(:do_request)[uc.digest_cache].merge
173
265
  failed = global_timeline.stats.group(:failed)[uc.digest_cache].merge
@@ -178,25 +270,25 @@ module Stella::Engine
178
270
  size = respgrp[:status => status].size
179
271
  statusi << "#{status}: #{size}"
180
272
  end
181
- Stella.li ' %-30s %d (%s)' % ['Total requests', stats.n, statusi.join(', ')]
182
- Stella.li ' %-29s %d' % [:success, stats.n - failed.n]
183
- Stella.li ' %-29s %d' % [:failed, failed.n]
273
+ @sumlog.info ' %-30s %d (%s)' % ['Total requests', stats.n, statusi.join(', ')]
274
+ @sumlog.info ' %-29s %d' % [:success, stats.n - failed.n]
275
+ @sumlog.info ' %-29s %d' % [:failed, failed.n]
184
276
 
185
277
  Load.timers.each do |sname|
186
278
  stats = global_timeline.stats.group(sname)[uc.digest_cache].merge
187
- Stella.li ' %-30s %.3fs %.3f(SD)' % [sname, stats.mean, stats.sd]
188
- Stella.lflush
279
+ @sumlog.info ' %-30s %.3fs %.3f(SD)' % [sname, stats.mean, stats.sd]
280
+ @sumlog.flush
189
281
  end
190
282
 
191
283
  Load.counts.each do |sname|
192
284
  stats = global_timeline.stats.group(sname)[uc.digest_cache].merge
193
- Stella.li ' %-30s %-12s (avg:%s)' % [sname, stats.sum.to_bytes, stats.mean.to_bytes]
194
- Stella.lflush
285
+ @sumlog.info ' %-30s %-12s (avg:%s)' % [sname, stats.sum.to_bytes, stats.mean.to_bytes]
286
+ @sumlog.flush
195
287
  end
196
- Stella.li $/
288
+ @sumlog.info $/
197
289
  end
198
290
 
199
- Stella.li ' ' << " %-66s ".att(:reverse) % 'Total:'
291
+ @sumlog.info ' ' << " %-66s ".att(:reverse) % 'Total:'
200
292
 
201
293
  failed = global_timeline.stats.group(:failed)
202
294
  respgrp = global_timeline.stats.group(:execute_response_handler)
@@ -206,38 +298,51 @@ module Stella::Engine
206
298
  size = respgrp[:status => status].size
207
299
  statusi << [status, size]
208
300
  end
209
- Stella.li ' %-30s %d' % ['Total requests', global_stats.n]
301
+ @sumlog.info ' %-30s %d' % ['Total requests', global_stats.n]
210
302
  success = global_stats.n - failed.n
211
- Stella.li ' %-29s %d (req/s: %.2f)' % [:success, success, success/test_time]
303
+ @sumlog.info ' %-29s %d (req/s: %.2f)' % [:success, success, success/test_time]
212
304
  statusi.each do |pair|
213
- Stella.li3 ' %-28s %s: %d' % ['', *pair]
305
+ @sumlog.info3 ' %-28s %s: %d' % ['', *pair]
214
306
  end
215
- Stella.li ' %-29s %d' % [:failed, failed.n]
307
+ @sumlog.info ' %-29s %d' % [:failed, failed.n]
216
308
 
217
309
  Load.timers.each do |sname|
218
310
  stats = global_timeline.stats.group(sname).merge
219
- Stella.li ' %-30s %-.3fs %-.3f(SD)' % [sname, stats.mean, stats.sd]
220
- Stella.lflush
311
+ @sumlog.info ' %-30s %-.3fs %-.3f(SD)' % [sname, stats.mean, stats.sd]
312
+ @sumlog.flush
221
313
  end
222
314
 
223
315
  Load.counts.each do |sname|
224
316
  stats = global_timeline.stats.group(sname).merge
225
- Stella.li ' %-30s %-12s (avg:%s)' % [sname, stats.sum.to_bytes, stats.mean.to_bytes]
226
- Stella.lflush
317
+ @sumlog.info ' %-30s %-12s (avg:%s)' % [sname, stats.sum.to_bytes, stats.mean.to_bytes]
318
+ @sumlog.flush
227
319
  end
228
- Stella.li $/
229
320
  end
230
321
 
231
322
 
232
323
  def update_prepare_request(client_id, usecase, req, counter)
233
-
324
+
234
325
  end
235
326
 
236
- def update_receive_response(client_id, usecase, uri, req, params, counter, container)
237
- desc = "#{usecase.desc} > #{req.desc}"
327
+ def update_receive_response(client_id, usecase, uri, req, params, headers, counter, container)
328
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
329
+ args.push usecase.digest.shorter, req.digest.shorter
330
+ args.push req.http_method, container.status, uri
331
+ args << params.to_a.collect { |el|
332
+ next if el[0].to_s == '__stella'
333
+ '%s=%s' % [el[0], el[1].to_s]
334
+ }.compact.join('&') # remove skipped params
335
+ args << headers.to_a.collect { |el|
336
+ next if el[0].to_s == 'X-Stella-ID'
337
+ '%s=%s' % el
338
+ }.compact.join('&') # remove skipped params
339
+ args << container.unique_id[0,10]
340
+ Benelux.thread_timeline.add_message args.join('; '),
341
+ :status => container.status,
342
+ :kind => :request
238
343
  args = [client_id.shorter, container.status, req.http_method, uri, params.inspect]
239
- Stella.li2 ' Client-%s %3d %-6s %s %s' % args
240
- Stella.ld ' Client-%s %3d %s' % [client_id.shorter, container.status, container.body]
344
+ Stella.stdout.info3 ' Client-%s %3d %-6s %s %s' % args
345
+
241
346
  end
242
347
 
243
348
  def update_execute_response_handler(client_id, req, container)
@@ -245,34 +350,65 @@ module Stella::Engine
245
350
 
246
351
  def update_error_execute_response_handler(client_id, ex, req, container)
247
352
  desc = "#{container.usecase.desc} > #{req.desc}"
248
- Stella.li $/ if Stella.loglev == 1
353
+ Stella.stdout.info $/ if Stella.stdout.lev == 1
249
354
  Stella.le ' Client-%s %-45s %s' % [client_id.shorter, desc, ex.message]
250
- Stella.li ex.backtrace
355
+ Stella.stdout.info ex.backtrace
251
356
  end
252
357
 
253
- def update_request_error(client_id, usecase, uri, req, params, ex)
358
+ def update_request_unhandled_exception(client_id, usecase, uri, req, params, ex)
254
359
  desc = "#{usecase.desc} > #{req.desc}"
255
- Stella.li $/ if Stella.loglev == 1
256
- Stella.le ' Client-%s %-45s %s' % [client_id.shorter, desc, ex.message]
257
- Stella.li ex.backtrace
360
+ Stella.stdout.info $/ if Stella.stdout.lev == 1
361
+ Stella.stdout.info ' Client-%s %-45s %s' % [client_id.shorter, desc, ex.message]
362
+ Stella.stdout.info ex.backtrace
258
363
  end
259
364
 
260
- def update_quit_usecase client_id, msg
261
- Stella.li2 " Client-%s QUIT %s" % [client_id.shorter, msg]
365
+ def update_usecase_quit client_id, msg, req, container
366
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
367
+ Benelux.thread_timeline.add_count :quit, 1
368
+ args.push [req, container.status, 'QUIT', msg, container.unique_id[0,10]]
369
+ Benelux.thread_timeline.add_message args.join('; '), :kind => :exception
370
+ Stella.stdout.info3 " Client-%s QUIT %s" % [client_id.shorter, msg]
371
+ end
372
+
373
+ def update_request_fail client_id, msg, req, container
374
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
375
+ Benelux.thread_timeline.add_count :failed, 1
376
+ args.push [req, container.status, 'FAIL', msg, container.unique_id[0,10]]
377
+ Benelux.thread_timeline.add_message args.join('; '), :kind => :exception
378
+ Stella.stdout.info3 " Client-%s FAILED %s" % [client_id.shorter, msg]
379
+ end
380
+
381
+ def update_request_error client_id, msg, req, container
382
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
383
+ Benelux.thread_timeline.add_count :error, 1
384
+ args.push [req, container.status, 'ERROR', msg, container.unique_id[0,10]]
385
+ Benelux.thread_timeline.add_message args.join('; '), :kind => :exception
386
+ Stella.stdout.info3 ' Client-%s %-45s %s' % [client_id.shorter, desc, ex.message]
387
+ end
388
+
389
+ def update_request_repeat client_id, counter, total, req, container
390
+ Stella.stdout.info3 " Client-%s REPEAT %d of %d" % [client_id.shorter, counter, total]
262
391
  end
263
392
 
264
- def update_fail_request client_id, msg
265
- Stella.li2 " Client-%s FAILED %s" % [client_id.shorter, msg]
393
+ def update_authenticate client_id, usecase, req, kind, domain, user, pass
394
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
395
+ args.push usecase.digest.shorter, req.digest.shorter
396
+ args.push 'AUTH', kind, domain, user, pass
397
+ Benelux.thread_timeline.add_message args.join('; '), :kind => :authentication
266
398
  end
267
399
 
268
- def update_repeat_request client_id, counter, total
269
- Stella.li2 " Client-%s REPEAT %d of %d" % [client_id.shorter, counter, total]
400
+ def update_request_timeout(client_id, usecase, uri, req, params, headers, counter, container)
401
+ args = [Time.now.to_f, Stella.sysinfo.hostname, client_id.short]
402
+ Benelux.thread_timeline.add_count :failed, 1
403
+ args.push [uri, 'TOUT', container.unique_id[0,10]]
404
+ Benelux.thread_timeline.add_message args.join('; '), :kind => :timeout
270
405
  end
271
406
 
272
407
  def self.rescue(client_id, &blk)
273
408
  blk.call
274
409
  rescue => ex
275
- Stella.le ' Error in Client-%s: %s' % [client_id.shorter, ex.message]
410
+ Stella.stdout.info ' Error in Client-%s: %s' % [client_id.shorter, ex.message]
411
+ puts ex.backtrace
276
412
  end
277
413
 
278
414
  Benelux.add_timer Stella::Engine::Load, :build_thread_package