lib splitted in more files. many new features (client, server, packet)
This commit is contained in:
parent
2f1c21ff79
commit
476d58d7ec
8 changed files with 512 additions and 309 deletions
12
test/dummy_server.rb
Normal file
12
test/dummy_server.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
module NSCA
|
||||
def self.dummy_server port, password = nil, key = nil
|
||||
require 'pathname'
|
||||
load Pathname.new( __FILE__).dirname.join( '..', 'lib', 'nsca.rb').to_s
|
||||
serv = NSCA::Server.new port, password: password, key: key
|
||||
sock = serv.accept
|
||||
sock.fetch
|
||||
ensure
|
||||
sock.close if sock
|
||||
serv.close if serv
|
||||
end
|
||||
end
|
|
@ -1,6 +1,34 @@
|
|||
require 'helper'
|
||||
|
||||
class TestNSCA < Test::Unit::TestCase
|
||||
class TestChecks
|
||||
extend NSCA::Checks
|
||||
perfdata :PD1, :pd1_in_sec, :s, 10, 20, 0, 30
|
||||
perfdata :PD2, :pd2_in_1, 1, 0.99, 0.98, 0, 1
|
||||
perfdata :PD3, :pd3_count, :c, 3, 5, 0
|
||||
check :T0, 'TestNSCA0', 'uxnags01-sbe.net.mobilkom.at'
|
||||
check :T1, 'TestNSCA1', 'uxnags01-sbe.net.mobilkom.at', [PD1, PD2]
|
||||
check :T2, :TestNSCA2, 'uxnags01-sbe.net.mobilkom.at', [PD1, PD2, PD3]
|
||||
end
|
||||
|
||||
context 'our test server' do
|
||||
should 'receive data. NSCA-server should run on localhost 5777. if not, ignore this test. password=abcdefghijkl' do
|
||||
PD1 = TestChecks::PD1
|
||||
PD2 = TestChecks::PD2
|
||||
PD3 = TestChecks::PD3
|
||||
T0 = TestChecks::T0
|
||||
T1 = TestChecks::T1
|
||||
T2 = TestChecks::T2
|
||||
NSCA.destinations << NSCA::Client.new( 'localhost', 5667, 2)
|
||||
NSCA.send TestChecks::T0.new( 1, "0123456789"*51+"AB")
|
||||
|
||||
return
|
||||
pd1 = PD1.new 3
|
||||
pd2 = PD2.new 0.9996
|
||||
pd3 = PD3.new 2
|
||||
NSCA.send TestChecks::T1.new( nil, "Should be OK", [pd1, pd2, pd3])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestNSCA::ReturnCode < Test::Unit::TestCase
|
||||
|
@ -26,19 +54,19 @@ end
|
|||
|
||||
class TestNSCA::PerformanceData < Test::Unit::TestCase
|
||||
should 'set a subclass for new PerfData-types' do
|
||||
NSCA::PerformanceData.new 'subclass test'
|
||||
NSCA::PerformanceData.create 'subclass test'
|
||||
assert_nothing_raised NameError do
|
||||
assert NSCA::PerformanceData::Subclass_test, "No subclass created."
|
||||
end
|
||||
end
|
||||
|
||||
def perfdata *a
|
||||
NSCA::PerformanceData.create *a
|
||||
NSCA::PerformanceData.new *a
|
||||
end
|
||||
|
||||
context 'Created NSCA::PerformanceData-subclasses' do
|
||||
should 'be the same like returned' do
|
||||
cl = NSCA::PerformanceData.new 'returned and subclass the same test'
|
||||
cl = NSCA::PerformanceData.create 'returned and subclass the same test'
|
||||
assert cl == NSCA::PerformanceData::Returned_and_subclass_the_same_test, 'Classes are not the same.'
|
||||
end
|
||||
should 'have a unit if given' do
|
||||
|
@ -57,8 +85,8 @@ class TestNSCA::PerformanceData < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
|
||||
class TestNSCA::Connection < Test::Unit::TestCase
|
||||
class TestNSCA::Client < Test::Unit::TestCase
|
||||
should '' do
|
||||
NSCA::Connection
|
||||
NSCA::Client
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue