<?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 legal-notices/CDDLv1_0.txt
! or http://forgerock.org/license/CDDLv1.0.html.
! 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 legal-notices/CDDLv1_0.txt.
! If applicable, add the following below this CDDL HEADER, with the
! fields enclosed by brackets "[]" replaced with your own identifying
! information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2009-2010 Sun Microsystems, Inc.
! Portions Copyright 2012 ForgeRock AS
! -->
<stax>
<!--- Test Case information
#@TestMarker Dsconfig Batch Mode Tests
#@TestName Dsconfig: Batch Mode: Batch Mode Basic
#@TestID Test 1
#@TestPurpose Purpose
#@TestPreamble
#@TestSteps
#@TestPostamble
#@TestResult
-->
<function name="dsconfig_batch-mode_001" scope="local">
<testcase name="getTestCaseName('Batch Mode Basic')">
<try>
<sequence>
<call function="'testCase_Preamble'" />
<script>
newSuffix='dc=batchmode,dc=com'
newBackend='myBackend'
batchJobName='dsconfig.batch'
templateName='dsconfig.template'
dsconfigbatchLdif='%s/dsconfigbatch.ldif' % remote.temp
batchJob=[]
batchJob.append('create-backend --set base-dn:%s --set enabled:true --type local-db --backend-name %s' % (newSuffix,newBackend))
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name cn' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name telephoneNumber' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --set index-type:substring --type generic --index-name mail' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name sn' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name uniqueMember' % newBackend)
batchJob.append('set-local-db-index-prop --backend-name %s --index-name uniqueMember --set index-entry-limit:5000' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name member' % newBackend)
batchJob.append('create-local-db-index --backend-name %s --set index-type:equality --type generic --index-name uid' % newBackend)
batchJob.append('set-backend-prop --backend-name %s --set index-entry-limit:6000' % newBackend)
</script>
<!-- Write batchJob to file -->
<script>
def write_file(filename,alist):
fout=open('%s' % filename,'w')
for line in alist:
fout.write('%s\n' % line)
fout.close()
write_file('%s/%s' % (local.temp,batchJobName),batchJob)
</script>
<!-- Copy batchJob file to SUT -->
<call function="'copyFile'">
{
'srcfile' : '%s/%s' % (local.temp,batchJobName),
'destfile' : '%s/%s' % (remote.temp,batchJobName),
'remotehost' : server.location
}
</call>
<!-- Use dsconfig with batchFilePath -->
<call function="'dsconfig'">
{
'subcommand' : '--batchFilePath %s/%s' % (remote.temp,batchJobName),
'expectedRC' : 0
}
</call>
<!-- Generate makeldif data -->
<script>
template=[]
template.append('define suffix=%s' % newSuffix)
template.append('define maildomain=%s' % dn2rfcmailaddr(newSuffix))
template.append('')
template.append('branch: [suffix]')
template.append('')
template.append('branch: ou=people,[suffix]')
template.append('subordinateTemplate: person:100')
template.append('')
template.append('template: person')
template.append('rdnAttr: uid')
template.append('objectClass: top')
template.append('objectClass: person')
template.append('objectClass: organizationalPerson')
template.append('objectClass: inetOrgPerson')
template.append('givenName: &lt;first>')
template.append('sn: &lt;last>')
template.append('cn: {givenName} {sn}')
template.append('initials: {givenName:1}&lt;random:chars:ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>{sn:1}')
template.append('employeeNumber: &lt;sequential:0>')
template.append('uid: user.{employeeNumber}')
template.append('mail: {uid}@[maildomain]')
template.append('userPassword: password')
template.append('telephoneNumber: &lt;random:telephone>')
template.append('homePhone: &lt;random:telephone>')
template.append('pager: &lt;random:telephone>')
template.append('mobile: &lt;random:telephone>')
template.append('street: &lt;random:numeric:5> &lt;file:streets> Street')
template.append('l: &lt;file:cities>')
template.append('st: &lt;file:states>')
template.append('postalCode: &lt;random:numeric:5>')
template.append('postalAddress: {cn}${street}${l}, {st} {postalCode}')
template.append('description: This is the description for {cn}.')
template.append('')
</script>
<!-- Write template to file -->
<script>
write_file('%s/%s' % (local.temp,templateName),template)
</script>
<!-- Copy template to SUT -->
<call function="'copyFile'">
{
'srcfile' : '%s/%s' % (local.temp,templateName),
'destfile' : '%s/%s' % (remote.temp,templateName),
'remotehost' : server.location
}
</call>
<call function="'MakeLdifWithScript'">
{ 'location' : server.location ,
'templateFile' : '%s/%s' % (remote.temp,templateName) ,
'ldifFile' : dsconfigbatchLdif }
</call>
<!-- On line import data on new suffix -->
<call function="'ImportLdifWithScript'">
{
'dsInstanceHost' : server.host ,
'dsInstanceAdminPort' : server.adminport ,
'dsInstanceDn' : server.dn ,
'dsInstancePswd' : server.password ,
'ldifFile' : dsconfigbatchLdif ,
'backEnd' : newBackend
}
</call>
<!-- Search on new suffix using created indexes -->
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : server.host ,
'dsInstancePort' : server.port ,
'dsInstanceDn' : server.dn ,
'dsInstancePswd' : server.password ,
'dsBaseDN' : newSuffix ,
'dsFilter' : 'objectclass=*' ,
'dsScope' : 'sub' ,
'dsAttributes' : 'dn'
}
</call>
<!-- Do dsconfig get on some properties and check match -->
<script>
batchJob=[]
batchJob.append('get-backend-prop --backend-name %s' % newBackend)
batchJob.append('list-local-db-indexes --backend-name %s' % newBackend)
</script>
<!-- Write batchJob to file -->
<script>
write_file('%s/%s' % (local.temp,batchJobName),batchJob)
</script>
<!-- Copy batchJob file to SUT -->
<call function="'copyFile'">
{
'srcfile' : '%s/%s' % (local.temp,batchJobName),
'destfile' : '%s/%s' % (remote.temp,batchJobName),
'remotehost' : server.location
}
</call>
<!-- Use dsconfig with batchFilePath -->
<call function="'dsconfig'">
{
'subcommand' : '--batchFilePath %s/%s' % (remote.temp,batchJobName),
'expectedRC' : 0
}
</call>
<script>
resultString=STAXResult[0][1]
</script>
<!-- Search for index-entry-limit : 6000 -->
<call function="'searchString'">
{ 'expectedString' : 'index-entry-limit : 6000',
'returnString' : resultString ,
}
</call>
<!-- Search for uniqueMember indexes -->
<call function="'searchString'">
{ 'expectedString' : 'uniqueMember : equality : 5000 : -',
'returnString' : resultString ,
}
</call>
</sequence>
<catch exception="'STAXException.*'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<call function="'testCase_Postamble'"/>
</finally>
</try>
</testcase>
</function>
</stax>