def run_test(self): global time_to_run, check_per_second result = TestResult() start = time() if isinstance(time_to_run, str) and time_to_run == 'infinate': time_to_run = -1 elif isinstance(time_to_run, str): time_to_run = 5 if time_to_run == -1: total_count = -1 else: total_count = check_per_second*time_to_run if time_to_run != -1: self.background = False last_major = 0 while self.results_count < total_count: old_stress_count = self.results_count old_noop_count = self.check_count sleep(5000) result.add_message(True, 'Commands/second: %d/%d'%( (self.results_count-old_stress_count)/5, (self.check_count-old_noop_count)/5 ) ) if (self.results_count*100/total_count) > last_major + 10: last_major = last_major + 10 log('%d%% Complete: %d checks per second <%d/%d>'%(self.results_count*100/total_count, (self.results_count-old_stress_count)/5, self.results_count, total_count)) elapsed = (time() - start) if elapsed == 0: elapsed = 1 result.add_message(True, 'Summary Collected %d instance in %d seconds: %d/s'%(self.results_count, elapsed, self.results_count/elapsed)) else: self.background = True result.add_message(True, 'Test running in background, run py_unittest_collect to collect results at any time.') return result
def wait_and_validate(self, uuid, result, msg, perf, tag): found = False for i in range(0,10): if not self.has_response(uuid): log_debug('Waiting for %s (%d/10)'%(uuid, i+1)) sleep(200) else: log_debug('Got response %s'%uuid) found = True break if not found: result.add_message(False, 'Failed to recieve message %s using %s'%(uuid, tag)) return False for i in range(0,10): rmsg = self.get_response(uuid) if not rmsg.got_simple_response or not rmsg.got_response: log_debug('Waiting for delayed response %s s/m: %s/%s - (%d/10)'%(uuid, rmsg.got_simple_response, rmsg.got_response, i+1)) sleep(500) else: log_debug('Got delayed response %s'%uuid) break result.add_message(rmsg.got_response, 'Testing to recieve message using %s'%tag) result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s'%tag) result.assert_equals(rmsg.command, uuid, 'Verify that command is sent through using %s'%tag) result.assert_contains(rmsg.message, msg, 'Verify that message is sent through using %s'%tag) #result.assert_equals(rmsg.last_source, source, 'Verify that source is sent through') #result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through using %s'%tag) self.del_response(uuid) return True
def submit_payload(self, alias, ssl, length, source, status, msg, perf, target): message = plugin_pb2.QueryRequestMessage() message.header.destination_id = target message.header.command = 'nrpe_forward' host = message.header.hosts.add() host.address = "127.0.0.1:15666" host.id = target if (target == 'valid'): pass else: enc = host.metadata.add() enc.key = "use ssl" enc.value = '%s'%ssl enc = host.metadata.add() enc.key = "payload length" enc.value = '%d'%length enc = host.metadata.add() enc.key = "timeout" enc.value = '5' uid = str(uuid.uuid4()) payload = message.payload.add() payload.command = 'check_py_nrpe_test_s' payload.arguments.append(uid) rmsg = self.get_request(uid) rmsg.status = status rmsg.message = msg rmsg.perfdata = perf self.set_request(rmsg) (result_code, response) = self.core.query('ignored', message.SerializeToString()) response_message = plugin_pb2.QueryResponseMessage() response_message.ParseFromString(response) result = TestResult('Testing NRPE: %s for %s'%(alias, target)) found = False for i in range(0,10): if self.has_response(uid): rmsg = self.get_response(uid) #result.add_message(rmsg.got_response, 'Testing to recieve message using %s'%alias) result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s'%alias) result.add_message(len(response_message.payload) == 1, 'Verify that we only get one payload response for %s'%alias, '%s != 1'%len(response_message.payload)) if len(response_message.payload) == 1 and len(response_message.payload[0].lines) == 1: result.assert_equals(response_message.payload[0].result, status, 'Verify that status is sent through %s'%alias) result.assert_equals(response_message.payload[0].lines[0].message, msg, 'Verify that message is sent through %s'%alias) #result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through') self.del_response(uid) found = True break else: log('Waiting for %s (%s/%s)'%(uid,alias,target)) sleep(500) if not found: result.add_message(False, 'Testing to recieve message using %s'%alias) return result
def run_test(self): result = TestResult('Checking CheckEventLog') cache = TestResult('Checking CheckEventLog CACHE') (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) cache.assert_equals(res, status.OK, "Validate cache is empty") cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) a_list = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'] result.add_message(self.test_create('Application Error', 1000, 'error', 0, 0, 0, a_list), 'Testing to create a log message') sleep(500) result.assert_equals(self.last_message, 'error Application Error: ', 'Verify that message is sent through') result.assert_equals(self.message_count, 1, 'Verify that onlyt one message is sent through') result.add_message(self.test_create('Application Error', 1000, 'info', 2, 1, 5, a_list), 'Testing to create a log message') sleep(500) result.assert_equals(self.last_message, 'info Application Error: ', 'Verify that message is sent through') result.assert_equals(self.message_count, 1, 'Verify that onlyt one message is sent through') (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) cache.assert_equals(res, status.CRITICAL, "Validate cache has items") cache.assert_equals(msg, 'error Application Error: , info Application Error: , eventlog: 2 = critical', "Validate cache is ok: %s"%msg) cache.assert_equals(perf, "'eventlog'=2;1;2", "Validate cache is ok: %s"%msg) (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) cache.assert_equals(res, status.OK, "Validate cache is empty (again)") cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) result.add(cache) r = TestResult('Checking filters') r.add(self.test_w_expected('id = 1000 and generated gt 1m', '%generated%', 0)) r.add(self.test_w_expected('id = 1000 and generated gt -1m', '%generated%', 2)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and id = 1000', '%generated%: %id%, %category%', 2)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and category = 1', '%category%', 1)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and category = 0', '%category%', 1)) r.add(self.test_w_expected("id = 1000 and generated gt -1m and level = 'error'", '%level%', 1)) r.add(self.test_w_expected("id = 1000 and generated gt -1m and level = 'info'", '%level%', 1)) result.add(r) r = TestResult('Checking syntax') r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%source% - %type% - %category%', 'Application Error - error - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%source% - %type% - %category%', 'Application Error - info - 1')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%facility% - %qualifier% - %customer%', '0 - 0 - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%facility% - %qualifier% - %customer%', '5 - 5 - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%rawid% - %severity% - %log%', '1000 - success - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%rawid% - %severity% - %log%', '2147812328 - warning - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) result.add(r) return result
def run_test(self): result = TestResult() start = time() total_count = install_checks*time_to_run/5 while self.stress_count < total_count: log('Waiting for %d: %d/%d'%(total_count, self.stress_count, self.noop_count)) old_stress_count = self.stress_count old_noop_count = self.noop_count sleep(5000) result.add_message(True, 'Commands/second: %d/%d'%( (self.stress_count-old_stress_count)/5, (self.noop_count-old_noop_count)/5 ) ) elapsed = (time() - start) if elapsed == 0: elapsed = 1 result.add_message(True, 'Summary Collected %d instance in %d seconds: %d/s'%(self.stress_count, elapsed, self.stress_count/elapsed)) return result
def run_test(self): global time_to_run, check_per_second result = TestResult() start = time() if isinstance(time_to_run, str) and time_to_run == 'infinate': time_to_run = -1 elif isinstance(time_to_run, str): time_to_run = 5 if time_to_run == -1: total_count = -1 else: total_count = check_per_second * time_to_run if time_to_run != -1: self.background = False last_major = 0 while self.results_count < total_count: old_stress_count = self.results_count old_noop_count = self.check_count sleep(5000) result.add_message( True, 'Commands/second: %d/%d' % ((self.results_count - old_stress_count) / 5, (self.check_count - old_noop_count) / 5)) if (self.results_count * 100 / total_count) > last_major + 10: last_major = last_major + 10 log('%d%% Complete: %d checks per second <%d/%d>' % (self.results_count * 100 / total_count, (self.results_count - old_stress_count) / 5, self.results_count, total_count)) elapsed = (time() - start) if elapsed == 0: elapsed = 1 result.add_message( True, 'Summary Collected %d instance in %d seconds: %d/s' % (self.results_count, elapsed, self.results_count / elapsed)) else: self.background = True result.add_message( True, 'Test running in background, run py_unittest_collect to collect results at any time.' ) return result
def run_test_proc(self): result = TestResult('Checking CheckProcState') for j in range(0,3): result.append(self.test_one_proc_int('notepad.exe', 0, j)) pids = [] for i in range(1,4): log('Starting notepad...') handle = subprocess.Popen('notepad.exe', shell=False) sleep(500) pids.append(handle.pid) for j in range(0,3): result.append(self.test_one_proc_int('notepad.exe', i, j)) for p in pids: subprocess.Popen("taskkill /F /T /PID %i"%p , shell=True) return result
def run_test_proc(self): result = TestResult('Checking CheckProcState') for j in range(0, 3): result.append(self.test_one_proc_int('notepad.exe', 0, j)) pids = [] for i in range(1, 4): log('Starting notepad...') handle = subprocess.Popen('notepad.exe', shell=False) sleep(500) pids.append(handle.pid) for j in range(0, 3): result.append(self.test_one_proc_int('notepad.exe', i, j)) for p in pids: subprocess.Popen("taskkill /F /T /PID %i" % p, shell=True) return result
def wait_and_validate(self, uuid, result, msg, perf, tag): found = False for i in range(0, 10): if not self.has_response(uuid): log_debug('Waiting for %s (%d/10)' % (uuid, i + 1)) sleep(200) else: log_debug('Got response %s' % uuid) found = True break if not found: result.add_message( False, 'Failed to recieve message %s using %s' % (uuid, tag)) return False for i in range(0, 10): rmsg = self.get_response(uuid) if not rmsg.got_simple_response or not rmsg.got_response: log_debug( 'Waiting for delayed response %s s/m: %s/%s - (%d/10)' % (uuid, rmsg.got_simple_response, rmsg.got_response, i + 1)) sleep(500) else: log_debug('Got delayed response %s' % uuid) break result.add_message(rmsg.got_response, 'Testing to recieve message using %s' % tag) result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s' % tag) result.assert_equals( rmsg.command, uuid, 'Verify that command is sent through using %s' % tag) result.assert_contains( rmsg.message, msg, 'Verify that message is sent through using %s' % tag) #result.assert_equals(rmsg.last_source, source, 'Verify that source is sent through') #result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through using %s'%tag) self.del_response(uuid) return True
def run_test(self): result = TestResult() start = time() total_count = install_checks * time_to_run / 5 while self.stress_count < total_count: log('Waiting for %d: %d/%d' % (total_count, self.stress_count, self.noop_count)) old_stress_count = self.stress_count old_noop_count = self.noop_count sleep(5000) result.add_message( True, 'Commands/second: %d/%d' % ((self.stress_count - old_stress_count) / 5, (self.noop_count - old_noop_count) / 5)) elapsed = (time() - start) if elapsed == 0: elapsed = 1 result.add_message( True, 'Summary Collected %d instance in %d seconds: %d/s' % (self.stress_count, elapsed, self.stress_count / elapsed)) return result
def run_test(self): self.core.load_module('Scheduler', self.sched_alias) result = TestResult() start = time() last_major = 0 elapsed = time()-start while elapsed < 60: if elapsed > 0: log("testing scheduler %d%% (collected %d instance in %d seconds)"%(elapsed/60*100, self.results_count, elapsed)) sleep(2000) elapsed = time()-start result.add_message(True, 'Summary Collected %d instance in %d seconds: %d/s'%(self.results_count, elapsed, self.results_count/elapsed)) self.check_one(result, "rand", 5, 10) self.check_one(result, "1s", 55, 65) self.check_one(result, "short", 10, 14) self.check_one(result, "30s", 1, 3) self.check_one(result, "explicit", 10, 14) self.check_one(result, "10s", 5, 7) return result
def run_test_proc(self): master = TestResult('Checking check_process') result = TestResult('0 notepads running') for j in range(0, 3): result.append(self.test_one_proc_int('notepad.exe', 0, j)) master.add(result) pids = [] for i in range(1, 4): result = TestResult('%d notepads running' % i) log('Starting notepad...') handle = subprocess.Popen('notepad.exe', shell=False) sleep(500) pids.append(handle.pid) for j in range(0, 3): result.append(self.test_one_proc_int('notepad.exe', i, j)) master.add(result) for p in pids: subprocess.Popen("taskkill /F /T /PID %i" % p, shell=True) return master
def run_test_proc(self): master = TestResult('Checking check_process') result = TestResult('0 notepads running') for j in range(0,3): result.append(self.test_one_proc_int('notepad.exe', 0, j)) master.add(result) pids = [] for i in range(1,4): result = TestResult('%d notepads running'%i) log('Starting notepad...') handle = subprocess.Popen('notepad.exe', shell=False) sleep(500) pids.append(handle.pid) for j in range(0,3): result.append(self.test_one_proc_int('notepad.exe', i, j)) master.add(result) for p in pids: subprocess.Popen("taskkill /F /T /PID %i"%p , shell=True) return master
def run_test(self): result = TestResult('Checking CheckEventLog') cache = TestResult('Checking CheckEventLog CACHE') sleep(2000) #(res, msg, perf) = self.core.simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) #cache.assert_equals(res, status.OK, "Validate cache is empty") #cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) a_list = [ 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a' ] result.add( self.test_create('Application Error', 1000, 'error', 'success', 0, 0, a_list)) result.add( self.test_create('Application Error', 1000, 'warning', 'informational', 1, 5, a_list)) result.add( self.test_create('Application Error', 1000, 'success', 'warning', 2, 5, a_list)) result.add( self.test_create('Application Error', 1000, 'info', 'error', 3, 5, a_list)) for x in range(1, 10): log('Waiting...%d/4.' % len(self.messages)) sleep(100) if len(self.messages) == 4: break log('Recieved %d messages.' % len(self.messages)) result.assert_equals(len(self.messages), 4, 'Verify that all 4 messages are sent through') for msg in self.messages: if msg.message.startswith('X1'): r = TestResult('Validating message X1') r.assert_equals(msg.message, 'X1 warning Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.WARNING, 'Verify status') result.add(r) elif msg.message.startswith('X2'): r = TestResult('Validating message X2') r.assert_equals(msg.message, 'X2 success Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_02', 'Verify channel') r.assert_equals(msg.tag, '002', 'Verify tag') r.assert_equals(msg.status, status.CRITICAL, 'Verify status') result.add(r) elif msg.message.startswith('X3'): r = TestResult('Validating message X3') r.assert_equals(msg.message, 'X3 info Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.UNKNOWN, 'Verify status') result.add(r) elif msg.message.startswith('X4'): r = TestResult('Validating message X4') r.assert_equals(msg.message, 'X4 error Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.OK, 'Verify status') result.add(r) #(res, msg, perf) = self.core.simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:4']) #cache.assert_equals(res, status.CRITICAL, "Validate cache has items: %s"%msg) #cache.assert_equals(msg, 'X4 error Application Error: , X1 warning Application Error: , X2 success Application Error: , X3 info Application Error: , eventlog: 4 = critical', "Validate cache message") #cache.assert_equals(perf, "'eventlog'=4;1;4", "Validate cache performance") #(res, msg, perf) = self.core.simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) #cache.assert_equals(res, status.OK, "Validate cache is empty (again)") #cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) #result.add(cache) r = TestResult('Checking filters') r.add( self.test_w_expected('id = 1000 and generated gt 1m', '%generated%', 0)) r.add( self.test_w_expected('id = 1000 and generated gt -1m', '%generated%', 4)) r.add( self.test_w_expected( 'id = 1000 and generated gt -1m and id = 1000', '%generated%: %id%, %category%', 4)) r.add( self.test_w_expected( 'id = 1000 and generated gt -1m and category = 1', '%category%', 1)) r.add( self.test_w_expected( 'id = 1000 and generated gt -1m and category = 0', '%category%', 1)) r.add( self.test_w_expected( "id = 1000 and generated gt -1m and level = 'error'", '%level%', 1)) r.add( self.test_w_expected( "id = 1000 and generated gt -1m and level = 'warning'", '%level%', 1)) result.add(r) r = TestResult('Checking syntax') r.add( self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%source% - %type% - %category%', 'Application Error - error - 0')) r.add( self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%source% - %type% - %category%', 'Application Error - warning - 1')) r.add( self.test_syntax('id = 1000 and generated gt -2m and category = 2', '%source% - %type% - %category%', 'Application Error - information - 2')) r.add( self.test_syntax('id = 1000 and generated gt -2m and category = 3', '%source% - %type% - %category%', 'Application Error - information - 3')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%facility% - %qualifier% - %customer%', '0 - 0 - 0')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%facility% - %qualifier% - %customer%', '5 - 5 - 0')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%rawid% - %severity% - %log%', '1000 - success - Application')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%rawid% - %severity% - %log%', '1074070504 - informational - Application')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 2', '%rawid% - %severity% - %log%', '2147812328 - warning - Application')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 3', '%rawid% - %severity% - %log%', '3221554152 - error - Application')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) #r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) result.add(r) return result
def run_test(self): result = TestResult('Checking CheckEventLog') cache = TestResult('Checking CheckEventLog CACHE') (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) cache.assert_equals(res, status.OK, "Validate cache is empty") cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) a_list = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'] result.add_message(self.test_create('Application Error', 1000, 'error', 'success', 0, 0, a_list), 'Testing to create a log message') result.add_message(self.test_create('Application Error', 1000, 'warning', 'informational', 1, 5, a_list), 'Testing to create a log message') result.add_message(self.test_create('Application Error', 1000, 'success', 'warning', 2, 5, a_list), 'Testing to create a log message') result.add_message(self.test_create('Application Error', 1000, 'info', 'error', 3, 5, a_list), 'Testing to create a log message') for x in range(1,10): sleep(100) if len(self.messages) == 4: break log('Recieved %d messages.'%len(self.messages)) result.assert_equals(len(self.messages), 4, 'Verify that all 4 messages are sent through') for msg in self.messages: if msg.message.startswith('X1'): r = TestResult('Validating message X1') r.assert_equals(msg.message, 'X1 warning Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.WARNING, 'Verify status') result.add(r) elif msg.message.startswith('X2'): r = TestResult('Validating message X2') r.assert_equals(msg.message, 'X2 success Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_02', 'Verify channel') r.assert_equals(msg.tag, '002', 'Verify tag') r.assert_equals(msg.status, status.CRITICAL, 'Verify status') result.add(r) elif msg.message.startswith('X3'): r = TestResult('Validating message X3') r.assert_equals(msg.message, 'X3 info Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.UNKNOWN, 'Verify status') result.add(r) elif msg.message.startswith('X4'): r = TestResult('Validating message X4') r.assert_equals(msg.message, 'X4 error Application Error: ', 'Verify message') r.assert_equals(msg.channel, 'pytest_evlog_01', 'Verify channel') r.assert_equals(msg.tag, '001', 'Verify tag') r.assert_equals(msg.status, status.OK, 'Verify status') result.add(r) (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:4']) cache.assert_equals(res, status.CRITICAL, "Validate cache has items: %s"%msg) cache.assert_equals(msg, 'X4 error Application Error: , X1 warning Application Error: , X2 success Application Error: , X3 info Application Error: , eventlog: 4 = critical', "Validate cache message") cache.assert_equals(perf, "'eventlog'=4;1;4", "Validate cache performance") (res, msg, perf) = Core.get().simple_query('CheckEventLogCACHE', ['warn=eq:1', 'crit=eq:2']) cache.assert_equals(res, status.OK, "Validate cache is empty (again)") cache.assert_equals(msg, 'Eventlog check ok', "Validate cache is ok: %s"%msg) result.add(cache) r = TestResult('Checking filters') r.add(self.test_w_expected('id = 1000 and generated gt 1m', '%generated%', 0)) r.add(self.test_w_expected('id = 1000 and generated gt -1m', '%generated%', 4)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and id = 1000', '%generated%: %id%, %category%', 4)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and category = 1', '%category%', 1)) r.add(self.test_w_expected('id = 1000 and generated gt -1m and category = 0', '%category%', 1)) r.add(self.test_w_expected("id = 1000 and generated gt -1m and level = 'error'", '%level%', 1)) r.add(self.test_w_expected("id = 1000 and generated gt -1m and level = 'info'", '%level%', 1)) result.add(r) r = TestResult('Checking syntax') r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%source% - %type% - %category%', 'Application Error - error - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%source% - %type% - %category%', 'Application Error - warning - 1')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 2', '%source% - %type% - %category%', 'Application Error - success - 2')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 3', '%source% - %type% - %category%', 'Application Error - info - 3')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%facility% - %qualifier% - %customer%', '0 - 0 - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%facility% - %qualifier% - %customer%', '5 - 5 - 0')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%rawid% - %severity% - %log%', '1000 - success - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%rawid% - %severity% - %log%', '1074070504 - informational - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 2', '%rawid% - %severity% - %log%', '2147812328 - warning - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 3', '%rawid% - %severity% - %log%', '3221554152 - error - Application')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 0', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) r.add(self.test_syntax('id = 1000 and generated gt -2m and category = 1', '%id% - %strings%', '1000 - a, a, a, a, a, a, a, a, a, a, a, a, a, ')) result.add(r) return result