From b840c76da175bd4700a38f70a203365b138fca87 Mon Sep 17 00:00:00 2001
From: al_xipe <al_xipe@localhost>
Date: Wed, 29 Aug 2007 19:29:47 +0000
Subject: [PATCH] 1. fix for case sensitive string search in groups 2. fix for memory hungry test and server log parsing - now uses temporary files instead of memory 3. update the test verdict to reflect inconclusive and known issue states 4. fix for wrapping log lines longer than 100 characters 5. fix to show known issue state only if a test fails 6. make log parsing more robust when the server is not installed where expected
---
opends/tests/functional-tests/shared/functions/utils.xml | 144 ++++++++++++++++++++++++-----------------------
1 files changed, 74 insertions(+), 70 deletions(-)
diff --git a/opends/tests/functional-tests/shared/functions/utils.xml b/opends/tests/functional-tests/shared/functions/utils.xml
index 89ff9cd..1189317 100755
--- a/opends/tests/functional-tests/shared/functions/utils.xml
+++ b/opends/tests/functional-tests/shared/functions/utils.xml
@@ -557,14 +557,12 @@
testcaseStart=int(time.time())
testcaseStartTime=strftime("%Y%m%d@%H:%M:%S",localtime())
issuesList=[]
- errorlog=open('%s/%s/logs/errors' % (TMPDIR,OPENDSNAME),'a')
- errorlog.seek(0,2)
- errorlog.write('Begin testcase %s\n' % STAXCurrentTestcase)
- errorlog.close()
- accesslog=open('%s/%s/logs/access' % (TMPDIR,OPENDSNAME),'a')
- accesslog.seek(0,2)
- accesslog.write('Begin testcase %s\n' % STAXCurrentTestcase)
- accesslog.close()
+ for logType in ['errors','access']:
+ if os.path.exists('%s/%s/logs/%s' % (TMPDIR,OPENDSNAME,logType)):
+ logfile=open('%s/%s/logs/%s' % (TMPDIR,OPENDSNAME,logType),'a')
+ logfile.seek(0,2)
+ logfile.write('Begin testcase %s\n' % STAXCurrentTestcase)
+ logfile.close()
</script>
<call function="'testCase_StartBanner'" />
</sequence>
@@ -605,15 +603,19 @@
numFail=int(STAFResult['numFails'])
else:
numFail=int(0)
-
+
+ if numFail == 0:
+ if numPass == 0:
+ _status='INCONCLUSIVE'
+ else:
+ _status='PASS'
+ else:
+ if len(issuesList)==0:
+ _status='FAIL'
+ else:
+ _status='KNOWN ISSUES (%s)' % issuesList.join(',')
</script>
-
- <if expr="numFail > 0">
- <message level="'status'">'## Test Verdict: FAIL ##'</message>
- <else>
- <message level="'status'">'## Test Verdict: PASS ##'</message>
- </else>
- </if>
+ <message level="'status'">'## Test Verdict: %s ##' % _status</message>
<call function="'testCase_EndBanner'" />
<script>
@@ -628,9 +630,12 @@
<script>
class Test:
def __init__(self, group, suite, fullname, start, stop, failures, successes, issues, duration):
- self.log=''
- self.error=''
- self.access=''
+ self.log='%s/test.log' % TMPDIR
+ self.errors='%s/error.log' % TMPDIR
+ self.access='%s/access.log' % TMPDIR
+ open(self.log,'w').write('')
+ open(self.errors,'w').write('')
+ open(self.access,'w').write('')
self.group=group
self.suite=suite
self.fullname=fullname
@@ -643,19 +648,19 @@
else:
self.name=fullname
self.duration = duration
- if len(issues) == 0:
- if failures == 0:
- if successes == 0:
- self.result='inconclusive'
- else:
- self.result='pass'
+ if failures == 0:
+ if successes == 0:
+ self.result='inconclusive'
else:
- self.result='fail'
+ self.result='pass'
else:
- self.result='known'
+ if len(issues) == 0:
+ self.result='fail'
+ else:
+ self.result='known'
self.issues=issues
-
-
+
+
def toXML(self):
xml = ' <test>%s' % newLine
xml += ' <name>%s</name>%s' % (self.name,newLine)
@@ -670,13 +675,13 @@
xml += ' <issue>%s</issue>%s' % (issue,newLine)
xml += ' </issues>%s' % newLine
xml += ' <log>\n<![CDATA[%s' % newLine
- xml += self.log
+ xml += open(self.log).read()
xml += ' ]]></log>%s' % newLine
xml += ' <error>\n<![CDATA[%s' % newLine
- xml += self.error
+ xml += open(self.errors).read()
xml += ' ]]></error>%s' % newLine
xml += ' <access>\n<![CDATA[%s' % newLine
- xml += self.access
+ xml += open(self.access).read()
xml += ' ]]></access>%s' % newLine
xml += ' </test>%s' % newLine
return xml
@@ -684,22 +689,31 @@
def appendLog(self, category, log):
wrappedLog=''
for _line in log.splitlines():
+ _line=_line.strip()
_leftPadding=''
while len(_line)>100:
- _logChunk=line[:100]
+ _logChunk=_line[:100]
_line=_line[100:]
wrappedLog+='%s%s%s' % (_leftPadding,_logChunk,newLine)
_leftPadding='... '
- wrappedLog += '%s%s%s' % (_leftPadding,log,newLine)
+ wrappedLog += '%s%s%s' % (_leftPadding,_line,newLine)
if category == 'access':
- self.access+=wrappedLog
+ fh=open(self.access,'a')
elif category == 'error':
- self.error+=wrappedLog
+ fh=open(self.errors,'a')
else:
- self.log += wrappedLog
+ fh=open(self.log,'a')
+ fh.seek(0,2)
+ fh.write(wrappedLog)
+ fh.close()
def getName(self):
return self.name
+
+ def clean(self):
+ for _file in [self.log,self.errors,self.access]:
+ if os.path.exists(_file):
+ os.remove(_file)
testcaseStop=int(time.time())
testcaseDuration=testcaseStop-testcaseStart
@@ -734,46 +748,36 @@
# parse the server's error log
# TODO: figure out how to do this for multiple instance for the replication
# tests for example
- errorlog=open('%s/%s/logs/errors' % (TMPDIR,OPENDSNAME),'a')
- errorlog.seek(0,2)
- errorlog.write('End testcase %s\n' % STAXCurrentTestcase)
- errorlog.close()
- accesslog=open('%s/%s/logs/access' % (TMPDIR,OPENDSNAME),'a')
- accesslog.seek(0,2)
- accesslog.write('End testcase %s\n' % STAXCurrentTestcase)
- accesslog.close()
-
- errorlog=open('%s/%s/logs/errors' % (TMPDIR,OPENDSNAME), 'r')
- _log=''
- _doLog=False
- for line in errorlog.readlines():
- if line.startswith('End testcase %s' % STAXCurrentTestcase):
+ for logType in ['errors','access']:
+ if os.path.exists('%s/%s/logs/%s' % (TMPDIR,OPENDSNAME,logType)):
+ logfile=open('%s/%s/logs/%s' % (TMPDIR,OPENDSNAME,logType),'a')
+ logfile.seek(0,2)
+ logfile.write('End testcase %s\n' % STAXCurrentTestcase)
+ logfile.close()
+ logfile=open('%s/%s/logs/%s' % (TMPDIR,OPENDSNAME,logType), 'r')
+ _log=''
_doLog=False
- if _doLog:
- _log+=line
- if line.startswith('Begin testcase %s' % STAXCurrentTestcase):
- _doLog=True
- errorlog.close()
- thisTest.appendLog('error', _log)
-
- accesslog=open('%s/%s/logs/access' % (TMPDIR,OPENDSNAME), 'r')
- _log=''
- _doLog=False
- for line in accesslog.readlines():
- if line.startswith('End testcase %s' % STAXCurrentTestcase):
- _doLog=False
- if _doLog:
- _log+=line
- if line.startswith('Begin testcase %s' % STAXCurrentTestcase):
- _doLog=True
- accesslog.close()
- thisTest.appendLog('access', _log)
+ while True:
+ line = logfile.readline()
+ if not line:
+ break
+ if line.startswith('End testcase %s' % STAXCurrentTestcase):
+ _doLog=False
+ if _doLog:
+ _log+=line
+ if line.startswith('Begin testcase %s' % STAXCurrentTestcase):
+ _doLog=True
+ logfile.close()
+ thisTest.appendLog(logType, _log)
# save to test log
testlog=open('%s/tests-log.xml' % TMPDIR,'a')
testlog.seek(0,2)
testlog.write(thisTest.toXML())
testlog.close()
+ # clean the temporary log files for this test
+ # this MUST be done AFTER the call to toXML or the logs will appear empty
+ thisTest.clean()
</script>
</sequence>
</function>
--
Gitblit v1.10.0