From b3ba51e8d1f4ac88411f716f20d3671c195ea759 Mon Sep 17 00:00:00 2001
From: al_xipe <al_xipe@localhost>
Date: Sat, 25 Aug 2007 12:21:54 +0000
Subject: [PATCH] massive retrofit of the logging tests into the framework

---
 opends/tests/functional-tests/testcases/logging/logging_rotation.xml |  499 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 257 insertions(+), 242 deletions(-)

diff --git a/opends/tests/functional-tests/testcases/logging/logging_rotation.xml b/opends/tests/functional-tests/testcases/logging/logging_rotation.xml
index e672dc0..4141b16 100755
--- a/opends/tests/functional-tests/testcases/logging/logging_rotation.xml
+++ b/opends/tests/functional-tests/testcases/logging/logging_rotation.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE stax SYSTEM "../../../stax.dtd">
+<!DOCTYPE stax SYSTEM "../../shared/stax.dtd">
 <!--
  ! CDDL HEADER START
  !
@@ -26,250 +26,265 @@
  !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  ! -->
 <stax>
-  
-<defaultcall function="logging_rotation"/>
-<function name="logging_rotation" scope="local">      
-
-<sequence>
-                               
-       
-       <!---
-  #@TestMarker            size limit  rotation 
-  #@TestName              size limit  rotation 
-  #@TestIssue               Check the size limit rotation policy
-  #@TestPreamble         none
-  #@TestStep                Create a new size limit rotation policy
-    #@TestStep                Configure the Size Limit rotation policy with a Max size to 4kb
-    #@TestStep                Execute ldapsearch request until the log are rotate
-  #@TestPostamble       none
-  #@TestResult             the logs size must match the rotation size            
+  <defaultcall function="logging_rotation"/>
+  <function name="logging_rotation" scope="local">
+    <sequence>
+      <script>
+        CurrentTestPath['suite']=STAXCurrentFunction
+      </script>
+      <call function="'testSuite_Preamble'" />
+      <!---
+          #@TestMarker     size limit  rotation
+          #@TestName       size limit  rotation
+          #@TestIssue      Check the size limit rotation policy
+          #@TestPreamble   none
+          #@TestStep       Create a new size limit rotation policy
+          #@TestStep       Configure the Size Limit rotation policy with a Max size to 4kb
+          #@TestStep       Execute ldapsearch request until the log are rotate
+          #@TestPostamble  none
+          #@TestResult     the logs size must match the rotation size
       -->
       
-    
-  <testcase name="'logging : Rotation  policy : size limit  '">
-
-   <sequence>
-    <call function="'testCase_Preamble'"/>
-  <message>
-        '----  Check the size limit rotation -----'
-    </message>            
-     
-    <message>'-- create a new size limit rotation policy --'</message>   
-    <call function="'dsconfig'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        '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:4kb',
-        'expectedRC'             : 0 } 
-    </call>  
-     
-  <message>'------  Add this rotation policy to the Access log publisher --' </message>
-    <call function="'dsconfig'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        '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-dn:"cn=my size Limit Rotation Policy,cn=Log Rotation Policies,cn=config"',
-        'expectedRC'             : 0 } 
-    </call>
-
-  <call function="'dsconfig'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        '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 --set buffer-size:64kb',
-        'expectedRC'             : 0 } 
-    </call>     
-
-    <call function="'dsconfigGet'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        'dsInstanceDn'           : DIRECTORY_INSTANCE_DN ,
-        'dsInstancePswd'       : DIRECTORY_INSTANCE_PSWD ,
-        'objectName'             : 'log-publisher' ,
-        'propertyType'           : 'publisher' ,
-        'propertyName'           : 'File-Based Access Logger',
-        'attributeName'          : 'rotation-policy-dn'
-    }
-    </call>     
-  
-
-   <call function="'Sleep'">
+      <testcase name="getTestCaseName('size limit')">
+        <sequence>
+          <call function="'testCase_Preamble'"/>
+          <message>
+            '----  Check the size limit rotation -----'
+          </message>
+          
+          <message>
+            '-- create a new size limit rotation policy --'
+          </message>
+          <call function="'dsconfig'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              '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:4kb',
+              'expectedRC'     : 0
+            }
+          </call>
+          
+          <message>
+            '------  Add this rotation policy to the Access log publisher --'
+          </message>
+          <call function="'dsconfig'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              '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-dn:"cn=my size Limit Rotation Policy,cn=Log Rotation Policies,cn=config"',
+              'expectedRC'     : 0
+            }
+          </call>
+          
+          <call function="'dsconfig'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              '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 --set buffer-size:64kb',
+              'expectedRC'     : 0
+            }
+          </call>
+          
+          <call function="'dsconfigGet'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+              'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+              'objectName'     : 'log-publisher',
+              'propertyType'   : 'publisher',
+              'propertyName'   : 'File-Based Access Logger',
+              'attributeName'  : 'rotation-policy-dn'
+            }
+          </call>
+          
+          <call function="'Sleep'">
             { 'sleepForMilliSeconds'  : 20000 }
-   </call>
-     
-   <!--  Starting loop -->       
-   <script>  
-          listName=[]
-          listSize=[]
-   </script>     
-   <script>
-     cpt=0
-     nbLog=0
-     </script>  
-   <!--  Execute ldapsearch until we detect a log rotation -->  
-   <!--   Stop when the first rotation is done -->
-     
-   <loop from="1" to="50" until="RC != 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="'dsconfigGet'">
-        { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        'dsInstanceDn'           : DIRECTORY_INSTANCE_DN ,
-        'dsInstancePswd'       : DIRECTORY_INSTANCE_PSWD ,
-        'objectName'             : 'log-publisher' ,
-        'propertyType'           : 'publisher' ,
-        'propertyName'           : 'File-Based Access Logger',
-        'attributeName'          : 'rotation-policy-dn'
-      }
-         </call>        
-                
-       <message>'--- Check log files ---'</message>  
-         <call function="'listFolder'">
-          { 'location' : '%s' % (DIRECTORY_INSTANCE_HOST),
-           'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
-           'filename' : 'access'
-           }
-    </call>    
-     
-      <if expr="len(cmdResult) > 0">
-        <sequence>                  
-          <iterate var="result" in="cmdResult">
-       <sequence>
-         <script>
-           logname=result["name"]
-           logsize=result["size"]
-           found=0
-         </script>
-         <message>'the log file status for file  "%s" is %s ' % (logname,logsize)</message>
-         <script>
-           for currentLog in listName:
-               if currentLog == logname:
-                  found=1
-                  currentIndex=listName.index(currentLog)
-                  currentSize=listSize[currentIndex]
-                  if currentSize != logsize:
-                      listSize[currentIndex]=logsize
-
-          if found == 0:
-             if nbLog != 0:
-                RC=1
-                newlogName=logname
-                newlogSize=logsize
-             listName.append(logname)
-             listSize.append(logsize)
-         </script>
-       </sequence>     
-      </iterate>     
-      <!--  set nbLog  when we find a log file -->    
+          </call>
+          
+          <!--  Starting loop -->
           <script>
-        nbLog=1
-      </script> 
-          <message>'The new log file status is : %s : %s' % (listName,listSize)</message>       
-          </sequence>        
-     </if>
-     <script>
-       cpt=cpt+1
-     </script>   
-     </sequence>   
-     </loop>  
-    
-     
-     <!-- ############################### -->
-   <!-- Check log file size                                                -->
-   <!-- all the log file size must be around 4kb                  -->
-    <!-- ############################### -->
-     
-   <if expr="RC == 1">
-     <sequence>
-          <message>'A log rotation has been done. The new rotation file is "%s" (size = %s) ' % (newlogName,newlogSize)</message>                  
-       
-       <if expr="int(newlogSize) &lt;  4100 and int(newlogSize) > 4000" >
-             <sequence>
-               <message>'SUCCESS. The rotation based on size limit is successfull.  The file "%s" (size = %s) ' % (newlogName,newlogSize)</message>
-               <call function="'testPassed'"/>              
-       </sequence>
-         <else>       
-           <sequence>
-           <message>'ERROR in the rotation. The file "%s" (size = %s) does not match the rotation size ' % (newlogName,newlogSize)</message>
-               <call function="'testFailed'"/>     
-         </sequence>
-     </else>
-     </if>       
-     </sequence>   
-   <else>
-     <sequence>
-     <message>'ERROR. The rotation process didn t work.'</message>
-         <call function="'testFailed'"/>     
-     </sequence>   
-     </else>  
-     </if>     
-
-     
-  <!-- ############################### -->
-    <!--   clean rotation policy -->     
-  <!-- ############################### -->   
-     
-  <message>'------  remove this rotation policy to the Access log publisher --' </message>
-    <call function="'dsconfig'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        '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-dn:"cn=my size Limit Rotation Policy,cn=Log Rotation Policies,cn=config"',
-        'expectedRC'             : 0 } 
-    </call>
-
-
-    <message>'-- delete a new size limit rotation policy --'</message>   
-    <call function="'dsconfig'">
-      { 'dsInstanceHost'       : DIRECTORY_INSTANCE_HOST,
-        'dsInstancePort'         : DIRECTORY_INSTANCE_PORT ,
-        '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>
-       
-</sequence>
-</function>
-
+            listName=[]
+            listSize=[]
+            cpt=0
+            nbLog=0
+          </script>
+          <!--  Execute ldapsearch until we detect a log rotation -->
+          <!--   Stop when the first rotation is done -->
+          
+          <loop from="1" to="50" until="RC != 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="'dsconfigGet'">
+                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                  'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+                  'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                  'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                  'objectName'     : 'log-publisher',
+                  'propertyType'   : 'publisher',
+                  'propertyName'   : 'File-Based Access Logger',
+                  'attributeName'  : 'rotation-policy-dn'
+                }
+              </call>
+              
+              <message>'--- Check log files ---'</message>  
+              <call function="'listFolder'">
+                { 'location'   : DIRECTORY_INSTANCE_HOST,
+                  'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
+                  'filename'   : 'access'
+                 }
+              </call>
+              
+              <if expr="len(cmdResult) > 0">
+                <sequence>                  
+                  <iterate var="result" in="cmdResult">
+                    <sequence>
+                      <script>
+                        logname=result["name"]
+                        logsize=result["size"]
+                        found=0
+                      </script>
+                      <message>
+                        'the log file status for file  "%s" is %s ' % (logname,logsize)
+                      </message>
+                      <script>
+                        for currentLog in listName:
+                          if currentLog == logname:
+                            found=1
+                            currentIndex=listName.index(currentLog)
+                            currentSize=listSize[currentIndex]
+                            if currentSize != logsize:
+                              listSize[currentIndex]=logsize
+                        
+                        if found == 0:
+                          if nbLog != 0:
+                            RC=1
+                            newlogName=logname
+                            newlogSize=logsize
+                          listName.append(logname)
+                          listSize.append(logsize)
+                      </script>
+                    </sequence>
+                  </iterate>
+                  <!--  set nbLog  when we find a log file -->
+                  <script>
+                    nbLog=1
+                  </script>
+                  <message>
+                    'The new log file status is : %s : %s' % (listName,listSize)
+                  </message>
+                </sequence>
+              </if>
+              <script>
+                cpt=cpt+1
+              </script>
+            </sequence>
+          </loop>
+          
+          
+          <!-- ############################### -->
+          <!-- Check log file size             -->
+          <!-- all the log file size must be around 4kb -->
+          <!-- ############################### -->
+          
+          <if expr="RC == 1">
+            <sequence>
+              <message>
+                'A log rotation has been done. The new rotation file is "%s" (size = %s) ' % (newlogName,newlogSize)
+              </message>                  
+              
+              <if expr="int(newlogSize) &lt;  4100 and int(newlogSize) > 4000" >
+                <sequence>
+                  <message>
+                    'SUCCESS. The rotation based on size limit is successfull.  The file "%s" (size = %s) ' % (newlogName,newlogSize)
+                  </message>
+                  <call function="'testPassed'"/>
+                </sequence>
+                <else>
+                  <sequence>
+                    <message>
+                      'ERROR in the rotation. The file "%s" (size = %s) does not match the rotation size ' % (newlogName,newlogSize)
+                    </message>
+                    <call function="'testFailed'"/>
+                  </sequence>
+                </else>
+              </if>
+            </sequence>
+            <else>
+              <sequence>
+                <message>'ERROR. The rotation process didn t work.'</message>
+                <call function="'testFailed'"/>
+              </sequence>
+            </else>
+          </if>
+          
+          <!-- ############################### -->
+          <!--   clean rotation policy -->     
+          <!-- ############################### -->   
+          
+          <message>
+            '------  remove this rotation policy to the Access log publisher --'
+          </message>
+          <call function="'dsconfig'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              '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-dn:"cn=my size Limit Rotation Policy,cn=Log Rotation Policies,cn=config"',
+              'expectedRC'     : 0
+            }
+          </call>
+          
+          <message>
+            '-- delete a new size limit rotation policy --'
+          </message>
+          <call function="'dsconfig'">
+            { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+              'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
+              '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>
+  </function>
 </stax>
   

--
Gitblit v1.10.0