[Asterisk-code-review] Add syslog logging to test runs. (testsuite[master])

Mark Michelson asteriskteam at digium.com
Tue Nov 3 14:14:35 CST 2015


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/1560

Change subject: Add syslog logging to test runs.
......................................................................

Add syslog logging to test runs.

This adds some simple syslog logging when running the testsuite. This
will print when the test run begins, when each individual test begins,
when each individual test ends, and when all tests have concluded.

The reason this is being added is because on some monitored test agents,
we have seen increases in memory use and other system resources. The
problem is, since tests aren't failing, their logs are removed from the
system after the test has concluded. By having some simple syslog
logging, our monitoring tools can correlate increased system resource
usage with specific tests.

Change-Id: I33d7fba756a83e9c4d3a7c2d51482c44b97bf67c
---
M runtests.py
1 file changed, 15 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/60/1560/1

diff --git a/runtests.py b/runtests.py
index b971004..d0a5027 100755
--- a/runtests.py
+++ b/runtests.py
@@ -20,6 +20,7 @@
 import random
 import select
 import signal
+import syslog
 
 try:
     import lxml.etree as ET
@@ -164,7 +165,9 @@
                 status = 'passed'
             else:
                 status = 'failed'
-            print 'Test %s %s\n' % (cmd, status)
+            pass_str = 'Test %s %s\n' % (cmd, status)
+            print pass_str
+            syslog.syslog(pass_str)
 
         else:
             print "FAILED TO EXECUTE %s, it must exist and be executable" % cmd
@@ -559,7 +562,9 @@
                     self.total_skipped += 1
                     continue
 
-            print "--> Running test '%s' ..." % t.test_name
+            running_str = "--> Running test '%s' ..." % t.test_name
+            print running_str
+            syslog.syslog(running_str)
 
             if self.options.dry_run:
                 t.passed = True
@@ -779,9 +784,13 @@
     while ((iteration < options.number or continue_forever) and not abandon_test_suite):
 
         test_suite = TestSuite(ast_version, options)
+        syslog.openlog(ident='AsteriskTestsuite', logoption=syslog.LOG_PID)
 
-        print "Running tests for Asterisk {0} (run {1})...\n".format(
+        running_str = "Running tests for Asterisk {0} (run {1})...\n".format(
             str(ast_version).strip('\n'), iteration + 1)
+        print running_str
+        syslog.syslog(running_str)
+
         test_suite.run()
         test_suite.write_results_xml(doc, doc.documentElement)
 
@@ -816,6 +825,9 @@
     print "\n"
     print doc.toprettyxml("  ", encoding="utf-8")
 
+    syslog.syslog("All tests concluded")
+    syslog.closelog()
+
     return test_suite.total_failures
 
 

-- 
To view, visit https://gerrit.asterisk.org/1560
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33d7fba756a83e9c4d3a7c2d51482c44b97bf67c
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list