aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.d/controller/lua.d/aft.lua27
-rw-r--r--conf.d/controller/lua.d/helloworld.lua7
2 files changed, 26 insertions, 8 deletions
diff --git a/conf.d/controller/lua.d/aft.lua b/conf.d/controller/lua.d/aft.lua
index f0c7388..4d0fac7 100644
--- a/conf.d/controller/lua.d/aft.lua
+++ b/conf.d/controller/lua.d/aft.lua
@@ -108,11 +108,13 @@ end
function _AFT.triggerEvtCallback(eventName)
if _AFT.monitored_events[eventName].cb then
- local data_n = table_size(_AFT.monitored_events[event.name].data)
- if _AFT.event_history == true then
- _AFT.monitored_events[event.name].cb(v.name, _AFT.monitored_events[event.name].data[data_n], _AFT.monitored_events[event.name].data)
- else
- _AFT.monitored_events[event.name].cb(v.name, _AFT.monitored_events[event.name].data[data_n])
+ if _AFT.monitored_events[eventName].data ~= nil then
+ local data_n = table_size(_AFT.monitored_events[eventName].data)
+ if _AFT.event_history == true then
+ _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n], _AFT.monitored_events[eventName].data)
+ else
+ _AFT.monitored_events[eventName].cb(v.name, _AFT.monitored_events[eventName].data[data_n])
+ end
end
end
end
@@ -204,7 +206,7 @@ end
function _AFT.assertEvtGrpNotReceived(eventGroup, timeout)
local count = 0
local eventName = ""
- for _,event in pairs(eventGroup) do
+ for key,event in pairs(eventGroup) do
eventGroup[key] = {name = event, receivedCount = _AFT.monitored_events[event].receivedCount}
end
@@ -251,6 +253,19 @@ function _AFT.assertEvtGrpReceived(eventGroup, timeout)
end
end
+function _AFT.testEvtGrpReceived(testName, eventGroup, timeout, setUp, tearDown)
+ _AFT.describe(testName, function()
+ _AFT.assertEvtGrpReceived(eventGroup, timeout)
+ end, setUp, tearDown)
+end
+
+function _AFT.testEvtGrpNotReceived(testName, eventGroup, timeout, setUp, tearDown)
+ _AFT.describe(testName, function()
+ _AFT.assertEvtGrpNotReceived(eventGroup, timeout)
+ end, setUp, tearDown)
+end
+
+
function _AFT.assertEvtNotReceived(eventName, timeout)
local count = _AFT.monitored_events[eventName].receivedCount
if timeout then
diff --git a/conf.d/controller/lua.d/helloworld.lua b/conf.d/controller/lua.d/helloworld.lua
index 8fcf077..bffb230 100644
--- a/conf.d/controller/lua.d/helloworld.lua
+++ b/conf.d/controller/lua.d/helloworld.lua
@@ -55,5 +55,8 @@ _AFT.testVerbStatusSuccess('testEventPushanotherEvent', 'hello', 'eventpush', {t
_AFT.testVerbStatusSuccess('testGenerateWarning', 'hello', 'verbose', {level = 4, message = 'My Warning message!'})
-_AFT.testEvtReceived("testanEventReceived", "hello/anEvent",3000000)
-_AFT.testEvtReceived("testanotherEventReceived", "hello/anotherEvent",3000000)
+_AFT.testEvtGrpReceived("testEventGroupReceived",{"hello/anEvent","hello/anotherEvent"},300000)
+_AFT.testEvtGrpNotReceived("testEventGroupNotReceived",{"hello/anEvent","hello/anotherEvent"},300000)
+
+_AFT.testEvtReceived("testanEventReceived", "hello/anEvent",300000)
+_AFT.testEvtReceived("testanotherEventReceived", "hello/anotherEvent",300000)