utils.xml revision 4974
2788N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2788N/A<!DOCTYPE stax SYSTEM "/stax.dtd">
2788N/A<!--
2788N/A ! CDDL HEADER START
2788N/A !
2788N/A ! The contents of this file are subject to the terms of the
2788N/A ! Common Development and Distribution License, Version 1.0 only
2788N/A ! (the "License"). You may not use this file except in compliance
2788N/A ! with the License.
2788N/A !
2788N/A ! You can obtain a copy of the license at
2788N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
2788N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
2788N/A ! See the License for the specific language governing permissions
2788N/A ! and limitations under the License.
2788N/A !
2788N/A ! When distributing Covered Code, include this CDDL HEADER in each
2788N/A ! file and include the License file at
2788N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
2788N/A ! add the following below this CDDL HEADER, with the fields enclosed
2788N/A ! by brackets "[]" replaced with your own identifying information:
2788N/A ! Portions Copyright [yyyy] [name of copyright owner]
2788N/A !
2788N/A ! CDDL HEADER END
2788N/A !
4458N/A ! Copyright 2007-2009 Sun Microsystems, Inc.
2788N/A ! -->
2788N/A<stax>
2788N/A <function name="checkRC">
2788N/A <function-prolog>
2788N/A This function checks a return code against an expected return code
2788N/A </function-prolog>
2788N/A
2788N/A <function-map-args>
2788N/A <function-arg-def name="returncode" type="required">
2788N/A <function-arg-description>
2788N/A return code received from command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="result" type="required">
2788N/A <function-arg-description>
2788N/A the output of the result
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="expected" type="optional" default="0">
2788N/A <function-arg-description>
2788N/A the expected return code
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
3194N/A <if expr="expected == 'noCheck'">
2788N/A <return/>
2788N/A </if>
2788N/A <if expr="returncode == expected">
2788N/A <sequence>
2788N/A <if expr="result == ''">
2788N/A <message log="1">
2788N/A 'RC=%s, Result=Ok' % (returncode)
2788N/A </message>
2788N/A <else>
2788N/A <message log="1">
2788N/A 'RC=%s, Result=%s' % (returncode,result)
2788N/A </message>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <message log="1" level="'Error'">
2788N/A 'RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A <return>RC</return>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="checktestRC">
2788N/A <function-prolog>
2788N/A This function checks the return code against an expected return code for a testcase
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="returncode" type="required">
2788N/A <function-arg-description>
2788N/A return code received from command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="result" type="required">
2788N/A <function-arg-description>
2788N/A the output of the result
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="expected" type="optional" default="0">
2788N/A <function-arg-description>
2788N/A the expected return code
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
3951N/A </function-arg-def>
3951N/A <function-arg-def name="issue" type="optional" default="None">
3951N/A <function-arg-description>
3951N/A Issue id. Corresponds to an issue number.
3951N/A </function-arg-description>
3951N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
3951N/A </function-map-args>
2788N/A <sequence>
3194N/A <if expr="expected == 'noCheck'">
2788N/A <return/>
2788N/A </if>
2788N/A <if expr="returncode == expected">
2788N/A <sequence>
2788N/A <if expr="STAXCurrentTestcase != None">
2788N/A <sequence>
3951N/A <tcstatus result="'pass'"/>
2788N/A </sequence>
3600N/A </if>
4495N/A <if expr="VERBOSE_MODE == 'true'">
3600N/A <message log="1">
3600N/A 'SUCCESS: RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
3600N/A </message>
3600N/A <else>
3600N/A <message log="1">
3600N/A 'SUCCESS: RC=%s, Expected %s' % (returncode,expected)
3600N/A </message>
3600N/A </else>
3600N/A </if>
2788N/A <script>
2788N/A RC=0
2788N/A </script>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <if expr="STAXCurrentTestcase != None">
2788N/A <sequence>
3951N/A <if expr="issue == None">
3951N/A <tcstatus result="'fail'"/>
3951N/A <else>
3951N/A <sequence>
3951N/A <call function="'setKnownIssue'">
3951N/A { 'issueId' : issue }
3951N/A </call>
3951N/A </sequence>
3951N/A </else>
3951N/A </if>
3951N/A
2788N/A </sequence>
2788N/A </if>
2788N/A <message log="1" level="'Error'">
2788N/A 'ERROR : RC=%s, Expected %s, Result=%s' % (returncode,expected,result)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A </function>
2788N/A
3951N/A<!-- Set Known Issue -->
3951N/A <function name="setKnownIssue">
3951N/A <function-prolog>
3951N/A This function set the known issue flag and maintains list of known issues
3951N/A </function-prolog>
3951N/A
3951N/A <function-map-args>
3951N/A <function-arg-def name="issueId" type="required">
3951N/A <function-arg-description>
3951N/A Issue ID
3951N/A </function-arg-description>
3951N/A <function-arg-property name="type" value="string"/>
3951N/A </function-arg-def>
3951N/A </function-map-args>
3951N/A <sequence>
3951N/A <script>
3951N/A try:
3962N/A if issueId not in issuesList:
3962N/A issuesList.append(issueId)
3951N/A except:
3951N/A print 'Issues list undefined. Unable to add issue %s' % issueId
3951N/A </script>
3951N/A <message log="1" level="'Error'">
3951N/A 'ERROR: HIT **** Known Issue (%s) ****' % issueId
3951N/A </message>
3951N/A <tcstatus result="'fail'">
3951N/A 'KnownIssue: %s' % issuesList
3951N/A </tcstatus>
3951N/A </sequence>
3951N/A </function>
3951N/A
2788N/A<!-- testPassed -->
2788N/A<!-- Set the test status to PASS -->
2788N/A
2788N/A <function name="testPassed">
2788N/A <function-prolog>
2788N/A This function set the status of the tests: PASS
2788N/A </function-prolog>
2788N/A
2788N/A <sequence>
2788N/A <message>'Set test status to PASS'</message>
2788N/A <tcstatus result="'pass'"/>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A
2788N/A<!-- testFailed -->
2788N/A<!-- Set the test status to FAIL -->
2788N/A
2788N/A <function name="testFailed">
2788N/A <function-prolog>
2788N/A This function set the status of the tests: FAIL
2788N/A </function-prolog>
2788N/A
2788N/A <sequence>
2788N/A <message>'Set test status to FAIL'</message>
2788N/A <tcstatus result="'fail'"/>
2788N/A </sequence>
2788N/A </function>
4238N/A
4238N/A <!-- Search string -->
4238N/A <function name="searchString" scope="local">
4238N/A <function-prolog>
4238N/A This function search for a string in the retrun string of a testcase
4238N/A Return 0 if the string is found, 1 otherwise
4238N/A </function-prolog>
4238N/A
4238N/A <function-map-args>
4238N/A <function-arg-def name="expectedString" type="required">
4238N/A <function-arg-description>
4238N/A the substring expected from the command
4238N/A </function-arg-description>
4238N/A <function-arg-property name="type" value="string"/>
4238N/A </function-arg-def>
4238N/A <function-arg-def name="returnString" type="required">
4238N/A <function-arg-description>
4238N/A the return string received from command
4238N/A </function-arg-description>
4238N/A <function-arg-property name="type" value="string"/>
4238N/A </function-arg-def>
4724N/A <function-arg-def name="searchType"
4724N/A type="optional"
4724N/A default="'substring'">
4724N/A <function-arg-description>
4724N/A the type of the search: substring, exact-case-insensitive or
4724N/A exact-case-sensitive
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4238N/A <function-arg-def name="knownIssue" type="optional" default="None">
4238N/A <function-arg-description>
4238N/A Known issue. Corresponds to an issue number.
4238N/A </function-arg-description>
4238N/A <function-arg-property name="type" value="string"/>
4238N/A </function-arg-def>
4238N/A <function-arg-def name="expectedRC" type="optional" default="0">
4238N/A <function-arg-description>
4238N/A Expected return code value. Default value is 0.
4238N/A Wildcard 'noCheck' to not check the RC
4238N/A </function-arg-description>
4238N/A <function-arg-property name="type" value="string"/>
4238N/A </function-arg-def>
4238N/A </function-map-args>
4238N/A
4238N/A <sequence>
4238N/A <script>
4238N/A searchre = re.compile('%s' % expectedString)
4238N/A myRC = 0
4238N/A myReason = 'None'
4238N/A </script>
4238N/A
4238N/A <!-- Check that returnString is really a string -->
4238N/A <if expr='returnString.__class__ is not org.python.core.PyString'>
4238N/A <sequence>
4238N/A <message log="1" level="'Error'">
4238N/A 'ERROR : Invalid returnString type (%s), requires org.python.core.PyString.' \
4238N/A % returnString.__class__
4238N/A </message>
4238N/A <script>
4238N/A myRC = 1
4238N/A myReason = 'Python error'
4238N/A </script>
4238N/A
4238N/A <return>[myRC, myReason]</return>
4238N/A </sequence>
4238N/A </if>
4724N/A
4724N/A <script>
4724N/A if searchType == 'substring':
4724N/A searchResult = (re.search(searchre, returnString) != None)
4724N/A elif searchType == 'exact-case-sensitive':
4724N/A searchResult = (expectedString == returnString)
4724N/A elif searchType == 'exact-case-insensitive':
4724N/A searchResult = (expectedString.lower() == returnString.lower())
4724N/A </script>
4238N/A
4238N/A <!-- Search for the expectedString -->
4724N/A <if expr='searchResult'>
4238N/A <sequence>
4238N/A <message log="1">
4724N/A 'Search type: %s Found substring, %s, in the return string' \
4724N/A % (searchType, expectedString)
4238N/A </message>
4238N/A <script>
4238N/A myRC = 0
4238N/A myReason = 'String found'
4238N/A </script>
4238N/A </sequence>
4238N/A <else>
4238N/A <sequence>
4616N/A <message log="1">
4724N/A 'Search type: %s Did not find substring, %s, in the return \
4724N/A string, %s' % (searchType, expectedString, returnString)
4238N/A </message>
4238N/A <script>
4238N/A myRC = 1
4238N/A myReason = 'String not found'
4238N/A </script>
4238N/A </sequence>
4238N/A </else>
4238N/A </if>
4238N/A
4238N/A <!-- Manage expectedRC and knownIssue -->
4238N/A <if expr="expectedRC != 'noCheck'">
4238N/A <if expr="myRC == expectedRC">
4616N/A <sequence>
4616N/A <message log="1">
4616N/A 'SUCCESS: searchString successful'
4616N/A </message>
4616N/A <tcstatus result="'pass'"/>
4616N/A </sequence>
4238N/A <else>
4616N/A <sequence>
4616N/A <message log="1" level="'Error'">
4616N/A 'ERROR: searchString fail'
4616N/A </message>
4616N/A <if expr="knownIssue == None">
4616N/A <tcstatus result="'fail'"/>
4616N/A <else>
4616N/A <call function="'setKnownIssue'">
4616N/A { 'issueId' : knownIssue }
4616N/A </call>
4616N/A </else>
4616N/A </if>
4616N/A </sequence>
4238N/A </else>
4238N/A </if>
4238N/A </if>
4238N/A
4238N/A <return>[myRC, myReason]</return>
4238N/A </sequence>
4238N/A </function>
4238N/A
4238N/A <!-- DEPRECATED, use searchString function -->
2788N/A <function name="checktestString">
2788N/A <function-prolog>
2788N/A This function checks the return string against an expected return substring for a testcase
2788N/A </function-prolog>
2788N/A
2788N/A <function-map-args>
2788N/A <function-arg-def name="expectedString" type="required">
2788N/A <function-arg-description>
2788N/A the substring expected from the command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="returnString" type="required">
2788N/A <function-arg-description>
2788N/A the return string received from command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
3951N/A </function-arg-def>
3951N/A <function-arg-def name="issue" type="optional" default="None">
3951N/A <function-arg-description>
3951N/A Known issue. Corresponds to an issue number.
3951N/A </function-arg-description>
3951N/A <function-arg-property name="type" value="string" />
3951N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <script>
2788N/A searchre = re.compile('%s' % expectedString)
2788N/A </script>
2788N/A
3973N/A <!-- Check that returnString is really a string -->
3973N/A <if expr='returnString.__class__ is not org.python.core.PyString'>
3973N/A <sequence>
3973N/A <message log="1" level="'Error'">
3973N/A 'ERROR : Invalid returnString type (%s), requires org.python.core.PyString.' % returnString.__class__
3973N/A </message>
3973N/A <tcstatus result="'fail'"/>
3973N/A </sequence>
3973N/A </if>
2788N/A <if expr='re.search(searchre, returnString) != None'>
2788N/A <sequence>
2788N/A <tcstatus result="'pass'"/>
2788N/A <message log="1">
2788N/A 'SUCCESS : Found substring, %s, in the return string' % (expectedString)
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
3951N/A <if expr="issue == None">
3951N/A <tcstatus result="'fail'"/>
3951N/A <else>
3951N/A <sequence>
3951N/A <call function="'setKnownIssue'">
3951N/A { 'issueId' : issue }
3951N/A </call>
3951N/A </sequence>
3951N/A </else>
3951N/A </if>
2788N/A <message log="1" level="'Error'">
2788N/A 'ERROR : Did not find substring, %s, in the return string, %s' % (expectedString, returnString)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A </function>
2788N/A
4238N/A <!-- DEPRECATED, use searchString function -->
2788N/A <function name="checktestStringNotPresent">
2788N/A <function-prolog>
2788N/A This function checks the return string against an expected return substring that should not be present for a testcase
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="testString" type="required">
2788N/A <function-arg-description>
2788N/A the substring being tested from the command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="returnString" type="required">
2788N/A <function-arg-description>
2788N/A the return string received from command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
3951N/A <function-arg-def name="issue" type="optional" default="None">
3951N/A <function-arg-description>
3951N/A Known issue. Corresponds to an issue number.
3951N/A </function-arg-description>
3951N/A <function-arg-property name="type" value="string" />
3951N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <script>
2788N/A searchre = re.compile('%s' % testString)
2788N/A </script>
2788N/A <if expr='re.search(searchre, returnString) == None'>
2788N/A <sequence>
2788N/A <tcstatus result="'pass'"/>
2788N/A <message log="1">
2788N/A 'Did Not Find substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
3951N/A <if expr="issue == None">
3951N/A <tcstatus result="'fail'"/>
3951N/A <else>
3951N/A <sequence>
3951N/A <call function="'setKnownIssue'">
3951N/A { 'issueId' : issue }
3951N/A </call>
3951N/A </sequence>
3951N/A </else>
3951N/A </if>
2788N/A <message log="1" level="'Error'">
2788N/A 'Found substring, %s, in the return string, %s' % (testString, returnString)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A </function>
2788N/A
4238N/A <!-- DEPRECATED, use searchString function -->
2788N/A <function name="searchStringForSubstring">
2788N/A <function-prolog>
2788N/A This function simply searches a string for a substring
2788N/A </function-prolog>
2788N/A
2788N/A <function-map-args>
2788N/A <function-arg-def name="testString" type="required">
2788N/A <function-arg-description>
2788N/A the substring being tested from the command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="returnString" type="required">
2788N/A <function-arg-description>
2788N/A the return string received from command
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="expectedResult" type="optional" default="'2'">
2788N/A <function-arg-description>
2788N/A the expected result, 0 for false (not present), 1 for true (present), 2 for old behavior
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <!-- Until all the test cases are refactored to use the expectedResult param,
2788N/A we need this if-else conditional. -->
2788N/A <sequence>
2788N/A <if expr="expectedResult == '2'">
2788N/A <sequence>
2788N/A <script>
2788N/A searchre = re.compile(testString)
2788N/A </script>
2788N/A <if expr='re.search(searchre, returnString) == None'>
2788N/A <sequence>
2788N/A <script>returnCode='0'</script>
2788N/A <message log="1">
2788N/A 'Did Not Find substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <script>returnCode='1'</script>
2788N/A <message log="1">
2788N/A 'Found substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A <return>returnCode</return>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <script>
2788N/A searchre = re.compile(testString)
2788N/A </script>
2788N/A <if expr='re.search(searchre, returnString) == None'>
2788N/A <sequence>
2788N/A <script>returnCode='0'</script>
2788N/A <if expr="expectedResult == '0'">
2788N/A <sequence>
2788N/A <tcstatus result="'pass'"/>
2788N/A <message log="1">
2788N/A 'SUCCESS : Did Not Find substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <tcstatus result="'fail'"/>
3847N/A <message log="1" level="'Error'">
2788N/A 'ERROR : Did Not Find substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <script>returnCode='1'</script>
2788N/A <if expr="expectedResult == '1'">
2788N/A <sequence>
2788N/A <tcstatus result="'pass'"/>
2788N/A <message log="1">
2788N/A 'SUCCESS : Found substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
2788N/A <tcstatus result="'fail'"/>
3847N/A <message log="1" level="'Error'">
2788N/A 'ERROR : Found substring, %s, in the return string' % (testString)
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A <return>returnCode</return>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="isAlive" scope="local">
2788N/A <function-prolog>
2788N/A Checks that the ldap server is running
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="location" type="optional" default="STAF_REMOTE_HOSTNAME">
2788N/A <function-arg-description>
2788N/A Location of target host
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="hostname"/>
2788N/A </function-arg-def>
4153N/A <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
2788N/A <function-arg-description>
2788N/A Pathname to installation root
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="pathname"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="noOfLoops" type="required">
2788N/A <function-arg-description>
2788N/A Number of iterations
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="noOfMilliSeconds" type="required">
2788N/A <function-arg-description>
2788N/A Number of seconds to wait between iterations
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="seconds"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="dsInstanceHost" type="optional" default="DIRECTORY_INSTANCE_HOST">
2788N/A <function-arg-description>
2788N/A Directory server hostname or IP address
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="hostname"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="dsInstancePort" type="optional" default="DIRECTORY_INSTANCE_PORT">
2788N/A <function-arg-description>
2788N/A Directory server port number
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="Port number"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="dsInstanceDn" type="optional" default="DIRECTORY_INSTANCE_DN">
2788N/A <function-arg-description>
2788N/A Bind DN
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="DN"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="dsInstancePswd" type="optional" default="DIRECTORY_INSTANCE_PSWD">
2788N/A <function-arg-description>
2788N/A Bind password
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <!-- Local variables -->
2788N/A <script>
2788N/A mylocation=location
2788N/A mypath=dsPath
2788N/A myhost=dsInstanceHost
2788N/A myport=dsInstancePort
2788N/A mydn=dsInstanceDn
2788N/A mypswd=dsInstancePswd
2788N/A </script>
2788N/A
4495N/A <script>
4495N/A myLoop=0
4495N/A ldapRC=9999
4495N/A </script>
2788N/A <loop from="1" to="noOfLoops" while="ldapRC != 0">
2788N/A <sequence>
4495N/A <script>
4495N/A myLoop=myLoop+1
4495N/A </script>
4495N/A
2788N/A <call function="'SearchObject'">
2788N/A { 'location' : mylocation,
2788N/A 'dsPath' : mypath,
2788N/A 'dsInstanceHost' : myhost ,
2788N/A 'dsInstancePort' : myport ,
2788N/A 'dsInstanceDn' : mydn ,
2788N/A 'dsInstancePswd' : mypswd ,
2788N/A 'dsScope' : 'base' ,
2788N/A 'dsBaseDN' : 'cn=config' ,
2788N/A 'dsFilter' : 'objectclass=*' ,
2788N/A 'attributes' : 'dn',
2788N/A 'expectedRC' : 'noCheck'
2788N/A }
2788N/A </call>
2788N/A
2788N/A <script>
2788N/A ldapRC=RC
2788N/A </script>
4495N/A
4495N/A <message>
4495N/A 'LOOP %s => RC=%s' % (myLoop, ldapRC)
4495N/A </message>
4495N/A
2788N/A <call function="'Sleep'">
2788N/A { 'sleepForMilliSeconds' : noOfMilliSeconds }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A </loop>
2788N/A
4495N/A <call function="'checktestRC'">
4495N/A { 'returncode' : ldapRC ,
4495N/A 'result' : 'Check is alive' }
4495N/A </call>
2788N/A </sequence>
2788N/A </function>
2788N/A
4865N/A <function name="isStopped" scope="local">
4865N/A <function-prolog>
4865N/A Checks that the ldap server is stopped
4865N/A </function-prolog>
4865N/A <function-map-args>
4865N/A <function-arg-def name="location"
4865N/A type="optional"
4865N/A default="STAF_REMOTE_HOSTNAME">
4865N/A <function-arg-description>
4865N/A Location of target host
4865N/A </function-arg-description>
4865N/A <function-arg-property name="type" value="hostname"/>
4865N/A </function-arg-def>
4865N/A <function-arg-def name="dsPath"
4865N/A type="optional"
4865N/A default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
4865N/A <function-arg-description>
4865N/A Pathname to installation root
4865N/A </function-arg-description>
4865N/A <function-arg-property name="type" value="pathname"/>
4865N/A </function-arg-def>
4865N/A <function-arg-def name="noOfLoops"
4865N/A type="optional"
4865N/A default="10">
4865N/A <function-arg-description>
4865N/A Number of iterations
4865N/A </function-arg-description>
4865N/A <function-arg-property name="type" value="integer"/>
4865N/A </function-arg-def>
4865N/A <function-arg-def name="noOfMilliSeconds"
4865N/A type="optional"
4865N/A default="2000">
4865N/A <function-arg-description>
4865N/A Number of seconds to wait between iterations
4865N/A </function-arg-description>
4865N/A <function-arg-property name="type" value="seconds"/>
4865N/A </function-arg-def>
4865N/A </function-map-args>
4865N/A
4865N/A <sequence>
4865N/A <script>checkRC=9999</script>
4865N/A <loop from="1" to="noOfLoops" var="loop" while="checkRC != 48">
4865N/A <sequence>
4865N/A <message>
4865N/A 'Check if %s/logs/server.pid still exists on host %s' \
4865N/A % (dsPath,location)
4865N/A </message>
4865N/A
4865N/A <call function="'GetEntry'">
4865N/A { 'location' : location,
4865N/A 'entry' : '%s/logs/server.pid' % dsPath,
4865N/A 'attribute' : 'TYPE'
4865N/A }
4865N/A </call>
4865N/A
4865N/A <script>
4865N/A checkRC = RC
4865N/A </script>
4865N/A
4865N/A <message>'LOOP %s => RC %s' % (loop,checkRC)</message>
4865N/A
4865N/A <message>'Sleep for %sms' % noOfMilliSeconds</message>
4865N/A <call function="'Sleep'">
4865N/A { 'sleepForMilliSeconds' : noOfMilliSeconds }
4865N/A </call>
4865N/A </sequence>
4865N/A </loop>
4865N/A
4865N/A <if expr="checkRC != 48">
4865N/A <message>
4865N/A 'Server is not stopped after %sms \
4865N/A (%s/logs/server.pid still exists on %s)' \
4865N/A % (noOfLoops*noOfMilliSeconds,dsPath,location)
4865N/A </message>
4865N/A </if>
4865N/A </sequence>
4865N/A </function>
4865N/A
2788N/A <function name="Sleep">
2788N/A <function-prolog>
2788N/A Sleep for number of milliseconds
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="sleepForMilliSeconds" type="required">
2788N/A <function-arg-description>
2788N/A Number of milliseconds to sleep
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="seconds"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <stafcmd name="'STAF Command: Delay'">
4680N/A <location>STAXServiceMachine</location>
2788N/A <service>'delay'</service>
2788N/A <request>
2788N/A 'delay %i' % sleepForMilliSeconds
2788N/A </request>
2788N/A </stafcmd>
2788N/A
2788N/A <call function="'checkRC'">
2788N/A { 'returncode' : RC ,
2788N/A 'result' : STAFResult }
2788N/A </call>
2788N/A </sequence>
2788N/A </function>
2788N/A
3194N/A <function name="getOSvariables">
2788N/A <function-prolog>
3194N/A Get OS related variables
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="hostname" type="required">
2788N/A <function-arg-description>
2788N/A Name of host on which to retrieve variables
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="hostname"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A <sequence>
2788N/A <stafcmd name="'STAF Command: Get OS Name'">
2788N/A <location>'%s' % hostname</location>
2788N/A <service>'var'</service>
2788N/A <request>
2788N/A 'get system var STAF/Config/OS/Name'
2788N/A </request>
2788N/A </stafcmd>
2788N/A <message>
2788N/A 'OS Name= %s' % STAFResult
2788N/A </message>
2788N/A <return>STAFResult</return>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testCase_StartBanner">
2788N/A <function-prolog>
2788N/A Pretty prints a banner at the start of a test.
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A <message level="'start'">'testcase: %s' % STAXCurrentTestcase</message>
2788N/A <message>'****************************************************'</message>
2788N/A <message>'*** STARTING TEST CASE %s.' % STAXCurrentTestcase</message>
2788N/A <message>'***'</message>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testCase_EndBanner">
2788N/A <function-prolog>
2788N/A Pretty prints a banner at the end of a test.
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A <message>'***'</message>
2788N/A <message>'*** ENDING TEST CASE %s.' % STAXCurrentTestcase</message>
2788N/A <message>'****************************************************'</message>
2788N/A <message level="'stop'">'testcase: %s' % STAXCurrentTestcase</message>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testCase_Preamble">
2788N/A <function-prolog>
2788N/A Performs all the preoperations for a test case
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A <script>
2788N/A import time
2788N/A testcaseStart=int(time.time())
2788N/A testcaseStartTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A issuesList=[]
2788N/A for logType in ['errors','access']:
2788N/A if os.path.exists('%s/%s/logs/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME,logType)):
2788N/A logfile=open('%s/%s/logs/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME,logType),'a')
2788N/A logfile.seek(0,2)
2788N/A logfile.write('Begin testcase %s\n' % STAXCurrentTestcase)
2788N/A logfile.close()
2788N/A </script>
2788N/A <call function="'testCase_StartBanner'" />
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testCase_Postamble">
2788N/A <function-prolog>
2788N/A Performs all the post operations for a test suite
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A
2788N/A <!-- Check the SignalRaised flag -->
2788N/A <if expr="SignalRaised">
2788N/A <sequence>
2788N/A <message>
2788N/A 'A signal (%s) was raised during this test case' % SignalRaised
2788N/A </message>
2788N/A <tcstatus result="'fail'"/>
2788N/A </sequence>
2788N/A </if>
2788N/A
2788N/A <!-- Reset the SignalRaised flag -->
2788N/A <script>
2788N/A SignalRaised=''
2788N/A </script>
2788N/A
2788N/A <!-- Query the test case results -->
2788N/A <call function="'queryTestcase'" />
2788N/A
2788N/A <script>
2788N/A if STAFResult.has_key('numPasses'):
2788N/A numPass=int(STAFResult['numPasses'])
2788N/A else:
2788N/A numPass=int(0)
2788N/A
2788N/A if STAFResult.has_key('numFails'):
2788N/A numFail=int(STAFResult['numFails'])
2788N/A else:
2788N/A numFail=int(0)
4777N/A
4777N/A if STAFResult.has_key('startedTimestamp'):
4777N/A startTimestamp=STAFResult['startedTimestamp']
4777N/A else:
4777N/A startTimestamp=int(0)
4777N/A
4777N/A if STAFResult.has_key('information'):
4777N/A information=STAFResult['information']
4777N/A else:
4777N/A information=''
2788N/A
2788N/A if numFail == 0:
2788N/A if numPass == 0:
2788N/A _status='INCONCLUSIVE'
4865N/A _result='unknown'
2788N/A else:
2788N/A _status='PASS'
4865N/A _result='pass'
2788N/A else:
2788N/A if len(issuesList)==0:
2788N/A _status='FAIL'
4865N/A _result='fail'
2788N/A else:
2788N/A _status='KNOWN ISSUES %s' % str(issuesList)
4865N/A _result='fail'
2788N/A </script>
4865N/A
4865N/A <message level="'status'">
4865N/A '## Test Verdict: %s ##' % _status
4865N/A </message>
4865N/A
2788N/A <call function="'testCase_EndBanner'" />
2788N/A
2788N/A <script>
2788N/A testcaseEndTime = strftime("%Y%m%d@%H:%M:%S",localtime())
4777N/A
4777N/A testcaseStop=int(time.time())
4777N/A testcaseDuration=testcaseStop-testcaseStart
4777N/A shortName=get_test_name(STAXCurrentTestcase)
4777N/A
4777N/A xml.testcase = doc.createElement("testcase")
4777N/A xml.createAttr(doc,xml.testcase,"name",STAXCurrentTestcase)
4777N/A xml.createAttr(doc,xml.testcase,"duration",testcaseDuration)
4777N/A xml.createAttr(doc,xml.testcase,"group",ThisGroupName)
4865N/A xml.createAttr(doc,xml.testcase,"result",_result)
4777N/A xml.createAttr(doc,xml.testcase,"shortname",shortName.lower())
4777N/A xml.createAttr(doc,xml.testcase,"start",startTimestamp)
4777N/A xml.createAttr(doc,xml.testcase,"stop",testcaseEndTime)
4777N/A xml.createAttr(doc,xml.testcase,"suite",ThisSuiteName)
4777N/A xml.createAttr(doc,xml.testcase,"info",information)
4777N/A xml.testsuite.appendChild(xml.testcase)
4777N/A
4865N/A if len(issuesList)!=0:
4865N/A xml.issues = doc.createElement("issues")
4865N/A xml.testcase.appendChild(xml.issues)
4865N/A
4865N/A for issueID in issuesList:
4865N/A xml.issue = doc.createElement("issue")
4865N/A xml.createAttr(doc,xml.issue,"id",issueID)
4865N/A xml.issues.appendChild(xml.issue)
4865N/A
4777N/A xml.writeXMLfile(doc,"%s/results2.xml" % logs.reports)
2788N/A </script>
2788N/A
2788N/A <call function="'queryLogs'">
2788N/A { 'location' : STAXServiceMachine,
2788N/A 'logname' : 'STAX_Job_%s_User' % STAXJobID,
2788N/A 'startfrom' : testcaseStartTime,
2788N/A 'endat' : testcaseEndTime }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testSuite_Preamble">
2788N/A <function-prolog>
2788N/A Performs all the pre operations for a test suite
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A
2788N/A <!-- Take the values from the current test path -->
2788N/A <script>
2788N/A if not CurrentTestPath.has_key('group'):
2788N/A CurrentTestPath['group']='unknown-group'
2788N/A
2788N/A if not CurrentTestPath.has_key('suite'):
2788N/A CurrentTestPath['suite']='unknown-suite'
2788N/A
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A ThisSuiteName=CurrentTestPath['suite']
4777N/A
4777N/A #Create testsuite element
4777N/A xml.testsuite = doc.createElement("testsuite")
4777N/A xml.createAttr(doc,xml.testsuite,"name",ThisSuiteName)
4777N/A xml.createAttr(doc,xml.testsuite,"shortname",ThisSuiteName)
4777N/A xml.testgroup.appendChild(xml.testsuite)
4777N/A
4777N/A xml.writeXMLfile(doc,"%s/results2.xml" % logs.reports)
4777N/A
2788N/A </script>
2788N/A
2788N/A <!-- Start time of test suite -->
2788N/A <script>
2788N/A TestSuiteStartTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A </script>
2788N/A
2788N/A <message>
2788N/A '#### %s/%s suite preamble ####' % (ThisGroupName,ThisSuiteName)
2788N/A </message>
2788N/A
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testSuite_Postamble">
2788N/A <function-prolog>
2788N/A Performs all the post operations for a test suite
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A
2788N/A <!-- Take the values from the current test path -->
2788N/A <script>
2788N/A if CurrentTestPath.has_key('suite'):
2788N/A ThisSuiteName=CurrentTestPath['suite']
2788N/A else:
2788N/A ThisSuiteName='unknown-suite'
2788N/A
2788N/A if CurrentTestPath.has_key('group'):
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A else:
2788N/A ThisGroupName='unknown-group'
2788N/A </script>
2788N/A
2788N/A <message>
2788N/A '#### %s/%s suite postamble ####' % (ThisGroupName,ThisSuiteName)
2788N/A </message>
2788N/A
2788N/A <!-- Start time of test suite -->
2788N/A <script>
2788N/A TestSuiteEndTime=strftime("%Y%m%d@%H:%M:%S",localtime())
2788N/A </script>
2788N/A
2788N/A <!-- Format the test group and suite names to create folder -->
2788N/A <script>
2788N/A FormattedTestcase=format_testcase()
2788N/A FormattedTestgroup=FormattedTestcase.group(ThisGroupName)
2788N/A FormattedTestsuite=FormattedTestcase.suite(ThisSuiteName)
2788N/A
3816N/A TestLogDir= '%s/%s' % (logs.tests,FormattedTestgroup)
3855N/A TestLogFile='%s/%s' % (TestLogDir,FormattedTestsuite)
2788N/A </script>
2788N/A
2788N/A <call function="'WriteLogsForTestCase'">
2788N/A { 'starttime' : TestSuiteStartTime,
2788N/A 'endtime' : TestSuiteEndTime,
3855N/A 'logFile' : TestLogFile }
2788N/A </call>
2788N/A
2788N/A <script>
2788N/A if CurrentTestPath.has_key('suite'):
2788N/A del CurrentTestPath['suite']
2788N/A </script>
2788N/A
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testGroup_Preamble">
2788N/A <function-prolog>
2788N/A Performs all the pre operations for a test group
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A <!-- Take the values from the current test path -->
2788N/A <script>
2788N/A if not CurrentTestPath.has_key('group'):
2788N/A CurrentTestPath['group']='unknown-group'
2788N/A
2788N/A ThisGroupName=CurrentTestPath['group']
4777N/A
4777N/A xml=xmldoc_service()
4777N/A
4777N/A doc = xml.parseXMLfile("%s/results2.xml" % logs.reports)
4777N/A
4777N/A qa = doc.getDocumentElement()
4777N/A ft = qa.getChildNodes().item(1)
4974N/A results = ft.getChildNodes().item(3)
4777N/A
4777N/A #Create testgroup element
4777N/A xml.testgroup = doc.createElement("testgroup")
4777N/A xml.createAttr(doc,xml.testgroup,"name",ThisGroupName)
4777N/A results.appendChild(xml.testgroup)
4777N/A
4777N/A xml.writeXMLfile(doc,"%s/results2.xml" % logs.reports)
4777N/A
2788N/A </script>
2788N/A <message>'##### %s group preamble #####' % ThisGroupName</message>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="testGroup_Postamble">
2788N/A <function-prolog>
2788N/A Performs all the post operations for a test group
2788N/A </function-prolog>
2788N/A <function-no-args />
2788N/A <sequence>
2788N/A
2788N/A <script>
2788N/A if CurrentTestPath.has_key('group'):
2788N/A ThisGroupName=CurrentTestPath['group']
2788N/A else:
2788N/A ThisGroupName='unknown-group'
4777N/A
2788N/A coverage='N/A'
2788N/A </script>
2788N/A
2788N/A <message>'##### %s group postamble #####' % ThisGroupName</message>
3816N/A
3816N/A <script>
3816N/A emmaJar='%s/%s/lib/emma.jar' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
3816N/A </script>
4777N/A
3816N/A <if expr="os.path.exists(emmaJar)">
2788N/A <sequence>
4645N/A <script>
4647N/A coveragePath=os.path.join(LOGS_ROOT,'coverage')
4647N/A coverageEm=os.path.join(coveragePath,'coverage.em')
4647N/A ecPath=os.path.join(coveragePath,CurrentTestPath['group'])
4647N/A coverageEcs=[ os.path.join(ecPath,ec) for ec in os.listdir(ecPath) if ec.startswith('coverage') and ec.endswith('.ec')]
4647N/A coverageFiles=','.join(coverageEcs)
4647N/A coverageXml=os.path.join(ecPath,'coverage.xml')
4647N/A coverageHtml=os.path.join(ecPath,'coverage.html')
4645N/A srcPathPrefix = os.path.join(TMPDIR,"..","..","..","..","..","..","src")
4645N/A srcPaths = [ os.path.join(srcPathPrefix,"server"),
4645N/A os.path.join(srcPathPrefix,"ads"),
4645N/A os.path.join(srcPathPrefix,"server","org"),
4645N/A os.path.join(srcPathPrefix,"admin","defn","org"),
4645N/A os.path.join(srcPathPrefix,"snmp","src","org"),
4645N/A os.path.join(srcPathPrefix,"ads","org"),
4645N/A os.path.join(srcPathPrefix,"dsml","org"),
4645N/A os.path.join(srcPathPrefix,"messages","src","org")
4645N/A ]
4645N/A srcArgs = " -sp ".join(srcPaths)
4645N/A </script>
2788N/A <call function="'runCommand'">
4645N/A { 'name' : 'Generate coverage xml report for test group %s' % CurrentTestPath['group'],
4645N/A 'command' : 'java',
4645N/A 'arguments' : ' -Xms64M -Xmx1G -cp %s emma report -r html -in %s,%s -Dreport.html.out.file=%s -sp %s' % (emmaJar, coverageEm, coverageFiles, coverageHtml, srcArgs),
4645N/A 'path' : TMPDIR
2788N/A }
2788N/A </call>
2788N/A </sequence>
4777N/A </if>
2788N/A
2788N/A <script>
2788N/A if CurrentTestPath.has_key('group'):
2788N/A del CurrentTestPath['group']
2788N/A </script>
2788N/A </sequence>
2788N/A </function>
2788N/A
3855N/A <function name="WriteLogsForTestCase" scope="local">
2788N/A
2788N/A <function-prolog>
2788N/A Queries the staf logs for the test case and write to file as text
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="starttime" type="required">
2788N/A <function-arg-description>
2788N/A timestamp to start logging from
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="timestamp"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="endtime" type="required">
2788N/A <function-arg-description>
2788N/A timestamp to start logging to
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="timestamp"/>
2788N/A </function-arg-def>
3855N/A <function-arg-def name="logFile" type="required">
2788N/A <function-arg-description>
2788N/A name of file to write the logs
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="filepath"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A
3855N/A <script>
3862N/A xmlFile = '%s-log.xml' % logFile
3862N/A htmlFile = '%s-log.html' % logFile
4259N/A xslFile = '%s/gen-logs.xsl' % TESTS_XSL_DIR
3855N/A </script>
3855N/A
3855N/A <!-- Query STAF to obtain the logs for the test case -->
2788N/A <call function="'queryLogs'">
2788N/A { 'location' : STAXServiceMachine,
2788N/A 'logname' : 'STAX_Job_%s_User' % STAXJobID,
2788N/A 'startfrom' : starttime,
2788N/A 'endat' : endtime }
2788N/A </call>
2788N/A
3855N/A <!-- Write out the logs into an XML file -->
3855N/A <call function="'WriteXmlLogs'">
2788N/A { 'queryresult' : STAFResult,
3855N/A 'output' : xmlFile }
3855N/A </call>
3855N/A
3855N/A <!-- Transform the XML file into an HTML file -->
3855N/A <call function="'WriteHtmlLogs'">
3855N/A { 'input' : xmlFile,
3855N/A 'stylesheet' : xslFile,
3855N/A 'output' : htmlFile }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A
2788N/A </function>
2788N/A
3855N/A <function name="WriteXmlLogs" scope="local">
2788N/A
2788N/A <function-prolog>
2788N/A Process staf log query results and write them to a file
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="queryresult" type="required">
2788N/A <function-arg-description>
2788N/A result of the staf log query
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
3855N/A <function-arg-def name="output" type="required">
2788N/A <function-arg-description>
3855N/A name of the XML file to where results are written
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A
2788N/A <script>
3855N/A logFile=output
3855N/A NewLogDir=os.path.dirname(logFile)
2788N/A </script>
3855N/A
3855N/A <message>'Creating XML log file %s' % logFile</message>
3855N/A
2788N/A <call function="'createFolder'">
2788N/A { 'location' : STAXServiceMachine,
2788N/A 'foldername' : NewLogDir }
2788N/A </call>
2788N/A
2788N/A <script>
3855N/A from xml.dom.minidom import Document
3855N/A doc = Document()
3855N/A
3855N/A # Create the qa base element
3855N/A qa = doc.createElement("qa")
3855N/A doc.appendChild(qa)
3855N/A
3855N/A # Create the base element
3855N/A logs = doc.createElement("logs")
3855N/A qa.appendChild(logs)
3855N/A
3870N/A # Try to pass only the pretty print of the test suite name
3870N/A try:
3870N/A suite=CurrentTestPath['suite'].split('.')[2].strip()
3870N/A except:
3870N/A formattedTestcase = format_testcase()
3870N/A suite = formattedTestcase.suite(CurrentTestPath['suite'])
3855N/A
3855N/A # Create the log element
3855N/A log = doc.createElement("log")
3855N/A log.setAttribute("group", "%s" % CurrentTestPath['group'])
3862N/A log.setAttribute("suite", "%s" % suite)
3855N/A log.setAttribute("jobid", "%s" % STAXJobID)
3855N/A log.setAttribute("parent", "%s" % STAXParentID)
3855N/A logs.appendChild(log)
2788N/A </script>
2956N/A
2956N/A <if expr="queryresult == '[]'">
2956N/A <sequence>
2956N/A <script>
2956N/A output1 = 'queryresult is empty'
2956N/A output2 = 'check the date between the OS, the logs'
2956N/A output3 = 'and the local time zone'
2956N/A output = '%s %s %s' % (output1,output2,output3)
2956N/A </script>
2956N/A <call function="'checktestRC'">
2956N/A { 'returncode' : '1' ,
2956N/A 'result' : output,
2956N/A 'expected' : '0' }
2956N/A </call>
2956N/A </sequence>
2956N/A <else>
2956N/A <iterate var="element" in="queryresult">
2956N/A <script>
2956N/A level=element['level']
2956N/A message=element['message']
2956N/A timestamp=element['timestamp']
3855N/A
3855N/A line = doc.createElement("line")
3855N/A line.setAttribute("timestamp", "%s" % timestamp)
3855N/A line.setAttribute("level", "%s" % level)
3855N/A line.setAttribute("message", "%s" % message)
3862N/A if level == 'Start':
3903N/A tag=get_test_name(message.replace('testcase: ',''))
3862N/A line.setAttribute("tag", "%s" % tag.lower())
3855N/A log.appendChild(line)
2956N/A </script>
2956N/A </iterate>
2956N/A </else>
2956N/A </if>
2956N/A
3855N/A <script>
3855N/A _message='Generated XML test case report.'
3855N/A testlogfh=open('%s' % logFile,'w')
3855N/A try:
3855N/A testlogfh.writelines(doc.toprettyxml(indent=" "))
3855N/A except AttributeError,details:
3855N/A _message='Unable to generate XML test case report %s.' % details
3855N/A except:
3855N/A _message='Unable to generate XML test case report !!!'
3855N/A testlogfh.close()
4753N/A
4753N/A firstline=0
4753N/A newlines=[]
4753N/A testlogfh=open('%s' % logFile,'r')
4753N/A lines=testlogfh.readlines()
4753N/A
4753N/A for l in lines:
4753N/A if firstline==0:
4753N/A newlines.append('&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;\n')
4753N/A firstline=1
4753N/A else:
4753N/A newlines.append(l)
4753N/A
4753N/A testlogfh.close()
4753N/A
4753N/A testlogfh=open('%s' % logFile,'w')
4753N/A testlogfh.writelines(newlines)
4753N/A testlogfh.close()
3855N/A </script>
3855N/A
3855N/A <message>_message</message>
3855N/A
2788N/A </sequence>
2788N/A
2788N/A </function>
2788N/A
3855N/A <function name="WriteHtmlLogs" scope="local">
3855N/A
3855N/A <function-prolog>
3862N/A Process XML file and transform that to an HTML log file
3855N/A </function-prolog>
3855N/A <function-map-args>
3855N/A <function-arg-def name="input" type="required">
3855N/A <function-arg-description>
3855N/A name of the XML file to where results are obtained
3855N/A </function-arg-description>
3855N/A <function-arg-property name="type" value="string"/>
3855N/A </function-arg-def>
3855N/A <function-arg-def name="output" type="required">
3855N/A <function-arg-description>
3855N/A name of the HTML file to where results are written
3855N/A </function-arg-description>
3855N/A <function-arg-property name="type" value="string"/>
3855N/A </function-arg-def>
3855N/A <function-arg-def name="stylesheet" type="required">
3855N/A <function-arg-description>
3855N/A name of the XSL stylesheet used to transform results
3855N/A </function-arg-description>
3855N/A <function-arg-property name="type" value="string"/>
3855N/A </function-arg-def>
3855N/A </function-map-args>
3855N/A
3855N/A <sequence>
3855N/A
3855N/A <script>
3855N/A xmlFile=input
3855N/A htmlFile=output
3855N/A xslFile=stylesheet
3855N/A </script>
3855N/A
3855N/A <message>'Inputting XML file %s' % xmlFile</message>
3855N/A <message>'Transform XSL file %s' % xslFile</message>
3855N/A <message>'Creating HTML file %s' % htmlFile</message>
3855N/A
3855N/A <script>
3862N/A _message='Generated test case logs.'
3862N/A testCaseLogs=report_generation()
3855N/A stringParamsDict={}
3855N/A
3855N/A try:
3862N/A testCaseLogs.transformReport(xslFile,xmlFile,htmlFile,stringParamsDict)
3855N/A except java.io.FileNotFoundException,details:
3862N/A _message='Unable to generate test case logs %s.' % details
3855N/A except IOError,details:
3862N/A _message='Unable to generate test case logs %s.' % details
3855N/A except:
3862N/A _message='Unable to generate test case logs !!!'
3855N/A </script>
3855N/A
3855N/A <message>'%s' % _message</message>
3855N/A
3855N/A </sequence>
3855N/A
3862N/A </function>
2788N/A
2788N/A <function name="CheckMatches">
2788N/A <function-prolog>
2788N/A check the number of matching sub-string in a string
2788N/A </function-prolog>
2788N/A <function-map-args>
2788N/A <function-arg-def name="string2find" type="required">
2788N/A <function-arg-description>
2788N/A the sub-string to check
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="mainString" type="required">
2788N/A <function-arg-description>
2788N/A the main string where the search is done
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2957N/A <function-arg-def name="caseSensitive" type="optional" default="True">
2788N/A <function-arg-description>
2957N/A comparison using case sensitive, or not value is : True/False
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="string"/>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="nbExpected" type="optional" default="1">
2788N/A <function-arg-description>
2788N/A number of expected sub-string that must be in the main string
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
4626N/A <function-arg-def name="issue" type="optional" default="None">
4626N/A <function-arg-description>
4626N/A Issue id. Corresponds to an issue number.
4626N/A </function-arg-description>
4626N/A <function-arg-property name="type" value="string"/>
4626N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <script>
2788N/A caseSensitiveInfo = '[case sensitive mode]'
2788N/A
2957N/A if caseSensitive == False:
2788N/A string2find = string2find.lower()
2788N/A mainString = mainString.lower()
2788N/A caseSensitiveInfo = '[case insensitive mode]'
2788N/A
2788N/A nbFound = mainString.count(string2find)
2788N/A if nbFound == nbExpected:
2788N/A myMessage = 'SUCCESS : %s matches %s time(s) (expected %s) %s' % (string2find,nbFound,nbExpected,caseSensitiveInfo)
2788N/A myRC=0
2788N/A else:
2788N/A myMessage = 'ERROR : %s matches %s time(s) (expected %s) in "%s" %s' % (string2find,nbFound,nbExpected,mainString,caseSensitiveInfo)
2788N/A myRC=1
2788N/A </script>
2788N/A <if expr="myRC == 0">
2788N/A <sequence>
2788N/A <tcstatus result="'pass'"/>
2788N/A <message log="1">
2788N/A '%s' % myMessage
2788N/A </message>
2788N/A </sequence>
2788N/A <else>
2788N/A <sequence>
4626N/A <if expr="issue == None">
4626N/A <tcstatus result="'fail'"/>
4626N/A <else>
4626N/A <sequence>
4626N/A <call function="'setKnownIssue'">
4626N/A { 'issueId' : issue }
4626N/A </call>
4626N/A </sequence>
4626N/A </else>
4626N/A </if>
2788N/A <message log="1" level="'Error'">
2788N/A '%s' % myMessage
2788N/A </message>
2788N/A </sequence>
2788N/A </else>
2788N/A </if>
2788N/A <return>myRC,myMessage</return>
2788N/A </sequence>
2788N/A </function>
2788N/A
3973N/A <function name="runFunction" scope="local">
2788N/A <function-map-args>
2788N/A <function-arg-def name="functionName" type="required">
2788N/A <function-arg-description>
2788N/A Name of the function to run
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionArguments" type="optional">
2788N/A <function-arg-description>
2788N/A Arguments to be passed on to the called function.
2788N/A This can be a map or a list of arguments, whatever the called function
2788N/A expects will be carried on here.
2788N/A . for a map, pass the arguments like this:
2788N/A { 'argumentA' : 'argumentAvalue' ,
2788N/A 'argumentB' : 1 ,
2788N/A ...
2788N/A }
2788N/A . for a list, pass the arguments like this:
2788N/A [ 'argumentAvalue, 1, ... ]
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="expectedRC" type="optional" default="0">
2788N/A <function-arg-description>
2788N/A The expected return code of the function to run.
2788N/A This is then passed onto the checkRC function.
2788N/A It is also used to throw an exception if the argument
2788N/A functionException is provided and set the test case status if the
2788N/A argument functionSetsTCStatus is provided
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="integer"/>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionException" type="optional">
2788N/A <function-arg-description>
2788N/A The exception to throw if the return code differs from the expected
2788N/A RC. The exception is appended to STAXException.
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionMessage" type="optional">
2788N/A <function-arg-description>
2788N/A An optional message to display before running the function
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionSetsTCStatus" type="optional">
2788N/A <function-arg-description>
2788N/A Whether the function to run sets the testcase status or not.
2788N/A If this is set, the test case status is set according to whether
2788N/A or not the function meets the expected return code.
2788N/A True or False should be used for this argument.
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionFailureTC" type="optional">
2788N/A <function-arg-description>
2788N/A If this argument is provided, a testcase will be created with
2788N/A this argument's value for name and set to fail only upon failure
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionSignal" type="optional">
2788N/A <function-arg-description>
2788N/A If this argument is provided, a signal will be raised upon unsuccesful
2788N/A execution of the function to run
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionCallBack" type="optional">
2788N/A <function-arg-description>
2788N/A If this argument is provided then functionCallBack will be called
2788N/A after the execution of function name.
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A
2788N/A <function-arg-def name="functionCallBackArguments" type="optional">
2788N/A <function-arg-description>
2788N/A This allows to specify arguments for the call back function
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A <sequence>
2788N/A <script>
2788N/A <!-- defining the booleans here should temporary while I find a nicer
2788N/A solution. We have a chicken and egg problem between the
2788N/A loadGlobalEnvironment and loadSharedLibraries functions in
2788N/A environment.xml at the moment.
2788N/A -->
2788N/A if not False:
2788N/A False=0
2788N/A
2788N/A if not True:
2788N/A True=1
3973N/A
3973N/A _expectedRC=int(expectedRC)
3973N/A
2788N/A _throwException=False
2788N/A if functionException:
2788N/A _throwException=True
2788N/A
2788N/A _displayMessage=False
2788N/A if functionMessage:
2788N/A _displayMessage=True
2788N/A
2788N/A _tcStatus='fail'
2788N/A _doSetTCStatus=False
2788N/A if functionSetsTCStatus:
2788N/A _doSetTCStatus=True
2788N/A
2788N/A _createFailureTC=False
2788N/A if functionFailureTC:
2788N/A _createFailureTC=True
2788N/A </script>
3973N/A <message log="1" level="'info'" if="_displayMessage == True">
3973N/A '%s' % functionMessage
3973N/A </message>
3973N/A <message log="1" level="'debug'">
3973N/A 'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)
3973N/A </message>
2788N/A <call function="functionName">functionArguments</call>
2788N/A <script>
3973N/A _functionRC = int(RC)
3973N/A _functionResult = STAXResult
2788N/A </script>
2788N/A
2788N/A <!-- this section handles the optional case when we need to set the
2788N/A test case status
2788N/A -->
2788N/A <if expr="_doSetTCStatus == True">
2788N/A <sequence>
3973N/A <if expr="_functionRC == _expectedRC">
2788N/A <script>_tcStatus='pass'</script>
2788N/A </if>
2788N/A <tcstatus result="_tcStatus" />
2788N/A </sequence>
2788N/A </if>
2788N/A
2788N/A <!-- this section handles the optional case when we need to throw an
2788N/A exception upon unexpected function return code
2788N/A -->
2788N/A <if expr="_throwException == True" >
3973N/A <if expr="_functionRC != _expectedRC" >
2788N/A <throw exception="'STAXException.%s' % functionException" />
2788N/A </if>
2788N/A </if>
2788N/A
2788N/A <!-- this section handles the optional case when we need to set a
2788N/A test case status to fail to reflect the failure in the test report.
2788N/A -->
2788N/A <if expr="_createFailureTC == True" >
3973N/A <if expr="_functionRC != _expectedRC" >
2788N/A <testcase name="'!!! %s [%s]' % (functionFailureTC,functionName)">
2788N/A <tcstatus result="'fail'" />
2788N/A </testcase>
2788N/A </if>
2788N/A </if>
2788N/A
2788N/A <!-- TODO: implement the signal raising mechanism -->
2788N/A <!-- TODO: implement the call back function mechanism -->
2788N/A
3973N/A <!-- bubble the function return code and result up one level -->
3973N/A <return>[_functionRC,_functionResult]</return>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="runCommand" >
2788N/A <function-description>
2788N/A A general wrapper to run a command without having to write a dedicated
2788N/A function for it
2788N/A </function-description>
2788N/A <function-map-args>
2788N/A <function-arg-def name="command" type="required">
2788N/A <function-arg-description>
2788N/A the command to run
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="path" type="optional" default="dsBinPath">
2788N/A <function-arg-description>
2788N/A the path where the command is to be run from
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="arguments" type="optional" default="''">
2788N/A <function-arg-description>
2788N/A the path where the command is to be found
2788N/A </function-arg-description>
2788N/A </function-arg-def>
3949N/A <function-arg-def name="envCmd"
3949N/A type="optional"
3949N/A default="''">
2788N/A <function-arg-description>
2788N/A the environment variables to set. The default set here should just
2788N/A work for OpenDS commands
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="location"
2788N/A type="optional"
2788N/A default="STAXServiceMachine">
2788N/A <function-arg-description>
2788N/A Which machine should the command be executed on
2788N/A </function-arg-description>
2788N/A </function-arg-def>
4458N/A <function-arg-def name="name"
2788N/A default="'Running %s' % command"
2788N/A type="optional">
2788N/A <function-arg-description>
2788N/A The name to give the process (only matters in the STAX Monitor really)
2788N/A </function-arg-description>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="stripOutput" default="True" type="optional">
2788N/A <function-arg-description>
2788N/A A boolean (use True or False here, case matters) to enable disable
2788N/A stripping the output of a command
2788N/A TODO: consider allowing passing a function name to enable custom
2788N/A output manipulation (overkill?)
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="enum">
2788N/A <function-arg-property-description>
2788N/A This argument can only have boolean values
2788N/A </function-arg-property-description>
2788N/A <function-arg-property-data type="choice" value="True"/>
2788N/A <function-arg-property-data type="choice" value="False"/>
2788N/A </function-arg-property>
2788N/A </function-arg-def>
2788N/A <function-arg-def name="timerDuration"
2788N/A type="optional"
2788N/A default="'5m'">
2788N/A <function-arg-description>
2788N/A The duration that the process is allowed to run
2788N/A </function-arg-description>
3287N/A </function-arg-def>
3847N/A <function-arg-def name="inputFile" type="optional" default="'None'">
3847N/A <function-arg-description>
3847N/A input file containing the command input
3847N/A </function-arg-description>
3847N/A <function-arg-property name="type" value="file"/>
3847N/A </function-arg-def>
3287N/A <function-arg-def name="outputFile" type="optional" default="'None'">
3287N/A <function-arg-description>
3287N/A Output file containing the command output
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="file"/>
3287N/A </function-arg-def>
3194N/A <function-arg-def name="expectedRC" type="optional" default="0">
2949N/A <function-arg-description>
3194N/A Expected return code value. Default value is 0.
3194N/A Wildcard 'noCheck' to not check the RC
2949N/A </function-arg-description>
2949N/A </function-arg-def>
3951N/A <function-arg-def name="knownIssue" type="optional" default="None">
3951N/A <function-arg-description>
3951N/A Known issue. Corresponds to an issue number.
3951N/A </function-arg-description>
3951N/A </function-arg-def>
3315N/A <function-arg-def name="logStderr" type="optional" default="True">
3315N/A <function-arg-description>
3315N/A If true, stderr for the command is redirect to stdout.
3315N/A </function-arg-description>
3315N/A <function-arg-property name="type" value="enum">
3315N/A <function-arg-property-description>
3315N/A This argument can only have boolean values
3315N/A </function-arg-property-description>
3315N/A <function-arg-property-data type="choice" value="True"/>
3315N/A <function-arg-property-data type="choice" value="False"/>
3315N/A </function-arg-property>
3315N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A <sequence>
2788N/A <script>
2788N/A import random
2788N/A import java.util.Date
2788N/A random.seed(java.util.Date().getTime())
2788N/A _id = '%s#%d' % (strftime('%Y-%m-%d %H:%M:%S',localtime()),random.randint(0,999))
2788N/A
3949N/A env=[]
3949N/A for item in envCmd:
3949N/A env.append('%s' % item)
3949N/A if is_windows_platform(location):
4458N/A env.append('PATH=%s\\bin;C:\\Windows;C:\\Windows\\system32;%s' % (REMOTE_STAF_ROOT,path))
3949N/A env.append('JAVA_HOME=%s' % JAVA_HOME)
3949N/A else:
3949N/A env.append('PATH=/bin:/usr/bin:%s' % path)
3949N/A env.append('JAVA_HOME=%s' % JAVA_HOME)
4865N/A
4865N/A if command.endswith('setup.bat') or command.endswith('uninstall.bat'):
4865N/A arguments = arguments + ' &amp; set PROCESSRC=%ERRORLEVEL% &amp; exit %PROCESSRC%'
2788N/A </script>
2788N/A <message>
2788N/A '%s: Running command:\n %s %s\nlocation: %s\nenv: %s\nworkdir: %s' % (_id,command,arguments,location,env,path)
2788N/A </message>
3315N/A
3315N/A <!-- If 'logStderr' is True then redirect sdterr to sdtout -->
3315N/A <if expr="logStderr == True">
3315N/A <process name="name">
3315N/A <location>location</location>
3315N/A <command>command</command>
3315N/A <parms>arguments</parms>
3315N/A <workdir>path</workdir>
3315N/A <envs>env</envs>
3315N/A <console use="'same'"/>
3600N/A <stdout if="outputFile != 'None'" mode="'replace'">'%s' % outputFile</stdout>
3315N/A <stderr mode="'stdout'"/>
3315N/A <returnstdout/>
3315N/A </process>
3847N/A <elseif expr="inputFile != 'None'">
3847N/A <process name="name">
3847N/A <location>location</location>
3847N/A <command>command</command>
3847N/A <parms>arguments</parms>
3847N/A <workdir>path</workdir>
3847N/A <envs>env</envs>
3847N/A <console use="'same'"/>
3847N/A <stdin>'%s' % inputFile</stdin>
3847N/A <returnstdout/>
3847N/A </process>
3847N/A </elseif>
3847N/A <else>
3847N/A <process name="name">
3847N/A <location>location</location>
3847N/A <command>command</command>
3847N/A <parms>arguments</parms>
3847N/A <workdir>path</workdir>
3847N/A <envs>env</envs>
3847N/A <console use="'same'"/>
3847N/A <stdout if="outputFile != 'None'" mode="'replace'">'%s' % outputFile</stdout>
3847N/A <returnstdout/>
3847N/A </process>
3847N/A </else>
3315N/A </if>
4865N/A
3322N/A <!-- The problem here is that STAXResult can either be a
3322N/A string, list or a map object -->
3194N/A <script>
3322N/A try:
3322N/A cmdOutput=STAXResult[0][1]
3322N/A cmdRC = RC
3322N/A except:
3322N/A cmdOutput=STAXResult
3322N/A cmdRC = RC
3322N/A
3322N/A cmdResult=STAXResult
3194N/A </script>
3322N/A
2788N/A <script>
2788N/A def dig(var):
2788N/A try:
2788N/A if var.__class__==[].__class__:
2788N/A for i in range(len(var)):
2788N/A var[i]=dig(var[i])
2788N/A return var
2788N/A else:
2788N/A if var.__class__==''.__class__:
2788N/A return re.compile(r'EMMA:.*\n').sub('',var)
2788N/A else:
2788N/A return var
2788N/A except TypeError:
2788N/A return 'could not evaluate the following component: %s' % var
2788N/A
2788N/A if stripOutput == True:
3322N/A cmdResult=dig(cmdResult)
2788N/A </script>
4711N/A
4711N/A <if expr="expectedRC != 'noCheck'">
4711N/A <call function="'checktestRC'">
4711N/A { 'returncode' : cmdRC,
4711N/A 'result' : cmdResult,
4711N/A 'expected' : expectedRC,
4711N/A 'issue' : knownIssue
4711N/A }
4711N/A </call>
4711N/A </if>
4711N/A
2788N/A <return>
3322N/A cmdResult
2788N/A </return>
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A
2788N/A
2788N/A <function name="killDs">
2788N/A <function-prolog>
2788N/A Kill the ldap server
2788N/A </function-prolog>
2788N/A <function-map-args>
2913N/A <function-arg-def name="location"
2913N/A type="optional"
2913N/A default="STAF_REMOTE_HOSTNAME">
2788N/A <function-arg-description>
2788N/A Location of target host
3269N/A </function-arg-description>
3269N/A <function-arg-property name="type" value="hostname"/>
2788N/A </function-arg-def>
2913N/A <function-arg-def name="dsPath"
2913N/A type="optional"
2913N/A default="'%s/%s'
2913N/A % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
2788N/A <function-arg-description>
2788N/A Pathname to installation root
2788N/A </function-arg-description>
2788N/A <function-arg-property name="type" value="pathname"/>
2788N/A </function-arg-def>
2788N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A <message>
2788N/A 'Kill server running on %s at %s' % (location, dsPath)
2788N/A </message>
2788N/A
2788N/A <script>
2788N/A pidPath = '%s/logs/server.pid' % dsPath
2913N/A _args = '%s' % pidPath
2913N/A </script>
2788N/A
2913N/A <call function="'runSTAFCommand'">
2913N/A { 'name' : 'Read server pid file',
2913N/A 'location' : location,
2913N/A 'service' : 'FS',
2913N/A 'request' : 'GET FILE',
2913N/A 'arguments' : _args
2913N/A }
2913N/A </call>
2913N/A
2913N/A <script>
3621N/A if is_windows_platform(location):
2788N/A _cmd = 'tskill'
3203N/A _args = STAXResult
2788N/A else:
4458N/A _cmd = '/bin/kill'
3203N/A pid = STAXResult[:-1]
2788N/A _args = '-9 %s' % pid
2788N/A </script>
2788N/A <call function="'runCommand'">
2788N/A { 'name' : 'Kill DS server',
2788N/A 'location' : location,
2788N/A 'command' : _cmd,
2788N/A 'arguments' : _args
2788N/A }
2788N/A </call>
2788N/A <return>STAXResult</return>
2788N/A </sequence>
2788N/A </function>
2788N/A
2858N/A <function name="runSTAFCommand" >
2858N/A <function-description>
2858N/A A general wrapper to run a STAF command without having to write a
2858N/A dedicated function for it
2858N/A </function-description>
2858N/A <function-map-args>
2858N/A <function-arg-def name="location" type="optional" default="STAXServiceMachine">
2858N/A <function-arg-description>
2858N/A Which machine should the command be executed on
2858N/A </function-arg-description>
2858N/A </function-arg-def>
2858N/A <function-arg-def name="name" type="required">
2858N/A <function-arg-description>
2858N/A The name to give the process
2858N/A </function-arg-description>
2858N/A </function-arg-def>
2858N/A <function-arg-def name="service" type="required">
2858N/A <function-arg-description>
2858N/A the command to run
2858N/A </function-arg-description>
2858N/A </function-arg-def>
2858N/A <function-arg-def name="request" type="required">
2858N/A <function-arg-description>
2858N/A the command to run
2858N/A </function-arg-description>
2858N/A </function-arg-def>
2858N/A <function-arg-def name="arguments" type="optional" default="''">
2858N/A <function-arg-description>
2858N/A the arguments for the service request
2858N/A </function-arg-description>
2858N/A </function-arg-def>
2858N/A </function-map-args>
2858N/A <sequence>
2858N/A <script>
2858N/A import random
2858N/A import java.util.Date
2858N/A random.seed(java.util.Date().getTime())
2858N/A _id = '%s#%d' % (strftime('%Y-%m-%d %H:%M:%S',localtime()),random.randint(0,99999))
2858N/A
2858N/A </script>
2858N/A <message>
2858N/A '%s: Running STAF command:\n %s %s %s\nlocation: %s\n' % (_id,service,request,arguments,location)
2858N/A </message>
2858N/A
2858N/A <block name="'%s:Wrapper for %s' % (_id,name)">
2858N/A <stafcmd name="'STAF Command: %s' % name">
2858N/A <location>'%s' % location</location>
2858N/A <service>service</service>
2858N/A <request>
2858N/A '%s %s' % (request,arguments)
2858N/A </request>
2858N/A </stafcmd>
2858N/A </block>
2858N/A
2858N/A <message level="'info'">
2858N/A '%s: STAF Command returned:\n%s' % (_id,STAFResult)
2858N/A </message>
2858N/A
2858N/A <return>
2858N/A STAFResult
2858N/A </return>
2858N/A </sequence>
2858N/A </function>
3269N/A
3269N/A <function name="grep">
3269N/A <function-prolog>
3269N/A This function search for a given string in a given file.
3269N/A BEWARE! of potential performance degradation when grepping big files due
3269N/A to the use of getFile, which loads the whole file content into a variable.
3269N/A </function-prolog>
3269N/A <function-map-args>
3269N/A <function-arg-def name="location"
3269N/A type="optional"
3269N/A default="STAF_REMOTE_HOSTNAME">
3269N/A <function-arg-description>
3269N/A Location of target host
3269N/A </function-arg-description>
3269N/A <function-arg-property name="type" value="hostname"/>
3269N/A </function-arg-def>
3269N/A <function-arg-def name="filename" type="required">
3269N/A <function-arg-description>
3269N/A File path
3269N/A </function-arg-description>
3269N/A <function-arg-property name="type" value="pathname"/>
3269N/A </function-arg-def>
3269N/A <function-arg-def name="testString" type="required">
3269N/A <function-arg-description>
3269N/A String searched
3269N/A </function-arg-description>
3269N/A <function-arg-property name="type" value="string"/>
3269N/A </function-arg-def>
3269N/A <function-arg-def name="expectedRC" type="optional" default="0">
3269N/A <function-arg-description>
3269N/A Expected return code value.
3269N/A 0 for successful grep, 1 for unsuccessful grep. Default value is 0.
3269N/A Wildcard 'noCheck' to not check the RC
3269N/A </function-arg-description>
3269N/A </function-arg-def>
3269N/A </function-map-args>
3269N/A
3269N/A <sequence>
3269N/A <message>
3269N/A 'Search for string \"%s\" in file %s on host %s' % \
3269N/A (testString, filename, location)
3269N/A </message>
3269N/A
3269N/A <call function="'getFile'">
3269N/A {
3269N/A 'location' : location,
3269N/A 'filename' : filename
3269N/A }
3269N/A </call>
3269N/A
3269N/A <script>
3269N/A # getFile returns: STAXResult = [cmdRC, cmdResult]
3269N/A filecontent = STAXResult[1]
3269N/A
3269N/A if (expectedRC == 'noCheck'):
3269N/A # don't care about expected result
3269N/A myExpectedResult = '2'
3269N/A elif (expectedRC == 0):
3269N/A # expect testString to be present in filecontent
3269N/A myExpectedResult = '1'
3269N/A else:
3269N/A # expect testString not to be present in filecontent
3269N/A myExpectedResult = '0'
3269N/A </script>
3269N/A
3269N/A <call function="'searchStringForSubstring'">
3269N/A {
3269N/A 'testString' : testString,
3269N/A 'returnString' : filecontent,
3269N/A 'expectedResult' : myExpectedResult
3269N/A }
3269N/A </call>
3269N/A
3269N/A <return>STAXResult</return>
3269N/A </sequence>
3269N/A </function>
3269N/A
3287N/A <function name="compareFile">
3287N/A <function-prolog>
3287N/A This function compares two files.
3287N/A Print the differences if the comparison failed.
3287N/A </function-prolog>
3287N/A <function-map-args>
3287N/A <function-arg-def name="location"
3287N/A type="optional"
3287N/A default="STAXServiceMachine">
3287N/A <function-arg-description>
3287N/A Location of target host
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="hostname"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="remotehost"
3287N/A type="optional"
3287N/A default="STAF_REMOTE_HOSTNAME">
3287N/A <function-arg-description>
3287N/A The name of remote host
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="hostname"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="dsPath"
3287N/A type="optional"
4153N/A default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
3287N/A <function-arg-description>
3287N/A Pathname to installation root
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="hostname"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="outputFile" type="required">
3287N/A <function-arg-description>
3287N/A file containing output from the command
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="file"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="outputPath" type="optional">
3287N/A <function-arg-description>
3287N/A path containing outputFile
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="filepath"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="refFile" type="optional">
3287N/A <function-arg-description>
3287N/A reference file containing expected output
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="file"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="refPath" type="optional">
3287N/A <function-arg-description>
3287N/A reference path containing refFile
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="filepath"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="diffFile" type="optional">
3287N/A <function-arg-description>
3287N/A file containing diff output
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="file"/>
3287N/A </function-arg-def>
3287N/A <function-arg-def name="diffPath" type="optional">
3287N/A <function-arg-description>
3287N/A file containing diffFile
3287N/A </function-arg-description>
3287N/A <function-arg-property name="type" value="filepath"/>
3287N/A </function-arg-def>
3951N/A <function-arg-def name="knownIssue" type="optional" default="None">
3951N/A <function-arg-description>
3951N/A Known issue. Corresponds to an issue number.
3951N/A </function-arg-description>
3951N/A <function-arg-property name="type" value="string" />
3951N/A </function-arg-def>
3287N/A </function-map-args>
3287N/A
3287N/A <sequence>
3287N/A <script>
3287N/A if CurrentTestPath.has_key('group'):
3287N/A ThisGroupName = CurrentTestPath['group']
3287N/A else:
3287N/A ThisGroupName = 'unknown-group'
3287N/A
3287N/A FormattedTestcase = format_testcase()
3287N/A FormattedTestgroup = FormattedTestcase.group(ThisGroupName)
3287N/A
3287N/A if not outputPath:
3287N/A outputPath = '%s/..' % (dsPath)
3287N/A
3287N/A if not refFile:
3287N/A regexp = re.compile('\..*$')
3287N/A tmpName = re.sub(regexp, '', outputFile)
3287N/A refFile = '%s.ref' % tmpName
3287N/A
3287N/A if not refPath:
3816N/A refPath = '%s/%s' % (local.data,FormattedTestgroup)
3287N/A
3287N/A if not diffFile:
3287N/A regexp = re.compile('\..*$')
3287N/A tmpName = re.sub(regexp, '', outputFile)
3287N/A diffFile = '%s.diff' % tmpName
3287N/A
3287N/A if not diffPath:
3816N/A diffPath = '%s/%s/diffs' % (logs.tests,FormattedTestgroup)
3287N/A else:
3287N/A diffPath = '%s/diffs' % (diffPath)
3287N/A
3287N/A cflocation=location
3287N/A cfremotehost=remotehost
3287N/A </script>
3287N/A
3287N/A <!-- Check if 'diffPath' is already created -->
3287N/A <call function="'GetEntry'">
3287N/A {
3287N/A 'location' : cflocation,
3287N/A 'entry' : diffPath,
3287N/A 'attribute' : 'TYPE'
3287N/A }
3287N/A </call>
3287N/A <!-- If 'diffPath' is not already created then create it -->
3287N/A <if expr="RC == 48">
3287N/A <sequence>
3287N/A <message>
3287N/A 'Create folder %s' % diffPath
3287N/A </message>
3287N/A <call function="'createFolder'">
3287N/A {
3287N/A 'location' : cflocation ,
3287N/A 'foldername' : diffPath
3287N/A }
3287N/A </call>
3287N/A </sequence>
3287N/A </if>
3287N/A
3287N/A <message>
3287N/A 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \
3287N/A (outputPath, outputFile, cfremotehost, diffPath, outputFile, cflocation)
3287N/A </message>
3287N/A <call function="'copyFile'">
3287N/A {
3287N/A 'location' : cfremotehost ,
3287N/A 'srcfile' : '%s/%s' % (outputPath, outputFile) ,
3287N/A 'destfile' : '%s/%s' % (diffPath, outputFile) ,
3287N/A 'remotehost' : cflocation
3287N/A }
3287N/A </call>
3287N/A <script>
3287N/A outputRC=RC
3287N/A </script>
3287N/A
3287N/A <message>
3287N/A 'Copy file %s/%s (on %s) to %s/%s (on %s)' % \
3287N/A (refPath, refFile, cflocation, diffPath, refFile, cflocation)
3287N/A </message>
3287N/A <call function="'copyFile'">
3287N/A {
3287N/A 'location' : cflocation ,
3287N/A 'srcfile' : '%s/%s' % (refPath, refFile) ,
3287N/A 'destfile' : '%s/%s' % (diffPath, refFile) ,
3287N/A 'remotehost' : cflocation
3287N/A }
3287N/A </call>
3287N/A <script>
3287N/A refRC=RC
3287N/A </script>
3287N/A
3287N/A <!-- If the copy of 'outputFile' and 'refFile' succeed
3287N/A then compare these files -->
3287N/A <if expr="outputRC == 0 and refRC == 0">
3287N/A <sequence>
3287N/A <message>
3287N/A 'Compare file %s/%s to %s/%s on %s' % \
3287N/A (diffPath, outputFile, diffPath, refFile, cflocation)
3287N/A </message>
3287N/A <script>
3287N/A CompareFile = compare_file('%s/%s' % (diffPath, outputFile),
3287N/A '%s/%s' % (diffPath, refFile),
3287N/A '%s/%s' % (diffPath, diffFile))
3287N/A diff = CompareFile.genDiff()
3287N/A </script>
3287N/A
3287N/A <if expr="diff == ''">
3287N/A <sequence>
3287N/A <tcstatus result="'pass'"/>
3287N/A <message log="1">
3287N/A 'SUCCESS : No differences were found between %s and %s' % \
3287N/A (outputFile, refFile)
3287N/A </message>
3287N/A </sequence>
3287N/A <else>
3287N/A <sequence>
3951N/A <if expr="knownIssue == None">
3951N/A <tcstatus result="'fail'"/>
3951N/A <else>
3951N/A <call function="'setKnownIssue'">
3951N/A { 'issueId' : knownIssue }
3951N/A </call>
3951N/A </else>
3951N/A </if>
3287N/A <message log="1">
3287N/A 'ERROR : Differences were found between %s and %s\n%s' % \
3287N/A (outputFile, refFile, diff)
3287N/A </message>
3287N/A <message log="1">
3287N/A 'ERROR : Diff file is here: %s/%s' % (diffPath, diffFile)
3287N/A </message>
3287N/A </sequence>
3287N/A </else>
3287N/A </if>
3287N/A </sequence>
3287N/A <else>
3287N/A <sequence>
3287N/A <tcstatus result="'fail'"/>
3287N/A <message log="1">
3287N/A 'ERROR : Error during file comparision'
3287N/A </message>
3287N/A </sequence>
3287N/A </else>
3287N/A </if>
3287N/A </sequence>
3287N/A </function>
3549N/A
3600N/A <function name="compileJava" scope="local">
3600N/A <function-prolog>
3600N/A This function compile java files.
3600N/A </function-prolog>
3600N/A <function-map-args>
3600N/A <function-arg-def name="location"
3600N/A type="optional"
3600N/A default="STAXServiceMachine">
3600N/A <function-arg-description>
3600N/A Location of remote host
3600N/A </function-arg-description>
3600N/A <function-arg-property name="type" value="hostname"/>
3600N/A </function-arg-def>
4714N/A <function-arg-def name="foldername" type="optional">
3600N/A <function-arg-description>
3600N/A Path containing java files to compile
3600N/A </function-arg-description>
3600N/A <function-arg-property name="type" value="filepath"/>
3600N/A </function-arg-def>
4714N/A <function-arg-def name="destfolder" type="optional">
4714N/A <function-arg-description>
4714N/A Path where to place generated class files
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="filepath"/>
4714N/A </function-arg-def>
3600N/A <function-arg-def name="classpath" type="optional">
3600N/A <function-arg-description>
3600N/A Additional classpath
3600N/A </function-arg-description>
3600N/A <function-arg-property name="type" value="string"/>
3600N/A </function-arg-def>
3600N/A <function-arg-def name="expectedRC" type="optional" default="0">
3600N/A <function-arg-description>
4714N/A Expected return code value. Default value is 0.
3600N/A Wildcard 'noCheck' to not check the RC
3600N/A </function-arg-description>
3600N/A </function-arg-def>
3600N/A </function-map-args>
3600N/A
3600N/A <sequence>
3605N/A
3605N/A <!-- Build the command -->
3600N/A <script>
4714N/A cmdOptions = ''
4714N/A
3643N/A if is_windows_platform(location):
3643N/A separator=';'
3643N/A else:
3643N/A separator=':'
3643N/A
3600N/A if classpath:
3643N/A cp = 'CLASSPATH=%s%s.' % (classpath, separator)
3600N/A else:
3600N/A cp = 'CLASSPATH=.'
3621N/A
3600N/A if location == STAXServiceMachine:
3816N/A cmd = '%s/bin/javac' % LOCAL_JAVA_HOME
3600N/A env = ['%s' % cp]
3600N/A else:
3600N/A cmd = '%s/bin/javac' % JAVA_HOME
4711N/A env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp]
4714N/A
4714N/A if destfolder:
4714N/A cmdOptions = '-d %s' % destfolder
3600N/A </script>
3621N/A
3600N/A <call function="'listFolderByExtension'" >
3600N/A {
3600N/A 'location' : location ,
3600N/A 'foldername' : foldername ,
3600N/A 'extension' : 'java'
3600N/A }
3600N/A </call>
3600N/A
3600N/A <script>
3600N/A cmdResult = STAXResult
3600N/A </script>
3600N/A
3600N/A <if expr="cmdResult != 'Folder does not exist.'">
3600N/A <sequence>
3600N/A <script>
3600N/A list = ""
3600N/A for file in cmdResult:
3600N/A list = list + " " + file
3600N/A </script>
3600N/A
3600N/A <call function="'runCommand'" >
3600N/A {
3600N/A 'name' : 'Compile Java files' ,
3600N/A 'command' : cmd ,
4714N/A 'arguments' : '-target 1.5 %s %s' % (cmdOptions,list) ,
3600N/A 'location' : location ,
3600N/A 'path' : foldername ,
3949N/A 'envCmd' : env ,
3600N/A 'expectedRC' : expectedRC
3600N/A }
3600N/A </call>
3600N/A </sequence>
3600N/A <else>
3600N/A <tcstatus result="'fail'"></tcstatus>
3600N/A </else>
3600N/A </if>
3600N/A
3600N/A <return>
3600N/A STAXResult
3600N/A </return>
3600N/A </sequence>
3600N/A </function>
3600N/A
4714N/A <function name="createJar" scope="local">
4714N/A <function-prolog>
4714N/A This function create a jar file.
4714N/A </function-prolog>
4714N/A <function-map-args>
4714N/A <function-arg-def name="location"
4714N/A type="optional"
4714N/A default="STAXServiceMachine">
4714N/A <function-arg-description>
4714N/A Location of remote host
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="hostname"/>
4714N/A </function-arg-def>
4714N/A <function-arg-def name="jarname" type="required">
4714N/A <function-arg-description>
4714N/A Name of the jar file to create
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="string"/>
4714N/A </function-arg-def>
4714N/A <function-arg-def name="entrypoint" type="required">
4714N/A <function-arg-description>
4714N/A Path where to find generated class files
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="string"/>
4714N/A </function-arg-def>
4714N/A <function-arg-def name="pathfolder" type="required">
4714N/A <function-arg-description>
4714N/A Execution path
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="filepath"/>
4714N/A </function-arg-def>
4714N/A <function-arg-def name="manifestpath" type="optional">
4714N/A <function-arg-description>
4714N/A Path to the manifest file
4714N/A </function-arg-description>
4714N/A <function-arg-property name="type" value="filepath"/>
4714N/A </function-arg-def>
4714N/A <function-arg-def name="expectedRC" type="optional" default="0">
4714N/A <function-arg-description>
4714N/A Expected return code value. Default value is 0.
4714N/A Wildcard 'noCheck' to not check the RC
4714N/A </function-arg-description>
4714N/A </function-arg-def>
4714N/A </function-map-args>
4714N/A
4714N/A <sequence>
4714N/A
4714N/A <!-- Build the command -->
4714N/A <script>
4714N/A if location == STAXServiceMachine:
4714N/A cmd = '%s/bin/jar' % LOCAL_JAVA_HOME
4714N/A else:
4714N/A cmd = '%s/bin/jar' % JAVA_HOME
4714N/A
4714N/A if manifestpath:
4714N/A cmdOptions = 'cmf %s' % manifestpath
4714N/A else:
4714N/A cmdOptions = 'cf'
4714N/A </script>
4714N/A
4714N/A <!-- Check if the classfolder exists -->
4714N/A <call function="'GetEntry'">
4714N/A {
4714N/A 'location' : location ,
4714N/A 'entry' : '%s/%s' % (pathfolder,entrypoint) ,
4714N/A 'attribute' : 'TYPE'
4714N/A }
4714N/A </call>
4714N/A <if expr="RC != 48">
4714N/A <sequence>
4714N/A <call function="'runCommand'" >
4714N/A {
4714N/A 'name' : 'Create Jar file' ,
4714N/A 'command' : cmd ,
4714N/A 'arguments' : '%s %s %s' % (cmdOptions,jarname,entrypoint) ,
4714N/A 'location' : location ,
4714N/A 'path' : pathfolder ,
4714N/A 'expectedRC' : expectedRC
4714N/A }
4714N/A </call>
4714N/A </sequence>
4714N/A <else>
4714N/A <tcstatus result="'fail'"></tcstatus>
4714N/A </else>
4714N/A </if>
4714N/A
4714N/A <return>
4714N/A STAXResult
4714N/A </return>
4714N/A </sequence>
4714N/A </function>
4714N/A
3549N/A <function name="getFreePort" scope="local">
3549N/A <function-description>
3549N/A Returns the first free TCP port greater or equal to given number
3549N/A </function-description>
3549N/A <function-map-args>
3600N/A <function-arg-def name="host"
3600N/A type="optional"
3600N/A default="STAXServiceMachine">
3549N/A <function-arg-description>
3549N/A Which machine to look for the free port
3549N/A </function-arg-description>
3549N/A </function-arg-def>
3549N/A <function-arg-def name="port" type="required">
3549N/A <function-arg-description>
3549N/A The minimal port number to be returned
3549N/A </function-arg-description>
3549N/A </function-arg-def>
3549N/A </function-map-args>
3549N/A <sequence>
3549N/A <script>
3549N/A # returns first free port in [port; port+5]
3549N/A # if no free port in this interval, return -1
3630N/A from java.net import Socket
3630N/A from java.net import InetAddress
3630N/A from java.io import IOException
3630N/A
3630N/A hostAddr = InetAddress.getByName(host)
3549N/A i = 0
3630N/A
3549N/A while 1:
3549N/A i = i + 1
3549N/A if i > 5:
3630N/A port = -1
3630N/A break
3630N/A try:
3630N/A s = Socket(hostAddr, port)
3630N/A s.close()
3630N/A port = port + 1
3630N/A except IOException, ioe:
3630N/A break
3549N/A </script>
3549N/A <return>port</return>
3549N/A </sequence>
3549N/A </function>
3549N/A
3613N/A <function name="checkFileExists" scope="local">
3613N/A <function-description>
3613N/A Set testcase result to FAIL if file (as param) does not exist
3613N/A </function-description>
3613N/A <function-map-args>
3949N/A <function-arg-def name="location"
3949N/A type="optional"
3949N/A default="STAXServiceMachine">
3949N/A <function-arg-description>
3949N/A Location of target host
3949N/A </function-arg-description>
3949N/A <function-arg-property name="type" value="hostname"/>
3949N/A </function-arg-def>
3613N/A <function-arg-def name="file" type="required">
3613N/A <function-arg-description>
3613N/A The file to check existence
3613N/A </function-arg-description>
3613N/A </function-arg-def>
3613N/A </function-map-args>
3613N/A <sequence>
3949N/A <call function="'GetEntry'">
3949N/A {
3949N/A 'location' : STAF_REMOTE_HOSTNAME ,
3949N/A 'entry' : file ,
3949N/A 'attribute' : 'TYPE'
3949N/A }
3949N/A </call>
3949N/A <if expr="RC == 48">
3949N/A <sequence>
3949N/A <tcstatus result="'fail'"/>
3949N/A <message log="1" level="'Error'">
3949N/A 'ERROR : File %s does not exist' % file
3949N/A </message>
3949N/A </sequence>
3613N/A </if>
3613N/A </sequence>
3613N/A </function>
3613N/A
3613N/A <function name="checkFileNotExists" scope="local">
3613N/A <function-description>
3613N/A Set testcase result to FAIL if file (as param) exists
3613N/A </function-description>
3613N/A <function-map-args>
3949N/A <function-arg-def name="location"
3949N/A type="optional"
3949N/A default="STAXServiceMachine">
3949N/A <function-arg-description>
3949N/A Location of target host
3949N/A </function-arg-description>
3949N/A <function-arg-property name="type" value="hostname"/>
3949N/A </function-arg-def>
3613N/A <function-arg-def name="file" type="required">
3613N/A <function-arg-description>
3613N/A The file to check absence
3613N/A </function-arg-description>
3613N/A </function-arg-def>
3613N/A </function-map-args>
3613N/A <sequence>
3949N/A <call function="'GetEntry'">
3949N/A {
3949N/A 'location' : STAF_REMOTE_HOSTNAME ,
3949N/A 'entry' : file ,
3949N/A 'attribute' : 'TYPE'
3949N/A }
3949N/A </call>
3949N/A <if expr="RC != 48">
3949N/A <sequence>
3949N/A <tcstatus result="'fail'"/>
3949N/A <message log="1" level="'Error'">
3949N/A 'ERROR : File %s does not exist' % file
3949N/A </message>
3949N/A </sequence>
3613N/A </if>
3613N/A </sequence>
3613N/A </function>
4495N/A
4495N/A
4495N/A <function name="ldclt">
4495N/A <function-prolog>
4495N/A This function execute the ldclt tools.
4495N/A </function-prolog>
4495N/A <function-map-args>
4495N/A <function-arg-def name="location"
4495N/A type="optional"
4495N/A default="STAF_CLIENT_HOSTNAME">
4495N/A <function-arg-description>
4495N/A Location of target host
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="hostname"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="dsInstanceHost"
4495N/A type="optional"
4495N/A default="DIRECTORY_INSTANCE_HOST">
4495N/A <function-arg-description>
4495N/A Directory server hostname or IP address
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="hostname"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="dsInstancePort"
4495N/A type="optional"
4495N/A default="DIRECTORY_INSTANCE_PORT">
4495N/A <function-arg-description>
4495N/A Directory server port number
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="Port number"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="dsInstanceDn"
4495N/A type="optional"
4495N/A default="DIRECTORY_INSTANCE_DN">
4495N/A <function-arg-description>
4495N/A Bind DN
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="DN"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="dsInstancePswd"
4495N/A type="optional"
4495N/A default="DIRECTORY_INSTANCE_PSWD">
4495N/A <function-arg-description>
4495N/A Bind password
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="string"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="dsBaseDn"
4495N/A type="optional"
4495N/A default="DIRECTORY_INSTANCE_SFX">
4495N/A <function-arg-description>
4495N/A The baseDN for the LDAP operation
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="dn"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="ldcltOptions"
4495N/A type="required">
4495N/A <function-arg-description>
4495N/A The ldclt options
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="dn"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="outputFile"
4495N/A type="required">
4495N/A <function-arg-description>
4495N/A File containing output from the command
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="file"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="outputPath"
4495N/A type="optional"
4495N/A default="remote.temp">
4495N/A <function-arg-description>
4495N/A Path containing outputFile
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="filepath"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="expectedRC" type="optional" default="0">
4495N/A <function-arg-description>
4495N/A Expected return code value. Default value is 0
4495N/A Wildcard 'noCheck' to not check the RC
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="integer"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="knownIssue"
4495N/A type="optional"
4495N/A default="None">
4495N/A <function-arg-description>
4495N/A Known issue. Corresponds to an issue number.
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="string"/>
4495N/A </function-arg-def>
4495N/A </function-map-args>
4495N/A
4495N/A <sequence>
4495N/A <script>
4495N/A STAFCmdParamsList=[]
4495N/A STAFCmdParams=''
4495N/A
4495N/A STAFCmd='%s/bin/ldclt' % LDCLT_DIR
4495N/A
4495N/A if dsInstanceHost:
4495N/A STAFCmdParamsList.append('-h %s' % dsInstanceHost)
4495N/A
4495N/A if dsInstanceHost:
4495N/A STAFCmdParamsList.append('-p %s' % dsInstancePort)
4495N/A
4495N/A if dsInstanceDn:
4495N/A STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
4495N/A
4495N/A if dsInstancePswd:
4495N/A STAFCmdParamsList.append('-w %s' % dsInstancePswd)
4495N/A
4495N/A if dsBaseDn:
4495N/A STAFCmdParamsList.append('-b "%s"' % dsBaseDn)
4495N/A
4495N/A STAFCmdParamsList.append(ldcltOptions)
4495N/A
4495N/A STAFCmdParams=' '.join(STAFCmdParamsList)
4495N/A
4865N/A ld = 'LD_LIBRARY_PATH='
4495N/A env = ['%s' % ld]
4495N/A </script>
4495N/A
4495N/A <call function="'runCommand'" >
4495N/A {
4495N/A 'name' : 'LDCLT Script' ,
4495N/A 'command' : STAFCmd ,
4495N/A 'arguments' : STAFCmdParams ,
4495N/A 'location' : location ,
4495N/A 'path' : LDCLT_DIR ,
4495N/A 'envCmd' : env ,
4495N/A 'outputFile' : '%s/%s' % (outputPath, outputFile) ,
4495N/A 'expectedRC' : expectedRC ,
4495N/A 'logStderr' : True ,
4495N/A 'knownIssue' : knownIssue
4495N/A }
4495N/A </call>
4495N/A
4495N/A <return>
4495N/A STAXResult
4495N/A </return>
4495N/A </sequence>
4495N/A </function>
4495N/A
4495N/A <!-- This function uses make ldif to generate LDIF data files -->
4495N/A <function name="MakeALdcltTemplate">
4495N/A <function-prolog>
4495N/A This function makes a ldclt template file
4495N/A </function-prolog>
4495N/A
4495N/A <function-map-args>
4495N/A <function-arg-def name="templateFile" type="required">
4495N/A <function-arg-description>
4495N/A Template file name
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="filename"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="templateLocation"
4495N/A type="optional"
4495N/A default="STAF_CLIENT_HOSTNAME">
4495N/A <function-arg-description>
4495N/A Template file location
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="filename"/>
4495N/A </function-arg-def>
4495N/A <function-arg-def name="extraLine" type="optional">
4495N/A <function-arg-description>
4495N/A Extra line to add to the mkae-ldif template
4495N/A </function-arg-description>
4495N/A <function-arg-property name="type" value="string"/>
4495N/A </function-arg-def>
4495N/A </function-map-args>
4495N/A <sequence>
4495N/A <!-- Build the import task configuration object -->
4495N/A <script>
4495N/A ldifLines=[]
4495N/A
4495N/A ldifLines.append('objectClass: top')
4495N/A ldifLines.append('objectClass: person')
4495N/A ldifLines.append('objectClass: organizationalPerson')
4495N/A ldifLines.append('objectClass: inetOrgPerson')
4495N/A ldifLines.append('givenName: [A=RNDFROMFILE(%s/ldap/lib/names/Firstname.txt)]' % LDCLT_DIR)
4495N/A ldifLines.append('sn: [B=RNDFROMFILE(%s/ldap/lib/names/Lastname.txt)]' % LDCLT_DIR)
4495N/A ldifLines.append('employeeNumber: [C]')
4495N/A ldifLines.append('cn: [A] [B] [C]')
4495N/A ldifLines.append('mail: user.[C]@example.com')
4495N/A ldifLines.append('initials: [A][B]')
4495N/A ldifLines.append('homePhone: 0[RNDN(1;5;1)] [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)]')
4495N/A ldifLines.append('mobile: 06 [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)]')
4495N/A ldifLines.append('street: [D=RNDFROMFILE(%s/ldap/lib/names/Firstname.txt)]' % LDCLT_DIR)
4495N/A ldifLines.append('l: [E=RNDFROMFILE(%s/ldap/lib/names/Lastname.txt)]' % LDCLT_DIR)
4495N/A ldifLines.append('st: [F=RNDFROMFILE(%s/ldap/lib/names/Firstname.txt)]' % LDCLT_DIR)
4495N/A ldifLines.append('postalCode: [G=RNDN(0;80000;5)]')
4495N/A ldifLines.append('postalAddress: [A] [B] [C][D][E], [F] [G]')
4495N/A ldifLines.append('telephoneNumber: 0[RNDN(1;5;1)] [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)] [RNDN(0;99;2)]')
4495N/A ldifLines.append('description: This is the description for user.[C].')
4495N/A </script>
4495N/A
4495N/A <!-- Write out the make-ldif template file -->
4495N/A <script>
4495N/A tmpTemplateFile = '%s/tempLdcltTemplateFile' % local.temp
4495N/A outfile = open(tmpTemplateFile,"w")
4495N/A
4495N/A for line in ldifLines:
4495N/A outfile.write("%s\n" % line)
4495N/A
4495N/A outfile.close()
4495N/A </script>
4495N/A <script>
4495N/A STAXCode=RC
4495N/A STAXReason=STAXResult
4495N/A </script>
4495N/A <if expr="STAXCode != 0">
4495N/A <sequence>
4495N/A <message level="'error'">
4495N/A 'creation of a ldclt template failed (Code=%s,Reason=%s).' % (STAXCode,STAXReason)
4495N/A </message>
4495N/A </sequence>
4495N/A </if>
4495N/A <call function="'checktestRC'">
4495N/A { 'returncode' : STAXCode ,
4495N/A 'result' : STAXReason }
4495N/A </call>
4495N/A
4495N/A <call function="'copyFile'">
4495N/A { 'location' : STAXServiceMachine,
4495N/A 'srcfile' : tmpTemplateFile,
4495N/A 'destfile' : templateFile,
4495N/A 'remotehost' : templateLocation }
4495N/A </call>
4495N/A
4495N/A <call function="'checktestRC'">
4495N/A {
4495N/A 'returncode' : RC ,
4495N/A 'result' : STAXResult
4495N/A }
4495N/A </call>
4495N/A
4495N/A <return>[RC, STAXResult]</return>
4495N/A
4495N/A </sequence>
4495N/A </function>
4724N/A
4724N/A
4724N/A <!-- This function parses an ldif entry -->
4724N/A <function name="parseLdifEntry">
4724N/A <function-prolog>
4724N/A This function parses an ldif entry and returns a dictionary, e.g.:
4724N/A {'dn':['o=example'],'objectclass':['top','organization'],'o':['example']}
4724N/A </function-prolog>
4495N/A
4724N/A <function-map-args>
4724N/A <function-arg-def name="ldifEntry" type="required">
4724N/A <function-arg-description>
4724N/A Ldif entry to parse (single string).
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A </function-map-args>
4724N/A <sequence>
4724N/A <script>
4724N/A parsedEntry = {}
4724N/A prevAttr = None
4724N/A prevVal = None
4724N/A
4724N/A for line in ldifEntry.splitlines():
4724N/A notBlank = (len(line.strip()) != 0)
4724N/A if notBlank and (not line.startswith(' ')):
4724N/A # line corresponds to an attr:val
4724N/A attr = line[:line.find(':')].strip().lower()
4724N/A val = line[line.find(':') + 1:].lstrip()
4724N/A if val.startswith(':'):
4724N/A val = val[1:].lstrip()
4724N/A if attr == 'objectclass':
4724N/A val = val.lower()
4724N/A
4724N/A if not (attr in parsedEntry.keys()):
4724N/A # This is the first occurrence of this attr
4724N/A parsedEntry[attr] = [val]
4724N/A else:
4724N/A # There is already some value for this attr
4724N/A parsedEntry[attr].append(val)
4724N/A
4724N/A prevAttr = attr
4724N/A prevVal = val
4724N/A elif notBlank:
4724N/A # line corresponds to a trailing value
4724N/A parsedEntry[prevAttr].remove(prevVal)
4724N/A val = prevVal + line.lstrip()
4724N/A parsedEntry[prevAttr].append(val)
4724N/A prevVal = val
4724N/A </script>
4724N/A
4865N/A <return> parsedEntry </return>
4865N/A </sequence>
4865N/A </function>
4865N/A
4865N/A
4865N/A <!-- This function parses several ldif entries -->
4865N/A <function name="parseLdifEntries">
4865N/A <function-prolog>
4865N/A This function parses several ldif entries and returns a list of
4865N/A dictionaries such as those produced by parseLdifEntry
4865N/A </function-prolog>
4865N/A
4865N/A <function-map-args>
4865N/A <function-arg-def name="ldifEntries" type="required">
4865N/A <function-arg-description>
4865N/A Ldif entries to parse (single string).
4865N/A </function-arg-description>
4865N/A <function-arg-property name="type" value="string"/>
4865N/A </function-arg-def>
4865N/A </function-map-args>
4865N/A <sequence>
4865N/A <script>
4865N/A parsedEntryList = []
4865N/A ldifEntryList = []
4865N/A ldifEntryLines = []
4865N/A ldifEntry = None
4865N/A
4865N/A for line in ldifEntries.splitlines():
4865N/A notBlank = (len(line.strip()) != 0)
4865N/A if notBlank:
4865N/A ldifEntryLines.append(line)
4865N/A else:
4865N/A if len(ldifEntryLines) != 0:
4865N/A ldifEntry = '\n'.join(ldifEntryLines)
4865N/A ldifEntryList.append(ldifEntry)
4865N/A ldifEntryLines = []
4865N/A
4865N/A if len(ldifEntryLines) != 0:
4865N/A ldifEntry = '\n'.join(ldifEntryLines)
4865N/A ldifEntryList.append(ldifEntry)
4865N/A ldifEntryLines = []
4865N/A </script>
4865N/A
4865N/A <if expr="len(ldifEntryList) != 0">
4865N/A <iterate var="entryToParse" in="ldifEntryList">
4865N/A <sequence>
4865N/A <call function="'parseLdifEntry'">
4865N/A { 'ldifEntry' : entryToParse }
4865N/A </call>
4865N/A <script>
4865N/A parsedEntryList.append(STAXResult)
4865N/A </script>
4865N/A </sequence>
4865N/A </iterate>
4865N/A </if>
4865N/A
4865N/A <return> parsedEntryList </return>
4724N/A </sequence>
4724N/A </function>
4724N/A
4724N/A
4724N/A
4724N/A <!-- This function parses an ldif change -->
4724N/A <function name="parseLdifChange">
4724N/A <function-prolog>
4724N/A This function parses an ldif change and returns a list, e.g.:
4724N/A [ ['replace','l','London'], ['add','description','This is a test'] ]
4724N/A </function-prolog>
4724N/A
4724N/A <function-map-args>
4724N/A <function-arg-def name="ldifChange" type="required">
4724N/A <function-arg-description>
4724N/A Ldif change to parse (single string).
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A </function-map-args>
4724N/A <sequence>
4724N/A <script>
4724N/A parsedChange = []
4724N/A mod = []
4724N/A prevAttr = None
4724N/A prevVal = None
4724N/A
4724N/A for line in ldifChange.splitlines():
4724N/A notBlank = (len(line.strip()) != 0)
4724N/A if notBlank and (not line.startswith(' ')) and (not line.startswith('-')):
4724N/A # line corresponds to an attr:val
4724N/A attr = line[:line.find(':')].strip().lower()
4724N/A val = line[line.find(':') + 1:].lstrip()
4724N/A
4724N/A if val.startswith(':'):
4724N/A val = val[1:].lstrip()
4724N/A
4724N/A if attr == 'objectclass':
4724N/A val = val.lower()
4724N/A
4724N/A if (prevVal != None) and (attr == prevVal.lower()):
4724N/A # attr represents indeed an attribute type, so we may assume the
4724N/A # mod already has [mod_type,attr_type]
4724N/A mod.append(val)
4724N/A else:
4724N/A # attr represents the mod_type, and val the attr_type
4724N/A mod.append(attr)
4724N/A mod.append(val.lower())
4724N/A
4724N/A prevAttr = attr
4724N/A prevVal = val
4724N/A elif notBlank and line.startswith(' '):
4724N/A # line corresponds to a trailing value
4724N/A mod.remove(prevVal)
4724N/A val = prevVal + line.lstrip()
4724N/A mod.append(val)
4724N/A prevVal = val
4724N/A else:
4724N/A # line is empty or line starts with '-'; this means that
4724N/A # the mod is complete, so we can add it to the parsedChange list
4724N/A parsedChange.append(mod)
4724N/A mod = []
4724N/A
4724N/A if len(mod) != 0:
4724N/A # add the trailing mod to the parsedChange list
4724N/A parsedChange.append(mod)
4724N/A </script>
4724N/A
4724N/A <return> parsedChange </return>
4724N/A </sequence>
4724N/A </function>
4724N/A
4724N/A <!-- This function checks the content of an external changelog entry -->
4724N/A <function name="checkChangelogEntry">
4724N/A <function-prolog>
4724N/A This function checks the content of an external changelog entry
4724N/A </function-prolog>
4724N/A
4724N/A <function-map-args>
4724N/A <function-arg-def name="location"
4724N/A type="optional"
4724N/A default="STAF_REMOTE_HOSTNAME">
4724N/A <function-arg-description>
4724N/A Location of target host
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="hostname"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="dsPath"
4724N/A type="optional"
4724N/A default="'%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME)">
4724N/A <function-arg-description>
4724N/A Pathname to installation root
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="filepath"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="changelogEntry" type="required">
4724N/A <function-arg-description>
4724N/A External changelog entry (as an output of parseLdifEntry)
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="dictionary"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="targetDN" type="required">
4724N/A <function-arg-description>
4724N/A DN of the target entry for the change
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="changeType" type="required">
4724N/A <function-arg-description>
4724N/A Change type (e.g. add, delete, modify)
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="changeTime"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Change time
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="changeNumber"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Changenumber (only for changelog draft-compatible mode)
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="replicationCSN"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Replication CSN
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="targetEntryUUID"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Target entry uuid
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="replicaIdentifier"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Replica Identifier
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="newRDN"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A NewRDN
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="deleteOldRDN"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A DeleteOldRDN
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="newSuperior"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A NewSuperior
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="changes"
4724N/A type="optional"
4724N/A default="None">
4724N/A <function-arg-description>
4724N/A Changes. If changetype == add, changes should be a map, e.g.:
4724N/A {'dn':['o=example'],'objectclass':['top','organization'],'o':['example']}
4724N/A If changetype == modify, changes should be a list, e.g.:
4724N/A [ ['replace','l','London'], ['add','description','This is a test'] ]
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string"/>
4724N/A </function-arg-def>
4724N/A <function-arg-def name="knownIssue" type="optional" default="None">
4724N/A <function-arg-description>
4724N/A Known issue. Corresponds to an issue number.
4724N/A </function-arg-description>
4724N/A <function-arg-property name="type" value="string" />
4724N/A </function-arg-def>
4724N/A </function-map-args>
4724N/A
4724N/A <sequence>
4724N/A <script>
4724N/A myLocation = location
4724N/A myPath = dsPath
4724N/A
4724N/A # Mandatory attributes in a changeLogEntry
4724N/A ecl_DN = changelogEntry['dn'][0]
4724N/A ecl_targetDN = changelogEntry['targetdn'][0]
4724N/A ecl_changeType = changelogEntry['changetype'][0]
4724N/A ecl_changeTime = changelogEntry['changetime'][0]
4724N/A ecl_changeNumber = changelogEntry['changenumber'][0]
4724N/A
4724N/A # Optional attributes
4724N/A ecl_replicationCSN = None
4724N/A ecl_replicaIdentifier = None
4724N/A ecl_targetEntryUUID = None
4724N/A ecl_newRDN = None
4724N/A ecl_deleteOldRDN = None
4724N/A ecl_newSuperior = None
4724N/A ecl_changes = None
4724N/A
4724N/A if 'replicationcsn' in changelogEntry.keys():
4724N/A ecl_replicationCSN = changelogEntry['replicationcsn'][0]
4724N/A if 'replicaidentifier' in changelogEntry.keys():
4724N/A ecl_replicaIdentifier = changelogEntry['replicaidentifier'][0]
4724N/A if 'targetentryuuid' in changelogEntry.keys():
4724N/A ecl_targetEntryUUID = changelogEntry['targetentryuuid'][0]
4724N/A if 'newrdn' in changelogEntry.keys():
4724N/A ecl_newRDN = changelogEntry['newrdn'][0]
4724N/A if 'deleteoldrdn' in changelogEntry.keys():
4724N/A ecl_deleteOldRDN = changelogEntry['deleteoldrdn'][0]
4724N/A if 'newsuperior' in changelogEntry.keys():
4724N/A ecl_newSuperior = changelogEntry['newsuperior'][0]
4724N/A if 'changes' in changelogEntry.keys():
4724N/A ecl_changes = changelogEntry['changes'][0]
4724N/A </script>
4724N/A
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changelog entry %s against expected \
4724N/A values' % ecl_DN
4724N/A </message>
4724N/A
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking targetDN'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_targetDN,
4724N/A 'expectedString' : targetDN,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changeType'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_changeType,
4724N/A 'expectedString' : changeType,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A
4724N/A <if expr="changeTime">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changeTime'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_changeTime,
4724N/A 'expectedString' : changeTime,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A </if>
4724N/A
4724N/A <if expr="changeNumber">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changeNumber'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_changeNumber,
4724N/A 'expectedString' : changeNumber,
4724N/A 'searchType' : 'exact-case-sensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A </if>
4724N/A
4724N/A <if expr="replicationCSN">
4724N/A <if expr="ecl_replicationCSN">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking replicationCSN'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_replicationCSN,
4724N/A 'expectedString' : replicationCSN,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No replicationCSN could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="replicaIdentifier">
4724N/A <if expr="ecl_replicaIdentifier">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking replicaIdentifier'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_replicaIdentifier,
4724N/A 'expectedString' : replicaIdentifier,
4724N/A 'searchType' : 'exact-case-sensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No replicaIdentifier could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="targetEntryUUID">
4724N/A <if expr="ecl_targetEntryUUID">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking targetEntryUUID'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_targetEntryUUID,
4724N/A 'expectedString' : targetEntryUUID,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No targetEntryUUID could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="newRDN">
4724N/A <if expr="ecl_newRDN">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking newRDN'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_newRDN,
4724N/A 'expectedString' : newRDN,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No newRDN could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="deleteOldRDN">
4724N/A <if expr="ecl_deleteOldRDN">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking deleteOldRDN'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_deleteOldRDN,
4724N/A 'expectedString' : deleteOldRDN,
4724N/A 'searchType' : 'exact-case-sensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No deleteOldRDN could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="newSuperior">
4724N/A <if expr="ecl_newSuperior">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking newSuperior'
4724N/A </message>
4724N/A <call function="'searchString'">
4724N/A { 'returnString' : ecl_newSuperior,
4724N/A 'expectedString' : newSuperior,
4724N/A 'searchType' : 'exact-case-insensitive'
4724N/A }
4724N/A </call>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No newSuperior could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A <if expr="changes">
4724N/A <if expr="ecl_changes">
4724N/A <sequence>
4724N/A <!-- Decode the changes that are encoded in base64 -->
4724N/A <message>
4724N/A 'checkChangelogEntry: Decode external changelog entry changes'
4724N/A </message>
4724N/A <call function="'Base64WithScript'">
4724N/A { 'location' : myLocation,
4724N/A 'dsPath' : myPath,
4724N/A 'subcommand' : 'decode',
4724N/A 'encodedData' : ecl_changes
4724N/A }
4724N/A </call>
4724N/A <!-- STAXResult is not always a list-->
4724N/A <script>
4724N/A try:
4724N/A decodeRC, decodedChanges = STAXResult[0]
4724N/A except AttributeError, details:
4724N/A decodedChanges = 'AttributeError: can not parse STAXResult %s' \
4724N/A % details
4724N/A decodeRC = '1'
4724N/A </script>
4724N/A <message>
4724N/A 'checkChangelogEntry: Decoded changes:\n%s' % decodedChanges
4724N/A </message>
4724N/A
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changes'
4724N/A </message>
4724N/A <if expr="decodeRC == 0 and changeType == 'add'">
4724N/A <!-- If changetype:add, the changes look like a sequence of
4724N/A ! attribute:value, so we may parse them as an ldif entry -->
4724N/A <sequence>
4724N/A <call function="'parseLdifEntry'">
4724N/A { 'ldifEntry' : decodedChanges }
4724N/A </call>
4724N/A <script>
4724N/A ecl_changesMap = STAXResult
4724N/A </script>
4724N/A <message>
4724N/A 'Parsed changelog entry changes: \n%s' % ecl_changesMap
4724N/A </message>
4724N/A <iterate var="attr" in="changes.keys()">
4724N/A <sequence>
4724N/A <script>
4724N/A valueList = changes[attr]
4724N/A ecl_valueList = None
4724N/A
4724N/A if attr in ecl_changesMap.keys():
4724N/A ecl_valueList = ecl_changesMap[attr]
4724N/A ecl_valueList.sort()
4724N/A valueList.sort()
4724N/A </script>
4724N/A <if expr="ecl_valueList != None">
4724N/A <sequence>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changes: %s' % attr
4724N/A </message>
4724N/A <if expr="valueList == ecl_valueList">
4724N/A <message>
4724N/A 'Found expected values in changes: %s' % valueList
4724N/A </message>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'Expected values %s could not be found in %s' \
4724N/A % (valueList, ecl_valueList)
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No %s could be found in the changes' % attr
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </sequence>
4724N/A </iterate>
4724N/A </sequence>
4724N/A
4724N/A <elseif expr="decodeRC == 0">
4724N/A <!-- If changetype:modify, the changes look like a sequence of
4724N/A ! mod_type:attribute
4724N/A ! attribute:value
4724N/A ! so we need to treat them differently -->
4724N/A <sequence>
4724N/A <call function="'parseLdifChange'">
4724N/A { 'ldifChange' : decodedChanges }
4724N/A </call>
4724N/A <script>
4724N/A ecl_changesList = STAXResult
4724N/A </script>
4724N/A <message>
4724N/A 'Parsed changelog entry changes: \n%s' % ecl_changesList
4724N/A </message>
4724N/A <iterate var="mod" in="changes">
4724N/A <sequence>
4724N/A <script>
4724N/A mod_type = mod[0]
4724N/A mod_attr = mod[1]
4724N/A mod_val = None
4724N/A if len(mod) == 3:
4724N/A mod_val = mod[2]
4724N/A </script>
4724N/A <message>
4724N/A 'checkChangelogEntry: Checking changes: %s' % mod
4724N/A </message>
4724N/A <if expr="mod in ecl_changesList">
4724N/A <message>
4724N/A 'Found expected change:\n %s: %s\n %s: %s\n' \
4724N/A % (mod_type, mod_attr, mod_attr, mod_val)
4724N/A </message>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'Expected change %s could not be found in %s'\
4724N/A % (mod, ecl_changesList)
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </sequence>
4724N/A </iterate>
4724N/A </sequence>
4724N/A </elseif>
4724N/A </if>
4724N/A
4724N/A </sequence>
4724N/A <else>
4724N/A <sequence>
4724N/A <message log="1" level="'Error'">
4724N/A 'No changes could be found in the changelog entry'
4724N/A </message>
4724N/A <call function="'testFailed'"/>
4724N/A </sequence>
4724N/A </else>
4724N/A </if>
4724N/A </if>
4724N/A
4724N/A </sequence>
4724N/A </function>
2788N/A</stax>