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