From 8e68b9626c70a31c6f5a075a9c8be3840efe2455 Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Mon, 26 May 2008 08:30:57 +0000
Subject: [PATCH] Fix problem with SNMP tests on Windows and add timeout for trap tests

---
 opends/tests/shared/functions/snmp.xml                                 |   23 ++
 opends/tests/functional-tests/testcases/snmp/snmp_trap_defaultconf.xml |  373 ++++++++++++++++++++++++++++++++++------------------
 opends/tests/shared/functions/topology.xml                             |    7 
 opends/tests/shared/functions/utils.xml                                |    7 
 4 files changed, 272 insertions(+), 138 deletions(-)

diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_trap_defaultconf.xml b/opends/tests/functional-tests/testcases/snmp/snmp_trap_defaultconf.xml
index 826c6a4..930aed0 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_trap_defaultconf.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_trap_defaultconf.xml
@@ -50,10 +50,15 @@
           </script>
 
           <call function="'testSuite_Preamble'"/>
-
+          
+          <!--- Define default value for community -->          
+          <script>
+            timerDuration = '5m'
+          </script>
+          
           <!--- Test Case information
             #@TestMarker          SNMP trap with default configuration
-            #@TestName            snmp_trap_defaultconf: trap on stop-ds
+            #@TestName            trap_defaultconf: trap on stop-ds
             #@TestIssue           3241
             #@TestPurpose         Check that a trap is sent on OpenDS trap
                                   community after stop-ds command.
@@ -68,41 +73,83 @@
             #@TestPostamble       none
             #@TestResult          Success if SNMPTrapListener returns 0.
           -->
-          <testcase name="getTestCaseName
-          ('snmp_trap_defaultconf: trap on stop-ds')">
+          <testcase name="getTestCaseName('trap_defaultconf: trap on stop-ds')">
 
             <sequence>
-
-              <parallel>
+              
+              <timer duration="timerDuration">
                 <sequence>
-                  <message>
-                    'snmp_trap_defaultconf: run the trap listener'
-                  </message>
-
-                  <call function="'SNMPTrapListener'">
-                    {
-                    'location'          : STAF_REMOTE_HOSTNAME ,
-                    'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
-                    'snmpTrapPort'      : SNMP_TRAP_PORT ,
-                    'snmpTrapCommunity' : 'OpenDS' ,
-                    'snmpTrapNumber'    : '1,0,0,0,0,0'
-                    }
-                  </call>
+                  <parallel>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: run the trap listener'
+                      </message>
+                      
+                      <call function="'SNMPTrapListener'">
+                        {
+                        'location'          : STAF_REMOTE_HOSTNAME ,
+                        'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
+                        'snmpTrapPort'      : SNMP_TRAP_PORT ,
+                        'snmpTrapCommunity' : 'OpenDS' ,
+                        'snmpTrapNumber'    : '1,0,0,0,0,0'
+                        }
+                      </call>
+                    </sequence>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: wait event from the trap listener'
+                      </message>
+                      
+                      <call function="'WaitEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: delete event from the trap listener'
+                      </message>
+                      <call function="'DeleteEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: stop the server'
+                      </message>
+                      <call function="'StopDsWithScript'">
+                        { 'location' : STAF_REMOTE_HOSTNAME }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: send event to the trap listener'
+                      </message>
+                      
+                      <call function="'SendEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SendTrap/Complete'
+                        }
+                      </call>
+                    </sequence>
+                  </parallel>
                 </sequence>
+              </timer>
+              
+              <script>timerRC = RC</script>
+
+              <if expr="timerRC == 1">
                 <sequence>
+                  <tcstatus result="'fail'"></tcstatus>
+                  
                   <message>
-                    'snmp_trap_defaultconf: wait event from the trap listener'
+                    'trap_defaultconf: timeout occurred'
                   </message>
-
-                  <call function="'WaitEvent'">
-                    {
-                    'location' : STAF_REMOTE_HOSTNAME ,
-                    'name'     : 'SNMPTrapLister/Ready'
-                    }
-                  </call>
-
                   <message>
-                    'snmp_trap_defaultconf: delete event from the trap listener'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
                   <call function="'DeleteEvent'">
                     {
@@ -110,30 +157,22 @@
                     'name'     : 'SNMPTrapLister/Ready'
                     }
                   </call>
-
                   <message>
-                    'snmp_trap_defaultconf: stop the server'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
-                  <call function="'StopDsWithScript'">
-                    { 'location' : STAF_REMOTE_HOSTNAME }
-                  </call>
-
-                  <message>
-                    'snmp_trap_defaultconf: send event to the trap listener'
-                  </message>
-
-                  <call function="'SendEvent'">
+                  <call function="'DeleteEvent'">
                     {
                     'location' : STAF_REMOTE_HOSTNAME ,
                     'name'     : 'SendTrap/Complete'
                     }
                   </call>
                 </sequence>
-              </parallel>
-
-              <script>
-                knownIssue(3241)
-              </script>
+                <else>
+                  <script>
+                    knownIssue(3241)
+                  </script>
+                </else>
+              </if>
 
               <call function="'testCase_Postamble'"/>
 
@@ -143,7 +182,7 @@
 
           <!--- Test Case information
             #@TestMarker          SNMP trap with default configuration
-            #@TestName            snmp_trap_defaultconf: trap on start-ds
+            #@TestName            trap_defaultconf: trap on start-ds
             #@TestIssue           3241
             #@TestPurpose         Check that a trap is sent on OpenDS trap
                                   community after start-ds command.
@@ -159,39 +198,82 @@
             #@TestResult          Success if SNMPTrapListener returns 0.
           -->
           <testcase name="getTestCaseName
-          ('snmp_trap_defaultconf: trap on start-ds')">
+          ('trap_defaultconf: trap on start-ds')">
 
             <sequence>
-
-              <parallel>
+              
+              <timer duration="timerDuration">
                 <sequence>
-                  <message>
-                    'snmp_trap_defaultconf: run the trap listener'
-                  </message>
-
-                  <call function="'SNMPTrapListener'">
-                    {
-                    'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
-                    'snmpTrapPort'      : SNMP_TRAP_PORT ,
-                    'snmpTrapCommunity' : 'OpenDS' ,
-                    'snmpTrapNumber'    : '1,0,0,0,0,0'
-                    }
-                  </call>
+                  <parallel>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: run the trap listener'
+                      </message>
+                      
+                      <call function="'SNMPTrapListener'">
+                        {
+                        'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
+                        'snmpTrapPort'      : SNMP_TRAP_PORT ,
+                        'snmpTrapCommunity' : 'OpenDS' ,
+                        'snmpTrapNumber'    : '1,0,0,0,0,0'
+                        }
+                      </call>
+                    </sequence>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: wait event from the trap listener'
+                      </message>
+                      
+                      <call function="'WaitEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: delete event from the trap listener'
+                      </message>
+                      <call function="'DeleteEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: start the server'
+                      </message>
+                      <call function="'StartDsWithScript'">
+                        { 'location' : STAF_REMOTE_HOSTNAME }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: send event to the trap listener'
+                      </message>
+                      
+                      <call function="'SendEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SendTrap/Complete'
+                        }
+                      </call>
+                    </sequence>
+                  </parallel>
                 </sequence>
+              </timer>
+              
+              <script>timerRC = RC</script>
+
+              <if expr="timerRC == 1">
                 <sequence>
+                  <tcstatus result="'fail'"></tcstatus>
+                  
                   <message>
-                    'snmp_trap_defaultconf: wait event from the trap listener'
+                    'trap_defaultconf: timeout occurred'
                   </message>
-
-                  <call function="'WaitEvent'">
-                    {
-                    'location' : STAF_REMOTE_HOSTNAME ,
-                    'name'     : 'SNMPTrapLister/Ready'
-                    }
-                  </call>
-
                   <message>
-                    'snmp_trap_defaultconf: delete event from the trap listener'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
                   <call function="'DeleteEvent'">
                     {
@@ -199,30 +281,22 @@
                     'name'     : 'SNMPTrapLister/Ready'
                     }
                   </call>
-
                   <message>
-                    'snmp_trap_defaultconf: start the server'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
-                  <call function="'StartDsWithScript'">
-                    { 'location' : STAF_REMOTE_HOSTNAME }
-                  </call>
-
-                  <message>
-                    'snmp_trap_defaultconf: send event to the trap listener'
-                  </message>
-
-                  <call function="'SendEvent'">
+                  <call function="'DeleteEvent'">
                     {
                     'location' : STAF_REMOTE_HOSTNAME ,
                     'name'     : 'SendTrap/Complete'
                     }
                   </call>
                 </sequence>
-              </parallel>
-
-              <script>
-                knownIssue(3241)
-              </script>
+                <else>
+                  <script>
+                    knownIssue(3241)
+                  </script>
+                </else>
+              </if>
 
               <call function="'testCase_Postamble'"/>
 
@@ -232,7 +306,7 @@
 
           <!--- Test Case information
             #@TestMarker          SNMP trap with default configuration
-            #@TestName            snmp_trap_defaultconf: trap on stop-ds -R
+            #@TestName            trap_defaultconf: trap on stop-ds -R
             #@TestIssue           3241
             #@TestPurpose         Check that 2 traps are sent on OpenDS trap
                                   community after stop-ds -R command.
@@ -248,39 +322,85 @@
             #@TestResult          Success if SNMPTrapListener returns 0.
           -->
           <testcase name="getTestCaseName
-          ('snmp_trap_defaultconf: trap on stop-ds -R')">
+          ('trap_defaultconf: trap on stop-ds -R')">
 
             <sequence>
-
-              <parallel>
+              
+              <timer duration="timerDuration">
                 <sequence>
-                  <message>
-                    'snmp_trap_defaultconf: run the trap listener'
-                  </message>
-
-                  <call function="'SNMPTrapListener'">
-                    {
-                    'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
-                    'snmpTrapPort'      : SNMP_TRAP_PORT ,
-                    'snmpTrapCommunity' : 'OpenDS' ,
-                    'snmpTrapNumber'    : '2,0,0,0,0,0'
-                    }
-                  </call>
+                  <parallel>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: run the trap listener'
+                      </message>
+                      
+                      <call function="'SNMPTrapListener'">
+                        {
+                        'snmpHost'          : DIRECTORY_INSTANCE_HOST ,
+                        'snmpTrapPort'      : SNMP_TRAP_PORT ,
+                        'snmpTrapCommunity' : 'OpenDS' ,
+                        'snmpTrapNumber'    : '2,0,0,0,0,0'
+                        }
+                      </call>
+                    </sequence>
+                    <sequence>
+                      <message>
+                        'trap_defaultconf: wait event from the trap listener'
+                      </message>
+                      
+                      <call function="'WaitEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: delete event from the trap listener'
+                      </message>
+                      <call function="'DeleteEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SNMPTrapLister/Ready'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: restart the server'
+                      </message>
+                      <call function="'StopDsWithScript'">
+                        {
+                        'location'  : STAF_REMOTE_HOSTNAME ,
+                        'dsRestart' : 'True'
+                        }
+                      </call>
+                      
+                      <message>
+                        'trap_defaultconf: send event to the trap listener'
+                      </message>
+                      
+                      <call function="'SendEvent'">
+                        {
+                        'location' : STAF_REMOTE_HOSTNAME ,
+                        'name'     : 'SendTrap/Complete'
+                        }
+                      </call>
+                    </sequence>
+                  </parallel>
                 </sequence>
+              </timer>
+              
+              <script>timerRC = RC</script>
+
+              <if expr="timerRC == 1">
                 <sequence>
+                  <tcstatus result="'fail'"></tcstatus>
+                  
                   <message>
-                    'snmp_trap_defaultconf: wait event from the trap listener'
+                    'trap_defaultconf: timeout occurred'
                   </message>
-
-                  <call function="'WaitEvent'">
-                    {
-                    'location' : STAF_REMOTE_HOSTNAME ,
-                    'name'     : 'SNMPTrapLister/Ready'
-                    }
-                  </call>
-
                   <message>
-                    'snmp_trap_defaultconf: delete event from the trap listener'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
                   <call function="'DeleteEvent'">
                     {
@@ -288,33 +408,22 @@
                     'name'     : 'SNMPTrapLister/Ready'
                     }
                   </call>
-
                   <message>
-                    'snmp_trap_defaultconf: restart the server'
+                    'trap_defaultconf: delete event from the trap listener'
                   </message>
-                  <call function="'StopDsWithScript'">
-                    {
-                    'location'  : STAF_REMOTE_HOSTNAME ,
-                    'dsRestart' : 'True'
-                    }
-                  </call>
-
-                  <message>
-                    'snmp_trap_defaultconf: send event to the trap listener'
-                  </message>
-
-                  <call function="'SendEvent'">
+                  <call function="'DeleteEvent'">
                     {
                     'location' : STAF_REMOTE_HOSTNAME ,
                     'name'     : 'SendTrap/Complete'
                     }
                   </call>
                 </sequence>
-              </parallel>
-
-              <script>
-                knownIssue(3241)
-              </script>
+                <else>
+                  <script>
+                    knownIssue(3241)
+                  </script>
+                </else>
+              </if>
 
               <call function="'testCase_Postamble'"/>
 
diff --git a/opends/tests/shared/functions/snmp.xml b/opends/tests/shared/functions/snmp.xml
index 39f75f5..bb7000b 100755
--- a/opends/tests/shared/functions/snmp.xml
+++ b/opends/tests/shared/functions/snmp.xml
@@ -151,11 +151,16 @@
         
         STAFCmd='SNMPGet'
         
+        if is_windows_platform(location):
+          separator=';'
+        else:
+          separator=':'
+        
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
         cp = 'CLASSPATH=%s%s%s%s.' \
-        % (opends_jarfile,pathSeparator,jdmk_jarfile,pathSeparator)
+        % (opends_jarfile,separator,jdmk_jarfile,separator)
         
         env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
       </script>
@@ -308,11 +313,16 @@
         
         STAFCmd='SNMPSet'
         
+        if is_windows_platform(location):
+          separator=';'
+        else:
+          separator=':'
+          
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
         cp = 'CLASSPATH=%s%s%s%s.' \
-        % (opends_jarfile,pathSeparator,jdmk_jarfile,pathSeparator)
+        % (opends_jarfile,separator,jdmk_jarfile,separator)
         
         env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
       </script>
@@ -417,12 +427,17 @@
         STAFCmdParams=' '.join(STAFCmdParamsList)
         
         STAFCmd='SNMPTrapListener'
-
+        
+        if is_windows_platform(location):
+          separator=';'
+        else:
+          separator=':'
+          
         opends_jarfile='%s/%s' % (DIRECTORY_INSTANCE_DIR,SNMP_OPENDS_JARFILE)
         snmpPath='%s/%s/snmp' % (DIRECTORY_INSTANCE_DIR, relativeJavaDir)
         jdmk_jarfile='%s/jdmkrt.jar' % snmpPath
         cp = 'CLASSPATH=%s%s%s%s%s%s.' \
-        % (opends_jarfile,pathSeparator,jdmk_jarfile,pathSeparator,jstaf_jarfile,pathSeparator)
+        % (opends_jarfile,separator,jdmk_jarfile,separator,jstaf_jarfile,separator)
         
         env = ['JAVA_HOME=%s' % JAVA_HOME, '%s' % cp] 
       </script>
diff --git a/opends/tests/shared/functions/topology.xml b/opends/tests/shared/functions/topology.xml
index e92311d..d9c341a 100755
--- a/opends/tests/shared/functions/topology.xml
+++ b/opends/tests/shared/functions/topology.xml
@@ -387,13 +387,18 @@
                   </message>
                   <script>
                     opends_jarfile='%s/%s' % (TMPDIR,SNMP_OPENDS_JARFILE)
+                    
+                    if is_windows_platform(STAXServiceMachine):
+                      separator=';'
+                    else:
+                      separator=':'
                   </script>
                   <call function="'compileJava'" >
                     {
                     'location'   : STAXServiceMachine,
                     'foldername' : javaLocalDir,
                     'classpath'  : '%s%s%s%s%s' \
-                    % (opends_jarfile,pathSeparator,SNMP_OPENDMK_JARFILE,pathSeparator,jstaf_jarfile)
+                    % (opends_jarfile,separator,SNMP_OPENDMK_JARFILE,separator,jstaf_jarfile)
                     }
                   </call>
                   
diff --git a/opends/tests/shared/functions/utils.xml b/opends/tests/shared/functions/utils.xml
index a9ba108..94792a5 100755
--- a/opends/tests/shared/functions/utils.xml
+++ b/opends/tests/shared/functions/utils.xml
@@ -2025,8 +2025,13 @@
 
       <!-- Build the command -->
       <script>
+        if is_windows_platform(location):
+          separator=';'
+        else:
+          separator=':'
+        
         if classpath:
-          cp = 'CLASSPATH=%s%s.' % (classpath, pathSeparator)
+          cp = 'CLASSPATH=%s%s.' % (classpath, separator)
         else:
           cp = 'CLASSPATH=.'
         

--
Gitblit v1.10.0