aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-04-17 11:14:35 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-04-17 11:14:35 +0100
commitc8d16b7511969edbde58bc49ef44e0ff63e5cb8f (patch)
tree54679f51c429e0cb449581c96edbfd9db07175de /test
parent2cca449f78116aa02072e2e6c5036f63c2ec962b (diff)
* DuringRunner#now? caches its answer, indexed by time. The cache is renewed
on reinitialization. * AlertGroup#notify now initialises and keeps track of each DuringRunner to ensure cache usage.
Diffstat (limited to 'test')
-rw-r--r--test/tc_mauve_notification.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/tc_mauve_notification.rb b/test/tc_mauve_notification.rb
index 0b3bc04..ec5eaf6 100644
--- a/test/tc_mauve_notification.rb
+++ b/test/tc_mauve_notification.rb
@@ -315,4 +315,55 @@ EOF
end
+ #
+ # Test to make sure that if a bondary is crossed, then the during clauses all
+ # work.
+ #
+ def test_no_race_conditions_in_during
+
+ config=<<EOF
+person ("test1") {
+ all { true }
+}
+
+person ("test2") {
+ all { true }
+}
+
+alert_group("default") {
+ level URGENT
+ notify("test1") {
+ every 0
+ during { sleep 1 ; hours_in_day 1..7 }
+ }
+
+ notify("test2") {
+ every 0
+ during { hours_in_day 8..10 }
+ }
+
+}
+EOF
+
+ #
+ # Wind forward until 7:59:59am
+ #
+ Timecop.travel(Time.now + 7.hours + 59.minutes + 59.seconds)
+ Configuration.current = ConfigurationBuilder.parse(config)
+ Server.instance.setup
+ alert = Alert.new(
+ :alert_id => "test",
+ :source => "test",
+ :subject => "test"
+ )
+ alert.raise!
+
+ a = AlertChanged.first
+ assert_equal("urgent", a.level, "Level is wrong for #{a.person}")
+ assert_equal("raised", a.update_type, "Update type is wrong for #{a.person}")
+
+ assert_equal(1, Server.instance.notification_buffer.size, "Wrong number of notifications sent")
+ end
+
+
end