3361N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
3361N/A<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
3361N/A<!--
3361N/A ! CDDL HEADER START
3361N/A !
3361N/A ! The contents of this file are subject to the terms of the
3361N/A ! Common Development and Distribution License, Version 1.0 only
3361N/A ! (the "License"). You may not use this file except in compliance
3361N/A ! with the License.
3361N/A !
3361N/A ! You can obtain a copy of the license at
3361N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
3361N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
3361N/A ! See the License for the specific language governing permissions
3361N/A ! and limitations under the License.
3361N/A !
3361N/A ! When distributing Covered Code, include this CDDL HEADER in each
3361N/A ! file and include the License file at
3361N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
3361N/A ! add the following below this CDDL HEADER, with the fields enclosed
3361N/A ! by brackets "[]" replaced with your own identifying information:
3361N/A ! Portions Copyright [yyyy] [name of copyright owner]
3361N/A !
3361N/A ! CDDL HEADER END
3361N/A !
4134N/A ! Portions Copyright 2008-2009 Sun Microsystems, Inc.
3361N/A ! -->
3361N/A<stax>
3361N/A <defaultcall function="dsml_test" />
3361N/A <function name="dsml_test">
4495N/A <sequence>
4495N/A <block name="'dsml_test'">
4092N/A <try>
3949N/A <sequence>
4092N/A <!--- Test Suite information
4092N/A #@TestSuiteName test
4092N/A #@TestSuitePurpose test for the dsml test suite.
4092N/A #@TestSuiteGroup dsml test
4092N/A #@TestScript dsml_test.xml
4092N/A -->
4092N/A <script>
4092N/A if not CurrentTestPath.has_key('group'):
4092N/A CurrentTestPath['group'] = 'dsml'
4092N/A CurrentTestPath['suite'] = STAXCurrentBlock
4092N/A </script>
4092N/A <call function="'testSuite_Preamble'"/>
4495N/A
4495N/A <import machine="STAF_LOCAL_HOSTNAME"
4495N/A file="'%s/testcases/%s/dsml_setup.xml' % (TESTS_DIR,_group)"/>
4495N/A <call function="'dsml_setup'"/>
4495N/A
4092N/A <message>'TESTS_DATA_DIR=%s ' % (local.data)</message>
4092N/A
4092N/A <!--- Test Case information
4092N/A #@TestMarker test
4092N/A #@TestName test: test webcontainer
4092N/A #@TestIssue none
4092N/A #@TestPurpose test webcontainer responding necessary to the
4092N/A test suite.
4092N/A #@TestPreamble none
4092N/A #@TestSteps get the list of DSML test family
4092N/A #@TestSteps for each family get the list of DSML SOAP requests (testXYZ.dat)
4092N/A #@TestSteps for each SOAP request, submit it and store the result (testXYZ.run)
4092N/A #@TestSteps for each SOAP result, compare it with reference (testXYZ.run vs testXYZ.res)
4092N/A #@TestResult Success if returns 0.
4092N/A -->
4092N/A
4092N/A <message>'List DSML suites families'</message>
4092N/A
3949N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'list DSML suites families',
3949N/A 'location' : STAXServiceMachine,
3949N/A 'service' : 'FS',
3949N/A 'request' : 'LIST DIRECTORY',
4092N/A 'arguments' : '%s/dsml/suites SORTBYNAME TYPE d' % local.data
3949N/A }
3949N/A </call>
4092N/A
4092N/A <if expr="RC != 0">
4092N/A <sequence>
4092N/A <message>
4092N/A 'Folder %d/dsml/suites does not exist.' % (local.data)
4092N/A </message>
4092N/A <return>0</return>
4092N/A </sequence>
4092N/A </if>
4092N/A
3949N/A <script>
4092N/A cmdRC=RC
4092N/A familyList=STAFResult
4092N/A # The subversion folder could be present, if so remove it
4092N/A if familyList.count != 0:
4092N/A try:
4662N/A familyList.remove('genericIssues')
4662N/A except ValueError:
4662N/A print "List element genericIssues does not exist"
4662N/A try:
4092N/A familyList.remove('.svn')
4092N/A except ValueError:
4092N/A print "List element .svn does not exist"
4092N/A import re
4092N/A import base64
4092N/A runFileRE = re.compile( 'dat$')
4092N/A validAuthRE = re.compile ( '\%VALIDAUTH\%' )
4092N/A sslRE = re.compile( '_ssl' )
4092N/A urls = { \
4092N/A 'noSSL' : 'http://%s:%s/dsml/DSMLServlet' % (WC_HOST,WC_PORT), \
4092N/A 'SSL' : 'https://%s:%s/dsml/DSMLServlet' % (WC_HOST,WC_SSL_PORT) \
4092N/A }
3949N/A </script>
4662N/A <message>'dsml list of suites %s' % familyList</message>
4662N/A <message>'getting the list of generic known Issues spanning multiple tests'</message>
4662N/A <call function="'runSTAFCommand'">
4662N/A { 'name' : 'list known generic issues',
4662N/A 'location' : STAXServiceMachine,
4662N/A 'service' : 'FS',
4662N/A 'request' : 'LIST DIRECTORY',
4662N/A 'arguments' : '%s/dsml/suites/genericIssues EXT issue RECURSE' % (local.data)
4662N/A }
4662N/A </call>
4662N/A
4662N/A <if expr="RC != 0">
4662N/A <sequence>
4662N/A <message>
4662N/A 'Failed to get known generic issues from %s/dsml/suites/genericIssues' % (local.data)
4662N/A </message>
4662N/A <return>0</return>
4662N/A </sequence>
4662N/A <else>
4662N/A <script>
4662N/A genericIssues = STAFResult
4662N/A </script>
4662N/A </else>
4662N/A </if>
4662N/A
4092N/A <message>'DSML familyList = %s' % familyList</message>
4092N/A <iterate var="family" in="familyList">
4092N/A <sequence>
4092N/A <message>'DSML family %s ' % family</message>
4092N/A
4092N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'List DSML suite %s input' % family,
4092N/A 'location' : STAXServiceMachine,
4092N/A 'service' : 'FS',
4092N/A 'request' : 'LIST DIRECTORY',
4092N/A 'arguments' : '%s/dsml/suites/%s/data \
4092N/A SORTBYNAME EXT dat TYPE f' % (local.data,family)
4092N/A }
4092N/A </call>
4092N/A
4092N/A <script>
4092N/A familyInput = STAFResult
4092N/A </script>
4092N/A
4092N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'List DSML suite %s expected results' % family,
4092N/A 'location' : STAXServiceMachine,
4092N/A 'service' : 'FS',
4092N/A 'request' : 'LIST DIRECTORY',
4092N/A 'arguments' : '%s/dsml/suites/%s/data \
4092N/A SORTBYNAME EXT res TYPE f' % (local.data,family)
4092N/A }
4092N/A </call>
4092N/A
4092N/A <script>
4092N/A familyExpected = STAFResult
4092N/A </script>
4662N/A
4092N/A <iterate var="test" in="familyInput">
4092N/A <testcase name="getTestCaseName('%s-%s' % (family,test))">
4092N/A <sequence>
4092N/A <try>
4092N/A <sequence>
4092N/A <message>
4092N/A 'Test Name = %s' % STAXCurrentTestcase
4092N/A </message>
4092N/A <call function="'testCase_Preamble'"/>
4092N/A <script>
4092N/A runFileName = runFileRE.sub('run',test)
4153N/A runFilePath = '%s/%s_%s' % (local.temp, family, runFileName)
4092N/A requestFilePath = '%s/dsml/suites/%s/data/%s' % \
4092N/A (local.data,family,test)
4092N/A expectedFileName = runFileRE.sub('res',test)
4092N/A expectedFilePath = '%s/dsml/suites/%s/data/%s' % \
4092N/A (local.data,family,expectedFileName)
4092N/A if (sslRE.search(test) != None):
4092N/A url = urls['SSL']
4092N/A else:
4092N/A url = urls['noSSL']
4092N/A </script>
4092N/A
4092N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'List DSML suite %s file %s' % (family,test),
4092N/A 'location' : STAXServiceMachine,
4092N/A 'service' : 'FS',
4092N/A 'request' : 'GET FILE',
4092N/A 'arguments' : requestFilePath
4092N/A }
4092N/A </call>
4092N/A
4092N/A <script>
4092N/A from com.ibm.staf import STAFUtil
4092N/A BODYSeparator = '\n\n'
4092N/A BODYStart = STAFResult.index(BODYSeparator)
4092N/A h = STAFResult[:BODYStart]
4092N/A kvs=h.split("\n")
4092N/A SOAPHeaders = "HEADER content-type=text/xml "
4092N/A
4092N/A for e in kvs[1:]:
4092N/A if (e.upper().startswith("CONTENT-LENGTH:")):
4092N/A continue
4092N/A if len(e.strip()) == 0:
4092N/A continue
4092N/A if (e.upper().startswith("AUTHORIZATION:")):
4092N/A e = validAuthRE.sub( base64.encodestring('%s:%s' % \
4092N/A (DIRECTORY_INSTANCE_DN,DIRECTORY_INSTANCE_PSWD)) , \
4092N/A e )
4092N/A s = e.split(':')
4092N/A rs = re.compile(' ')
4092N/A s[1]=s[1].strip()
4092N/A if (rs.search(s[1]) != None):
4092N/A s[1] = '"' + s[1] + '"'
4092N/A SOAPHeaders = SOAPHeaders + 'HEADER ' + s[0] + '=' + s[1] + ' '
4092N/A
4092N/A SOAPBody = STAFUtil.wrapData(STAFResult[BODYStart+len(BODYSeparator):])
4092N/A </script>
4092N/A
4092N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'Submit SOAPBody',
4092N/A 'location' : STAXServiceMachine,
4092N/A 'service' : 'HTTP',
4092N/A 'request' : 'REQUEST METHOD POST',
4092N/A 'arguments' : 'URL %s FOLLOWREDIRECT %s CONTENT %s RETURNHEADERS ' \
4092N/A % (url, SOAPHeaders, SOAPBody)
4092N/A }
4092N/A </call>
3392N/A
4092N/A <!-- Check the STAFResult is expected class type -->
5585N/A <if expr='STAFResult.__class__ is not PyDictionary'>
4092N/A <sequence>
4092N/A <message log="1" level="'Error'">
5585N/A 'ERROR : Invalid result type (%s), requires PyDictionary.' % STAFResult.__class__
4092N/A </message>
4092N/A <throw exception="'STAXException.Results.TestCaseException'">
4092N/A 'Result not a PyDictionary object.'
4092N/A </throw>
4092N/A </sequence>
4092N/A </if>
3392N/A
4092N/A <call function="'checktestRC'">
4092N/A {
4092N/A 'returncode' : RC ,
4092N/A 'result' : STAFResult
4092N/A }
4092N/A </call>
3392N/A
4092N/A <if expr="result['statusCode'] == '200'">
4092N/A <sequence>
4092N/A <script>
4092N/A # writing the result file to compare with expected result
4092N/A httpHeaders = result['headers']
4092N/A httpContent = result['content']
4092N/A resultContent = "HTTP1.1 "
4092N/A resultContent += result['statusCode'] + ' '
4092N/A resultContent += result['statusMessage'] + '\n'
4092N/A resultContent += "\n".join(["%s: %s" % (k, v) for k, v in httpHeaders.items()])
4092N/A resultContent += '\n\n' + httpContent
4092N/A f=open(runFilePath,'w')
4092N/A f.write(resultContent)
4092N/A f.close()
4092N/A </script>
4092N/A <message>'Comparing result %s and expected result %s' % (runFilePath, expectedFilePath)</message>
4092N/A
4092N/A <call function="'runSTAFCommand'">
4092N/A { 'name' : 'Compare SOAPResult with expected result',
4092N/A 'location' : STAXServiceMachine,
4092N/A 'service' : 'DSML',
4092N/A 'request' : 'COMPARE FILE',
4092N/A 'arguments' : '%s EXP_FILE %s' %(runFilePath, expectedFilePath)
4092N/A }
4092N/A </call>
4662N/A <if expr="RC != 0">
4662N/A <sequence>
4780N/A <script>
4780N/A foundKnownIssue = False
4780N/A </script>
4662N/A <message>"check against test's known issues"</message>
4662N/A
4662N/A <call function="'runSTAFCommand'">
4662N/A { 'name' : 'list known issues for the test',
4662N/A 'location' : STAXServiceMachine,
4662N/A 'service' : 'FS',
4662N/A 'request' : 'LIST DIRECTORY',
4662N/A 'arguments' : '%s/dsml/suites/%s/data NAME %s* EXT issue RECURSE' % (local.data,family,expectedFileName)
4662N/A }
4662N/A </call>
4662N/A
4662N/A <if expr="RC != 0">
4662N/A <sequence>
4662N/A <message>
4662N/A 'Failed to get known issues for %s/dsml/suites/%s/data/%s ' % (local.data,family,expectedFileName)
4662N/A </message>
4662N/A <return>0</return>
4662N/A </sequence>
4662N/A <else>
4662N/A <try>
4662N/A <sequence>
4662N/A <script>
4662N/A knownTestIssues = STAFResult
4662N/A </script>
4662N/A <message >'known Test Issues %s' % knownTestIssues</message>
4662N/A <if expr="len(knownTestIssues) > 0">
4662N/A <iterate var="issueFile" in="knownTestIssues">
4662N/A <sequence>
4662N/A <script>
4662N/A # the issue number is the before last element of the '.' splited path
4662N/A issue=issueFile.split('.')[-2]
4662N/A issueFilePath = '%s/dsml/suites/%s/data/%s' % (local.data,family,issueFile)
4662N/A </script>
4662N/A <call function="'runSTAFCommand'">
4662N/A { 'name' : 'check if known issue %s' % issue,
4662N/A 'location' : STAXServiceMachine,
4662N/A 'service' : 'DSML',
4662N/A 'request' : 'COMPARE',
4662N/A 'arguments' : 'FILE %s EXP_FILE %s' %(runFilePath, issueFilePath)
4662N/A
4662N/A }
4662N/A </call>
4662N/A <if expr="RC == 0">
4662N/A <sequence>
4662N/A <!-- this is a known issue -->
4662N/A <call function="'setKnownIssue'">
4662N/A { 'issueId' : issue }
4662N/A </call>
4780N/A <script>
4780N/A foundKnownIssue = True
4780N/A </script>
4662N/A <break/>
4662N/A </sequence>
4662N/A </if>
4662N/A </sequence>
4662N/A </iterate>
4662N/A </if>
4780N/A <if expr="not foundKnownIssue and len(genericIssues) > 0">
4662N/A <iterate var="issueFile" in="genericIssues">
4662N/A <sequence>
4662N/A <script>
4662N/A # the issue number is the before last element of the '.' splited path
4662N/A issue=issueFile.split('.')[-2]
4662N/A issueFilePath = '%s/dsml/suites/genericIssues/%s' % (local.data,issueFile)
4662N/A </script>
4662N/A <call function="'runSTAFCommand'">
4662N/A { 'name' : 'check if known generic issue %s' % issue,
4662N/A 'location' : STAXServiceMachine,
4662N/A 'service' : 'DSML',
4662N/A 'request' : 'COMPARE',
4662N/A 'arguments' : 'FILE %s EXP_FILE %s' %(runFilePath, issueFilePath)
4662N/A
4662N/A }
4662N/A </call>
4662N/A <if expr="RC == 0">
4662N/A <sequence>
4662N/A <!-- this is a known issue -->
4662N/A <call function="'setKnownIssue'">
4662N/A { 'issueId' : issue }
4662N/A </call>
4780N/A <script>
4780N/A foundKnownIssue = True
4780N/A </script>
4662N/A <break/>
4662N/A </sequence>
4662N/A </if>
4662N/A </sequence>
4662N/A </iterate>
4662N/A </if>
4780N/A <if expr="not foundKnownIssue">
4780N/A <sequence>
4780N/A <message>'checking string marker issues in result'</message>
4780N/A <call function="'runSTAFCommand'">
4780N/A { 'name' : 'check if known issue %s' % issue,
4780N/A 'location' : STAXServiceMachine,
4780N/A 'service' : 'DSML',
4780N/A 'request' : 'CHECK_ERROR_STRINGS',
4780N/A 'arguments' : 'FILE %s ' %(runFilePath)
4776N/A
4780N/A }
4776N/A </call>
4780N/A <if expr="RC >= 100000000">
4780N/A <!-- string marked issues start from 100000000 -->
4780N/A <sequence>
4780N/A <script>
4780N/A issue = RC - 100000000
4780N/A </script>
4780N/A <!-- this is a known issue -->
4780N/A <call function="'setKnownIssue'">
4780N/A { 'issueId' : issue }
4780N/A </call>
4780N/A <script>
4780N/A foundKnownIssue=True
4780N/A </script>
4780N/A <break/>
4780N/A </sequence>
4780N/A </if>
4776N/A </sequence>
4776N/A </if>
4776N/A
4662N/A </sequence>
4662N/A <catch exception="'...'" typevar="eType" var="eInfo">
4662N/A <sequence>
4662N/A <message log="1" level="'fatal'">
4662N/A 'Test case (%s) failed. eType(%s),eInfo(%s)' % (STAXCurrentTestcase,eType,eInfo)
4662N/A </message>
4662N/A <tcstatus result="'fail'"/>
4662N/A </sequence>
4662N/A </catch>
4662N/A </try>
4662N/A </else>
4662N/A </if>
4662N/A
4662N/A </sequence>
4662N/A
4662N/A </if>
4092N/A <call function="'checktestRC'">
4092N/A {
4092N/A 'returncode' : RC ,
4092N/A 'result' : STAXResult
4092N/A }
4092N/A </call>
4092N/A </sequence>
4865N/A <elseif expr="result['statusCode'] == '404'">
4865N/A <call function="'checktestRC'">
4865N/A {
4865N/A 'returncode' : result['statusCode'] ,
4865N/A 'result' : result['statusMessage'],
4865N/A 'issue' : 4214
4865N/A }
4865N/A </call>
4865N/A </elseif>
4092N/A <else>
4092N/A <call function="'checktestRC'">
4092N/A {
4092N/A 'returncode' : result['statusCode'] ,
4092N/A 'result' : result['statusMessage']
4092N/A }
4092N/A </call>
4092N/A </else>
4092N/A </if>
4092N/A </sequence>
4092N/A <catch exception="'...'" typevar="eType" var="eInfo">
4092N/A <sequence>
4092N/A <message log="1" level="'fatal'">
4092N/A 'Test case (%s) failed. eType(%s),eInfo(%s)' % (STAXCurrentTestcase,eType,eInfo)
4092N/A </message>
4092N/A <tcstatus result="'fail'"/>
4092N/A </sequence>
4092N/A </catch>
4092N/A <finally>
4092N/A <call function="'testCase_Postamble'"/>
4092N/A </finally>
4092N/A </try>
3949N/A </sequence>
4092N/A </testcase>
4092N/A </iterate>
4092N/A </sequence>
4092N/A </iterate>
3949N/A
3949N/A </sequence>
4092N/A <finally>
4495N/A <sequence>
4495N/A <!-- Test Suite Cleanup -->
4495N/A <message>'Finally: Global DSML Cleanup.'</message>
4495N/A <try>
4495N/A <sequence>
4495N/A <import machine="STAF_LOCAL_HOSTNAME"
4495N/A file="'%s/testcases/%s/dsml_cleanup.xml' % (TESTS_DIR,_group)"/>
4495N/A <call function="'dsml_cleanup'"/>
4495N/A </sequence>
4495N/A <catch exception="'STAFException'">
4495N/A <sequence>
4495N/A <message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
4495N/A </sequence>
4495N/A </catch>
4495N/A <finally>
4495N/A <call function="'testSuite_Postamble'"/>
4495N/A </finally>
4495N/A </try>
4495N/A </sequence>
4092N/A </finally>
4495N/A
4092N/A </try>
4495N/A
4495N/A </block>
4495N/A </sequence>
3361N/A </function>
3361N/A</stax>