Ignore:
Timestamp:
06/05/12 07:35:30 (12 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.1, 0.4.2
Children:
742b035
Parents:
695f240
Message:

2012-06-05 MickeM

  • Tweaked all servers to use the new internals and added first testcase for NSCP socket

2012-05-24 MickeM

  • Reworked real time event log support to be a lot more flexible You can now specify all options on a "filter" level.
  • WARNING* Old syntax NOT supported (and will not upgrade) but hopefully not to many will be affected.
  • Added support for ipv6 allowed hosts validation

2012-05-21 MickeM

  • Sofia Born (My second daughter)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/python/test_eventlog.py

    r74e060a r465866c  
    1616  last_message = None 
    1717  last_perfdata = None 
     18  last_tag = [] 
    1819  got_simple_response = None 
    1920  message_count = 0 
     
    3738    self.key = '_%stest_command'%prefix 
    3839    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): 
    4244    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): 
    4754    message = unicodedata.normalize('NFKD', message).encode('ascii','ignore') 
    4855    log('Got simple message %s on %s'%(command, channel)) 
     
    5259    self.last_status = status 
    5360    self.last_message = message 
     61    if self.last_tag: 
     62      self.last_tag.append(tag) 
     63    else: 
     64      self.last_tag = [ tag ] 
    5465    self.message_count = self.message_count + 1 
    5566    self.last_perfdata = perf 
     
    105116    sleep(500) 
    106117    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) 
    108120 
    109121    result.add_message(self.test_create('Application Error', 1000, 'info', 2, 1, 5, a_list), 'Testing to create a log message') 
     
    113125 
    114126    (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) 
    116128    cache.assert_equals(msg, 'error Application Error: , info Application Error: , eventlog: 2 = critical', "Validate cache is ok: %s"%msg) 
    117129    cache.assert_equals(perf, "'eventlog'=2;1;2", "Validate cache is ok: %s"%msg) 
     
    145157    return result 
    146158 
     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   
    147166  def install(self, arguments): 
    148167    conf = Settings.get() 
     
    153172     
    154173    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     
    157178    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') 
    160179    conf.set_string('/settings/pytest_eventlog/real-time', 'debug', 'true') 
    161180    conf.set_string('/settings/pytest_eventlog/real-time', 'enable active', 'true') 
Note: See TracChangeset for help on using the changeset viewer.