Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Deprecated :dump and added scout and munin integration specs

  • Loading branch information...
commit 4a2332e898cde149097ab469f91d21a6f3c644de 1 parent c199d96
Bart ten Brinke barttenbrinke authored
2  lib/request_log_analyzer/aggregator/summarizer.rb
@@ -90,7 +90,7 @@ def aggregate(request)
90 90 # Call finalize on all trackers. Saves a YAML dump if this is set in the options.
91 91 def finalize
92 92 @trackers.each { |tracker| tracker.finalize }
93   - save_results_dump(options[:dump]) if options[:dump]
  93 + save_results_dump(options[:yaml]) if options[:yaml]
94 94 end
95 95
96 96 # Saves the results of all the trackers in YAML format to a file.
21 lib/request_log_analyzer/controller.rb
@@ -30,7 +30,7 @@ def self.build_from_arguments(arguments)
30 30 options[:database] = arguments[:database]
31 31 options[:reset_database] = arguments[:reset_database]
32 32 options[:debug] = arguments[:debug]
33   - options[:dump] = arguments[:dump]
  33 + options[:yaml] = arguments[:dump]
34 34 options[:parse_strategy] = arguments[:parse_strategy]
35 35 options[:no_progress] = arguments[:no_progress]
36 36 options[:format] = arguments[:format]
@@ -80,9 +80,9 @@ def self.build_from_arguments(arguments)
80 80 # * <tt>:database</tt> Database file
81 81 # * <tt>:reset_database</tt>
82 82 # * <tt>:debug</tt> Enables echo aggregator.
83   - # * <tt>:dump</tt>
  83 + # * <tt>:yaml</tt> Output to YAML
84 84 # * <tt>:parse_strategy</tt>
85   - # * <tt>:no_progress</tt>
  85 + # * <tt>:no_progress</tt> Do not display the progress bar
86 86 # * <tt>:output</tt> :fixed_width, :html or Output class. Defaults to fixed width.
87 87 # * <tt>:file</tt> Filestring or File or StringIO
88 88 # * <tt>:format</tt> :rails, {:apache => 'FORMATSTRING'}, :merb, etcetera or Format Class. Defaults to :rails.
@@ -100,7 +100,7 @@ def self.build_from_arguments(arguments)
100 100 # Refactor :database => options[:database], :dump => options[:dump] away from contoller intialization.
101 101 def self.build(options)
102 102 # Defaults
103   - options[:output] ||= :fixed_width
  103 + options[:output] ||= 'fixed_width'
104 104 options[:format] ||= :rails
105 105 options[:aggregator] ||= [:summarizer]
106 106 options[:report_width] ||= 80
@@ -108,6 +108,12 @@ def self.build(options)
108 108 options[:report_sort] ||= 'sum,mean'
109 109 options[:boring] ||= false
110 110
  111 + # Backwards compatibility
  112 + if options[:dump] && options[:yaml].blank?
  113 + warn "[DEPRECATION] `:dump` is deprecated. Please use `:yaml` instead."
  114 + options[:yaml] = options[:dump]
  115 + end
  116 +
111 117 # Set the output class
112 118 output_args = {}
113 119 output_object = nil
@@ -145,8 +151,9 @@ def self.build(options)
145 151 controller = Controller.new( RequestLogAnalyzer::Source::LogParser.new(file_format, :source_files => options[:source_files]),
146 152 { :output => output_instance,
147 153 :database => options[:database], # FUGLY!
148   - :dump => options[:dump],
149   - :reset_database => options[:reset_database]})
  154 + :yaml => options[:yaml],
  155 + :reset_database => options[:reset_database],
  156 + :no_progress => options[:no_progress]})
150 157
151 158 # register filters
152 159 if options[:after] || options[:before]
@@ -188,7 +195,7 @@ def self.build(options)
188 195 # <tt>format</tt> Logfile format. Defaults to :rails
189 196 # Options are passd on to the LogParser.
190 197 # * <tt>:database</tt> Database the controller should use.
191   - # * <tt>:dump</tt> Yaml Dump the contrller should use.
  198 + # * <tt>:yaml</tt> Yaml Dump the contrller should use.
192 199 # * <tt>:output</tt> All report outputs get << through this output.
193 200 # * <tt>:no_progress</tt> No progress bar
194 201 def initialize(source, options = {})
6 spec/integration/command_line_usage_spec.rb
@@ -72,9 +72,9 @@
72 72 end
73 73
74 74 it "should dump the results to a YAML file" do
75   - run("#{log_fixture(:rails_1x)} --dump #{temp_output_file(:dump)}")
76   - File.exist?(temp_output_file(:dump)).should be_true
77   - YAML::load(File.read(temp_output_file(:dump))).should have_at_least(1).item
  75 + run("#{log_fixture(:rails_1x)} --dump #{temp_output_file(:yaml)}")
  76 + File.exist?(temp_output_file(:yaml)).should be_true
  77 + YAML::load(File.read(temp_output_file(:yaml))).should have_at_least(1).item
78 78 end
79 79
80 80 it "should parse 4 requests from the standard input" do
58 spec/integration/munin_plugins_rails_spec.rb
... ... @@ -0,0 +1,58 @@
  1 +require File.dirname(__FILE__) + '/../spec_helper.rb'
  2 +
  3 +describe RequestLogAnalyzer, 'when harvesting like munin-plugins-rails the YAML output' do
  4 +
  5 + before(:each) do
  6 + cleanup_temp_files!
  7 + run("#{log_fixture(:rails_1x)} --dump #{temp_output_file(:yaml)}")
  8 + @rla = YAML::load(File.read(temp_output_file(:yaml)))
  9 + end
  10 +
  11 + after(:each) do
  12 + cleanup_temp_files!
  13 + end
  14 +
  15 + it "should contain database times" do
  16 + @rla["Database time"].each do |item|
  17 + item[1][:min].should_not be_nil
  18 + item[1][:max].should_not be_nil
  19 + item[1][:hits].should_not be_nil
  20 + item[1][:sum].should_not be_nil
  21 + end
  22 + end
  23 +
  24 + it "should contain request times" do
  25 + @rla["Request duration"].each do |item|
  26 + item[1][:min].should_not be_nil
  27 + item[1][:max].should_not be_nil
  28 + item[1][:hits].should_not be_nil
  29 + item[1][:sum].should_not be_nil
  30 + end
  31 + end
  32 +
  33 + it "should contain failed requests" do
  34 + @rla.keys.should include("Failed requests")
  35 + end
  36 +
  37 + it "should contain Process blockers" do
  38 + @rla.keys.should include("Process blockers (> 1 sec duration)")
  39 + end
  40 +
  41 + it "should contain HTTP Methods" do
  42 + @rla["HTTP methods"]["GET"].should_not be_nil
  43 + end
  44 +
  45 + it "should contain HTTP Methods" do
  46 + @rla["HTTP methods"]["GET"].should_not be_nil
  47 + end
  48 +
  49 + it "should contain view rendering times" do
  50 + @rla["View rendering time"].each do |item|
  51 + item[1][:min].should_not be_nil
  52 + item[1][:max].should_not be_nil
  53 + item[1][:hits].should_not be_nil
  54 + item[1][:sum].should_not be_nil
  55 + end
  56 + end
  57 +
  58 +end
19 spec/integration/scout_spec.rb
... ... @@ -0,0 +1,19 @@
  1 +require File.dirname(__FILE__) + '/../spec_helper.rb'
  2 +
  3 +describe RequestLogAnalyzer, 'when using the rla API like the scout plugin' do
  4 +
  5 + before(:each) do
  6 + @summary = StringIO.new
  7 + RequestLogAnalyzer::Controller.build(
  8 + :output => :HTML,
  9 + :file => @summary,
  10 + :source_files => "#{log_fixture(:rails_1x)}",
  11 + :no_progress => true
  12 + ).run!
  13 + end
  14 +
  15 + it "should generate a summary" do
  16 + @summary.string.should_not be_nil
  17 + end
  18 +
  19 +end
2  spec/unit/tracker/tracker_api_spec.rb
@@ -116,7 +116,7 @@
116 116 end
117 117
118 118 it "should receive :to_yaml object when finalizing" do
119   - @summarizer.options[:dump] = temp_output_file(:dump)
  119 + @summarizer.options[:yaml] = temp_output_file(:yaml)
120 120 @tracker.should_receive(:to_yaml_object).once
121 121 @summarizer.to_yaml
122 122 end

0 comments on commit 4a2332e

Please sign in to comment.
Something went wrong with that request. Please try again.