From f9118f488ab38c05b4a3738a10e00720d96f7600 Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Tue, 27 Aug 2013 15:06:42 +0000
Subject: [PATCH] Added retries on manage-tasks tool to avoid random test failure

---
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/import-ldif.xml |  181 +++++++-----
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml   |  335 +++++++++++++++--------
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/restore_db.xml  |  108 ++++---
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/export-ldif.xml |  185 ++++++++-----
 4 files changed, 496 insertions(+), 313 deletions(-)

diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
index 9dbf4a5..d748297 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
@@ -102,69 +102,113 @@
                 'backupID'            : 'recurring-backup-1',
                 'backEnd'             : DIRECTORY_INSTANCE_BE}
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-backup-1',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+      
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'recurring-backup-1',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+              
               <call function="'Sleep'">
                 { 'sleepForMilliSeconds'  :  120000 }
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-backup-1',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Completed successfully',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'recurring-backup-1',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+                  
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Completed successfully',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+                  
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <!-- cancel the recurring task recurring-backup-1 with manage-tasks -->
               <call function="'manage-tasks'">
                 { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -179,11 +223,10 @@
               <script>
                 returnString = STAXResult[0][1]
               </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Task recurring-backup-1 canceled',
-                'expectedResult'	   : '1' }
+
+              <call function="'searchString'">
+                { 'expectedString' : 'Task recurring-backup-1 canceled',
+                  'returnString'   : returnString }
               </call>
   
               <call function="'testCase_Postamble'"/>
@@ -224,7 +267,8 @@
               <script>checkRC=9999</script>
               <loop from="1" to="10" var="loop" while="checkRC != 0">
                 <sequence>
-                  <message>'LOOP %s' % loop</message>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
                   <!-- manage-tasks -->
                   <call function="'manage-tasks'">
                     { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -308,7 +352,8 @@
               <script>checkRC=9999</script>
               <loop from="1" to="10" var="loop" while="checkRC != 0">
                 <sequence>
-                  <message>'LOOP %s' % loop</message>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
                   <!-- manage-tasks -->
                   <call function="'manage-tasks'">
                     { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -418,7 +463,7 @@
             -->
   
   
-  <testcase name="getTestCaseName('schedule recurring backup task with the same name as previously')">
+          <testcase name="getTestCaseName('schedule recurring backup task with the same name as previously')">
             <sequence>
               <call function="'testCase_Preamble'"/>
   
@@ -456,12 +501,12 @@
                 returnString = STAXResult[0][1]
               </script>
   
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-backup-1',
-                'expectedResult'	   : '0' }
+              <call function="'searchString'">
+                { 'expectedString' : 'recurring-backup-1',
+                  'returnString'   : returnString ,
+                  'expectedRC'     : 1 }
               </call>
-  
+                  
               <call function="'backup'">
                 { 'location'          : STAF_REMOTE_HOSTNAME ,
                 'dsInstanceHost'      : DIRECTORY_INSTANCE_HOST,
@@ -474,62 +519,102 @@
                 'backEnd'             : DIRECTORY_INSTANCE_BE}
               </call>
   
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
   
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-backup-1',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+      
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'recurring-backup-1',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+              
               <call function="'Sleep'">
                 { 'sleepForMilliSeconds'  :  120000 }
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-backup-1',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Completed successfully',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+      
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'recurring-backup-1',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Completed successfully',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <call function="'StopDsWithScript'">
                 { 'location'  : STAF_REMOTE_HOSTNAME,
                 'dsHost'      : DIRECTORY_INSTANCE_HOST,
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/export-ldif.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/export-ldif.xml
index 34c0d64..3dab9b8 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/export-ldif.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/export-ldif.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2009 Sun Microsystems, Inc.
- !      Portions Copyright 2011 ForgeRock AS.
+ !      Portions Copyright 2011-2013 ForgeRock AS.
 ! -->
 <stax>
   <defaultcall function="export-ldif"/>
@@ -86,7 +86,8 @@
               <script>checkRC=9999</script>
               <loop from="1" to="10" var="loop" while="checkRC != 0">
                 <sequence>
-                  <message>'LOOP %s' % loop</message>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
                   <!-- manage-tasks -->
                   <call function="'manage-tasks'">
                     {'location'      : STAF_REMOTE_HOSTNAME,
@@ -171,7 +172,8 @@
               <script>checkRC=9999</script>
               <loop from="1" to="10" var="loop" while="checkRC != 0">
                 <sequence>
-                  <message>'LOOP %s' % loop</message>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
                   <!-- manage-tasks -->
                   <call function="'manage-tasks'">
                     { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -316,69 +318,113 @@
                 'schedulePattern'     : '"0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * *"',
                 'backEnd'             : DIRECTORY_INSTANCE_BE}
               </call>
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
   
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'ExportTask-',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'ExportTask-',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <call function="'Sleep'">
                 { 'sleepForMilliSeconds'  :  120000 }
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'ExportTask-*',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Completed successfully',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+              
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'ExportTask-*',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Completed successfully',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+              
               <!-- cancel the recurring task ExportTask-* with manage-tasks -->
               <call function="'manage-tasks'">
                 { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -394,18 +440,11 @@
                 returnString = STAXResult[0][1]
               </script>
   
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Task ExportTask-',
-                'expectedResult'	   : '1' }
+              <call function="'searchString'">
+                { 'expectedString' : 'Task ExportTask-\* canceled',
+                  'returnString'   : returnString }
               </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'canceled',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
               <call function="'testCase_Postamble'"/>
             </sequence>
           </testcase>
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/import-ldif.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/import-ldif.xml
index 4b1619c..7ffd549 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/import-ldif.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/import-ldif.xml
@@ -263,69 +263,113 @@
                 'schedulePattern'     : '"0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * *"',
                 'backEnd'             : DIRECTORY_INSTANCE_BE}
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'ImportTask-',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'ImportTask-',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <call function="'Sleep'">
                 { 'sleepForMilliSeconds'  :  120000 }
               </call>
-  
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'ImportTask-*',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Completed successfully',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'ImportTask-*',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Completed successfully',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <!-- cancel the recurring task ExportTask-* with manage-tasks -->
               <call function="'manage-tasks'">
                 { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -336,23 +380,16 @@
                 'dsQuiet'        : ' '
                 }
               </call>
-  
+
               <script>
                 returnString = STAXResult[0][1]
               </script>
   
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Task ImportTask-',
-                'expectedResult'	   : '1' }
+              <call function="'searchString'">
+                { 'expectedString' : 'Task ImportTask-\* canceled',
+                  'returnString'   : returnString }
               </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'canceled',
-                'expectedResult'	   : '1' }
-              </call>
-  
+
               <call function="'testCase_Postamble'"/>
             </sequence>
           </testcase>
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/restore_db.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/restore_db.xml
index 164d499..8074e80 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/restore_db.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/restore_db.xml
@@ -147,7 +147,7 @@
               <script>checkRC=9999</script>
               <loop from="1" to="10" var="loop" while="checkRC != 0">
                 <sequence>
-                  <message>'LOOP %s' % loop</message>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
                   <!-- manage-tasks -->
                   <call function="'manage-tasks'">
                     { 'location'       : STAF_REMOTE_HOSTNAME ,
@@ -297,48 +297,71 @@
                 returnString = STAXResult[0][1]
               </script>
   
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-restore-1',
-                'expectedResult'	   : '1' }
+              <call function="'searchString'">
+                { 'expectedString' : 'recurring-restore-1',
+                  'returnString'   : returnString }
               </call>
-  
+                  
               <call function="'Sleep'">
                 { 'sleepForMilliSeconds'  :  120000 }
               </call>
   
-              <!-- manage-tasks -->
-              <call function="'manage-tasks'">
-                { 'location'     : STAF_REMOTE_HOSTNAME ,
-                'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
-                'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
-                'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
-                'dsQuiet'        : ' '
-                }
-              </call>
-  
-              <script>
-                returnString = STAXResult[0][1]
-              </script>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'recurring-restore-1',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Completed successfully',
-                'expectedResult'	   : '1' }
-              </call>
-  
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Waiting on start time',
-                'expectedResult'	   : '1' }
-              </call>
-  
+              <script>checkRC=9999</script>
+              <loop from="1" to="10" var="loop" while="checkRC != 0">
+                <sequence>
+                  <message>'MANAGE-TASKS LOOP %s' % loop</message>
+                  
+                  <!-- manage-tasks -->
+                  <call function="'manage-tasks'">
+                    { 'location'     : STAF_REMOTE_HOSTNAME ,
+                    'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
+                    'dsInstanceDn'   : DIRECTORY_INSTANCE_DN,
+                    'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
+                    'dsQuiet'        : ' '
+                    }
+                  </call>
+
+                  <script>
+                    returnString = STAXResult[0][1]
+                  </script>
+      
+                  <call function="'searchString'">
+                    { 'expectedString' : 'recurring-restore-1',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = STAXResult[0]
+                  </script>
+                  
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Completed successfully',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+                  
+                  <call function="'searchString'">
+                    { 'expectedString' : 'Waiting on start time',
+                      'returnString'   : returnString ,
+                      'expectedRC'     : 'noCheck' }
+                  </call>
+
+                  <script>
+                    checkRC = checkRC + STAXResult[0]
+                  </script>
+
+                  <call function="'Sleep'">
+                    { 'sleepForMilliSeconds'  : 2000 }
+                  </call>
+
+                </sequence>
+              </loop>
+
               <!-- cancel the recurring task recurring-restore-1 with manage-tasks -->
               <call function="'manage-tasks'">
                 { 'location'     : STAF_REMOTE_HOSTNAME ,
@@ -354,12 +377,11 @@
                 returnString = STAXResult[0][1]
               </script>
   
-              <call function="'searchStringForSubstring'">
-                { 'returnString'	   : returnString,
-                'testString'	   : 'Task recurring-restore-1 canceled',
-                'expectedResult'	   : '1' }
+              <call function="'searchString'">
+                { 'expectedString' : 'Task recurring-restore-1 canceled',
+                  'returnString'   : returnString }
               </call>
-  
+              
               <call function="'testCase_Postamble'"/>
             </sequence>
           </testcase>

--
Gitblit v1.10.0