hippoload 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  Basic Ruby wrapper/parser for Httperf
4
4
 
5
- Currently it supports 'get' method of httperf.
6
5
 
6
+ > Httperf is a tool for measuring web server performance. It provides a flexible facility for generating various HTTP workloads and for measuring server performance.
7
+
8
+ Currently it supports 'get' method of httperf.
7
9
 
8
10
  ## Installation
9
11
 
@@ -26,6 +28,19 @@ require "hippoload"
26
28
 
27
29
  # for single connections and rate
28
30
 
31
+ # Conf arguments: (Note: Currently it supports only these arguments. New arguments are coming soon...)
32
+
33
+ # conf = {
34
+ # :connections => '300',
35
+ # :rate => '30',
36
+ # :server => 'mysite.com' # by default it's 'localhost',
37
+ # :port => '8080' # by default it's '3000',
38
+ # :connections_and_rates => [{:connections => 1000, :rate => 10}, {:connections => 2000, :rate => 200}]
39
+ # :uri => '/posts'
40
+ # }
41
+
42
+ # Note: Please assign either (:connections and :rate) or (:connections_and_rates) at a time
43
+
29
44
  conf = {:connections => 100, :rate => 10, :uri => "/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1" }
30
45
 
31
46
  hippo = Hippoload::Hippo.new(conf)
@@ -40,13 +55,14 @@ hippo_parser.parse(raw_output)
40
55
 
41
56
  # for connections and rates list
42
57
 
43
- conf = {:connections_and_rates => [{:connections => 100, :rate => 10}, {:connections => 200, :rate => 20}], :uri => "/api/v1/entities?app_token=ef6baaed0d294f8f54eef
58
+ conf = {:connections_and_rates => [{:connections => 100, :rate => 10}, {:connections => 200, :rate => 20}], :uri => "/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1"}
44
59
 
45
60
  hippo = Hippoload::Hippo.new(conf)
46
61
 
47
62
  hippo.becomes_crazy
48
63
 
49
64
  # connections list wise => {"100-10-/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1"=>"httperf --client=0/1 --server=localhost --port=3000 --uri=/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1 --rate=10 --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=1\nMaximum connect burst length: 1\n\nTotal: connections 100 requests 100 replies 100 test-duration 9.951 s\n\nConnection rate: 10.0 conn/s (99.5 ms/conn, <=5 concurrent connections)\nConnection time [ms]: min 34.3 avg 69.5 max 400.1 median 50.5 stddev 57.6\nConnection time [ms]: connect 0.1\nConnection length [replies/conn]: 1.000\n\nRequest rate: 10.0 req/s (99.5 ms/req)\nRequest size [B]: 120.0\n\nReply rate [replies/s]: min 10.0 avg 10.0 max 10.0 stddev 0.0 (1 samples)\nReply time [ms]: response 68.9 transfer 0.5\nReply size [B]: header 642.0 content 4901.0 footer 0.0 (total 5543.0)\nReply status: 1xx=0 2xx=100 3xx=0 4xx=0 5xx=0\n\nCPU time [s]: user 2.14 system 7.81 (user 21.5% system 78.5% total 99.9%)\nNet I/O: 55.6 KB/s (0.5*10^6 bps)\n\nErrors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0\nErrors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0\n", "150-15-/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1"=>"httperf --client=0/1 --server=localhost --port=3000 --uri=/api/v1/entities?app_token=ef6baaed0d294f8f54eef80aeb8a4ee1 --rate=15 --send-buffer=4096 --recv-buffer=16384 --num-conns=150 --num-calls=1\nMaximum connect burst length: 1\n\nTotal: connections 150 requests 150 replies 150 test-duration 9.988 s\n\nConnection rate: 15.0 conn/s (66.6 ms/conn, <=7 concurrent connections)\nConnection time [ms]: min 34.3 avg 92.1 max 415.4 median 71.5 stddev 68.8\nConnection time [ms]: connect 0.1\nConnection length [replies/conn]: 1.000\n\nRequest rate: 15.0 req/s (66.6 ms/req)\nRequest size [B]: 120.0\n\nReply rate [replies/s]: min 15.0 avg 15.0 max 15.0 stddev 0.0 (1 samples)\nReply time [ms]: response 91.9 transfer 0.0\nReply size [B]: header 642.0 content 4901.0 footer 0.0 (total 5543.0)\nReply status: 1xx=0 2xx=150 3xx=0 4xx=0 5xx=0\n\nCPU time [s]: user 1.76 system 8.21 (user 17.6% system 82.2% total 99.9%)\nNet I/O: 83.1 KB/s (0.7*10^6 bps)\n\nErrors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0\nErrors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0\n"}
65
+
50
66
  ```
51
67
  ## Contributing
52
68
 
@@ -55,3 +71,10 @@ hippo.becomes_crazy
55
71
  3. Commit your changes (`git commit -am 'Add some feature'`)
56
72
  4. Push to the branch (`git push origin my-new-feature`)
57
73
  5. Create new Pull Request
74
+
75
+ ## Other similar Ruby gems/libraries
76
+
77
+ 1. [httperfrb](https://github.com/rubyops/httperfrb)
78
+ 2. [stresser](https://github.com/moviepilot/stresser)
79
+ 3. [httperf-output-parser](https://github.com/wjessop/httperf-output-parser)
80
+
@@ -12,19 +12,27 @@ module Hippoload
12
12
  attr_reader :connections, :rate, :server, :port, :uri, :connections_and_rates
13
13
 
14
14
  def initialize(conf)
15
+
16
+ raise ArgumentError, 'Argument is not hash' unless conf.is_a? Hash
17
+
15
18
  @connections = conf[:connections]
16
19
  @rate = conf[:rate]
17
20
  @server = conf[:server] || 'localhost'
18
21
  @port = conf[:port] || '3000'
19
22
  @uri = conf[:uri]
20
- @connections_and_rates = conf[:connections_and_rates] || default_connections_and_rates
23
+ @connections_and_rates = if !conf[:connections_and_rates].nil?
24
+ conf[:connections_and_rates]
25
+ elsif @connections.nil? && @rate.nil?
26
+ default_connections_and_rates
27
+ end
21
28
 
22
- raise_error_if_wrong_conf
29
+ raise Hippo.wrong_conf_message if wrong_configuration
23
30
  end
24
31
 
25
32
  def attack
26
- set_connections if !@connections.nil?
27
- set_rate if !@rate.nil?
33
+ raise "Httperf is not installed on your machine" unless httperf_installed?
34
+ set_connections if @connections.nil?
35
+ set_rate if @rate.nil?
28
36
  %x(httperf --num-conns=#{@connections} --rate=#{@rate} --server=#{@server} --port=#{@port} --uri="#{@uri}")
29
37
  end
30
38
 
@@ -40,6 +48,13 @@ module Hippoload
40
48
  raw_outputs
41
49
  end
42
50
 
51
+ class << self
52
+ def wrong_conf_message
53
+ "You are missing :connections or :rate arrtibute or may be,
54
+ either assign (:connections, :rate) or assign :connections_and_rates attribute"
55
+ end
56
+ end
57
+
43
58
  private
44
59
 
45
60
  def default_connections_and_rates
@@ -50,21 +65,29 @@ module Hippoload
50
65
  { :connections => 500, :rate => 50 },
51
66
  { :connections => 700, :rate => 70 },
52
67
  { :connections => 1000, :rate => 100 }
53
- ] if (!@connections.nil? or !@rate.nil?) && !@connections_and_rates.nil?
68
+ ]
54
69
  end
55
70
 
56
71
  def set_connections
57
- @connections = @connections || default_connections_and_rates.first[:connections]
72
+ @connections ||= default_connections_and_rates[0][:connections]
73
+ puts "--" * 50
74
+ puts "NOTE: You haven't passed the no of connections, so setting default value (#{@connections}) for the connections."
75
+ puts "--" * 50
58
76
  end
59
77
 
60
78
  def set_rate
61
- @rate = @rate || default_connections_and_rates.first[:rate]
79
+ @rate ||= default_connections_and_rates[0][:rate]
80
+ puts "--" * 50
81
+ puts "NOTE: You haven't passed the value for rate, so setting default value (#{@rate}) for the rate."
82
+ puts "--" * 50
62
83
  end
63
84
 
64
- def raise_error_if_wrong_conf
65
- if (!@connections.nil? || !@rate.nil?) && !@connections_and_rates.nil?
66
- raise "You can not assign (:connections, :rate) at same with :connections_and_rates attributes. Either assign (:connections, :rate) or assign :connections_and_rates attribute"
67
- end
85
+ def wrong_configuration
86
+ (!@connections.nil? || !@rate.nil?) && !@connections_and_rates.nil?
87
+ end
88
+
89
+ def httperf_installed?
90
+ system("which httperf > /dev/null 2>&1")
68
91
  end
69
92
  end
70
93
  end
@@ -1,6 +1,8 @@
1
1
  module Hippoload
2
2
  class HippoParser
3
3
 
4
+ # Inspired by https://github.com/wjessop/httperf-output-parser/blob/master/lib/httperf-output-parser.rb
5
+
4
6
  DATATYPES = %w(
5
7
  total_conenctions
6
8
  duration
@@ -1,3 +1,3 @@
1
1
  module Hippoload
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -11,10 +11,15 @@ describe Hippoload::Hippo do
11
11
  :uri => "/posts",
12
12
  :connections_and_rates => [{ :connections => 100, :rate => 10 }]
13
13
  }
14
+
14
15
  end
15
16
 
17
+ let(:wrong_arg) {['worng_arg']}
18
+
16
19
  describe "Hippo#attributes_methods" do
17
20
 
21
+ # These tests are tested using real database with the httperf tool
22
+
18
23
  it "should have attributes reader" do
19
24
  hippo = Hippoload::Hippo.new(basic_conf)
20
25
  hippo.connections.should eql(100)
@@ -29,6 +34,10 @@ describe Hippoload::Hippo do
29
34
  expect { Hippoload::Hippo.new(wrong_conf) }.to raise_error
30
35
  end
31
36
 
37
+ it "should raise error if wrong argument passed" do
38
+ expect { Hippoload::Hippo.new(wrong_arg) }.to raise_error
39
+ end
40
+
32
41
  it "should not raise error if correct conf passed" do
33
42
  expect { Hippoload::Hippo.new(basic_conf) }.to_not raise_error
34
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hippoload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec