crusher 0.0.6 → 0.0.7
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.
- data/lib/crusher/crush_session.rb +8 -10
- data/lib/crusher/load_generator.rb +2 -6
- data/lib/crusher.rb +1 -0
- metadata +3 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
module Crusher
|
2
2
|
class CrushSession
|
3
3
|
|
4
|
-
attr_reader :target, :scenario, :
|
4
|
+
attr_reader :target, :scenario, :logger
|
5
5
|
|
6
6
|
def initialize(target, scenario, options = {})
|
7
7
|
@target = target
|
@@ -26,12 +26,8 @@ module Crusher
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def log(message)
|
29
|
-
log_message =
|
30
|
-
|
31
|
-
@log_file.syswrite(log_message)
|
32
|
-
else
|
33
|
-
puts log_message
|
34
|
-
end
|
29
|
+
log_message = @current_phase + ' ' + message
|
30
|
+
@logger.info log_message
|
35
31
|
nil
|
36
32
|
end
|
37
33
|
|
@@ -73,8 +69,11 @@ module Crusher
|
|
73
69
|
return nil if @queued_jobs.length == 0
|
74
70
|
|
75
71
|
fork do
|
76
|
-
|
77
|
-
@
|
72
|
+
log_output = @options[:log_file] ? @options.delete(:log_file) : STDOUT
|
73
|
+
@logger = Logger.new(log_output, File::APPEND)
|
74
|
+
formatter = Logger::Formatter.new
|
75
|
+
formatter.datetime_format = "%Y-%m-%d %H:%M:%S"
|
76
|
+
@logger.formatter = formatter
|
78
77
|
|
79
78
|
# Reseed the pseudorandom number generator with the process's PID file, otherwise
|
80
79
|
# we'll inherit our sequence of random numbers from the parent process
|
@@ -92,7 +91,6 @@ module Crusher
|
|
92
91
|
end
|
93
92
|
|
94
93
|
@queued_jobs = []
|
95
|
-
|
96
94
|
nil
|
97
95
|
end
|
98
96
|
|
@@ -7,12 +7,7 @@ module Crusher
|
|
7
7
|
@options = options
|
8
8
|
|
9
9
|
Dir.mkdir @options[:stats_log_dir] if @options[:stats_log_dir] && !File.exist?(@options[:stats_log_dir])
|
10
|
-
|
11
|
-
begin
|
12
|
-
@log_file = File.open(options[:log_file], 'a') if options[:log_file]
|
13
|
-
rescue Errno::ENOENT
|
14
|
-
log("Log file #{options[:log_file]} couldn't be opened; logging to STDOUT")
|
15
|
-
end
|
10
|
+
|
16
11
|
end
|
17
12
|
|
18
13
|
def act!; end
|
@@ -27,6 +22,7 @@ module Crusher
|
|
27
22
|
keys, values = data.map{|k,v| [k.to_s,v.to_s] }.transpose
|
28
23
|
stats_log_file(event_type) do |file|
|
29
24
|
file.syswrite "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')},#{values.join(',')}\n"
|
25
|
+
file.flush unless file.fsync
|
30
26
|
end
|
31
27
|
end
|
32
28
|
|
data/lib/crusher.rb
CHANGED
metadata
CHANGED