hansel 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.2.7
data/hansel.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hansel}
8
- s.version = "0.2.6"
8
+ s.version = "0.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Mylchreest"]
@@ -13,16 +13,12 @@ module HanselCore
13
13
  end
14
14
 
15
15
  def octave_formatter
16
- num_conns = results.first.num_conns rescue nil
16
+ res = results
17
+ opts, num_conns = options, (res.first.num_conns rescue nil)
17
18
  file_name = output_filename{ "-#{num_conns.to_s}" }
19
+ template = opts.template || File.join( [ File.dirname(__FILE__), '../../..', opts.template_path, 'octave.m.erb' ] )
18
20
  File.open(file_name, "w+") do |file|
19
- file.puts OctaveFormatter.new(results,
20
- {
21
- :output_file_name => file_name,
22
- :template => options.template ||
23
- File.join( [ File.dirname(__FILE__), '../../..', options.template_path, 'octave.m.erb' ] ),
24
- }
25
- ).format
21
+ file.puts OctaveFormatter.new(res, { :output_file_name => file_name, :template => template }).format
26
22
  end
27
23
  end
28
24
 
@@ -38,11 +34,10 @@ module HanselCore
38
34
  end
39
35
 
40
36
  def output_filename
41
- part = block_given? ? yield : ''
42
- type = { :yaml => 'yml', :csv => 'csv', :octave => 'm' }[options.format.to_sym]
43
- server = results.first.server
44
- port = results.first.port
45
- [File.join([options.output_dir, ("#{server}:#{port}" + part)]), type].join('.')
37
+ opts, part = options, (block_given? ? yield : '')
38
+ type = { :yaml => 'yml', :csv => 'csv', :octave => 'm' }[opts.format.to_sym]
39
+ server, port = (res = results.first) && res.server, res.port
40
+ [File.join([opts.output_dir, ("#{server}:#{port}" + part)]), type].join('.')
46
41
  end
47
42
  end
48
43
  end
data/lib/hansel/hansel.rb CHANGED
@@ -36,10 +36,12 @@ module HanselCore
36
36
  # Output the results based on the requested output format
37
37
  #
38
38
  def output
39
- if options.format
40
- FileUtils.mkdir_p options.output_dir
39
+ opts = options
40
+ if opts.format
41
+ FileUtils.mkdir_p opts.output_dir
41
42
  formatted_output
42
43
  end
44
+ @results.clear
43
45
  end
44
46
 
45
47
  def status text
@@ -50,18 +52,14 @@ module HanselCore
50
52
  # Run httperf from low_rate to high_rate, stepping by rate_step
51
53
  #
52
54
  def run
53
- status "starting run..."
54
55
  while @jobs.length > 0 do
55
56
  @current_job = @jobs.pop
56
57
  (@current_job.low_rate.to_i..@current_job.high_rate.to_i).step(@current_job.rate_step.to_i) do |rate|
57
- status "running httperf at rate: #{rate}"
58
58
  @current_rate = rate
59
59
  httperf
60
60
  end
61
61
  output
62
- @results.clear
63
62
  end
64
- status "ending run..."
65
63
  end
66
64
 
67
65
  def run_server
@@ -1,6 +1,7 @@
1
1
  module HanselCore
2
2
  module Httperf
3
3
  def build_httperf_cmd
4
+ cookie = @current_job.cookie
4
5
  httperf_cmd = [
5
6
  "httperf --hog",
6
7
  "--server=#{@current_job.server}",
@@ -8,7 +9,7 @@ module HanselCore
8
9
  "--uri=#{@current_job.uri}",
9
10
  "--num-conns=#{@current_job.num_conns}",
10
11
  "--rate=#{@current_rate}",
11
- @current_job.cookie && "--add-header='Cookie: #{@current_job.cookie}\\n'"
12
+ cookie && "--add-header='Cookie: #{cookie}\\n'"
12
13
  ].compact.join ' '
13
14
  end
14
15
 
@@ -29,7 +30,6 @@ module HanselCore
29
30
  }))
30
31
  HttperfResultParser.new(pipe).parse(httperf_result)
31
32
  end
32
- self
33
33
  end
34
34
 
35
35
  end
@@ -5,7 +5,6 @@ module HanselCore
5
5
  end
6
6
 
7
7
  def push_job job
8
- job.port = 80 unless job.port
9
8
  @jobs.push job
10
9
  end
11
10
 
@@ -13,11 +12,9 @@ module HanselCore
13
12
  @jobs.pop
14
13
  end
15
14
 
16
- #
17
- # Load jobs from queue
18
- #
19
15
  def load_job_queue
20
16
  (YAML.load_file File.join(config_path, 'jobs.yml')).map do |job|
17
+ job.merge!({:port => 80}) unless job[:port]
21
18
  self.push_job(OpenStruct.new job)
22
19
  end
23
20
  self
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 6
9
- version: 0.2.6
8
+ - 7
9
+ version: 0.2.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Mylchreest