log.xml revision d81978a0815d5b8a75633c35e3e1f8708d36f017
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2008 Sun Microsystems, Inc.
! -->
<stax>
<defaultcall function="main_log"/>
<!-- ************************************************************ -->
<function name="main_log" scope="local">
<sequence>
<message log="1">'main_log() do nothing'</message>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="createLogDir" scope="local">
<function-prolog>
'Create log directories for system test, using LOG_DIR variable'
</function-prolog>
<sequence>
<message log="1">
'Logs output set to %s' % LOG_DIR
</message>
<!-- Create folders -->
<call function="'createFolder'">
{ 'location' : STAF_LOCAL_HOSTNAME,
'foldername' : LOG_DIR,
'fileFd' : NO_FILE
}
</call>
<call function="'createFolder'">
{ 'location' : STAF_LOCAL_HOSTNAME,
'foldername' : LOG_TMP_DIR,
'fileFd' : NO_FILE
}
</call>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="getLogFileName" scope="local">
<function-prolog>
'return a log file name'
</function-prolog>
<function-map-args>
<function-arg-def name="type" type="required"/>
<function-arg-def name="object" type="required"/>
<function-arg-def name="prefix" type="required"/>
</function-map-args>
<sequence>
<if expr="type == 'client'">
<script>
logName = '%s_%s_%s_%s' % \
( prefix,\
object.getName(),object.getHost(),object.getId())
</script>
<elseif expr="type == 'instance'">
<script>
logName = '%s_%s_%s' % (prefix,object.getName(),object.getHost())
</script>
</elseif>
<else>
<script>
logName = 'getLogFileName_%s' % NOT_DEFINED
</script>
</else>
</if>
<script>
logFile = '%s/%s.xml' % (LOG_TMP_DIR,logName)
</script>
<return>
[ logFile , logName ]
</return>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeSummary" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="scenario" type="required"/>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<script>
def writeSummaryTag(objPhase):
if objPhase.getRun() == 'true':
str = '&lt;phaseSummmary'
str = '%s name=\"%s\"' % (str,objPhase.getName())
str = '%s errNum=\"%s\"' % (str,objPhase.getErrNum())
str = '%s percentage=\"%s\"' % (str,objPhase.getPercentage())
str = '%s start=\"%s\"' % (str,objPhase.getStartTime())
str = '%s stop=\"%s\"' % (str,objPhase.getStopTime())
str = '%s/&gt;\n' % str
fileFd.write(str)
fileFd.write('&lt;summary&gt;\n')
# write scenario informations into summary part
str = '&lt;scenario name=\"%s\"' % scenario.getName()
str = '%s duration=\"%s%s\" &gt;\n' % \
(str,scenario.getDurationTime(),scenario.getDurationUnit())
str = '%s %s \n&lt;/scenario&gt;\n' % \
(str,scenario.getDescription())
fileFd.write(str)
writeSummaryTag(PHASE_PARSER)
writeSummaryTag(PHASE_INSTALLATION)
writeSummaryTag(PHASE_GEN_LDIF)
writeSummaryTag(PHASE_PRE_CONFIGURATION)
writeSummaryTag(PHASE_CONFIGURATION)
writeSummaryTag(PHASE_POST_CONFIGURATION)
writeSummaryTag(PHASE_SCHEDULER)
writeSummaryTag(PHASE_VERDICT)
</script>
<!-- write link to comments.txt file -->
<script>
commentsFile = 'comments.txt'
commentsFilePath = '%s/%s' % (LOG_DIR,commentsFile)
commentsFileFd = open(commentsFilePath,'w')
commentsFileFd.write('Additional comments...\n')
commentsFileFd.close()
</script>
<call function="'writeMessage'">
{
'content' : 'Additional comments : %s' % commentsFile,
'xlink' : commentsFile,
'fileFd' : fileFd
}
</call>
<script>
fileFd.write('&lt;/summary&gt;\n')
</script>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="mergeClientsFiles" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="scheduler" type="required">
<function-arg-description>
scheduler object
</function-arg-description>
</function-arg-def>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<iterate in="scheduler" var="module">
<sequence>
<!--== If module is disabled, just write it in xml result ==-->
<if expr="module.getEnabled() == 'false'">
<script>
fileFd.write('\n&lt;module name=\"%s\" enabled=\"false\"/&gt;\n'\
% module.getName() )
</script>
<!--== Module is enabled and have clients log files ==-->
<else>
<sequence>
<!--== Write module tag ==-->
<script>
fileFd.write('\n&lt;module name=\"%s\" enabled=\"true\"&gt;\n'\
% module.getName() )
</script>
<!--== Concat each module's clients log files ==-->
<script>
cFileList = []
</script>
<iterate in="module.getClients()" var="client">
<sequence>
<call function="'getLogFileName'">
{
'type' : 'client',
'object' : client,
'prefix' : 'client'
}
</call>
<script>
cFileList.append(STAXResult[0])
</script>
</sequence>
</iterate>
<!--== Merge files ==-->
<call function="'mergeFiles'">
{
'fileList' : cFileList,
'fileFd' : fileFd
}
</call>
<!--== Write end module tag ==-->
<script>
fileFd.write('\n&lt;/module&gt;\n')
</script>
</sequence>
</else>
</if>
</sequence>
</iterate>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="mergeFiles" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileList" type="required"/>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<script>
msg = ''
</script>
<if expr="len(fileList) != 0">
<iterate in="fileList" var="cFile">
<sequence>
<script>
try:
cFd = open(cFile,'r')
try:
fileFd.write(cFd.read())
except IOError:
msg = '%s\n ERROR concat file % in main file' % (msg,cFile)
try:
cFd.close()
except IOError:
msg = '%s\n ERROR cant close file %' % (msg,cFile)
except IOError:
msg = '%s\n ERROR cant open file %' % (msg,cFile)
</script>
<if expr="msg != ''">
<sequence>
<message>
'ERROR when merging files : %s' % msg
</message>
<call function="'writeMessage'">
{ 'content' : 'ERROR when merging files : %s' % msg,
'fileFd' : fileFd }
</call>
</sequence>
<!-- no error during merge, remove original file -->
<!-- <else>
<script>
import os
os.remove(cFile)
</script>
</else> -->
</if>
</sequence>
</iterate>
<else>
<message>'WARNING : no file to merge'</message>
</else>
</if>
<return> msg </return>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeTag" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="tagName" type="required">
<function-arg-description>
name of the tag
</function-arg-description>
</function-arg-def>
<function-arg-def name="tagAttr" type="required">
<function-arg-description>
attribute/value of the tag [[attr1,val1],[attr2,val2],...]
</function-arg-description>
</function-arg-def>
<function-arg-def name="content" type="optional" default="''">
<function-arg-description>
content of the tag
</function-arg-description>
</function-arg-def>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<script>
myString = ''
for attr in tagAttr:
myString = '%s %s=\"%s\"' % (myString,attr[0],attr[1])
</script>
<if expr="fileFd == NO_FILE">
<message>'%s %s : %s' % (tagName,myString,content)</message>
<else>
<script>
fileFd.write('&lt;%s %s&gt; %s &lt;/%s&gt;\n' % \
(tagName,myString,content,tagName))
</script>
</else>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeMessage" scope="local">
<function-prolog>
write content in file
</function-prolog>
<function-map-args>
<function-arg-def name="content" type="required">
<function-arg-description>
string to write in a file
</function-arg-description>
</function-arg-def>
<function-arg-def name="xlink" type="optional" default="NOT_DEFINED">
<function-arg-description>
if you want the content to be a href of xlink
</function-arg-description>
</function-arg-def>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
sys.path.append("%s/phases/log" % TESTS_DIR )
from log import htmlTransformation
content = htmlTransformation(content)
if xlink == NOT_DEFINED:
str = '&lt;message&gt;'
else:
str = '&lt;message xlink:href="%s" xlink:type="simple"&gt;' % xlink
str = '%s %s&lt;/message&gt;\n' % (str,content)
fileFd.write(str)
</script>
<else>
<message>content</message>
</else>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeOperationResult" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="returncode" type="required"/>
<function-arg-def name="expected" type="required"/>
<function-arg-def name="result" type="required"/>
<function-arg-def name="status" type="required"/>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<if expr="fileFd == NO_FILE">
<message>
'%s return code %s (expected %s) : %s' % \
(status,returncode,expected,result)
</message>
<else>
<sequence>
<script>
sys.path.append("%s/phases/log" % TESTS_DIR )
from log import htmlTransformation
result = htmlTransformation(result)
str = '&lt;operationResult returncode=\"%s\"' % returncode
str = '%s expected=\"%s\" status=\"%s\"' % (str,expected,status)
str = '%s&gt; %s &lt;/operationResult&gt;\n' % (str,result)
fileFd.write(str)
</script>
</sequence>
</else>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTagStep" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="tagName"/>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;step name=\"%s\"&gt;\n' % tagName)
</script>
</if>
</sequence>
</function>
<function name="writeEndTagStep" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/step&gt;\n\n')
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTagInstance" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="instance" type="required"/>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
str = '\n&lt;instance name=\"%s\"' % instance.getName()
str = '%s host=\"%s\"' % (str, instance.getHost())
str = '%s port=\"%s\"' % (str, instance.getLDAPPort())
str = '%s product=\"%s\"&gt;\n' % (str, instance.getProduct())
fileFd.write(str)
</script>
</if>
</sequence>
</function>
<function name="writeEndTagInstance" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/instance&gt;\n\n')
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTagClient" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="client" type="required">
</function-arg-def>
<function-arg-def name="extraParameters" type="optional"
default="NOT_DEFINED">
<function-arg-description>
extra parameters to add in the node
</function-arg-description>
</function-arg-def>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
str = '\n&lt;client name=\"%s\"' % client.getName()
str = '%s id=\"%s\"' % (str,client.getId())
str = '%s host=\"%s\"' % (str,client.getHost())
str = '%s start=\"%s\"' % (str,client.getStart())
str = '%s stop=\"%s\"' % (str,client.getStop())
str = '%s dependency=\"%s\"' % (str,client.getDependency())
if extraParameters != NOT_DEFINED:
str = '%s %s' % (str,extraParameters)
str = '%s &gt;\n' % str
fileFd.write(str)
</script>
</if>
</sequence>
</function>
<function name="writeEndTagClient" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/client&gt;\n\n')
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTagOperation" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="tagName">
</function-arg-def>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
date = strftime("%Y%m%d@%H:%M:%S",localtime())
str = '&lt;operation name=\"%s\" date=\"%s\"&gt;\n'% (tagName,date)
fileFd.write(str)
</script>
</if>
</sequence>
</function>
<function name="writeEndTagOperation" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileFd" type="required">
<function-arg-description>
file descriptor
</function-arg-description>
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/operation&gt;\n\n')
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTagPhase" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="tagName" type="required">
</function-arg-def>
<function-arg-def name="tagAttr" type="optional" default='[]'>
<function-arg-description>
attribute/value of the tag [[attr1,val1],[attr2,val2],...]
</function-arg-description>
</function-arg-def>
<function-arg-def name="fileFd" type="required">
</function-arg-def>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<sequence>
<script>
fileFd.write('&lt;phase name=\"%s\"' % tagName)
</script>
<if expr="tagAttr != []">
<sequence>
<script>
str = ''
for attr in tagAttr:
str = '%s %s=\"%s\"' % (str,attr[0],attr[1])
fileFd.write(str)
</script>
</sequence>
</if>
<script>
fileFd.write('&gt;\n')
</script>
</sequence>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeEndTagPhase" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/phase&gt;\n\n')
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeStartTag" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="nodeName" type="required"/>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;%s&gt;\n' % nodeName)
</script>
</if>
</sequence>
</function>
<!-- ************************************************************ -->
<function name="writeEndTag" scope="local">
<function-prolog>
''
</function-prolog>
<function-map-args>
<function-arg-def name="nodeName" type="required"/>
<function-arg-def name="fileFd" type="required"/>
</function-map-args>
<sequence>
<if expr="fileFd != NO_FILE">
<script>
fileFd.write('&lt;/%s&gt;\n' % nodeName)
</script>
</if>
</sequence>
</function>
</stax>