From 947f30ad4e7241fe6b3e2ab9dd7d319ed550f4d1 Mon Sep 17 00:00:00 2001
From: Gary Williams <gary.williams@forgerock.com>
Date: Tue, 20 Mar 2012 10:27:47 +0000
Subject: [PATCH] Factor out tail log file method in functional tests.
---
opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml | 17 +----------------
opendj-sdk/opends/tests/staf-tests/shared/python/common.py | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
index 8fc4cef..e20df96 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/dsadm.xml
@@ -659,12 +659,6 @@
STAFCmdParams=' '.join(STAFCmdParamsList)
from java.util import Date
- from java.text import SimpleDateFormat
- import re
-
- pattern=re.compile("\[(.*)\]")
- formatter = SimpleDateFormat("dd/MMM/yy:H:m:s Z")
-
stop_current_time = Date()
</script>
@@ -720,17 +714,8 @@
}
</call>
<script>
- for line in STAXResult[1].split('\n'):
- mymatch = pattern.match(line)
- if mymatch:
- timestamp=mymatch.group(1)
- timestamp_object = formatter.parse(timestamp)
- if date_compare(stop_current_time,timestamp_object) == 'Less':
- print line
+ tail_logfile(STAXResult,stop_current_time)
</script>
- <message>
- 'Result = %s' % STAXResult
- </message>
</sequence>
</function>
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/python/common.py b/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
index b50c9bf..8efe129 100644
--- a/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
+++ b/opendj-sdk/opends/tests/staf-tests/shared/python/common.py
@@ -58,7 +58,8 @@
"md5_hash" ,
"value_not_string" ,
"get_system_uid" ,
- "date_compare"
+ "date_compare" ,
+ "tail_logfile"
]
class format_testcase:
@@ -889,3 +890,18 @@
return "Less"
else:
return "Equal"
+
+def tail_logfile(log_file,from_time):
+ from java.text import SimpleDateFormat
+ import re
+
+ pattern=re.compile("\[(.*)\]")
+ formatter = SimpleDateFormat("dd/MMM/yy:H:m:s Z")
+
+ for line in log_file[1].split('\n'):
+ mymatch = pattern.match(line)
+ if mymatch:
+ timestamp=mymatch.group(1)
+ timestamp_object = formatter.parse(timestamp)
+ if date_compare(from_time,timestamp_object) == 'Less':
+ print line
--
Gitblit v1.10.0