[asterisk-commits] Add syslog logging to test runs. (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 4 17:45:35 CST 2015


Anonymous Coward #1000019 has submitted this change and it was merged.

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, 23 insertions(+), 3 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/runtests.py b/runtests.py
index b971004..638652a 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,10 @@
                 status = 'passed'
             else:
                 status = 'failed'
-            print 'Test %s %s\n' % (cmd, status)
+            pass_str = 'Test %s %s\n' % (cmd, status)
+            print pass_str
+            if self.options.syslog:
+                syslog.syslog(pass_str)
 
         else:
             print "FAILED TO EXECUTE %s, it must exist and be executable" % cmd
@@ -559,7 +563,10 @@
                     self.total_skipped += 1
                     continue
 
-            print "--> Running test '%s' ..." % t.test_name
+            running_str = "--> Running test '%s' ..." % t.test_name
+            print running_str
+            if self.options.syslog:
+                syslog.syslog(running_str)
 
             if self.options.dry_run:
                 t.passed = True
@@ -711,6 +718,9 @@
     parser.add_option("-L", "--list-tags", action="store_true",
                       dest="list_tags", default=False,
                       help="List available tags")
+    parser.add_option("-s", "--syslog", action="store_true",
+                      dest="syslog", default=False,
+                      help="Log test start/stop to syslog")
     parser.add_option("-t", "--test", action="append", default=[],
                       dest="tests",
                       help="Run a single specified test (directory) instead "
@@ -776,12 +786,18 @@
 
     continue_forever = True if options.number < 0 else False
     iteration = 0
+    if options.syslog:
+        syslog.openlog('AsteriskTestsuite', syslog.LOG_PID)
     while ((iteration < options.number or continue_forever) and not abandon_test_suite):
 
         test_suite = TestSuite(ast_version, options)
 
-        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
+        if options.syslog:
+            syslog.syslog(running_str)
+
         test_suite.run()
         test_suite.write_results_xml(doc, doc.documentElement)
 
@@ -816,6 +832,10 @@
     print "\n"
     print doc.toprettyxml("  ", encoding="utf-8")
 
+    if options.syslog:
+        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: merged
Gerrit-Change-Id: I33d7fba756a83e9c4d3a7c2d51482c44b97bf67c
Gerrit-PatchSet: 4
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list