2140N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2887N/A<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
2140N/A<!--
2140N/A ! CDDL HEADER START
2140N/A !
2140N/A ! The contents of this file are subject to the terms of the
2140N/A ! Common Development and Distribution License, Version 1.0 only
2140N/A ! (the "License"). You may not use this file except in compliance
2140N/A ! with the License.
2140N/A !
6982N/A ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6982N/A ! or http://forgerock.org/license/CDDLv1.0.html.
2140N/A ! See the License for the specific language governing permissions
2140N/A ! and limitations under the License.
2140N/A !
2140N/A ! When distributing Covered Code, include this CDDL HEADER in each
6982N/A ! file and include the License file at legal-notices/CDDLv1_0.txt.
6982N/A ! If applicable, add the following below this CDDL HEADER, with the
6982N/A ! fields enclosed by brackets "[]" replaced with your own identifying
6982N/A ! information:
2140N/A ! Portions Copyright [yyyy] [name of copyright owner]
2140N/A !
2140N/A ! CDDL HEADER END
2140N/A !
4618N/A ! Copyright 2007-2009 Sun Microsystems, Inc.
2140N/A ! -->
2140N/A<stax>
2235N/A <defaultcall function="logging_rotation"/>
2235N/A <function name="logging_rotation" scope="local">
4618N/A <block name="STAXCurrentFunction">
4618N/A <try>
2235N/A <sequence>
4618N/A <script>
4618N/A CurrentTestPath['suite']=STAXCurrentFunction
4618N/A </script>
4618N/A <call function="'testSuite_Preamble'" />
2235N/A
4618N/A <call function="'common_setup'">
4618N/A {
4618N/A 'quickStart' : True ,
4618N/A 'startServer' : True ,
4618N/A 'stopServer' : False
2235N/A }
2235N/A </call>
4618N/A
4618N/A <!--- Test Suite information
4618N/A #@TestSuiteName Rotation Policy Tests
4618N/A #@TestSuitePurpose Verify the Rotation Policy
4618N/A #@TestSuiteID Logging
4618N/A #@TestSuiteGroup Logging
4618N/A #@TestGroup Logging
4618N/A #@TestScript logging_rotation.xml
4618N/A #@TestHTMLLink http://opends.dev.java.net/
4618N/A -->
4618N/A
4618N/A <!---
4618N/A #@TestMarker Rotation Policy Tests
4618N/A #@TestName Size limit rotation
4618N/A #@TestPurpose Check the size limit rotation policy
4618N/A #@TestPreamble none
4618N/A #@TestStep Create a new size limit rotation policy
4618N/A #@TestStep Configure the Size Limit rotation policy with a Max size to 64kb
4618N/A #@TestStep Execute ldapsearch request until the log are rotate
4618N/A #@TestPostamble none
4618N/A #@TestResult the logs size must match the rotation size
4618N/A -->
2235N/A
4618N/A <testcase name="getTestCaseName('size limit')">
2235N/A <sequence>
4618N/A <call function="'testCase_Preamble'"/>
4618N/A <message>
4618N/A '---- Check the size limit rotation -----'
4618N/A </message>
2235N/A
4618N/A <message>
4618N/A '-- create a new size limit rotation policy --'
4618N/A </message>
4618N/A <call function="'dsconfig'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'subcommand' : 'create-log-rotation-policy',
4618N/A 'objectType' : 'policy-name',
4618N/A 'objectName' : 'my size Limit Rotation Policy',
4618N/A 'optionsString' : '--type size-limit --set file-size-limit:4kb',
2235N/A 'expectedRC' : 0
2235N/A }
2235N/A </call>
2235N/A
4618N/A <message>
4618N/A '------ Add this rotation policy to the Access log publisher --'
4618N/A </message>
4618N/A <call function="'dsconfig'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
4618N/A 'subcommand' : 'set-log-publisher-prop',
4618N/A 'objectType' : 'publisher-name',
4618N/A 'objectName' : 'File-Based Access Logger',
4618N/A 'optionsString' : '--add rotation-policy:"my size Limit Rotation Policy"',
4618N/A 'expectedRC' : 0
4618N/A }
4618N/A </call>
2235N/A
4618N/A <call function="'dsconfig'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'subcommand' : 'set-log-publisher-prop',
4618N/A 'objectType' : 'publisher-name',
4618N/A 'objectName' : 'File-Based Access Logger',
4618N/A 'optionsString' : '--add auto-flush:true --set append:true --set asynchronous:false --set buffer-size:64kb',
4618N/A 'expectedRC' : 0
4618N/A }
4618N/A </call>
4618N/A
4618N/A
2235N/A <call function="'dsconfigGet'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
2235N/A 'objectName' : 'log-publisher',
2235N/A 'propertyType' : 'publisher',
2235N/A 'propertyName' : 'File-Based Access Logger',
2624N/A 'attributeName' : 'rotation-policy'
2235N/A }
2235N/A </call>
4618N/A
2235N/A
4618N/A <!-- Starting loop -->
4618N/A <script>
4618N/A listName=[]
4618N/A listSize=[]
4618N/A cpt=0
4618N/A nbLog=0
4618N/A </script>
4618N/A <!-- Execute ldapsearch until we detect a log rotation -->
4618N/A <!-- Stop when the first rotation is done -->
2235N/A
4618N/A <loop from="1" to="50" until="RC != 0">
4618N/A <sequence>
4618N/A <message>'###########################'</message>
4618N/A <message>' LOOP %s :' % cpt </message>
4618N/A <message>'###########################'</message>
4618N/A <message>'--- Execute a Search request ---'</message>
4618N/A
4618N/A <call function="'ldapSearchWithScript'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
4618N/A 'dsBaseDN' : DIRECTORY_INSTANCE_SFX,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'dsFilter' : 'objectclass=*',
4618N/A 'dsScope' : 'base',
4618N/A 'expectedRC' : 0
4618N/A }
4618N/A </call>
4618N/A
4618N/A
4618N/A <call function="'dsconfigGet'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'objectName' : 'log-publisher',
4618N/A 'propertyType' : 'publisher',
4618N/A 'propertyName' : 'File-Based Access Logger',
4618N/A 'attributeName' : 'rotation-policy'
4618N/A }
4618N/A </call>
4618N/A
4618N/A <message>'--- Check log files ---'</message>
4618N/A <call function="'listFolder'">
4618N/A { 'location' : DIRECTORY_INSTANCE_HOST,
4618N/A 'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
4618N/A 'filename' : 'access'
4618N/A }
4618N/A </call>
4618N/A
4618N/A <if expr="len(cmdResult) > 0">
4618N/A <sequence>
4618N/A <iterate var="result" in="cmdResult">
4618N/A <sequence>
4618N/A <script>
4618N/A logname=result["name"]
4618N/A logsize=result["size"]
4618N/A found=0
4618N/A </script>
4618N/A <message>
4618N/A 'the log file status for file "%s" is %s ' % (logname,logsize)
4618N/A </message>
4618N/A <script>
4618N/A for currentLog in listName:
4618N/A if currentLog == logname:
4618N/A found=1
4618N/A currentIndex=listName.index(currentLog)
4618N/A currentSize=listSize[currentIndex]
4618N/A if currentSize != logsize:
4618N/A listSize[currentIndex]=logsize
4618N/A
4618N/A if found == 0:
4618N/A if nbLog != 0:
4618N/A RC=1
4618N/A newlogName=logname
4618N/A newlogSize=logsize
4618N/A listName.append(logname)
4618N/A listSize.append(logsize)
4618N/A </script>
4618N/A </sequence>
4618N/A </iterate>
4618N/A
4618N/A <!-- set nbLog when we find a log file -->
2235N/A <script>
4618N/A nbLog=1
2235N/A </script>
2235N/A <message>
4618N/A 'The new log file status is : %s : %s' % (listName,listSize)
2235N/A </message>
2235N/A </sequence>
4618N/A </if>
2235N/A <script>
4618N/A cpt=cpt+1
2235N/A </script>
2235N/A </sequence>
4618N/A </loop>
4618N/A
2235N/A
4618N/A <!-- ############################### -->
4618N/A <!-- Check log file size -->
4618N/A <!-- all the log file size must be around 4kb -->
4618N/A <!-- ############################### -->
4618N/A
4618N/A <if expr="RC == 1">
2235N/A <sequence>
2235N/A <message>
4618N/A 'A log rotation has been done. The new rotation file is "%s" (size = %s) ' % (newlogName,newlogSize)
4618N/A </message>
4618N/A
5189N/A <if expr="int(newlogSize) &lt; 4100 and int(newlogSize) > 3800" >
4618N/A <sequence>
4618N/A <message>
4618N/A 'SUCCESS. The rotation based on size limit is successfull. The file "%s" (size = %s) ' % (newlogName,newlogSize)
4618N/A </message>
4618N/A <call function="'testPassed'"/>
4618N/A </sequence>
4618N/A <else>
4618N/A <sequence>
4618N/A <message>
4618N/A 'ERROR in the rotation. The file "%s" (size = %s) does not match the rotation size ' % (newlogName,newlogSize)
4618N/A </message>
4618N/A <call function="'testFailed'"/>
4618N/A </sequence>
4618N/A </else>
4618N/A </if>
2235N/A </sequence>
2235N/A <else>
2235N/A <sequence>
4618N/A <message>'ERROR. The rotation process didn t work.'</message>
2235N/A <call function="'testFailed'"/>
2235N/A </sequence>
2235N/A </else>
2235N/A </if>
4618N/A
4618N/A <!-- ############################### -->
4618N/A <!-- clean rotation policy -->
4618N/A <!-- ############################### -->
4618N/A
4618N/A <message>
4618N/A '------ remove this rotation policy to the Access log publisher --'
4618N/A </message>
4618N/A <call function="'dsconfig'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'subcommand' : 'set-log-publisher-prop',
4618N/A 'objectType' : 'publisher-name',
4618N/A 'objectName' : 'File-Based Access Logger',
4618N/A 'optionsString' : '--remove rotation-policy:"my size Limit Rotation Policy"',
4618N/A 'expectedRC' : 0
4618N/A }
4618N/A </call>
4618N/A
4618N/A <message>
4618N/A '-- delete a new size limit rotation policy --'
4618N/A </message>
4618N/A <call function="'dsconfig'">
4618N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'subcommand' : 'delete-log-rotation-policy',
4618N/A 'objectType' : 'policy-name',
4618N/A 'objectName' : 'my size Limit Rotation Policy',
4618N/A 'expectedRC' : 0
4618N/A }
4618N/A </call>
4618N/A <call function="'testCase_Postamble'" />
2235N/A </sequence>
4618N/A </testcase>
2235N/A
2235N/A </sequence>
4618N/A <finally>
4618N/A <sequence>
4618N/A <!-- Test Suite Cleanup -->
4618N/A <message>'Finally: Global Log Rotation Cleanup.'</message>
4618N/A <try>
4618N/A <call function="'common_cleanup'" />
4618N/A <catch exception="'STAFException'">
4618N/A <sequence>
4618N/A <message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
4618N/A </sequence>
4618N/A </catch>
4618N/A <finally>
4618N/A <call function="'testSuite_Postamble'"/>
4618N/A </finally>
4618N/A </try>
4618N/A </sequence>
4618N/A </finally>
4618N/A
4618N/A </try>
4618N/A </block>
2418N/A </function>
2140N/A</stax>
2175N/A