dsml_setup.xml revision 6404c2cfdb4e1b679f83318944b95b25e7d1d84b
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Portions Copyright 2008-2010 Sun Microsystems, Inc.
! -->
<stax>
<defaultcall function="dsml_setup" />
<function name="dsml_setup">
<block name="'dsml_setup'">
<sequence>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: prepare DSML directory server
#@TestIssue none
#@TestPurpose Prepare the directory server necessary to the
test suite.
#@TestPreamble none
#@TestStep prepare dsml directory server instance
#@TestPostamble none
#@TestResult Success if returns 0.
-->
<testcase name="getTestCaseName('prepare DSML STAF service')">
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'createFolder'">
{
'location' : STAXServiceMachine,
'foldername' : '%s/dsml/STAF-INF/jars' % local.temp
}
</call>
<!--- In IPS mode, get OpenDS.jar from remote machine-->
<if expr="IPS_PKG == True">
<call function="'copyFile'">
{
'location' : STAF_REMOTE_HOSTNAME,
'srcfile' : '%s/%s/lib/OpenDS.jar' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME),
'destfile' : '%s/dsml/STAF-INF/jars/OpenDS.jar' % local.temp,
'remotehost' : STAXServiceMachine
}
</call>
<else>
<sequence>
<call function="'unZipFile'">
{
'location' : STAXServiceMachine,
'zipfile' : '%s/%s' % (ZIPPATH, ZIPNAME),
'file' : '%s/lib/OpenDS.jar' % OPENDSNAME,
'unzipdir' : '%s/dsml' % local.temp
}
</call>
<!-- The war file can be included in the OpenDS archive -->
<if expr="not PRODUCTNAME.startswith('OpenDS')">
<sequence>
<call function="'unZipFile'">
{
'location' : STAXServiceMachine,
'zipfile' : '%s/%s' % (ZIPPATH, ZIPNAME),
'file' : '%s/addons/DSML.war' % OPENDSNAME,
'unzipdir' : '%s/dsml' % local.temp
}
</call>
</sequence>
</if>
<call function="'copyFile'">
{
'location' : STAXServiceMachine,
'srcfile' : '%s/dsml/%s/lib/OpenDS.jar' % (local.temp,OPENDSNAME),
'destfile' : '%s/dsml/STAF-INF/jars/OpenDS.jar' % local.temp,
'remotehost' : STAXServiceMachine
}
</call>
</sequence>
</else>
</if>
<!-- The war file can be included in the OpenDS archive -->
<script>
if not PRODUCTNAME.startswith('OpenDS'):
DSML_WARPATH = '%s/dsml/%s/addons/DSML.war' % (local.temp,OPENDSNAME)
</script>
<call function="'unZipFile'">
{
'location' : STAXServiceMachine,
'zipfile' : DSML_WARPATH,
'directory': 'WEB-INF/classes',
'unzipdir' : '%s/dsml' % local.temp,
}
</call>
<call function="'copyFolder'">
{
'location' : STAXServiceMachine,
'srcfolder' : '%s/dsml/WEB-INF/classes' % local.temp,
'destfolder' : '%s/dsml/STAF-INF/classes' % local.temp,
'remotehost' : STAXServiceMachine
}
</call>
<call function="'copyFile'">
{
'location' : STAF_REMOTE_HOSTNAME,
'srcfile' : '%/ext/emma/lib/emma.jar' % TESTS_ROOT,
'destfile' : '%s/dsml/STAF-INF/jars/emma.jar' % TMPDIR,
'remotehost' : STAXServiceMachine
}
</call>
<script>
if is_windows_platform(STAXServiceMachine):
separator=';'
else:
separator=':'
opendsjar='%s/dsml/STAF-INF/jars/OpenDS.jar' % local.temp
emmajar='%s/dsml/STAF-INF/jars/emma.jar' % local.temp
dsmlclasses='%s/dsml/STAF-INF/classes' % local.temp
</script>
<call function="'GetVar'">
{
'location' : STAXServiceMachine,
'type' : 'system',
'variable' : 'STAF/Env/CLASSPATH'
}
</call>
<script>
cp=STAFResult
</script>
<call function="'compileJava'" >
{
'location' : STAXServiceMachine,
'foldername' : '%s/src' % TESTS_DSML_DIR,
'destfolder' : '%s/dsml/STAF-INF/classes' % local.temp,
'classpath' : '%s%s%s%s%s%s%s' \
% (opendsjar,separator,emmajar,separator,dsmlclasses,separator,cp)
}
</call>
<call function="'copyFile'">
{
'location' : STAXServiceMachine,
'srcfile' : '%s/resource/errorStrings.properties' % TESTS_DSML_DIR,
'destfile' : '%s/dsml/STAF-INF/classes/errorStrings.properties' % local.temp,
'remotehost' : STAXServiceMachine
}
</call>
<call function="'createFolder'">
{
'location' : location,
'foldername' : '%s/dsml' % local.java
}
</call>
<call function="'createJar'" >
{
'location' : STAXServiceMachine,
'jarname' : '%s/dsml/dsmlService.jar' % local.java,
'entrypoint' : 'STAF-INF',
'pathfolder' : '%s/dsml' % local.temp,
'manifestpath' : '%s/MANIFEST.MF' % TESTS_DSML_DIR
}
</call>
<call function="'addSTAFJavaService'" >
{
'location' : STAXServiceMachine,
'serviceName' : 'dsml',
'serviceJar' : '%s/dsml/dsmlService.jar' % local.java,
'J2' : '-Xms128m -Xmx512m'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: prepare DSML directory server
#@TestIssue none
#@TestPurpose Prepare the directory server necessary to the
test suite.
#@TestPreamble none
#@TestStep prepare dsml directory server instance
#@TestPostamble none
#@TestResult Success if returns 0.
-->
<testcase name="getTestCaseName('prepare DSML Directory backend')">
<sequence>
<call function="'testCase_Preamble'"/>
<!-- Create the DS instance necessary to the test group/suite -->
<message>
'prepare instance DS as described in config.py '
</message>
<call function="'prepareInstanceCreation'">
{ 'groupDataDir' : 'dsml',
'fileExtensions' : ['dat','res','issue'] }
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: create DSML directory server
#@TestIssue none
#@TestPurpose Create the directory server necessary to the
test suite.
#@TestPreamble none
#@TestStep Create Directory server as defined in config.py.
#@TestPostamble none
#@TestResult Success if returns 0.
-->
<testcase name="getTestCaseName('Create, Initialize and Start DSML Directory backend')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Create DS as described in config.py '
</message>
<call function="'createInstance'"/>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<message>
'Start DS instance'
</message>
<call function="'StartDsWithScript'">
{ 'location' : DIRECTORY_INSTANCE_HOST }
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'isAlive'">
{ 'noOfLoops' : 10 ,
'noOfMilliSeconds' : 2000 }
</call>
<call function="'checkRC'">
{ 'returncode' : RC ,
'result' : STAXResult }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: import DSML directory server test data
#@TestIssue none
#@TestPurpose Import the directory server test data.
#@TestPreamble none
#@TestStep Import Directory server as defined in config.py.
#@TestPostamble none
#@TestResult Success if returns 0.
-->
<testcase name="getTestCaseName('Import DSML test data in Directory backend')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'Import DSML test data'
</message>
<script>
dsmlBaseDNs = {
'o=dsmlfe.com' : ('dsmlfe.ldif', 'dsmlfe_BE', 160),
'dc=example,dc=com' : ('oasis.ldif', 'oasis_BE', 160),
'o=IMC, c=US' : ('search.ldif', 'example_BE', 1084),
}
</script>
<iterate var="baseDN" in="dsmlBaseDNs.keys()">
<sequence>
<message>
'Import DSML test data [%s | %s | %s/%s/db/%s | %s/%s/import-tmp]' %\
(baseDN,\
dsmlBaseDNs.get(baseDN)[1],\
DIRECTORY_INSTANCE_DIR, OPENDSNAME, dsmlBaseDNs.get(baseDN)[1],\
DIRECTORY_INSTANCE_DIR, OPENDSNAME)
</message>
<message>
'Create database backend %s.' % dsmlBaseDNs.get(baseDN)[1]
</message>
<script>
options=[]
options.append('--backend-name %s' % dsmlBaseDNs.get(baseDN)[1])
options.append('--set db-directory:%s' % dsmlBaseDNs.get(baseDN)[1])
options.append('--set base-dn:"%s"' % baseDN)
options.append('--set enabled:true')
options.append('--set writability-mode:enabled')
options.append('-t local-db')
createBackendOptions=' '.join(options)
</script>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'create-backend',
'optionsString' : createBackendOptions
}
</call>
<call function="'ImportLdifWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'ldifFile' : '%s/dsml/ldif-files/%s' % (remote.data,dsmlBaseDNs.get(baseDN)[0]),
'backEnd' : '%s' % dsmlBaseDNs.get(baseDN)[1]
}
</call>
<script>
nbEntriesExpected = dsmlBaseDNs.get(baseDN)[2]
</script>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : baseDN,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn',
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: %s' % nbEntriesExpected,
'issue' : '4178'
}
</call>
<call function="'checkRC'">
{ 'returncode' : RC ,
'result' : STAXResult }
</call>
</sequence>
</iterate>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: create webcontainer
#@TestIssue none
#@TestPurpose Create the webcontainer necessary to the
test suite.
#@TestPreamble none
#@TestStep Create webcontainer as described in config.py.
#@TestPostamble none
#@TestResult Success if createWebcontainer returns 0.
-->
<testcase name="getTestCaseName('setup: create webcontainer')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'setup: create webcontainer as described in config.py'
</message>
<call function="'createWebcontainer'" />
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: deploy web application WAR file
#@TestIssue none
#@TestPurpose Deploy web application necessary to the
test suite.
#@TestPreamble none
#@TestStep Deploy web application as described in config.py.
#@TestPostamble none
#@TestResult Success if deployWebApplicationWAR returns 0.
-->
<testcase name="getTestCaseName('setup: deploy Webapplication')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'setup: deploy DSML gateway webapp as described in config.py'
</message>
<!-- The war file can be included in the OpenDS archive -->
<script>
if not PRODUCTNAME.startswith('OpenDS'):
DSML_WARPATH = '%s/dsml/%s/addons/DSML.war' % (local.temp,OPENDSNAME)
</script>
<call function="'deployWebApplicationWAR'">
{ 'warFilePath' : '%s' % DSML_WARPATH }
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: start web webcontainer
#@TestIssue none
#@TestPurpose Start the webcontainer necessary to the
test suite.
#@TestPreamble none
#@TestStep start webcontainer as described in config.py.
#@TestPostamble none
#@TestResult Success if statWebcontainerWithScript returns 0.
-->
<testcase name="getTestCaseName('setup: start webcontainer')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'setup: start webcontainer as described in config.py'
</message>
<call function="'startWebcontainerWithScript'"/>
<stafcmd name="'waiting for webcontainer startup'">
<location>'%s' % location</location>
<service>'delay'</service>
<request>' DELAY 10000'</request>
</stafcmd>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: configure DSML gateway DS port param
#@TestIssue none
#@TestPurpose Set the gateway web.xml param pointing to DS
#@TestPreamble none
#@TestSteps extract web.xml out of DSML war file locally
#@TestSteps substitute default port 389 with DIRECTORY_INSTANCE_PORT
#@TestSteps substitute default directory host localhost with DIRECTORY_INSTANCE_HOST
#@TestSteps overwrite the destination DSML gateway web.xml
#@TestPostamble none
#@TestResult Success if statWebcontainerWithScript returns 0.
-->
<testcase name="getTestCaseName('configure: dsml web.xml port')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'setup: configure DSML gateway DS port param.'
</message>
<script>
myTmpDir='%s/%s' % (local.temp, STAF_REMOTE_HOSTNAME)
</script>
<message>
'Create folder %s on host %s' % (myTmpDir,STAXServiceMachine)
</message>
<call function="'createFolder'">
{ 'location' : STAXServiceMachine,
'foldername' : '%s' % myTmpDir
}
</call>
<!-- The war file can be included in the OpenDS archive -->
<script>
if not PRODUCTNAME.startswith('OpenDS'):
DSML_WARPATH = '%s/dsml/%s/addons/DSML.war' % (local.temp,OPENDSNAME)
</script>
<call function="'runSTAFCommand'">
{ 'name' : 'Extract DSML gateway web.xml',
'location' : STAXServiceMachine,
'service' : 'ZIP',
'request' : 'UNZIP',
'arguments' : 'ZIPFILE %s TODIRECTORY %s FILE WEB-INF/web.xml' \
% (DSML_WARPATH, myTmpDir)
}
</call>
<script>
webXmlInput=open('%s/WEB-INF/web.xml' % myTmpDir,'r')
import re
portRegEx = re.compile('389')
hostRegEx = re.compile('localhost')
c0=webXmlInput.read()
c1=portRegEx.sub(DIRECTORY_INSTANCE_PORT, c0)
content=hostRegEx.sub(DIRECTORY_INSTANCE_HOST, c1)
webXmlInput.close()
webXmlOutput=open('%s/WEB-INF/web.xml.out' % myTmpDir,'w')
webXmlOutput.write(content)
webXmlOutput.close()
</script>
<message>
'Update DSML gateway web.xml file on host %s' % STAF_REMOTE_HOSTNAME
</message>
<script>
# create the autodeploy webapp path
destWebXml = None
if WC_TYPE == 'tomcat':
destWebXml = os.path.join(WC_DIRECTORY, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'webapps',
'dsml', 'WEB-INF', 'web.xml')
destEmmaProp = os.path.join(WC_DIRECTORY, 'apache-%s-%s' % (WC_TYPE, WC_VERSION), 'webapps',
'dsml', 'WEB-INF', 'classes', 'emma.properties')
elif WC_TYPE == 'glassfish':
destWebXml = os.path.join(WC_DIRECTORY, 'glassfishv3', 'glassfish',
'domains', 'domain1', 'applications',
'dsml', 'WEB-INF', 'web.xml')
destEmmaProp = os.path.join(WC_DIRECTORY, 'glassfishv3', 'glassfish',
'domains', 'domain1', 'applications',
'dsml', 'WEB-INF', 'classes', 'emma.properties')
elif WC_TYPE == 'sunwebserver':
destWebXml = os.path.join(WC_DIRECTORY, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME,
'generated', STAF_REMOTE_HOSTNAME, 'dsml', 'WEB-INF', 'web.xml')
destEmmaProp = os.path.join(WC_DIRECTORY, '%s-%s' % (WC_TYPE, WC_VERSION), 'https-%s' % STAF_REMOTE_HOSTNAME,
'generated', STAF_REMOTE_HOSTNAME, 'dsml', 'WEB-INF', 'classes', 'emma.properties')
nbLoop = 10
loopSleep = 1000 # 1000 millisecondes
</script>
<message>'checking presence of deployed dsml %s' % destWebXml</message>
<loop from="0" to="nbLoop" while="RC == 48">
<sequence>
<call function="'Sleep'">
{'sleepForMilliSeconds' : loopSleep }
</call>
<message>'going to sleep for 2 secondes'</message>
<call function="'GetEntry'">
{
'location' : STAF_REMOTE_HOSTNAME,
'entry' : destWebXml,
'attribute': 'TYPE'
}
</call>
</sequence>
</loop>
<if expr="RC == 0">
<sequence>
<message>
'going to copy %s:%s/WEB-INF/web.xml.out to %s:%s' % (STAXServiceMachine,myTmpDir,STAF_REMOTE_HOSTNAME,destWebXml)
</message>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME,
'srcfile' : '%s/WEB-INF/web.xml.out' % myTmpDir,
'destfile' : destWebXml
}
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<script>
ecPath = os.path.join(remote.temp,'coverage',CurrentTestPath['group'],'coverage_dsml.ec')
coveragefh = open( '%s/emma_dsml.properties' % local.temp, 'w')
coveragefh.write( 'coverage.out.file=%s\n' % ecPath )
coveragefh.write( 'verbosity.level=silent\n')
coveragefh.write( 'coverage.out.merge=true\n')
coveragefh.close()
</script>
<message>
'PATH ORIG %s/emma_dsml.properties' % local.temp
</message>
<message>
'PATH DEST %s' % destEmmaProp
</message>
<call function="'copyFile'">
{ 'location' : STAXServiceMachine,
'remotehost' : '%s' % STAF_REMOTE_HOSTNAME,
'srcfile' : '%s/emma_dsml.properties' % local.temp,
'destfile' : destEmmaProp
}
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'stopWebcontainerWithScript'"/>
<call function="'startWebcontainerWithScript'"/>
</sequence>
<else>
<message>
'the target %s is not available after %sms' % (destWebXml, (nbLoop*loopSleep))
</message>
</else>
</if>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
</sequence>
</block>
</function>
</stax>