Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added test

  • Loading branch information...
commit 2b1c0a878e009b590c32dc8744ae5cd6f28e4526 1 parent 346c5aa
@itsderek23 itsderek23 authored
View
10 apache_load/fixtures/initial.txt
@@ -0,0 +1,10 @@
+Total Accesses: 10
+Total kBytes: 37785
+CPULoad: .0235016
+Uptime: 701143
+ReqPerSec: .60533
+BytesPerSec: 55.1839
+BytesPerReq: 91.1634
+BusyWorkers: 1
+IdleWorkers: 49
+Scoreboard: ________________________W......................................................................................................._________________________.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
View
8 apache_load/fixtures/restart.txt
@@ -0,0 +1,8 @@
+Total Accesses: 0
+Total kBytes: 0
+Uptime: 2
+ReqPerSec: 0
+BytesPerSec: 0
+BusyWorkers: 1
+IdleWorkers: 49
+Scoreboard: _________________________.......................................W________________________.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
View
10 apache_load/fixtures/second_run.txt
@@ -0,0 +1,10 @@
+Total Accesses: 20
+Total kBytes: 37789
+CPULoad: .0235202
+Uptime: 701482
+ReqPerSec: .605333
+BytesPerSec: 55.1631
+BytesPerReq: 91.1286
+BusyWorkers: 1
+IdleWorkers: 49
+Scoreboard: _________________________.......................................................................................................____________W____________.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
View
38 apache_load/test.rb
@@ -0,0 +1,38 @@
+require File.expand_path('../../test_helper.rb', __FILE__)
+require File.expand_path('../apache_load.rb', __FILE__)
+
+class ApacheLoadTest < Test::Unit::TestCase
+
+ def setup
+ @options=parse_defaults("apache_load")
+ end
+
+ def teardown
+ FakeWeb.clean_registry
+ end
+
+ def test_run
+ time = Time.parse("12/1/12 12:00")
+ Timecop.travel(time) do
+ plugin=ApacheLoad.new(nil,{},@options)
+ FakeWeb.register_uri(:get, 'http://localhost/server-status?auto', :body => File.read(File.dirname(__FILE__)+'/fixtures/initial.txt'))
+
+ res= plugin.run()
+
+ assert res[:alerts].empty?, res[:alerts]
+ assert res[:errors].empty?, res[:errors]
+ assert_equal 49, res[:reports].first[:idle_workers]
+ assert_equal 1, res[:reports].first[:busy_workers]
+ memory=res[:memory]
+ assert memory.any?
+
+ Timecop.travel(time+60) do
+ plugin=ApacheLoad.new(nil,memory,@options)
+ FakeWeb.register_uri(:get, 'http://localhost/server-status?auto', :body => File.read(File.dirname(__FILE__)+'/fixtures/second_run.txt'))
+ res= plugin.run()
+ assert_in_delta 10/60.to_f, res[:reports].first[:current_load], 0.001
+ end
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.