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

al_xipe
24.24.2007 4ced2397e6a733f1fe69254134b6f6e626639e7a
1. allow to bypass proxy check in functional tests wrapper
2. add modify index test cases
3. add the rebuild-index CLI wrapper in utils.xml
4. add the ability in runFunction to set a test case status upon failure to reflect an exception being thrown or things like that
3 files modified
289 ■■■■ changed files
opends/tests/functional-tests/shared/functions/tools.xml 49 ●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/utils.xml 45 ●●●●● patch | view | raw | blame | history
opends/tests/functional-tests/testcases/indexes/indexes.xml 195 ●●●● patch | view | raw | blame | history
opends/tests/functional-tests/shared/functions/tools.xml
@@ -423,9 +423,48 @@
    
    
  <function name="CLI_rebuild-index">
    <function-prolog>
      This wraps the rebuild-index tool to make it easy to use from STAX
    </function-prolog>
    <function-map-args>
      <function-arg-def name="baseDN" type="required">
        <function-arg-description>
          Specify a back-end supporting indexing and triggers a rebuild of all
          indexes in the scope of the provided baseDN
        </function-arg-description>
      </function-arg-def>
      <function-arg-def name="attributes" type="required">
        <function-arg-description>
          Specify a list of attributes to trigger index rebuild on
        </function-arg-description>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <script>
        _cmd='%s/rebuild-index%s' % (dsBinPath,fileExt)
        _args=' -b %s -i %s' % ( baseDN, ' '.join(attributes) )
      </script>
      <message log="1" level="'info'">
        '%s %s' % (_cmd,_args)
      </message>
      <process name="'rebuild-index'">
        <location>'%s' % location</location>
        <command>'%s' % _cmd</command>
        <parms>'%s' % _args</parms>
        <workdir>'%s' % dsBinPath</workdir>
        <envs>
          ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
        </envs>
        <console use="'same'"/>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>
      <return>STAXResult</return>
    </sequence>
  </function>
</stax>
opends/tests/functional-tests/shared/functions/utils.xml
@@ -844,6 +844,33 @@
          True or False should be used for this argument.
        </function-arg-description>
      </function-arg-def>
      <function-arg-def name="functionFailureTC" type="optional">
        <function-arg-description>
          If this argument is provided, a testcase will be created with
          this argument's value for name and set to fail only upon failure
        </function-arg-description>
      </function-arg-def>
      <function-arg-def name="functionSignal" type="optional">
        <function-arg-description>
          If this argument is provided, a signal will be raised upon unsuccesful
          execution of the function to run
        </function-arg-description>
      </function-arg-def>
      <function-arg-def name="functionCallBack" type="optional">
        <function-arg-description>
          If this argument is provided then functionCallBack will be called
          after the execution of function name.
        </function-arg-description>
      </function-arg-def>
      <function-arg-def name="functionCallBackArguments" type="optional">
        <function-arg-description>
           This allows to specify arguments for the call back function
        </function-arg-description>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <script>
@@ -870,6 +897,10 @@
        _doSetTCStatus=False
        if functionSetsTCStatus:
          _doSetTCStatus=True
        _createFailureTC=False
        if functionFailureTC:
          _createFailureTC=True
      </script>
      <message log="1" level="'info'" if="_displayMessage == True">'%s' % functionMessage</message>
      <message log="1" level="'debug'">'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)</message>
@@ -906,6 +937,20 @@
        </if>
      </if>
      
      <!-- this section handles the optional case when we need to set a
           test case status to fail to reflect the failure in the test report.
      -->
      <if expr="_createFailureTC == True" >
        <if expr="_functionRC != expectedRC" >
          <testcase name="'!!! %s [%s]' % (functionFailureTC,functionName)">
            <tcstatus result="'fail'" />
          </testcase>
        </if>
      </if>
      <!-- TODO: implement the signal raising mechanism -->
      <!-- TODO: implement the call back function mechanism -->
      <!-- bubble the function return code up one level -->
      <return>_functionRC</return>
    </sequence>
opends/tests/functional-tests/testcases/indexes/indexes.xml
@@ -28,36 +28,169 @@
<stax>
  <defaultcall function="indexes" />
  <function name="indexes">
    <sequence>
      <script>
        CurrentTestPath={'group':'indexes','suite':'indexes'}
        envAlreadyLoaded='true'
      </script>
      <try>
        <iterate in="['testGroup_Preamble','testSuite_Preamble','indexes_setup','indexes_search']" var="testStep">
          <call function="testStep" />
        </iterate>
        <catch exception="'STAXException.Topology.CreationException'">
          <message log="1" level="'fatal'">'Could not create the topology. Bailing out.'</message>
        </catch>
        <catch exception="'STAXException.Topology.StartException'">
          <message log="1" level="'fatal'">'Could not start at least one server in the topology. Bailing out.'</message>
        </catch>
        <finally>
          <iterate in="['indexes_cleanup','testSuite_Postamble','testGroup_Postamble']" var="testStep">
            <call function="'%s' % testStep" />
          </iterate>
        </finally>
      </try>
    </sequence>
    <block name="'indexes'">
      <sequence>
        <script>
          CurrentTestPath={'group':'indexes','suite':'indexes'}
          envAlreadyLoaded='true'
          _setupSteps=['testGroup_Preamble','testSuite_Preamble','indexes_setup']
          _testSteps=['indexes_search','indexes_modify']
        </script>
        <!---
          #@TestSuiteName      Indexes
          #@TestSuitePurpose   test the database index feature from ldap
          #@TestSuiteGroup     indexes
          #@TestScript         indexes.xml
        -->
        <try>
          <!-- the pre-requisites are in a separate ite -->
          <sequence>
            <iterate in="_setupSteps" var="_setupStep">
              <call function="_setupStep" />
            </iterate>
            <iterate in="_testSteps" var="_testStep" indexvar="_testStepNumber">
              <call function="_testStep" />
            </iterate>
          </sequence>
          <catch exception="'STAXException.Topology.CreationException'">
            <message log="1" level="'fatal'">'Could not create the topology. Bailing out.'</message>
          </catch>
          <catch exception="'STAXException.Topology.StartException'">
            <message log="1" level="'fatal'">'Could not start at least one server in the topology. Bailing out.'</message>
          </catch>
          <finally>
            <iterate in="['indexes_cleanup','testSuite_Postamble','testGroup_Postamble']" var="_cleanupStep">
              <call function="'%s' % _cleanupStep" />
            </iterate>
          </finally>
        </try>
      </sequence>
    </block>
  </function>
  
  <function name="indexes_search" >
    <sequence>
      <message log="1" level="'info'">
        'starting the search tests'
      </message>
  <function name="indexes_search" scope="local">
    <!---
      This set of tests loop through a set of search filters to verify that
      the default indexes behave as expected
      #@TestMarker                indexes
      #@TestName                  indexes_search
      #@TestIssue                 TODO: look up the issue in issue tracker
      #@TestPurpose               harden the default indexes
      #@TestPreamble              none
      #@TestStep                  iterate through file search.filters
      #@TestPostamble             none
      #@TestResult                Success if entry are indexed correctly
    -->
    <block name="'indexes_search'">
      <sequence>
        <message log="1" level="'info'">
          'starting the search tests'
        </message>
        <call function="'loopThroughFilters'">
          { 'filters' : 'search' }
        </call>
      </sequence>
    </block>
  </function>
  <function name="indexes_modify" scope="local">
    <!--
      This test alters the uid default index so that it does subString search
      and then verifies that it worked
      #@TestMarker                indexes
      #@TestName                  indexes_search
      #@TestIssue                 TODO: look up the issue in issue tracker
      #@TestPurpose               harden the default indexes
      #@TestPreamble              none
      #@TestStep                  iterate through file search.filters
      #@TestPostamble             none
      #@TestResult                Success if entry are indexed correctly
    -->
    <block name="'indexes_modify'">
      <sequence>
        <try>
          <sequence>
            <call function="'loopThroughFilters'">
              { 'filters' : 'before-modify' }
            </call>
            <call function="'runFunction'">
              { 'functionName'      : 'modifyAnAttribute',
                'functionException' : 'LDAP.ModifyException',
                'functionFailureTC' : 'Indexes - Modify' ,
                'functionMessage'   : 'Adding substring index to attribute uid'       ,
                'functionArguments' : { 'dsInstanceHost'    : DIRECTORY_INSTANCE_HOST ,
                                      'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                                      'dsInstanceDn'      : DIRECTORY_INSTANCE_DN   ,
                                      'dsInstancePswd'    : DIRECTORY_INSTANCE_PSWD ,
                                      'DNToModify'        : 'ds-cfg-index-attribute=uid,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config' ,
                                      'attributeName'     : 'ds-cfg-index-type'     ,
                                      'newAttributeValue' : 'substring'             ,
                                      'changetype'        : 'add'                   }
              }
            </call>
            <call function="'runFunction'">
              { 'functionName'      : 'StopDsWithScript'               ,
                'functionException' : 'CLI.stop-ds'                    ,
                'functionFailureTC' : 'Indexes - Modify' ,
                'functionArguments' : { 'location'  : STAF_LOCAL_HOSTNAME   ,
                                        'dsHost'    : DIRECTORY_INSTANCE_HOST,
                                        'dsPort'    : DIRECTORY_INSTANCE_PORT,
                                        'dsBindDN'  : DIRECTORY_INSTANCE_DN  ,
                                        'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
              }
            </call>
            <call function="'runFunction'">
              { 'functionName'      : 'CLI_rebuild-index' ,
                'functionException' : 'CLI.RebuildIndex'  ,
                'functionFailureTC' : 'Indexes - Modify'  ,
                'functionArguments' : { 'baseDN'     : DIRECTORY_INSTANCE_SFX ,
                                        'attributes' : [ 'uid' ]              }
              }
            </call>
            <call function="'runFunction'">
              { 'functionName'      : 'StartDsWithScript',
                'functionException' : 'CLI.start-ds'     ,
                'functionFailureTC' : 'Indexes - Modify' ,
                'functionArguments' : { 'location' : STAF_LOCAL_HOSTNAME }
              }
            </call>
            <call function="'loopThroughFilters'">
              { 'filters' : 'after-modify' }
            </call>
          </sequence>
          <catch exception="'STAXException.LDAP.ModifyException'">
            <message log="1" level="'fatal'">'Fatal Error: Failed to alter index for attribute uid'</message>
          </catch>
          <catch exception="'STAXException.CLI.RebuildIndex'">
            <message log="1" level="'fatal'">'Fatal Error: Failed to rebuild index for attribute uid'</message>
          </catch>
        </try>
      </sequence>
    </block>
  </function>
  <!--
  <function name="indexes_add" scope="local">
  </function>
  <function name="indexes_rebuild" scope="local">
  </function>
  <function name="indexes_delete" scope="local">
  </function>
  <function name="indexes_verify" scope="local">
  </function>
  -->
  <function name="loopThroughFilters" scope="local">
    <function-map-args>
      <function-arg-def name="filters" type="required" />
    </function-map-args>
    <sequence>
      <script>
        class indexTest:
          "Describes an index test with indexed attribute, filter to test with and expected behaviour"
@@ -103,7 +236,7 @@
            
        indexTests = []
        
        f = open('%s/testcases/indexes/search.filters' % TESTS_DIR,'r')
        f = open('%s/testcases/indexes/%s.filters' % (TESTS_DIR,filters),'r')
        for line in f.readlines():
          if line.startswith('#'):
            continue
@@ -111,20 +244,20 @@
            testLine = line.split(' ')
            indexTests.append(indexTest(testLine[0], testLine[1], testLine[2], testLine[3], testLine[4]))
          
        iteration=0
        indexTestNumber=0
        previousTestName=''
        testNumber=0
      </script>
      <iterate var="test" in="indexTests">
        <sequence>
          <script>
          iteration=iteration+1
          indexTestNumber=indexTestNumber+1
          if previousTestName != test.getName():
            previousTestName=test.getName()
            testNumber=0
            
          </script>
          <testcase name="'Indexes: 1.Search: %03d-%03d.%s: %s%02d' % ( len(indexTests)-iteration, iteration, test.getAttribute(), test.getName(), testNumber)" >
          <testcase name="'Indexes: %d.%s: %03d-%03d.%s: %s%02d' % ( len(_testSteps)-_testStepNumber, filters, len(indexTests)-indexTestNumber, indexTestNumber, test.getAttribute(), test.getName(), testNumber)" >
            <sequence>
              <call function="'testCase_Preamble'" />
              <message log="1" level="'trace'">