logging_retention.xml revision d25372dc8e65a9ed019a88fdf659ca61313f1b31
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2007-2008 Sun Microsystems, Inc.
! -->
<stax>
<defaultcall function="logging_retention"/>
<function name="logging_retention" scope="local">
<block name="STAXCurrentFunction">
<sequence>
<script>
CurrentTestPath['suite']=STAXCurrentFunction
</script>
<call function="'testSuite_Preamble'" />
<!--- Test Suite information
#@TestSuiteName Retention Policy Tests
#@TestSuitePurpose Verify the Retention Policy
#@TestSuiteID Logging
#@TestSuiteGroup Logging
#@TestGroup Logging
#@TestScript logging_retention.xml
#@TestHTMLLink http://opends.dev.java.net/
-->
<!--- Test Case : retention policy -->
<!---
#@TestMarker Retention Policy Tests
#@TestName Count limit retention policy
#@TestPurpose Check the count retention policy
#@TestPreamble none
#@TestStep Create a new count limit retention policy
#@TestStep Configure the count Limit retention policy with a Max file to 3
#@TestStep Execute ldapsearch request until the log are cleaned
#@TestPostamble none
#@TestResult the number of logs must not exceed 3
-->
<testcase name="getTestCaseName('Count limit retention')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'---- Check the file count -----'
</message>
<!-- set the max number of files to keep -->
<script>
numberFiles=5
maxFiles=6
</script>
<call function="'ldapSearchWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsBaseDN' : DIRECTORY_INSTANCE_SFX,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsFilter' : 'objectclass=*',
'dsScope' : 'base',
'expectedRC' : 0
}
</call>
<message>
'-- create a new file count retention policy --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'create-log-retention-policy',
'objectType' : 'policy-name',
'objectName' : 'my file count retention policy',
'optionsString' : '--type file-count --set number-of-files:%s' % (numberFiles),
'expectedRC' : 0
}
</call>
<message>
'------ Add this retention policy to the Access log publisher --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'set-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'optionsString' : '--add retention-policy:"my file count retention policy"',
'expectedRC' : 0
}
</call>
<message>
'-- create a new size limit rotation policy --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'create-log-rotation-policy',
'objectType' : 'policy-name',
'objectName' : 'my size Limit Rotation Policy',
'optionsString' : '--type size-limit --set file-size-limit:2kb',
'expectedRC' : 0
}
</call>
<message>
'------ Add this rotation policy to the Access log publisher --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'set-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'optionsString' : '--add rotation-policy:"my size Limit Rotation Policy"',
'expectedRC' : 0
}
</call>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'set-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'optionsString' : '--add auto-flush:true --set append:true --set asynchronous:false',
'expectedRC' : 0
}
</call>
<!-- Get configuration -->
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'get-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'expectedRC' : 0
}
</call>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'get-log-rotation-policy-prop',
'objectType' : 'policy-name',
'objectName' : 'my size Limit Rotation Policy',
'expectedRC' : 0
}
</call>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'get-log-retention-policy-prop',
'objectType' : 'policy-name',
'objectName' : 'my file count retention policy',
'expectedRC' : 0
}
</call>
<!-- Starting loop -->
<!-- Execute ldapsearch until we detect a log rotation -->
<!-- Check the number of logs files never exceed the number-of-files -->
<script>
cpt=0
error=0
</script>
<loop from="1" to="10" until="error != 0">
<sequence>
<message>'###########################'</message>
<message>' LOOP %s :' % cpt </message>
<message>'###########################'</message>
<message>'--- Execute a Search request ---'</message>
<call function="'ldapSearchWithScript'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
'dsBaseDN' : DIRECTORY_INSTANCE_SFX,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsFilter' : 'objectclass=*',
'dsScope' : 'base',
'expectedRC' : 0
}
</call>
<call function="'listFolder'">
{ 'location' : DIRECTORY_INSTANCE_HOST,
'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
'filename' : 'access'
}
</call>
<if expr="int(len(cmdResult)) > maxFiles">
<sequence>
<script>
error=1
</script>
<message>
'Error, the number of logs files is %s and exceed the retention policy' % int(len(cmdResult))
</message>
<call function="'testFailed'" />
</sequence>
</if>
<script>
cpt=cpt+1
</script>
</sequence>
</loop>
<if expr="error == 0" >
<sequence>
<message>
'SUCCESS: the retention policy has been checked'
</message>
<call function="'testPassed'"/>
</sequence>
</if>
<!-- cleanup -->
<message>
'------ remove this rotation policy to the Access log publisher --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'set-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'optionsString' : '--remove rotation-policy:"my size Limit Rotation Policy"',
'expectedRC' : 0
}
</call>
<message>
'------ remove this retention policy to the Access log publisher --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'set-log-publisher-prop',
'objectType' : 'publisher-name',
'objectName' : 'File-Based Access Logger',
'optionsString' : '--remove retention-policy:"my file count retention policy"',
'expectedRC' : 0
}
</call>
<message>
'-- delete a new file count retention policy --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'subcommand' : 'delete-log-retention-policy' ,
'objectType' : 'policy-name' ,
'objectName' : 'my file count retention policy',
'expectedRC' : 0
}
</call>
<message>
'-- delete a new size limit rotation policy --'
</message>
<call function="'dsconfig'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'subcommand' : 'delete-log-rotation-policy',
'objectType' : 'policy-name',
'objectName' : 'my size Limit Rotation Policy',
'expectedRC' : 0
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<call function="'testSuite_Postamble'"/>
</sequence>
</block>
</function>
</stax>