2140N/A<?
xml version="1.0" encoding="UTF-8" standalone="no"?>
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 ! You can obtain a copy of the license at 2140N/A ! See the License for the specific language governing permissions 2140N/A ! and limitations under the License. 2140N/A ! When distributing Covered Code, include this CDDL HEADER in each 2140N/A ! file and include the License file at 2140N/A ! add the following below this CDDL HEADER, with the fields enclosed 2140N/A ! by brackets "[]" replaced with your own identifying information: 2140N/A ! Portions Copyright [yyyy] [name of copyright owner] 4618N/A ! Copyright 2007-2009 Sun Microsystems, Inc. 2235N/A <
defaultcall function="logging_rotation"/>
2235N/A <
function name="logging_rotation" scope="local">
4618N/A <
block name="STAXCurrentFunction">
4618N/A CurrentTestPath['suite']=STAXCurrentFunction
4618N/A <
call function="'testSuite_Preamble'" />
4618N/A <
call function="'common_setup'">
4618N/A <!--- Test Suite information 4618N/A #@TestSuiteName Rotation Policy Tests 4618N/A #@TestSuitePurpose Verify the Rotation Policy 4618N/A #@TestMarker Rotation Policy Tests 4618N/A #@TestName Size limit rotation 4618N/A #@TestPurpose Check the size limit rotation policy 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 #@TestResult the logs size must match the rotation size 4618N/A <
testcase name="getTestCaseName('size limit')">
4618N/A <
call function="'testCase_Preamble'"/>
4618N/A '---- Check the size limit rotation -----'
4618N/A '-- create a new size limit rotation policy --'
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',
4618N/A '------ Add this rotation policy to the Access log publisher --'
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 <
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',
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'
4618N/A <!-- Execute ldapsearch until we detect a log rotation --> 4618N/A <!-- Stop when the first rotation is done --> 4618N/A <
loop from="1" to="50" until="RC != 0">
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 <
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 <
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 <
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 <
if expr="len(cmdResult) > 0">
4618N/A <
iterate var="result" in="cmdResult">
4618N/A 'the log file status for file "%s" is %s ' % (logname,logsize)
4618N/A for currentLog in listName:
4618N/A currentSize=listSize[currentIndex]
4618N/A listSize[currentIndex]=logsize
4618N/A <!-- set nbLog when we find a log file --> 4618N/A 'The new log file status is : %s : %s' % (listName,listSize)
4618N/A <!-- ############################### --> 4618N/A <!-- Check log file size --> 4618N/A <!-- all the log file size must be around 4kb --> 4618N/A <!-- ############################### --> 4618N/A 'A log rotation has been done. The new rotation file is "%s" (size = %s) ' % (newlogName,newlogSize)
5189N/A <
if expr="int(newlogSize) < 4100 and int(newlogSize) > 3800" >
4618N/A 'SUCCESS. The rotation based on size limit is successfull. The file "%s" (size = %s) ' % (newlogName,newlogSize)
4618N/A <
call function="'testPassed'"/>
4618N/A 'ERROR in the rotation. The file "%s" (size = %s) does not match the rotation size ' % (newlogName,newlogSize)
4618N/A <
call function="'testFailed'"/>
4618N/A <
message>'ERROR. The rotation process didn t work.'</
message>
2235N/A <
call function="'testFailed'"/>
4618N/A <!-- ############################### --> 4618N/A <!-- clean rotation policy --> 4618N/A <!-- ############################### --> 4618N/A '------ remove this rotation policy to the Access log publisher --'
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 '-- delete a new size limit rotation policy --'
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 <
call function="'testCase_Postamble'" />
4618N/A <!-- Test Suite Cleanup --> 4618N/A <
message>'Finally: Global Log Rotation Cleanup.'</
message>
4618N/A <
call function="'common_cleanup'" />
4618N/A <
catch exception="'STAFException'">
4618N/A <
message log="1" level="'fatal'">'Cleanup of test suite failed.'</
message>
4618N/A <
call function="'testSuite_Postamble'"/>