[Asterisk-code-review] Testsuite/ARI: Added a pluggable module for log validation. (testsuite[master])

Benjamin Keith Ford asteriskteam at digium.com
Tue Jul 28 09:21:13 CDT 2015


Benjamin Keith Ford has uploaded a new change for review.

  https://gerrit.asterisk.org/978

Change subject: Testsuite/ARI: Added a pluggable module for log validation.
......................................................................

Testsuite/ARI: Added a pluggable module for log validation.

This pluggable module is used to verify a log files existence. It
will look inside the current test's log directory and check to see
if the given file is present or not. Another option, pass-if-present,
can be set to True or False based on what we expect the test to do.

* Added log validation pluggable module
* Log files can be verified in the testuite

ASTERISK-25252

Change-Id: I3bf8e63071e579552838e814aeda0ba5d6bb6180
---
M lib/python/asterisk/pluggable_modules.py
1 file changed, 28 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/78/978/1

diff --git a/lib/python/asterisk/pluggable_modules.py b/lib/python/asterisk/pluggable_modules.py
index b1be1f8..66e5ec8 100755
--- a/lib/python/asterisk/pluggable_modules.py
+++ b/lib/python/asterisk/pluggable_modules.py
@@ -812,6 +812,34 @@
 PLUGGABLE_ACTION_REGISTRY.register("logger", LogActionModule)
 
 
+class ValidateLogActionModule(object):
+    """An action module that validates a log files existence."""
+
+    def __init__(self, test_object, config):
+        self.test_object = test_object
+        self.logfile = config["logfile"]
+        self.pass_if_present = config["pass-if-present"]
+
+    def run(self, triggered_by, source, extra):
+        """Check to see if log file is present or not."""
+        files = []
+        testpath = ('%s/var/log/asterisk' %
+                    (self.test_object.ast[0].base))
+        for (dirpath, dirnames, filenames) in os.walk(testpath):
+            files.extend(filenames)
+            break
+        if self.logfile in files:
+            if (self.pass_if_present):
+                self.test_object.set_passed(True)
+            else:
+                self.test_object.set_passed(False)
+        else:
+            if (self.pass_if_present):
+                self.test_object.set_passed(False)
+            else:
+                self.test_object.set_passed(True)
+PLUGGABLE_ACTION_REGISTRY.register("validate-log", ValidateLogActionModule)
+
 class CallbackActionModule(object):
     """An action module that calls the specified callback."""
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bf8e63071e579552838e814aeda0ba5d6bb6180
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>



More information about the asterisk-code-review mailing list