blob: 7e7c4dd956c29fa772b3bd3de34d9c2e0f783850 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
$:.unshift "../lib"
require 'th_mauve'
require 'mauve/alert_group'
require 'th_mauve_resolv'
require 'pp'
class TcMauveAlertGroup < Mauve::UnitTest
def test_matches_alert
alert = Mauve::Alert.new
alert_group = Mauve::AlertGroup.new("test")
alert_group.includes = Proc.new { true }
assert( alert_group.matches_alert?(alert) )
alert_group.includes = Proc.new { false }
assert( !alert_group.matches_alert?(alert) )
alert_group.includes = Proc.new { summary =~ /Free swap/ }
alert.summary = "Free swap memory (mem_swap) too low"
assert( alert_group.matches_alert?(alert) )
alert.summary = "Free memory (mem_swap) too low"
assert( ! alert_group.matches_alert?(alert) )
alert_group.includes = Proc.new{ source == 'supportbot' }
alert.source = "supportbot"
assert( alert_group.matches_alert?(alert) )
alert.source = "support!"
assert( ! alert_group.matches_alert?(alert) )
alert_group.includes = Proc.new{ /raid/i.match(summary) }
alert.summary = "RAID failure"
assert( alert_group.matches_alert?(alert) )
alert.summary = "Disc failure"
assert( ! alert_group.matches_alert?(alert) )
end
end
|