Changeset bd1e5e5 in nscp for scripts


Ignore:
Timestamp:
01/20/12 07:54:34 (17 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
6fbb689
Parents:
b175d61
Message:

ARGH!!! included the script this time :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/python/test_nsca.py

    rb175d61 rbd1e5e5  
    4343    #self.uuid = unicodedata.normalize('NFKD', command).encode('ascii','ignore') 
    4444    self.command = command 
    45     self.uuid = None 
    4645    self.source = None 
    4746    self.status = None 
     
    8988  def set_response(self, msg): 
    9089    with sync: 
     90      if msg.uuid in self._responses: 
     91        log('Updated: %s'%msg.uuid) 
    9192      self._responses[msg.uuid].copy_changed_attributes(msg) 
     93      else: 
     94        log('Added: %s'%msg.uuid) 
     95        self._responses[msg.uuid] = msg 
     96       
    9297 
    9398  def del_response(self, id): 
     
    120125  def simple_inbox_handler_wrapped(self, channel, source, command, status, message, perf): 
    121126    log('Got simple message %s on %s'%(command, channel)) 
    122     msg = self.get_response(command) 
     127    msg = NSCAMessage(command) 
    123128    msg.source = source 
    124129    msg.status = status 
     
    135140    log('Got message %s on %s'%(command, channel)) 
    136141     
    137     msg = self.get_response(command) 
     142    msg = NSCAMessage(command) 
    138143    msg.got_response = True 
    139144    self.set_response(msg) 
     
    148153      if self.has_response(uuid): 
    149154        rmsg = self.get_response(uuid) 
     155        if not rmsg.got_simple_response or not rmsg.got_response: 
     156          for j in range(0,3): 
     157            rmsg = self.get_response(uuid) 
     158            if rmsg.got_simple_response and rmsg.got_response: 
     159              log('Got delayed response %s'%uuid) 
     160        else: 
     161              log('Waiting for delayed response %s (%d/10)'%(uuid, j+1)) 
     162           
    150163        result.add_message(rmsg.got_response, 'Testing to recieve message using %s'%tag) 
    151         if 'exec' in tag and 'UNKNOWN' in tag and not rmsg.got_simple_response: 
    152           result.add_message(True, 'FAILED -- TODO -- FIX ME -- Testing to recieve simple message using %s'%tag) 
    153         else: 
    154164          result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s'%tag) 
    155         #result.assert_equals(rmsg.last_source, source, 'Verify that source is sent through') 
    156165        result.assert_equals(rmsg.command, uuid, 'Verify that command is sent through using %s'%tag) 
    157166        result.assert_contains(rmsg.message, msg, 'Verify that message is sent through using %s'%tag) 
    158         result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through using %s'%tag) 
     167         
     168        #result.assert_equals(rmsg.last_source, source, 'Verify that source is sent through') 
     169        #result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through using %s'%tag) 
    159170        self.del_response(uuid) 
    160171        return True 
     
    190201    (result_code, err) = core.submit('nsca_test_outbox', message.SerializeToString()) 
    191202 
    192     result = TestResult('Testing payload: %s'%tag) 
     203    result = TestResult('Testing payload submission (via API): %s'%tag) 
    193204    result.add_message(len(err) == 0, 'Testing to send message using %s/sbp'%tag, err) 
    194205    self.wait_and_validate(uid, result, msg, perf, '%s/spb'%tag) 
     
    208219      ] 
    209220    (result_code, result_message) = core.simple_exec('any', 'nsca_submit', args) 
    210     result = TestResult() 
     221    result = TestResult('Testing payload submission (via command line exec): %s'%tag) 
    211222     
    212223    result.add_message(result_code == 0, 'Testing to send message using %s/exec:1'%tag) 
Note: See TracChangeset for help on using the changeset viewer.