mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

mkeyes
22.43.2007 64950e9504e67ffe28d9cb9bcc9444cac6ac39ef
Four lib task functions are modified to only check whether a task is done if the task was successfully scheduled.

Two new task functions are added for server shutdown and restart tasks.

These modifications are being added in preparation for the commit of the Privileges test suites.
1 files modified
309 ■■■■ changed files
opendj-sdk/opends/tests/functional-tests/shared/functions/dsadm.xml 309 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/shared/functions/dsadm.xml
@@ -1310,14 +1310,18 @@
      </call>
      
      <!-- Check that the ldap task is completed -->
      <call function="'CheckLdapTask'">
        { 'location'   : myLocation,
          'dsTaskDn'   : taskDN,
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd }
      </call>
      <if expr="STAFCmdRC == 0">
        <sequence>
          <call function="'CheckLdapTask'">
            { 'location'   : myLocation,
              'dsTaskDn'   : taskDN,
              'dsHost'     : dsInstanceHost,
              'dsPort'     : dsInstancePort,
              'dsBindDn'   : dsInstanceDn,
              'dsBindPswd' : dsInstancePswd }
          </call>
        </sequence>
      </if>
      
    </sequence>
    
@@ -1781,15 +1785,18 @@
      </call>
      
      <!-- Check that the task is completed -->
      <call function="'CheckLdapTask'">
        { 'location'   : myLocation,
          'dsTaskDn'   : taskDN,
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd }
      </call>
      <if expr="STAFCmdRC == 0">
        <sequence>
            <call function="'CheckLdapTask'">
            { 'location'   : myLocation,
              'dsTaskDn'   : taskDN,
              'dsHost'     : dsInstanceHost,
              'dsPort'     : dsInstancePort,
              'dsBindDn'   : dsInstanceDn,
              'dsBindPswd' : dsInstancePswd }
           </call>
        </sequence>
      </if>
    </sequence>
  </function>
  
@@ -2032,15 +2039,18 @@
      </call>
 
      <!-- Check that the ldap task is completed -->
      <call function="'CheckLdapTask'">
        { 'location'   : myLocation,
          'dsTaskDn'   : taskDN,
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd }
      </call>
      <if expr="STAFCmdRC == 0">
        <sequence>
            <call function="'CheckLdapTask'">
            { 'location'   : myLocation,
              'dsTaskDn'   : taskDN,
              'dsHost'     : dsInstanceHost,
              'dsPort'     : dsInstancePort,
              'dsBindDn'   : dsInstanceDn,
              'dsBindPswd' : dsInstancePswd }
            </call>
        </sequence>
      </if>
    </sequence>
    
  </function>
@@ -2235,19 +2245,248 @@
      </call>
 
      <!-- Check that the ldap task is completed -->
      <call function="'CheckLdapTask'">
        { 'location'   : myLocation,
          'dsTaskDn'   : taskDN,
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd }
      </call>
      <if expr="STAFCmdRC == 0">
        <sequence>
            <call function="'CheckLdapTask'">
            { 'location'   : myLocation,
              'dsTaskDn'   : taskDN,
              'dsHost'     : dsInstanceHost,
              'dsPort'     : dsInstancePort,
              'dsBindDn'   : dsInstanceDn,
              'dsBindPswd' : dsInstancePswd }
            </call>
         </sequence>
      </if>
    </sequence>
    
  </function>
 
  <!-- Shutdown Task Function -->
  <function name="shutdownTask">
    <function-prolog>
      This function performs an on line export task for shutdown of the directory
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="pathname"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional">
        <function-arg-description>
          Directory server host name
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePort" type="optional">
        <function-arg-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="optional">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="dn"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="optional">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="taskID" type="optional">
        <function-arg-description>
          The identifier for the task
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        myLocation=location
        taskLdifFile='shutdown-task.ldif'
        taskLdif='%s/../%s/%s' % (dsPath,relativeDataDir,taskLdifFile)
        tmpTaskLdif='%s/%s' % (logsTempDir,taskLdifFile)
        taskDN='ds-task-id=%s,cn=Scheduled Tasks,cn=Tasks' % taskID
      </script>
      <!-- Build the shutdown task configuration object -->
      <script>
        ldifLines=[]
        ldifLines.append('dn: %s' % taskDN)
        ldifLines.append('objectclass: top')
        ldifLines.append('objectclass: ds-task')
        ldifLines.append('objectclass: ds-task-shutdown')
        ldifLines.append('ds-task-class-name: org.opends.server.tasks.ShutdownTask')
        ldifLines.append('ds-task-id: %s' % taskID)
      </script>
      <!-- Write out the shutdown-task ldif -->
      <script>
        outfile = open(tmpTaskLdif,"w")
        for line in ldifLines:
          outfile.write("%s\n" % line)
        outfile.close()
      </script>
      <!-- Copy the shutdown-task ldif to remote host -->
      <message>'Copy shutdown task ldif (%s) to %s' % (tmpTaskLdif,taskLdif)</message>
      <call function="'copyFile'">
        { 'location'   : STAXServiceMachine,
          'srcfile'    : tmpTaskLdif,
          'destfile'   : taskLdif,
          'remotehost' : myLocation }
      </call>
      <!-- Start the task using ldap task interface -->
      <call function="'StartLdapTask'">
        { 'location'   : myLocation,
          'taskLabel'  : 'Online Export Task',
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd,
          'dsTaskLdif' : taskLdif }
      </call>
      <return>STAFCmdRC</return>
    </sequence>
  </function>
  <!-- Restart Task Function -->
  <function name="restartTask">
    <function-prolog>
      This function performs an on line export task for restart of the directory
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
        <function-arg-description>
          Location of target host
        </function-arg-description>
        <function-arg-property name="type" value="hostname"/>
      </function-arg-def>
      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
        <function-arg-description>
          Pathname to installation root
        </function-arg-description>
        <function-arg-property name="type" value="pathname"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceHost" type="optional">
        <function-arg-description>
          Directory server host name
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePort" type="optional">
        <function-arg-description>
          Directory server port number
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
      <function-arg-def name="dsInstanceDn" type="optional">
        <function-arg-description>
          Bind DN
        </function-arg-description>
        <function-arg-property name="type" value="dn"/>
      </function-arg-def>
      <function-arg-def name="dsInstancePswd" type="optional">
        <function-arg-description>
          Bind password
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="taskID" type="optional">
        <function-arg-description>
          The identifier for the task
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Local variables -->
      <script>
        myLocation=location
        taskLdifFile='restart-task.ldif'
        taskLdif='%s/../%s/%s' % (dsPath,relativeDataDir,taskLdifFile)
        tmpTaskLdif='%s/%s' % (logsTempDir,taskLdifFile)
        taskDN='ds-task-id=%s,cn=Scheduled Tasks,cn=Tasks' % taskID
      </script>
      <!-- Build the restart task configuration object -->
      <script>
        ldifLines=[]
        ldifLines.append('dn: %s' % taskDN)
        ldifLines.append('objectclass: top')
        ldifLines.append('objectclass: ds-task')
        ldifLines.append('objectclass: ds-task-shutdown')
        ldifLines.append('ds-task-class-name: org.opends.server.tasks.ShutdownTask')
        ldifLines.append('ds-task-restart-server: true')
        ldifLines.append('ds-task-id: %s' % taskID)
      </script>
      <!-- Write out the restart-task ldif -->
      <script>
        outfile = open(tmpTaskLdif,"w")
        for line in ldifLines:
          outfile.write("%s\n" % line)
        outfile.close()
      </script>
      <!-- Copy the restart-task ldif to remote host -->
      <message>'Copy restart task ldif (%s) to %s' % (tmpTaskLdif,taskLdif)</message>
      <call function="'copyFile'">
        { 'location'   : STAXServiceMachine,
          'srcfile'    : tmpTaskLdif,
          'destfile'   : taskLdif,
          'remotehost' : myLocation }
      </call>
      <!-- Start the task using ldap task interface -->
      <call function="'StartLdapTask'">
        { 'location'   : myLocation,
          'taskLabel'  : 'Online Export Task',
          'dsHost'     : dsInstanceHost,
          'dsPort'     : dsInstancePort,
          'dsBindDn'   : dsInstanceDn,
          'dsBindPswd' : dsInstancePswd,
          'dsTaskLdif' : taskLdif }
      </call>
      <!--- Check that DS started -->
      <if expr="STAFCmdRC == 0">
        <sequence>
          <call function="'isAlive'">
            { 'noOfLoops'        : 5 ,
              'noOfMilliSeconds' : 2000 }
          </call>
        </sequence>
      </if>
      <return>STAFCmdRC</return>
    </sequence>
  </function>
  <!-- Add Schema Task Function --> 
  <function name="addSchemaTask">