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 !
2140N/A ! You can obtain a copy of the license at
2140N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
2140N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
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
2140N/A ! file and include the License file at
2140N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
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]
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_writer"/>
2235N/A <function name="logging_writer" scope="local">
4618N/A <block name="STAXCurrentFunction">
4618N/A <try>
2235N/A <sequence>
2235N/A <script>
2235N/A CurrentTestPath['suite']=STAXCurrentFunction
2235N/A </script>
2235N/A <call function="'testSuite_Preamble'"/>
3153N/A
4618N/A <call function="'common_setup'">
4618N/A {
4618N/A 'quickStart' : True ,
4618N/A 'startServer' : True ,
4618N/A 'stopServer' : False
4618N/A }
4618N/A </call>
3153N/A
4618N/A <!--- Test Suite information
4618N/A #@TestSuiteName Basic tests on logging
4618N/A #@TestSuitePurpose Check the log of information under Access or Debug files is correctly done
4618N/A #@TestSuiteID Logging
4618N/A #@TestSuiteGroup Logging
4618N/A #@TestGroup Logging
4618N/A #@TestScript logging_writer.xml
4618N/A #@TestHTMLLink http://opends.dev.java.net/
4618N/A -->
4618N/A
2235N/A <!-- #################################### -->
2235N/A <!--
3174N/A #@TestMarker Basic tests on logging
3174N/A #@TestName Basic test on access log publisher
2235N/A #@TestIssue
3174N/A #@TestPurpose Check informations are correclty logged under Access log files.
3174N/A #@TestPurpose the Access log publisher is configured with asynchronous mode and auto-flush
2235N/A #@TestPreamble none
3174N/A #@TestStep Set the publisher Access Logger's properties to be an asynchronous mode
2235N/A #@TestStep Set the auto-flush to TRUE
2235N/A #@TestStep Set the append property to false
2235N/A #@TestStep Configure the Size Limit rotation policy with a Max size to 1mb
2235N/A #@TestStep Execute ldapsearch request until the log are writen in the disk
2235N/A #@TestPostamble none
2235N/A #@TestResult The recors must be written to disk after each operation
2235N/A -->
2235N/A <!-- #################################### -->
2417N/A
2417N/A <testcase name="getTestCaseName('Synchronous mode Access logger')">
2235N/A <sequence>
2235N/A <call function="'testCase_Preamble'"/>
2235N/A <message>
2235N/A '---- Check the Synchronous mode for Access loggers -----'
2235N/A </message>
2235N/A <message>
2235N/A ' asynchronous:false - auto-flush:true - append:false - buffer-size:20kb '
2235N/A </message>
2235N/A <message>'------ set properties --' </message>
2235N/A <call function="'dsconfig'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
2235N/A 'subcommand' : 'set-log-publisher-prop',
2235N/A 'objectType' : 'publisher-name',
2235N/A 'objectName' : 'File-Based Access Logger',
2235N/A 'optionsString' : '--set auto-flush:true --set append:false --set asynchronous:false --set buffer-size:20kb',
2235N/A 'expectedRC' : 0
2235N/A }
2235N/A </call>
2235N/A
2235N/A <call function="'dsconfig'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
2235N/A 'subcommand' : 'set-log-rotation-policy-prop',
2235N/A 'objectType' : 'policy-name',
2235N/A 'objectName' : 'Size Limit Rotation Policy',
2235N/A 'optionsString' : '--set file-size-limit:1mb',
2235N/A 'expectedRC' : 0
2235N/A }
2235N/A </call>
2235N/A
2235N/A <!-- Starting loop -->
2235N/A <script>
2235N/A listName=[]
2235N/A listSize=[]
2235N/A cpt=0
2235N/A </script>
2235N/A
2235N/A <!-- Execute ldapsearch until logs are written to disk -->
2235N/A <!-- as auto-flush is true, the logs must be written after each operation -->
2235N/A <loop from="1" to="5" until="RC != 0">
2235N/A <sequence>
2235N/A <message>'###########################'</message>
2235N/A <message>' LOOP %s :' % cpt </message>
2235N/A <message>'###########################'</message>
2235N/A <message>'--- Execute a Search request ---'</message>
2235N/A
2235N/A <call function="'ldapSearchWithScript'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
2235N/A 'dsBaseDN' : DIRECTORY_INSTANCE_SFX,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
2235N/A 'dsFilter' : 'objectclass=*',
2235N/A 'dsScope' : 'base',
2235N/A 'expectedRC' : 0
2235N/A }
2235N/A </call>
2235N/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>
2235N/A
2235N/A <message>'--- Check log files ---'</message>
2235N/A <call function="'listFolder'">
2235N/A { 'location' : '%s' % (DIRECTORY_INSTANCE_HOST),
2235N/A 'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
2235N/A 'filename' : 'access'
2235N/A }
2235N/A </call>
2140N/A
2235N/A <if expr="len(cmdResult) > 0">
2235N/A <sequence>
2235N/A <iterate var="result" in="cmdResult">
2235N/A <sequence>
2235N/A <script>
2235N/A logname=result["name"]
2235N/A logsize=result["size"]
2235N/A found=0
2235N/A </script>
2235N/A <message>
2235N/A 'log file status for file %s is %s ' % (logname,logsize)
2235N/A </message>
2235N/A <script>
2235N/A for currentLog in listName:
2235N/A if currentLog == logname:
2235N/A found=1
2235N/A currentIndex=listName.index(currentLog)
2235N/A currentSize=listSize[currentIndex]
2235N/A if currentSize != logsize:
2235N/A RC=1
2235N/A listSize[currentIndex]=logsize
2235N/A break
2235N/A
2235N/A if found == 0:
2235N/A listName.append(logname)
2235N/A listSize.append(logsize)
2235N/A </script>
2235N/A </sequence>
2235N/A </iterate>
2235N/A </sequence>
2235N/A </if>
2235N/A <message>
2235N/A 'The new log file status is : %s : %s' % (listName,listSize)
2235N/A </message>
2235N/A <script>
2235N/A cpt=cpt+1
2235N/A </script>
2235N/A </sequence>
2235N/A </loop>
2235N/A <message>
2235N/A 'The log file status of the file "%s" has changed ' % logname
2235N/A </message>
2235N/A
2235N/A <!-- Check log file -->
2235N/A <!-- records must be writen after each operation -->
2235N/A <!-- we should exit the loop after the first ldapsearch -->
2235N/A <if expr="cpt != 2">
2235N/A <sequence>
2235N/A <message>
2235N/A 'ERROR. The writer are not flushed after every log records'
2235N/A </message>
2235N/A <call function="'testFailed'"/>
2235N/A </sequence>
2235N/A <else>
2235N/A <sequence>
2235N/A <message>
2235N/A 'SUCCESS. The writer are flushed after every log records'
2235N/A </message>
2235N/A <call function="'testPassed'"/>
2235N/A </sequence>
2235N/A </else>
2235N/A </if>
2534N/A <call function="'testCase_Postamble'"/>
2235N/A </sequence>
2235N/A </testcase>
2235N/A
2235N/A <!-- #################################### -->
2235N/A <!--
3174N/A #@TestMarker Basic tests on logging
3174N/A #@TestName Basic test on Debug log publisher
2235N/A #@TestIssue
3174N/A #@TestPurpose Check informations are correclty logged under Debug log files.
2235N/A #@TestPreamble none
2235N/A #@TestStep Enabled the Debug Logger
3153N/A #@TestStep Define a specific log file for debug message
2235N/A #@TestStep set the debug-log-level to All
2235N/A #@TestStep Restart the server
2235N/A #@TestStep Execute a ldapsearch request
2235N/A #@TestPostamble none
2235N/A #@TestResult Check the debug log file has been created and contains datas
2235N/A -->
2235N/A <!-- #################################### -->
2235N/A
2235N/A <testcase name="getTestCaseName('basic tests on Debug logger')">
2235N/A <sequence>
2235N/A <call function="'testCase_Preamble'"/>
2235N/A <message>
2235N/A '---- Basic tests on Debug loggers -----'
2235N/A </message>
2481N/A
2235N/A <message>'------ Enabled Debug logger --' </message>
2235N/A <call function="'dsconfig'">
2235N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2235N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2235N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
2235N/A 'subcommand' : 'set-log-publisher-prop',
2235N/A 'objectType' : 'publisher-name',
2235N/A 'objectName' : 'File-Based Debug Logger',
2481N/A 'optionsString' : '--set enabled:true --set default-debug-level:warning --set log-file:logs/mydebug',
2235N/A 'expectedRC' : 0
2235N/A }
2235N/A </call>
2235N/A
4153N/A <call function="'StopDsWithScript'">
4153N/A { 'location' : STAF_REMOTE_HOSTNAME,
4153N/A 'dsHost' : DIRECTORY_INSTANCE_HOST,
3853N/A 'dsAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
3853N/A 'dsBindDN' : DIRECTORY_INSTANCE_DN,
3853N/A 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
2235N/A }
2235N/A </call>
4153N/A <call function="'StartDsWithScript'">
4153N/A { 'location' : STAF_REMOTE_HOSTNAME }
4153N/A </call>
4153N/A <!--- Check that DS started -->
4153N/A <call function="'isAlive'">
4153N/A {
4153N/A 'noOfLoops' : 10 ,
4153N/A 'noOfMilliSeconds' : 2000
4153N/A }
4153N/A </call>
4153N/A
2235N/A <message>'--- Check log files ---'</message>
2235N/A <call function="'listFolder'">
2235N/A { 'location' : '%s' % DIRECTORY_INSTANCE_HOST,
2235N/A 'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
2235N/A 'filename' : 'mydebug'
2235N/A }
2235N/A </call>
2140N/A
2235N/A <script>
2235N/A error=0
2235N/A </script>
2235N/A <if expr="len(cmdResult) == 0">
2175N/A <sequence>
2235N/A <message>'ERROR. The Debug logger should be created'</message>
2235N/A <script>
2235N/A error=1
2235N/A </script>
2235N/A </sequence>
2235N/A <else>
2235N/A <sequence>
2235N/A <iterate var="result" in="cmdResult">
2235N/A <sequence>
2235N/A <script>
2235N/A logsize=result["size"]
2235N/A </script>
2235N/A <if expr="logsize == 0">
2235N/A <sequence>
2235N/A <message>'ERROR. The Debug logger should contain data'</message>
2235N/A <script>
2235N/A error=1
2235N/A </script>
2235N/A </sequence>
2235N/A </if>
2235N/A </sequence>
2235N/A </iterate>
2235N/A </sequence>
2235N/A </else>
2235N/A </if>
2235N/A
2235N/A <if expr="error == 0">
2235N/A <call function="'testPassed'"/>
2235N/A <else>
2235N/A <call function="'testFailed'"/>
2235N/A </else>
2235N/A </if>
2481N/A
2481N/A <message>'------ Disable Debug logger --' </message>
2481N/A <call function="'dsconfig'">
2481N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
2481N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
2481N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
2481N/A 'subcommand' : 'set-log-publisher-prop',
2481N/A 'objectType' : 'publisher-name',
2481N/A 'objectName' : 'File-Based Debug Logger',
2481N/A 'optionsString' : '--set enabled:false',
2481N/A 'expectedRC' : 0
2481N/A }
2481N/A </call>
2534N/A
2534N/A <call function="'testCase_Postamble'"/>
2235N/A </sequence>
2235N/A </testcase>
4618N/A
2534N/A </sequence>
4618N/A <finally>
4618N/A <sequence>
4618N/A <!-- Test Suite Cleanup -->
4618N/A <message>'Finally: Global Log Writer 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>
2417N/A </block>
2235N/A </function>
2146N/A</stax>