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

Christophe Sovant
12.03.2008 480cca4b07191e953b25d424ce818426c42d5ca7
Add verifiy-index and rebuild-index testsuites
2 files added
2 files modified
1191 ■■■■■ changed files
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu.xml 2 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml 578 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_verify-index_checkbehavior.xml 399 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/shared/functions/tools.xml 212 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu.xml
@@ -60,6 +60,8 @@
            testList.append(['.','clu_status_checkbehavior'])
            testList.append(['.','clu_ldappasswordmodify_checkbehavior'])
            testList.append(['.','clu_ldifsearch_checkbehavior'])
            testList.append(['.','clu_verify-index_checkbehavior'])
            testList.append(['.','clu_rebuild-index_checkbehavior'])
            testList.append(['.','clu_cleanup'])
          </script>
          
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml
New file
@@ -0,0 +1,578 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../../shared/stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, exclude this CDDL HEADER in each
 ! file and exclude the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2008 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="clu_rebuild-index_checkbehavior"/>
  <function name="clu_rebuild-index_checkbehavior">
    <sequence>
      <block name="'clu_rebuild-index_checkbehavior'">
        <sequence>
          <!--- Test Suite information
            #@TestSuiteName       rebuild-index check behavior tests
            #@TestSuitePurpose    Test the results of rebuild-index command.
            #@TestSuiteGroup      rebuild-index check behavior tests
            #@TestScript          clu_rebuild-index_checkbehavior.xml
          -->
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group'] = 'clu'
            CurrentTestPath['suite'] = STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Case information
            #@TestMarker          rebuild-index check behavior tests
            #@TestName            rebuild-index: check on a single index
            #@TestIssue           none
            #@TestPurpose         Verify that rebuild-index command failed if
                                  the server is started and successful otherwise
                                  and that the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a rebuild-index on a single index.
            #@TestStep            Check the output of the command.
            #@TestStep            Create a new index using dsconfig for the
                                  other testcases.
            #@TestStep            Stop the server.
            #@TestStep            Do a rebuild-index on a single index.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 1 when the
                                  server is running, 0 when the server is
                                  stopped and the outputs are correct.
          -->
          <testcase name="getTestCaseName('rebuild-index: single index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'rebuild-index: try to rebuild a single index while the server \
                is running'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'uid' ] ,
                'expectedRC'   : 1
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'An error occurred while attempting to acquire a'
                msg2 = 'exclusive lock for backend userRoot'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <message>
                'rebuild-index: create a new index for the other testcases'
              </message>
              <call function="'dsconfig'">
                {
                'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
                'subcommand'       : 'create-local-db-index' ,
                'objectType'       : 'backend-name' ,
                'objectName'       : 'userRoot' ,
                'optionsString'    : '--index-name st --set index-type:equality'
                }
              </call>
              <message>
                'rebuild-index: stop the server'
              </message>
              <call function="'StopDsWithScript'">
                { 'location' : STAF_REMOTE_HOSTNAME }
              </call>
              <message>
                'rebuild-index: rebuild a single index with the server stopped'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'uid' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Rebuild of index\(es\) uid started with 1048'
                msg2 = 'total records to process'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Rebuild complete. Processed 1048 records'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          rebuild-index check behavior tests
            #@TestName            rebuild-index: check without index option
            #@TestIssue           none
            #@TestPurpose         Verify that rebuild-index command failed
                                  and that the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a rebuild-index without index option.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 1 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('rebuild-index: without index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'rebuild-index: without index'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'expectedRC'   : 1
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'At least one index must be specified'
                msg2 = 'for the rebuild process'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          rebuild-index check behavior tests
            #@TestName            rebuild-index: check on multiple indexes
            #@TestIssue           none
            #@TestPurpose         Verify that rebuild-index command is
                                  successful and that the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a rebuild-index on multiple indexes.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 0 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('rebuild-index: multiple indexes')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'rebuild-index: multiple indexes'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'uid', 'cn' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Rebuild of index\(es\) uid, cn started'
                msg2 = 'with 2096 total records to process'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Rebuild complete. Processed 2096 records'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          rebuild-index check behavior tests
            #@TestName            rebuild-index: check on a non existing index
            #@TestIssue           none
            #@TestPurpose         Verify that rebuild-index command failed
                                  and that the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a rebuild-index on a non existing index.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 1 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('rebuild-index: non existing index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'rebuild-index: non existing index'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'myindex' ] ,
                'expectedRC'    : 1
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'There is no index configured for'
                msg2 = 'attribute type \'myindex\''
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          rebuild-index check behavior tests
            #@TestName            rebuild-index: after creation
            #@TestIssue           none
            #@TestPurpose         Verify that rebuild-index command is
                                  successfull on a newly created index
                                  and that the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verifiy-index before rebuild on
                                  the new index.
            #@TestStep            Check the output of the command.
            #@TestStep            Do a rebuild-index on the new index.
            #@TestStep            Check the output of the command.
            #@TestStep            Do a verify-index after rebuild on
                                  the new index.
            #@TestStep            Check the output of the command.
            #@TestStep            Do again a rebuild-index on the new index.
            #@TestStep            Check the output of the command.
            #@TestStep            Re-start the server.
            #@TestPostamble       none
            #@TestResult          Success if all the commands return 0 and
                                  the outputs are correct.
          -->
          <testcase name="getTestCaseName
          ('rebuild-index: rebuild index after creation')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'rebuild-index: verify index st before rebuild'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'st' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Due to changes in the configuration, index'
                msg2 = 'dc_com_st.equality is currently operating in a'
                msg3 = 'degraded state and must be rebuilt before it can used'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s %s' % (msg1, msg2, msg3)
                }
              </call>
              <script>
                msg1 = 'Statistics for records that have'
                msg2 = 'exceeded the entry limit:'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <script>
                msg1 = 'File dc_com_st.equality has 51 such record\(s\)'
                msg2 = 'min=14 max=31 median=20'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <message>
                'rebuild-index: rebuild index st'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'st' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Due to changes in the configuration, index'
                msg2 = 'dc_com_st.equality is currently operating in a'
                msg3 = 'degraded state and must be rebuilt before it can used'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s %s' % (msg1, msg2, msg3)
                }
              </call>
              <script>
                msg1 = 'Rebuild of index\(es\) st started with 1048'
                msg2 = 'total records to process'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <script>
                msg = 'Rebuild complete. Processed 1048 records'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <message>
                'rebuild-index: verify index st after rebuild'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'st' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Due to changes in the configuration, index'
                msg2 = 'dc_com_st.equality is currently operating in a'
                msg3 = 'degraded state and must be rebuilt before it can used'
              </script>
              <call function="'checktestStringNotPresent'">
                {
                'returnString' : returnString ,
                'testString'   : '%s %s %s' % (msg1, msg2, msg3)
                }
              </call>
              <script>
                msg = 'Checked 1048 entries and found 0 error'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <message>
                'rebuild-index: rebuild again index st'
              </message>
              <call function="'rebuildIndexWithScript'">
                {
                'dsBaseDN'     : 'dc=com' ,
                'dsIndexList'  : [ 'st' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'Due to changes in the configuration, index'
                msg2 = 'dc_com_st.equality is currently operating in a'
                msg3 = 'degraded state and must be rebuilt before it can used'
              </script>
              <call function="'checktestStringNotPresent'">
                {
                'returnString' : returnString ,
                'testString'   : '%s %s %s' % (msg1, msg2, msg3)
                }
              </call>
              <script>
                msg1 = 'Rebuild of index\(es\) st started with 1048'
                msg2 = 'total records to process'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <script>
                msg = 'Rebuild complete. Processed 1048 records'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <message>
                'rebuild-index: start the server'
              </message>
              <call function="'StartDsWithScript'">
                { 'location' : STAF_REMOTE_HOSTNAME }
              </call>
              <!--- Check that DS started -->
              <call function="'isAlive'">
                {
                'noOfLoops'        : 5 ,
                'noOfMilliSeconds' : 2000
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_verify-index_checkbehavior.xml
New file
@@ -0,0 +1,399 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../../shared/stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, exclude this CDDL HEADER in each
 ! file and exclude the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2008 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="clu_verify-index_checkbehavior"/>
  <function name="clu_verify-index_checkbehavior">
    <sequence>
      <block name="'clu_verify-index_checkbehavior'">
        <sequence>
          <!--- Test Suite information
            #@TestSuiteName       verify-index check behavior tests
            #@TestSuitePurpose    Test the results of verify-index command.
            #@TestSuiteGroup      verify-index check behavior tests
            #@TestScript          clu_verify-index_checkbehavior.xml
          -->
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group'] = 'clu'
            CurrentTestPath['suite'] = STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: check on a single index
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command is successful
                                  and the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index on a single index.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 0 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('verify-index: single index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: single index'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'       : 'dc=com' ,
                'dsIndexList'    : [ 'uid' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Checked 1048 entries and found 0 error'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: check without index option
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command is successful
                                  and the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index without index option.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 0 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('verify-index: without index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: without index'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'       : 'dc=com'
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Checked 1048 entries and found 0 error'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: check on multiple indexes
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command is successful
                                  and the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index on multiple indexes.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 0 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('verify-index: multiple indexes')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: multiple indexes'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'       : 'dc=com' ,
                'dsIndexList'    : [ 'uid', 'cn' ]
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Checked 1048 entries and found 0 error'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: check with clean option
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command is successful
                                  and the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index with clean option..
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 0 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('verify-index: clean option')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: clean option'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'      : 'dc=com' ,
                'dsIndexList'   : [ 'uid' ] ,
                'dsClean'       : 'True'
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : 'Checked 1000 records and found 0 error'
                }
              </call>
              <script>
                msg = 'Number of records referencing more than one entry: 10'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <script>
                msg = 'Number of records that exceed the entry limit: 0'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <script>
                msg = 'Average number of entries referenced is 1.04/record'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <script>
                msg = 'Maximum number of entries referenced by any record is 5'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: multiple indexes, clean option
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command failed and
                                  the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index on multiple indexes with
                                  clean option.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 1 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName
          ('verify-index: clean option and multiple indexes')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: clean option and multiple indexes'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'      : 'dc=com' ,
                'dsIndexList'   : [ 'uid', 'cn' ] ,
                'dsClean'       : 'True' ,
                'expectedRC'    : 1
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg = 'Only one index at a time may be verified for cleanliness'
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : msg
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
            #@TestMarker          verify-index check behavior tests
            #@TestName            verify-index: check with a non existing index
            #@TestIssue           none
            #@TestPurpose         Verify that verify-index command failed and
                                  the output is correct.
            #@TestPreamble        none
            #@TestStep            Do a verify-index on a non existing index.
            #@TestStep            Check the output of the command.
            #@TestPostamble       none
            #@TestResult          Success if verify-index returns 1 and the
                                  output is correct.
          -->
          <testcase name="getTestCaseName('verify-index: non existing index')">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                'verify-index: non existing index'
              </message>
              <call function="'verifyIndexWithScript'">
                {
                'dsBaseDN'      : 'dc=com' ,
                'dsIndexList'   : [ 'myindex' ] ,
                'expectedRC'    : 1
                }
              </call>
              <script>
                returnString = STAXResult[0][1]
              </script>
              <script>
                msg1 = 'There is no index configured for'
                msg2 = 'attribute type \'myindex\''
              </script>
              <call function="'checktestString'">
                {
                'returnString'   : returnString ,
                'expectedString' : '%s %s' % (msg1, msg2)
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/shared/functions/tools.xml
@@ -978,7 +978,7 @@
  </function>
  
  <!-- This function perform a search operation in a LDIF file -->
  <function name="ldifSearchWithScript">
  <function name="ldifSearchWithScript" scope="local">
    <function-prolog>
      This function perform a search operation in a LDIF file
    </function-prolog>
@@ -1150,4 +1150,214 @@
      <return>STAXResult</return>
    </sequence>
  </function>
  <!-- This function execute the rebuild-index tool -->
  <function name="rebuildIndexWithScript" scope="local">
    <function-prolog>
      This function execute the rebuild-index tool
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location"
                        type="optional"
                        default="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="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsBaseDN" type="required">
        <function-arg-description>
          Specify a back-end supporting indexing and triggers a verification
          of all indexes in the scope of the provided baseDN
        </function-arg-description>
        <function-arg-property name="type" value="dn"/>
      </function-arg-def>
      <function-arg-def name="dsIndexList" type="optional">
        <function-arg-description>
          Specify a list of indexes
          This should be passed as a python array like
          [ 'uid','telephonenumber' ]
        </function-arg-description>
        <function-arg-property name="type" value="array"/>
      </function-arg-def>
      <function-arg-def name="dsHelp" type="optional">
        <function-arg-description>
          Display this usage information
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="dsVersion" type="optional">
        <function-arg-description>
          Display Directory Server version information
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
        <function-arg-description>
          Expected return code value. Default value is 0.
          Wildcard 'noCheck' to not check the RC
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Build the Command -->
      <script>
        STAFCmdParamsList=[]
        STAFCmdParams=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/rebuild-index%s' % (dsBinPath,fileExt)
        if dsBaseDN:
          STAFCmdParamsList.append('-b "%s"' % dsBaseDN)
        if dsIndexList:
          STAFCmdParamsList.append('-i %s' % (' -i '.join(dsIndexList)))
        if dsHelp:
          STAFCmdParamsList.append('-H')
        if dsVersion:
          STAFCmdParamsList.append('-V')
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <call function="'runCommand'">
        {
        'name'       : 'Rebuild index script',
        'command'    : STAFCmd,
        'arguments'  : STAFCmdParams,
        'location'   : location,
        'expectedRC' : expectedRC
        }
      </call>
      <return>STAXResult</return>
    </sequence>
  </function>
  <!-- This function execute the verify-index tool -->
  <function name="verifyIndexWithScript" scope="local">
    <function-prolog>
      This function execute the verify-index tool
    </function-prolog>
    <function-map-args>
      <function-arg-def name="location"
                        type="optional"
                        default="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="filepath"/>
      </function-arg-def>
      <function-arg-def name="dsBaseDN" type="required">
        <function-arg-description>
          Specify a back-end supporting indexing and triggers a verification
          of all indexes in the scope of the provided baseDN
        </function-arg-description>
        <function-arg-property name="type" value="dn"/>
      </function-arg-def>
      <function-arg-def name="dsIndexList" type="optional">
        <function-arg-description>
          Specify a list of indexes
          This should be passed as a python array like
          [ 'uid','telephonenumber' ]
        </function-arg-description>
        <function-arg-property name="type" value="array"/>
      </function-arg-def>
      <function-arg-def name="dsClean" type="optional">
        <function-arg-description>
          Verify that an index is clean
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="dsCountErrors" type="optional">
        <function-arg-description>
          Count the number of errors found during the verification
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="dsHelp" type="optional">
        <function-arg-description>
          Display this usage information
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="dsVersion" type="optional">
        <function-arg-description>
          Display Directory Server version information
        </function-arg-description>
        <function-arg-property name="type" value="option"/>
      </function-arg-def>
      <function-arg-def name="expectedRC" type="optional" default="0">
        <function-arg-description>
          Expected return code value. Default value is 0.
          Wildcard 'noCheck' to not check the RC
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Build the Command -->
      <script>
        STAFCmdParamsList=[]
        STAFCmdParams=''
        if dsPath:
          dsBinPath='%s/%s' % (dsPath,fileFolder)
          STAFCmd='%s/verify-index%s' % (dsBinPath,fileExt)
        if dsBaseDN:
          STAFCmdParamsList.append('-b "%s"' % dsBaseDN)
        if dsIndexList:
          STAFCmdParamsList.append('-i %s' % (' -i '.join(dsIndexList)))
        if dsClean:
          STAFCmdParamsList.append('-c')
        if dsCountErrors:
          STAFCmdParamsList.append('--countErrors ')
        if dsHelp:
          STAFCmdParamsList.append('-H')
        if dsVersion:
          STAFCmdParamsList.append('-V')
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <call function="'runCommand'">
        {
        'name'      : 'Verify index script',
        'command'    : STAFCmd,
        'arguments'  : STAFCmdParams,
        'location'   : location,
        'expectedRC' : expectedRC
        }
      </call>
      <return>STAXResult</return>
    </sequence>
  </function>
</stax>