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

al_xipe
13.37.2006 f9a2fa9a3bfdee01e9273f51fd20ec25006bb7b6
finalize the move to ant for the integration tests
2 files modified
489 ■■■■■ changed files
opends/tests/integration-tests-testng/build.sh 263 ●●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/build.xml 226 ●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/build.sh
@@ -25,261 +25,26 @@
#
#      Portions Copyright 2006 Sun Microsystems, Inc.
OLD_DIR=`pwd`
[ -z "${DEBUG}" ] || set -x
die() {
    rc=$1
    shift
    echo $@
    exit $rc
}
# Change to the location of this build script.
cd `dirname $0`
# save the path to the functional tests in a variable
ft_home=`pwd`
# save the path to directory server in a variable
cd ../..
ds_home=`pwd`
# change to the functional test directory
cd ${ft_home}
# check for java
if [ -z "${JAVA_HOME}" ]; then
    JAVA_HOME=`java -cp ${ds_home}/resource FindJavaHome`
    if [ -z "${JAVA_HOME}" ]; then
        die 10 "Please set JAVA_HOME to the root of a Java 5.0 installation."
    else
        export JAVA_HOME
    fi
else
# See if JAVA_HOME is set.  If not, then see if there is a java executable in
# the path and try to figure it out.
if test -z "${JAVA_HOME}"
then
  JAVA_HOME=`java -cp ../../resource FindJavaHome`
  if test -z "${JAVA_HOME}"
  then
    echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
    exit 1
  else
    export JAVA_HOME
  fi
fi
# Make sure that the TestNG JAR file is in the CLASSPATH so that ant will be
# able to find it.
testng_jar=${ds_home}/tests/integration-tests-testng/ext/testng/lib/testng-5.0.2-jdk15.jar
if [ -f "${testng_jar}" ]; then
    CLASSPATH="${ds_home}/tests/integration-tests-testng/ext/testng/lib/testng-5.0.2-jdk15.jar"
    export CLASSPATH
else
    die 11 "Could not find junit library in ${ds_home}/ext/testng/lib"
fi
ANT_HOME=${ds_home}/ext/ant
if [ -d "${ANT_HOME}" ]; then
    export ANT_HOME
else
    die 12 "Could not find ant in ${ANT_HOME}"
fi
# check if the product is built
# Let's wait on this for now.
if [ ! -d "${ds_home}/build" ]; then
    # Do you want to build directory server ?
    # maybe the question should be asked interactively, I don't know
    echo "Could not find the openDS bits, starting a build of openDS now"
    cd ${ds_home}
    ./build.sh package
    cd ${ft_home}
fi
# generate the testcase from the template
hostname=`uname -n`
template_home="${ft_home}/src/server/org/opends/server/"
integration_home="${template_home}/integration"
testcase_file="DirectoryServerAcceptanceTestCase.java"
template_file="${testcase_file}.template"
#cat ${template_home}/${template_file}|sed "s|<hostname>|${hostname}|"|sed "s|<integration_home>|$integration_home|" >  ${template_home}/${testcase_file}
echo "Starting the build for the integration test suites"
ANT_HOME=`cd ../..;pwd`/ext/ant
export ANT_HOME
# Execute the ant script and pass it any additional command-line arguments.
${ANT_HOME}/bin/ant --noconfig ${*}
if [ $? -eq 0 ]; then
    echo "Successfully built the integration test suite"
    echo " "
    echo "There are two options for running the integration test suites."
    echo " "
    echo "Option 1 - You must have OpenDS freshly installed and started."
    echo "You must also set the variables in ${ft_home}/ext/testng/testng.xml"
    echo "For option 1, execute"
    echo "${ft_home}/test.sh [OpenDS home directory]"
    echo " "
    echo "Option 2 (recommended) - Let the test.sh script install and start OpenDS."
    echo "The file, ${ft_home}/ext/testng/testng.xml,"
    echo "will also be automatically generated."
    echo "For option 2, execute"
    echo "${ft_home}/test.sh installOpenDS [OpenDS installation directory] [port number]"
    echo " "
    cat > ${ft_home}/test.sh <<EOF
#!/bin/sh
if [ \$# != 1 -a \$# != 3 ]
then
echo "If you already have an OpenDS installed and started,"
echo "usage: ${ft_home}/test.sh [OpenDS home]"
echo " "
echo "If you wish the test.sh script to install OpenDS, start OpenDS, generate a TestNG xml file, and start the integration tests,"
echo "usage: ${ft_home}/test.sh installOpenDS [OpenDS install directory] [port number]"
exit
fi
[ -z "\${DEBUG}" ] || set -x
if [ \$# = 1 ]
then
OPENDS_HOME=\${1}
cd \${OPENDS_HOME}
echo "OpenDS Integration Tests have started........."
CLASSPATH="${ds_home}/tests/integration-tests-testng/ext/testng/lib/testng-5.0.2-jdk15.jar:${ds_home}/build/integration-tests:\${OPENDS_HOME}/lib/OpenDS.jar:\${OPENDS_HOME}/lib/je.jar"
java -ea -cp \${CLASSPATH} org.testng.TestNG -d /tmp/testng -listener org.opends.server.OpenDSTestListener ${ft_home}/ext/testng/testng.xml
else
OPENDS_INSTALL_DIR=\${2}
OPENDS_PORT=\${3}
OPENDS_HOME=\${OPENDS_INSTALL_DIR}/OpenDS-0.1
HOSTNAME=\`hostname\`
INTEG_TEST_DIR=`pwd`
if [ -d \${OPENDS_INSTALL_DIR} ]
then
echo "Directory, \${OPENDS_INSTALL_DIR} currently exists"
else
echo "Directory, \${OPENDS_INSTALL_DIR} does not exist, creating it......"
mkdir -p \${OPENDS_INSTALL_DIR}
fi
if [ -d \${INTEG_TEST_DIR}/opends/logs ]
then
echo "Directory, \${INTEG_TEST_DIR}/opends/logs currently exists"
else
echo "Directory, \${INTEG_TEST_DIR}/opends/logs does not exist, creating it......"
mkdir -p \${INTEG_TEST_DIR}/opends/logs
fi
if [ -d \${INTEG_TEST_DIR}/opends/backup ]
then
echo "Directory, \${INTEG_TEST_DIR}/opends/backup currently exists"
else
echo "Directory, \${INTEG_TEST_DIR}/opends/backup does not exist, creating it......"
mkdir -p \${INTEG_TEST_DIR}/opends/backup
fi
if [ -d \${INTEG_TEST_DIR}/opends/reports ]
then
echo "Directory, \${INTEG_TEST_DIR}/opends/reports currently exists"
else
echo "Directory, \${INTEG_TEST_DIR}/opends/reports does not exist, creating it......"
mkdir -p \${INTEG_TEST_DIR}/opends/reports
fi
cp \${INTEG_TEST_DIR}/ext/testng/testng.xml \${INTEG_TEST_DIR}/ext/testng/testng.xml.save
cat > \${INTEG_TEST_DIR}/ext/testng/testng.xml <<EOF2
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="OpenDS"   verbose="1" >
    <parameter name="hostname" value="\${HOSTNAME}"/>
    <parameter name="port" value="\${OPENDS_PORT}"/>
    <parameter name="sport" value="636"/>
    <parameter name="bindDN" value="cn=Directory Manager"/>
    <parameter name="bindPW" value="password"/>
    <parameter name="integration_test_home" value="\${INTEG_TEST_DIR}/src/server/org/opends/server/integration"/>
    <parameter name="logDir" value="\${INTEG_TEST_DIR}/opends/logs"/>
    <parameter name="dsee_home" value="\${OPENDS_HOME}"/>
    <parameter name="backupDir" value="\${INTEG_TEST_DIR}/opends/backup"/>
    <parameter name="exportDir" value="\${INTEG_TEST_DIR}/opends"/>
    <packages>
        <package name="org.opends.server.integration.quickstart"/>
        <package name="org.opends.server.integration.bob"/>
        <package name="org.opends.server.integration.frontend"/>
        <package name="org.opends.server.integration.schema"/>
        <package name="org.opends.server.integration.core"/>
        <package name="org.opends.server.integration.security"/>
        <package name="org.opends.server.integration.backend"/>
    </packages>
    <test name="precommit">
        <groups>
            <run>
                <include name="precommit"/>
                <exclude name="broken"/>
            </run>
        </groups>
    </test>
    <test name="integration-tests">
          <groups>
          <define name="all">
                  <include name="quickstart"/>
                  <include name="bob"/>
                  <include name="frontend"/>
                  <include name="schema"/>
                  <include name="core"/>
                  <include name="security"/>
                  <include name="backend"/>
          </define>
          <define name="quickstart">
          <include name="quickstart"/>
          </define>
          <define name="bob">
          <include name="bob"/>
          </define>
          <define name="frontend">
          <include name="frontend"/>
          </define>
          <define name="schema">
          <include name="schema"/>
          </define>
          <define name="core">
          <include name="core"/>
          </define>
          <define name="security">
          <include name="security"/>
          </define>
          <define name="backend">
          <include name="backend"/>
          </define>
          <run>
          <include name="all"/>
              </run>
          </groups>
    </test>
</suite>
EOF2
cp ${ds_home}/build/package/OpenDS-0.1.zip \${OPENDS_INSTALL_DIR}
cd \${OPENDS_INSTALL_DIR}
unzip OpenDS-0.1.zip
echo "OpenDS has been installed in \${OPENDS_INSTALL_DIR}"
echo "Configuring OpenDS to use port \${OPENDS_PORT}"
\${OPENDS_HOME}/bin/configure-ds.sh -p \${OPENDS_PORT}
echo "Starting OpenDS and the OpenDS Integration Tests...."
\${OPENDS_HOME}/bin/start-ds.sh -nodetach&
sleep 30
echo "OpenDS Integration Tests have started........."
CLASSPATH="${ds_home}/tests/integration-tests-testng/ext/testng/lib/testng-5.0.2-jdk15.jar:${ds_home}/build/integration-tests:\${OPENDS_HOME}/lib/OpenDS.jar:\${OPENDS_HOME}/lib/je.jar"
java -ea -cp \${CLASSPATH} org.testng.TestNG -d /tmp/testng -listener org.opends.server.OpenDSTestListener ${ft_home}/ext/testng/testng.xml
echo "The output from OpenDS is in \${INTEG_TEST_DIR}/opends/logs"
fi
cd ${ds_home}/tests/integration-tests-testng
EOF
    chmod 755 ${ft_home}/test.sh
else
    die 14 "Error when running ant"
fi
$ANT_HOME/bin/ant --noconfig ${*}
opends/tests/integration-tests-testng/build.xml
@@ -25,62 +25,240 @@
 !      Portions Copyright 2006 Sun Microsystems, Inc.
 ! -->
<project name="Directory Server" basedir="." default="all">
<project name="opends-tests-integration" basedir="." default="all">
  <description>
    This is the build script for the functional tests for the 
    OpenDS Directory Server.  See the
    BUILDING file in this directory for build instructions.
  </description>
  <!-- General build-wide properties                                        -->
  <property name="opends.dir" location="../.."                               />
  <property name="tests.src.dir"       location="src/server"                 />
  <property name="tests.build.dir"
            location="${opends.dir}/build/integration-tests"                 />
  <property name="lib.dir"          location="${opends.dir}/lib"             />
  <property name="ext.dir"          location="${opends.dir}/ext"             />
  <property name="testng.dir"       location="${ext.dir}/testng"             />
  <property name="testng.lib.dir"   location="${testng.dir}/lib"             />
  <!-- General server-wide properties                                     -->
  <property name="opends.dir" location="../.."                          />
  <property name="src.dir"       location="src/server"                  />
  <property name="built.dir"
            location="${opends.dir}/build/integration-tests"            />
  <property name="ds.classes"    location="${opends.dir}/build/classes" />
  <property name="lib.dir"       location="${opends.dir}/lib"           />
  <property name="ext.dir"       location="${opends.dir}/ext"           />
  <property name="opends.build.dir"   location="${opends.dir}/build"         />
  <property name="opends.package.dir" location="${opends.build.dir}/package" />
  <property name="opends.classes"     location="${opends.build.dir}/classes" />
  <!-- default configuration values for opends -->
  <property name="install.dir.default" value="${basedir}/install"            />
  <property name="product.version"     value="0.1"                           />
  <property name="product.name"        value="OpenDS"                        />
  <!-- generate the timestamp we'll use to tag/store the test results       -->
  <tstamp>
    <format property="run.time" pattern="yyyy.mm.dd-HH.mm.ss"                />
  </tstamp>
  <!-- assertion to determine the operating system -->
  <condition property="isWindows">
    <os family="windows"/>
  </condition>
  <condition property="isUnix">
    <not>
      <os family="windows"/>
    </not>
  </condition>
  <!-- edit or create this file if you need custom port or install path
       it can have any of the following properties
       port.ldap
       install.dir
  -->
  <property file="integration-tests.properties"                              />
  <!-- The build target that should be used to build everything. -->
  <target name="all"
       depends="clean,functests"
       depends="uninstall,clean,tests,install,configure,start,run-tests,stop"
       description="Build using all defined targets." />
  <!-- Remove all dynamically-generated build files. -->
  <target name="clean"
       description="Clean up any files generated during the build process">
    <delete dir="${built.dir}"           />
    <delete dir="${tests.build.dir}"           />
  </target>
  <!-- Compile the functional tests source files. -->
  <target name="tests"
       description="Compile the functional tests source files.">
    <mkdir dir="${tests.build.dir}" />
  <!-- Compile the Directory Server source files. -->
  <target name="functests"
       description="Compile the functional test source files.">
    <mkdir dir="${built.dir}" />
    <javac srcdir="${src.dir}" destdir="${built.dir}" optimize="true"
    <javac srcdir="${tests.src.dir}" destdir="${tests.build.dir}" optimize="true"
         debug="on" debuglevel="lines,source" source="1.5" target="1.5"
         deprecation="true" fork="true" >
      <compilerarg value="-Xlint:all" />
      <classpath>
        <!-- libraries required to build -->
        <fileset dir="${lib.dir}">
          <include name="*.jar" />
        </fileset>
        <fileset dir="${ext.dir}">
        <!-- include the testng library to build the test cases -->
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
        <pathelement location="${ds.classes}" />
        <pathelement location="${opends.classes}" />
      </classpath>
    </javac>
  </target>
  <target name="run-tests"
          description="run the integration test suite"
          depends="set-default-install-props">
    <taskdef resource="testngtasks">
      <classpath>
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </taskdef>
    <property name="run.dir" value="${basedir}/run/${run.time}" />
    <mkdir dir="${run.dir}"         />
    <mkdir dir="${run.dir}/logs"    />
    <mkdir dir="${run.dir}/backup"  />
    <mkdir dir="${run.dir}/report"  />
    <echo message="generating tests xml file ..."/>
    <copy file="testng.xml.stubs"
          tofile="testng.xml"
          overwrite="true"           >
      <filterchain>
        <expandproperties/>
      </filterchain>
    </copy>
    <fileset id="testng.xml" dir="${basedir}" >
      <include name="testng.xml"  />
    </fileset>
    <testng outputdir="${run.dir}/report"
            haltonfailure="true"
            enableAssert="false"
            listener="org.opends.server.OpenDSTestListener"
            dumpCommand="true">
      <classpath>
        <!-- where to get the testng library -->
        <fileset dir="${testng.lib.dir}">
          <include name="*.jar" />
        </fileset>
        <!-- where to get the test classes -->
        <pathelement location="${tests.build.dir}" />
        <!-- where to get the server classes -->
        <pathelement  location="${opends.classes}"/>
      </classpath>
      <!-- where to get the test suite definition -->
      <xmlfileset dir="${basedir}" includes="testng.xml"/>
    </testng>
  </target>
  <target name="set-default-install-props"
          description="defines the default values if no custom values were provided">
    <property name="install.dir" value="${install.dir.default}"              />
    <property name="port.ldap"   value="1389"                                />
    <property name="port.ssl"    value="1636"                                />
    <property name="host.name"   value="localhost"                           />
    <property name="bindDN"      value="cn=Directory Manager"                />
    <property name="password"    value="password"                            />
    <property name="full.install.dir"
            value="${install.dir}/${product.name}-${product.version}"        />
  </target>
  <target name="install"
          description="deploy the server bits"
          depends="set-default-install-props"  >
    <property name="config.file"
              location="${full.install.dir}/config/config.ldif"/>
    <!-- Set the defaults
         Does not override the custom values provided in the
         integration-tests.properties file if any                           -->
    <mkdir dir="${install.dir}"/>
    <unzip dest="${install.dir}">
      <fileset dir="${opends.package.dir}">
        <include name="*.zip"/>
      </fileset>
    </unzip>
  </target>
  <target name="configure"
          description="configures opends to listen on the right port number"
          depends="set-default-install-props"
          >
    <java classname="org.opends.server.tools.ConfigureDS">
      <!-- building the classpath to run the configurator -->
      <classpath>
        <pathelement path="${full.install.dir}/classes"/>
        <fileset dir="${full.install.dir}">
          <include name="lib/*.jar"/>
        </fileset>
      </classpath>
      <!-- provide the arguments here -->
      <arg value="--configClass" />
      <arg value="org.opends.server.config.ConfigFileHandler"  />
      <arg value="--configFile" />
      <arg value="${full.install.dir}/config/config.ldif"       />
      <arg line="-p ${port.ldap}" />
    </java>
  </target>
  <!-- Windows specific start / stop / configure commands -->
  <target name="start-windows" if="isWindows">
    <echo message="Starting in the background ..."/>
    <exec
      executable="${full.install.dir}\bin\start-ds.bat"
      spawn="true"                                                           />
  </target>
  <target name="stop-windows"  if="isWindows" >
    <echo message="Stopping ..." />
    <exec
      executable="${full.install.dir}\bin\stop-ds.bat">
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${password}"/>
      <arg value="-D"/>
      <arg value="${bindDN}"/>
    </exec>
  </target>
  <!-- Unix specific start / stop / configure commands -->
  <target name="start-unix" if="isUnix" >
    <echo message="Starting in the background ..."/>
    <exec
      executable="${full.install.dir}/bin/start-ds.sh"
      spawn="true"                                                           />
  </target>
  <target name="stop-unix" if="isUnix" >
    <echo message="Stopping ..." />
    <exec
      executable="${full.install.dir}/bin/stop-ds.sh" >
      <arg line="-h ${host.name}"/>
      <arg line="-p ${port.ldap}"/>
      <arg line="-w ${password}"/>
      <arg value="-D"/>
      <arg value="${bindDN}"/>
    </exec>
  </target>
  <!-- platform independent start / stop targets -->
  <target name="start"
          description="stop the server"
          depends="set-default-install-props,start-windows,start-unix" />
  <target name="stop"
          description="stop the server"
          depends="set-default-install-props,stop-windows,stop-unix" />
  <target name="uninstall"
          description="Uninstalls the server"
          depends="set-default-install-props" >
    <delete dir="${install.dir}" />
  </target>
</project>