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

Christophe Sovant
04.57.2013 9d93abef5957aab5fda51c296d54b8c0ea44c1d5
CR-1789 Added mode to run tests from upgraded instance
3 files modified
212 ■■■■■ changed files
opends/tests/staf-tests/shared/functions/dsadm.xml 74 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/topology.xml 135 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/tests/config.py.stubs 3 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/dsadm.xml
@@ -52,6 +52,80 @@
  </function>
  <!-- This function upgrades DS using the upgrade script -->
  <function name="UpgradeDsWithScript" scope="local">
    <function-prolog>
      This function upgrades DS using the upgrade script
    </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_BIN,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="dsHelp" type="optional">
        <function-arg-description>
          Help option
        </function-arg-description>
        <function-arg-property name="help" 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-def>
      <function-arg-def name="knownIssue" type="optional" default="None">
        <function-arg-description>
          Known issue. Corresponds to an issue number.
        </function-arg-description>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <!-- Build the Command -->
      <script>
        STAFCmdParamsList=[]
        STAFCmdParams=''
        if dsPath:
          STAFCmd='%s/upgrade%s' % (dsPath,fileExt)
          STAFCmdParamsList.append('-n')
        if dsHelp:
          STAFCmdParamsList.append('-H')
        STAFCmdParams=' '.join(STAFCmdParamsList)
      </script>
      <message>
        '%s %s' % (STAFCmd, STAFCmdParams)
      </message>
      <call function="'runCommand'">
        { 'location'  : location,
          'name'      : 'Upgrade DS Script',
          'command'   : STAFCmd,
          'arguments' : STAFCmdParams,
          'path'      : dsPath,
          'expectedRC': expectedRC,
          'knownIssue': knownIssue
        }
      </call>
    </sequence>
  </function>
  <!-- This function sets up DS using the setup script -->
  <function name="SetUpDsWithScript" scope="local">
    <function-prolog>
opends/tests/staf-tests/shared/functions/topology.xml
@@ -434,16 +434,105 @@
        </else>
      </if>
      <!--- Install DS Extract zip file -->
      <message>
        'Extract DS zip archive to %s on %s' % (dsDir,dsHost)
      </message>
      <call function="'unZipFile'">
        { 'location' : dsHost,
          'zipfile'  : '%s/%s' % (dsDir,ZIPNAME),
          'unzipdir' : dsDir
        }
      </call>
      <if expr="UPGRADE_ZIPNAME == ''">
        <sequence>
          <!-- *********** -->
          <!-- NORMAL MODE -->
          <!-- *********** -->
          <!--- Install DS Extract zip file -->
          <message>
            'Extract DS zip archive to %s on %s' % (dsDir,dsHost)
          </message>
          <call function="'unZipFile'">
            { 'location' : dsHost,
              'zipfile'  : '%s/%s' % (dsDir,ZIPNAME),
              'unzipdir' : dsDir
            }
          </call>
        </sequence>
        <else>
          <sequence>
            <!-- ************ -->
            <!-- UPGRADE MODE -->
            <!-- ************ -->
            <!--- Install old DS Extract zip file -->
            <message>
              'Extract old DS zip archive to %s on %s' % (local.temp,STAXServiceMachine)
            </message>
            <call function="'unZipFile'">
              { 'location' : STAXServiceMachine,
                'zipfile'  : '%s/%s' % (UPGRADE_ZIPPATH,UPGRADE_ZIPNAME),
                'unzipdir' : local.temp
              }
            </call>
            <!-- Rename folder for the old version, for instanceOpenDJ-2.4.5 -> opendj -->
            <message>
              'Rename old DS zip folder from %s/%s to %s/%s' % (local.temp,UPGRADE_OPENDJNAME,local.temp,OPENDSNAME)
            </message>
            <script>
              import os
              srcDir = os.path.join(local.temp, UPGRADE_OPENDJNAME)
              destDir = os.path.join(local.temp, OPENDSNAME)
              os.rename(srcDir, destDir)
            </script>
            <!-- Re-create a new archive for the old DS -->
            <message>
              'Re-create old DS archive %s/%s from %s/%s' % (local.temp,UPGRADE_ZIPNAME,local.temp,OPENDSNAME)
            </message>
            <call function="'zipUpFile'">
              { 'location'   : STAXServiceMachine,
                'zipfile'    : '%s/%s' % (local.temp,UPGRADE_ZIPNAME),
                'folder'     : '%s/%s' % (local.temp,OPENDSNAME),
                'relativeto' : local.temp
              }
            </call>
            <!-- Check if old DS Copy zip exists -->
            <call function="'GetEntry'">
              {
                'location'  : dsHost,
                'entry'     : '%s/%s' % (dsDir,UPGRADE_ZIPNAME),
                'attribute' : 'TYPE'
              }
            </call>
            <if expr="RC == 48">
              <sequence>
                <!--- Copy old DS Copy zip file -->
                <message>
                  'Copy old DS zip archive %s/%s to %s' % (local.temp,UPGRADE_ZIPNAME,dsHost)
                </message>
                <call function="'copyFile'">
                  { 'srcfile'    : '%s/%s' % (local.temp,UPGRADE_ZIPNAME),
                    'destfile'   : '%s/%s' % (dsDir,UPGRADE_ZIPNAME),
                    'remotehost' : dsHost
                  }
                </call>
              </sequence>
              <else>
                <message>
                  'Old DS zip archive %s/%s already exists, nothing to do' % (dsDir,UPGRADE_ZIPNAME)
                </message>
              </else>
            </if>
            <!--- Install DS Extract zip file -->
            <message>
              'Extract old DS zip archive to %s on %s' % (dsDir,dsHost)
            </message>
            <call function="'unZipFile'">
              { 'location' : dsHost,
                'zipfile'  : '%s/%s' % (dsDir,UPGRADE_ZIPNAME),
                'unzipdir' : dsDir
              }
            </call>
          </sequence>
        </else>
      </if>
      
      <!-- fixMe: Windows Services are not enabled -->
      <if expr="is_windows_platform(dsHost)">
@@ -501,6 +590,32 @@
          </message>
        </else>
      </if>
      <!-- ******* -->
      <!-- UPGRADE -->
      <!-- ******* -->
      <if expr="UPGRADE_ZIPNAME != ''">
        <sequence>
          <!-- Copy content of new version into old version -->
          <!-- Install DS Extract zip file -->
          <message>
            'Extract DS zip archive to %s on %s' % (dsDir,dsHost)
          </message>
          <call function="'unZipFile'">
            { 'location' : dsHost,
              'zipfile'  : '%s/%s' % (dsDir,ZIPNAME),
              'unzipdir' : dsDir
            }
          </call>
          <!--  Upgrade instance -->
          <call function="'UpgradeDsWithScript'">
            { 'location'   : dsHost,
              'dsPath'     : '%s/%s' % (dsDir, OPENDSNAME),
            }
          </call>
        </sequence>
      </if>
    </sequence> 
  </function>
  
opends/tests/staf-tests/shared/tests/config.py.stubs
@@ -34,6 +34,9 @@
OPENDSNAME                    = 'opendj'
ZIPNAME                       = '${opends.name}.zip'
ZIPPATH                       = '${opends.dir}'
UPGRADE_OPENDJNAME            = '${upgrade.opendj.name}'
UPGRADE_ZIPNAME               = '${upgrade.opendj.name}.zip'
UPGRADE_ZIPPATH               = '${upgrade.opendj.dir}'
TESTS_TIMESTAMP               = '${tests.timestamp}'
TESTS_TYPE                    = '${tests.type}'
TESTS_ROOT                    = '${basedir}'