Changeset 465866c in nscp for scripts/python/test_eventlog.py
- Timestamp:
- 06/05/12 07:35:30 (12 months ago)
- Branches:
- master, 0.4.1, 0.4.2
- Children:
- 742b035
- Parents:
- 695f240
- File:
-
- 1 edited
-
scripts/python/test_eventlog.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scripts/python/test_eventlog.py
r74e060a r465866c 16 16 last_message = None 17 17 last_perfdata = None 18 last_tag = [] 18 19 got_simple_response = None 19 20 message_count = 0 … … 37 38 self.key = '_%stest_command'%prefix 38 39 self.reg = Registry.get(plugin_id) 39 self.reg.simple_subscription('pytest_evlog', EventLogTest.simple_inbox_handler) 40 41 def simple_inbox_handler(channel, source, command, code, message, perf): 40 self.reg.simple_subscription('pytest_evlog_01', EventLogTest.simple_inbox_handler_01) 41 self.reg.simple_subscription('pytest_evlog_02', EventLogTest.simple_inbox_handler_02) 42 43 def simple_inbox_handler_01(channel, source, command, code, message, perf): 42 44 instance = EventLogTest.getInstance() 43 return instance.simple_inbox_handler_wrapped(channel, source, command, code, message, perf) 44 simple_inbox_handler = Callable(simple_inbox_handler) 45 46 def simple_inbox_handler_wrapped(self, channel, source, command, status, message, perf): 45 return instance.simple_inbox_handler_wrapped(channel, source, command, code, message, perf, '001') 46 simple_inbox_handler_01 = Callable(simple_inbox_handler_01) 47 48 def simple_inbox_handler_02(channel, source, command, code, message, perf): 49 instance = EventLogTest.getInstance() 50 return instance.simple_inbox_handler_wrapped(channel, source, command, code, message, perf, '002') 51 simple_inbox_handler_02 = Callable(simple_inbox_handler_02) 52 53 def simple_inbox_handler_wrapped(self, channel, source, command, status, message, perf, tag): 47 54 message = unicodedata.normalize('NFKD', message).encode('ascii','ignore') 48 55 log('Got simple message %s on %s'%(command, channel)) … … 52 59 self.last_status = status 53 60 self.last_message = message 61 if self.last_tag: 62 self.last_tag.append(tag) 63 else: 64 self.last_tag = [ tag ] 54 65 self.message_count = self.message_count + 1 55 66 self.last_perfdata = perf … … 105 116 sleep(500) 106 117 result.assert_equals(self.last_message, 'error Application Error: ', 'Verify that message is sent through') 107 result.assert_equals(self.message_count, 1, 'Verify that onlyt one message is sent through') 118 result.assert_equals(self.message_count, 1, 'Verify that only one message is sent through') 119 log('Got tags: %s'%self.last_tag) 108 120 109 121 result.add_message(self.test_create('Application Error', 1000, 'info', 2, 1, 5, a_list), 'Testing to create a log message') … … 113 125 114 126 (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) 115 cache.assert_equals(res, status.CRITICAL, "Validate cache has items ")127 cache.assert_equals(res, status.CRITICAL, "Validate cache has items: %s"%msg) 116 128 cache.assert_equals(msg, 'error Application Error: , info Application Error: , eventlog: 2 = critical', "Validate cache is ok: %s"%msg) 117 129 cache.assert_equals(perf, "'eventlog'=2;1;2", "Validate cache is ok: %s"%msg) … … 145 157 return result 146 158 159 def install_filter(self, conf, path, target, filter): 160 conf.set_string(path, 'filter', filter) 161 conf.set_string(path, 'maximum age', '5s') 162 conf.set_string(path, 'destination', target) 163 conf.set_string(path, 'language', 'english') 164 conf.set_string(path, 'debug', 'true') 165 147 166 def install(self, arguments): 148 167 conf = Settings.get() … … 153 172 154 173 conf.set_string('/settings/pytest_eventlog/real-time', 'enabled', 'true') 155 conf.set_string('/settings/pytest_eventlog/real-time', 'filter', 'id = 1000 and category = 0') 156 conf.set_string('/settings/pytest_eventlog/real-time/filters', 'test', 'id = 1000 and category = 1') 174 175 self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_001', 'pytest_evlog_01', 'id = 1000 and category = 0') 176 self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_002', 'pytest_evlog_02', 'id = 1000 and category = 1') 177 157 178 conf.set_string('/settings/pytest_eventlog/real-time', 'maximum age', '5s') 158 conf.set_string('/settings/pytest_eventlog/real-time', 'destination', 'pytest_evlog')159 conf.set_string('/settings/pytest_eventlog/real-time', 'language', 'english')160 179 conf.set_string('/settings/pytest_eventlog/real-time', 'debug', 'true') 161 180 conf.set_string('/settings/pytest_eventlog/real-time', 'enable active', 'true')
Note: See TracChangeset
for help on using the changeset viewer.








