| | |
| | | <function-no-args /> |
| | | <sequence> |
| | | <script> |
| | | import time |
| | | 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() |
| | | </script> |
| | | <call function="'testCase_StartBanner'" /> |
| | | </sequence> |
| | |
| | | SignalRaised='' |
| | | </script> |
| | | |
| | | <!-- Query the test case results --> |
| | | <!-- Query the test case results --> |
| | | <call function="'queryTestcase'" /> |
| | | |
| | | <script> |
| | |
| | | 'endat' : testcaseEndTime } |
| | | </call> |
| | | <script> |
| | | import re |
| | | |
| | | class Matcher: |
| | | def search(self, r,s): |
| | | _tmp = re.compile(r) |
| | | self.value = _tmp.match(s) |
| | | return self.value |
| | | def __getitem__(self, i): |
| | | return self.value.group(i) |
| | | |
| | | class Test: |
| | | def __init__(self, group, suite, fullname, start, stop, failures, successes, issues): |
| | | def __init__(self, group, suite, fullname, start, stop, failures, successes, issues, duration): |
| | | self.log='' |
| | | self.error='' |
| | | self.access='' |
| | | self.group=group |
| | | self.suite=suite |
| | | self.fullname=fullname |
| | |
| | | self.name=''.join(tmp) |
| | | else: |
| | | self.name=fullname |
| | | self.duration = 0 |
| | | self.duration = duration |
| | | if len(issues) == 0: |
| | | if failures == 0: |
| | | if successes == 0: |
| | |
| | | |
| | | |
| | | def toXML(self): |
| | | xml = ' <test>\n' |
| | | xml += ' <name>%s</name>\n' % self.name |
| | | xml += ' <group>%s</group>\n' % self.group |
| | | xml += ' <suite>%s</suite>\n' % self.suite |
| | | xml += ' <start>%s</start>\n' % self.start |
| | | xml += ' <stop>%s</stop>\n' % self.stop |
| | | xml += ' <result>%s</result>\n' % self.result |
| | | xml += ' <duration>%d</duration>\n' % self.duration |
| | | xml += ' <issues>\n' |
| | | xml = ' <test>%s' % newLine |
| | | xml += ' <name>%s</name>%s' % (self.name,newLine) |
| | | xml += ' <group>%s</group>%s' % (self.group,newLine) |
| | | xml += ' <suite>%s</suite>%s' % (self.suite,newLine) |
| | | xml += ' <start>%s</start>%s' % (self.start,newLine) |
| | | xml += ' <stop>%s</stop>%s' % (self.stop,newLine) |
| | | xml += ' <result>%s</result>%s' % (self.result,newLine) |
| | | xml += ' <duration>%d</duration>%s' % (self.duration,newLine) |
| | | xml += ' <issues>%s' % newLine |
| | | for issue in self.issues: |
| | | xml += ' <issue>%s</issue>\n' % issue |
| | | xml += ' </issues>\n' |
| | | xml += ' <log>\n<![CDATA[' |
| | | xml += '%s' % self.log |
| | | xml += ' ]]></log>\n' |
| | | xml += ' </test>\n' |
| | | xml += ' <issue>%s</issue>%s' % (issue,newLine) |
| | | xml += ' </issues>%s' % newLine |
| | | xml += ' <log>\n<![CDATA[%s' % newLine |
| | | xml += self.log |
| | | xml += ' ]]></log>%s' % newLine |
| | | xml += ' <error>\n<![CDATA[%s' % newLine |
| | | xml += self.error |
| | | xml += ' ]]></error>%s' % newLine |
| | | xml += ' <access>\n<![CDATA[%s' % newLine |
| | | xml += self.access |
| | | xml += ' ]]></access>%s' % newLine |
| | | xml += ' </test>%s' % newLine |
| | | return xml |
| | | |
| | | def appendLog(self, log): |
| | | |
| | | def appendLog(self, category, log): |
| | | _leftPadding='' |
| | | wrappedLog='' |
| | | while len(log)>100: |
| | | _logChunk=log[:100] |
| | | log=log[100:] |
| | | self.log+='%s%s\n' % (_leftPadding,_logChunk) |
| | | wrappedLog+='%s%s%s' % (_leftPadding,_logChunk,newLine) |
| | | _leftPadding='... ' |
| | | self.log += '%s%s\n' % (_leftPadding,log) |
| | | wrappedLog += '%s%s%s' % (_leftPadding,log,newLine) |
| | | if category == 'access': |
| | | self.access+=wrappedLog |
| | | elif category == 'error': |
| | | self.error+=wrappedLog |
| | | else: |
| | | self.log += wrappedLog |
| | | |
| | | def getName(self): |
| | | return self.name |
| | | |
| | | thisTest = Test(CurrentTestPath['group'],CurrentTestPath['suite'],STAXCurrentTestcase, testcaseStartTime,testcaseEndTime,numFail,numPass,issuesList) |
| | | |
| | | |
| | | testcaseStop=int(time.time()) |
| | | testcaseDuration=testcaseStop-testcaseStart |
| | | thisTest = Test(CurrentTestPath['group'],CurrentTestPath['suite'],STAXCurrentTestcase, testcaseStartTime,testcaseEndTime,numFail,numPass,issuesList,testcaseDuration) |
| | | |
| | | doLog = False |
| | | testlog=open('%s/tests-log.xml' % TMPDIR,'a') |
| | | testlog.seek(0,2) |
| | | |
| | | |
| | | # loop through the log lines |
| | | for element in STAFResult: |
| | | level=element['level'] |
| | |
| | | |
| | | # if the current element is actually this test's output then log it |
| | | if doLog == True: |
| | | thisTest.appendLog(element['message']) |
| | | thisTest.appendLog('test',element['message']) |
| | | |
| | | # this test is AFTER the append log so we don't get the |
| | | # "starting testcase ..." header in the XML |
| | |
| | | # log facility) |
| | | if tmp[3] == thisTest.getName(): |
| | | doLog=True |
| | | |
| | | |
| | | # 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): |
| | | _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) |
| | | |
| | | # save to test log |
| | | testlog=open('%s/tests-log.xml' % TMPDIR,'a') |
| | | testlog.seek(0,2) |
| | | testlog.write(thisTest.toXML()) |
| | | testlog.close() |
| | | </script> |