<!--
|
! 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, include this CDDL HEADER in each
|
! file and include 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
|
!
|
!
|
! Copyright 2008-2009 Sun Microsystems, Inc.
|
! -->
|
<project name="tests">
|
|
<description>
|
Execute the tests.
|
</description>
|
|
<target name="run">
|
<tstamp>
|
<format property="tests.run.time" pattern="yyyy.MM.dd-HH.mm.ss"/>
|
</tstamp>
|
|
<!-- clean up tmp dir -->
|
<if>
|
<equals arg1="${tests.mode}" arg2="local"/>
|
<then>
|
<delete dir="${tests.tmp.dir}"/>
|
<mkdir dir="${tests.tmp.dir}"/>
|
</then>
|
</if>
|
|
<!-- make all the necessary directories for this test run -->
|
<mkdir dir="${tests.run.dir}/${tests.run.time}"/>
|
<mkdir dir="${tests.run.dir}/${tests.run.time}/config"/>
|
<!-- these will serve for after-the-fact archiving the logs -->
|
<mkdir dir="${tests.run.dir}/${tests.run.time}/staf-logs"/>
|
<mkdir dir="${tests.run.dir}/${tests.run.time}/coverage"/>
|
|
<if>
|
<equals arg1="${test.plan.custom}" arg2=""/>
|
<then>
|
<var name="test.plan.custom" value="${test.plan.default}"/>
|
</then>
|
</if>
|
|
<!-- generate the config file that will be used for this run -->
|
<copy file="${tests.config.stubs}"
|
tofile="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}">
|
<filterchain>
|
<expandproperties/>
|
</filterchain>
|
</copy>
|
|
<!-- generate the topology files that will be used for this run -->
|
<copy todir="${tests.run.dir}/${tests.run.time}/config">
|
<fileset dir="${tests.topology.dir}">
|
<include name="**/*.txt"/>
|
</fileset>
|
<filterchain>
|
<expandproperties/>
|
</filterchain>
|
</copy>
|
|
<!-- this is a windows-specific measure to replace the windows file
|
separator by a forward slash. Staf otherwise fails to find the files. -->
|
<replace file="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}" token="\" value="/"/>
|
|
<property name="tests.request" value="EXECUTE FILE ${tests.xml} JOBNAME OpenDS_${tests.type} SCRIPTFILE ${tests.run.dir}/${tests.run.time}/config/${tests.config.file} WAIT CLEARLOGS"/>
|
|
<echo>While the tests are running you may tail the job logs at</echo>
|
<echo>${staf.install.dir}/logs/MACHINE/${host.name}</echo>
|
<echo>Running tests. This will take more than a while.</echo>
|
<property name="CLASSPATH" value="${staf.lib.dir}/JSTAF.jar${path.separator}${e.CLASSPATH}"/>
|
<exec
|
dir="${staf.bin.dir}"
|
executable="${staf.executable}"
|
>
|
<arg line="LOCAL STAX ${tests.request}"/>
|
<env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}${e.CLASSPATH}"/>
|
<env key="LD_LIBRARY_PATH" value="${staf.lib.dir}"/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
|
<env key="STAFCODEPAGE" value="LATIN_1"/>
|
</exec>
|
|
<symlink link="${tests.run.dir}/latest" resource="${tests.run.time}" overwrite="true"/>
|
<echo>Report is available at</echo>
|
<echo>${tests.run.dir}/latest</echo>
|
</target>
|
|
<target name="configure">
|
<echo>* Tests configuration</echo>
|
|
<input message=" Run the tests on the local machine or on a remote machine?"
|
defaultvalue="local"
|
validargs="local,remote"
|
addproperty="tests.mode.input"/>
|
|
<input message=" Enter local hostname:"
|
defaultvalue="${local.hostname}"
|
addproperty="local.hostname.input"/>
|
|
<if>
|
<equals arg1="${tests.mode.input}" arg2="remote"/>
|
<then>
|
<input message=" Enter remote hostname:"
|
defaultvalue=""
|
addproperty="remote.hostname.input"/>
|
|
<!-- Tests-defined values -->
|
<if>
|
<available file="${basedir}/tests-${local.hostname.input}-${remote.hostname.input}.properties"/>
|
<then>
|
<var file="${basedir}/tests-${local.hostname.input}-${remote.hostname.input}.properties"/>
|
</then>
|
</if>
|
</then>
|
<else>
|
<property name="remote.hostname.input" value="${local.hostname.input}"/>
|
|
<!-- Tests-defined values -->
|
<if>
|
<available file="${basedir}/tests-${local.hostname.input}.properties"/>
|
<then>
|
<var file="${basedir}/tests-${local.hostname.input}.properties"/>
|
</then>
|
</if>
|
</else>
|
</if>
|
|
<input message=" Enter path to logs directory:"
|
defaultvalue="${logs.dir}"
|
addproperty="logs.dir.input"/>
|
|
<input message=" Enter path to OpenDS archive:"
|
defaultvalue="${opends.dir}"
|
addproperty="opends.dir.input"/>
|
|
<input message=" Enter OpenDS name:"
|
defaultvalue="${opends.name}"
|
addproperty="opends.name.input"/>
|
|
<input message=" Enter java home (on local machine):"
|
defaultvalue="${local.javahome}"
|
addproperty="local.javahome.input"/>
|
|
<if>
|
<equals arg1="${tests.mode.input}" arg2="remote" />
|
<then>
|
<input message=" Enter java home (on remote machine):"
|
defaultvalue="${remote.javahome}"
|
addproperty="remote.javahome.input"/>
|
</then>
|
<else>
|
<property name="remote.javahome.input" value="${local.javahome.input}"/>
|
</else>
|
</if>
|
|
<if>
|
<equals arg1="${tests.mode.input}" arg2="remote" />
|
<then>
|
<input message=" Enter directory instance directory (on remote machine):"
|
defaultvalue="${tests.tmp.dir}"
|
addproperty="tests.tmp.dir.input"/>
|
</then>
|
<else>
|
<input message=" Enter directory instance directory (on local machine):"
|
defaultvalue="${tests.tmp.dir}"
|
addproperty="tests.tmp.dir.input"/>
|
</else>
|
</if>
|
|
<input message=" Use default directory instance?"
|
defaultvalue="${tests.default}"
|
validargs="true,false"
|
addproperty="tests.default.input"/>
|
<if>
|
<equals arg1="${tests.default.input}" arg2="false"/>
|
<then>
|
<input message=" Enter OpenDS ldap port:"
|
defaultvalue="${opends.port.ldap}"
|
addproperty="opends.port.ldap.input"/>
|
<input message=" Enter OpenDS admin port:"
|
defaultvalue="${opends.port.admin}"
|
addproperty="opends.port.admin.input"/>
|
<input message=" Enter OpenDS secure ldap port:"
|
defaultvalue="${opends.port.ldaps}"
|
addproperty="opends.port.ldaps.input"/>
|
<input message=" Enter OpenDS admin DN (also called root DN):"
|
defaultvalue="${opends.admin.dn}"
|
addproperty="opends.admin.dn.input"/>
|
<input message=" Enter OpenDS admin password:"
|
defaultvalue="${opends.admin.pwd}"
|
addproperty="opends.admin.pwd.input"/>
|
<input message=" Enter OpenDMK lib directory:"
|
defaultvalue="${snmp.opendmk.lib.dir}"
|
addproperty="snmp.opendmk.lib.dir.input"/>
|
</then>
|
<else>
|
<property name="opends.port.ldap.input" value="${opends.port.ldap}"/>
|
<property name="opends.port.admin.input" value="${opends.port.admin}"/>
|
<property name="opends.port.ldaps.input" value="${opends.port.ldaps}"/>
|
<property name="opends.admin.dn.input" value="${opends.admin.dn}"/>
|
<property name="opends.admin.pwd.input" value="${opends.admin.pwd}"/>
|
<property name="snmp.opendmk.lib.dir.input" value="${snmp.opendmk.lib.dir}"/>
|
</else>
|
</if>
|
|
<input message=" Run tests using verbose mode?"
|
defaultvalue="${verbose.mode}"
|
validargs="true,false"
|
addproperty="verbose.mode.input"/>
|
|
<echo>* Test plan configuration</echo>
|
<if>
|
<equals arg1="${test.plan.custom}" arg2=""/>
|
<then>
|
<echo> No previous customized test plan found.</echo>
|
<property name="prompt" value="y"/>
|
</then>
|
<else>
|
<echo> A previously customized test plan was detected:</echo>
|
<echo> ${test.plan.custom}</echo>
|
<echo></echo>
|
<input message=" Do you want to change the list of suites to run?"
|
validargs="y,n"
|
defaultvalue="n"
|
addproperty="prompt"/>
|
</else>
|
</if>
|
<if>
|
<equals arg1="${prompt}" arg2="y" />
|
<then>
|
<var name="test.plan.custom" value=""/>
|
<input message=" Do you want to execute all the tests?"
|
validargs="y,n"
|
defaultvalue="y"
|
addproperty="answer"/>
|
<if>
|
<equals arg1="${answer}" arg2="y" />
|
<then>
|
<var name="test.plan.custom" value="${test.plan.default}"/>
|
</then>
|
<else>
|
<for param="item">
|
<dirset dir="${tests.dir}/testcases"
|
includes="*"
|
excludes="quickstart,sample">
|
<type type="dir"/>
|
</dirset>
|
|
<sequential>
|
<var name="test" unset="true"/>
|
<var name="answer" unset="true"/>
|
|
<basename property="test" file="@{item}"/>
|
<input message=" Do you want to execute ${test}?"
|
validargs="y,n"
|
defaultvalue="y"
|
addproperty="answer"/>
|
<if>
|
<equals arg1="${answer}" arg2="y" />
|
<then>
|
<if>
|
<equals arg1="${test.plan.custom}" arg2=""/>
|
<then>
|
<var name="test.plan.custom" value="${test}"/>
|
</then>
|
<else>
|
<var name="test.plan.custom" value="${test.plan.custom},${test}"/>
|
</else>
|
</if>
|
</then>
|
</if>
|
</sequential>
|
</for>
|
</else>
|
</if>
|
</then>
|
</if>
|
|
<echo>Saving ...</echo>
|
<if>
|
<equals arg1="${tests.mode.input}" arg2="remote"/>
|
<then>
|
<property name="property.file" value="tests-${local.hostname.input}-${remote.hostname.input}.properties"/>
|
</then>
|
<else>
|
<property name="property.file" value="tests-${local.hostname.input}.properties"/>
|
</else>
|
</if>
|
<echo file="${basedir}/${property.file}"># Tests-defined values
|
# This file is generated by "build tests-configure" command
|
tests.mode=${tests.mode.input}
|
local.hostname=${local.hostname.input}
|
local.javahome=${local.javahome.input}
|
remote.hostname=${remote.hostname.input}
|
remote.javahome=${remote.javahome.input}
|
logs.dir=${logs.dir.input}
|
opends.dir=${opends.dir.input}
|
opends.name=${opends.name.input}
|
tests.tmp.dir=${tests.tmp.dir.input}
|
tests.default=${tests.default.input}
|
opends.port.ldap=${opends.port.ldap.input}
|
opends.port.admin=${opends.port.admin.input}
|
opends.port.ldaps=${opends.port.ldaps.input}
|
opends.admin.dn=${opends.admin.dn.input}
|
opends.admin.pwd=${opends.admin.pwd.input}
|
snmp.opendmk.lib.dir=${snmp.opendmk.lib.dir.input}
|
verbose.mode=${verbose.mode.input}
|
test.plan.custom=${test.plan.custom}</echo>
|
</target>
|
|
|
<target name="coverage-init">
|
<path id="emma.lib">
|
<pathelement location="${project.home}/ext/emma/lib/emma.jar" />
|
<pathelement location="${project.home}/ext/emma/lib/emma_ant.jar" />
|
</path>
|
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
|
</target>
|
<target name="coverage-on" depends="coverage-init">
|
<property name="coverage.on" value="true"/>
|
</target>
|
<target name="coverage-instrument" if="coverage.on">
|
<delete dir="${tests.tmp.dir}/coverage-instr" />
|
<mkdir dir="${tests.tmp.dir}/coverage-instr" />
|
<!-- unzip the original package in a temporary location to make the
|
changes necessary so that the coverage tool is called
|
-->
|
<unzip src="${product.package}"
|
dest="${tests.tmp.dir}/coverage-instr"/>
|
|
<!-- Add emma in the package along with the other librairies
|
this has the advantage of being automatically picked up by the scripts
|
-->
|
<copy file="${project.home}/ext/emma/lib/emma.jar"
|
tofile="${tests.tmp.dir}/coverage-instr/${product.name}/lib/emma.jar"/>
|
|
<!-- move the original product package to make room for the coverage
|
enabled package
|
-->
|
<move file="${product.package}" tofile="${product.package}.nocov"/>
|
|
<!-- intrument the OpenDS java archive to gather coverage -->
|
<java classpath="${tests.tmp.dir}/coverage-instr/${product.name}/lib$/emma.jar"
|
classname="emma" fork="true">
|
<jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/${product.name}/coverage.em" />
|
<arg value="instr" />
|
<arg value="-m" />
|
<arg value="overwrite" />
|
<arg value="-ip" />
|
<arg value="${tests.tmp.dir}/coverage-instr/${product.name}/lib/OpenDS.jar:${tests.tmp.dir}/coverage-instr/${product.name}/lib/extensions/snmp-mib2605.jar" />
|
</java>
|
<echo>Writing properties file</echo>
|
<echo file="${tests.tmp.dir}/coverage-instr/${product.name}/classes/emma.properties">coverage.out.file=${tests.tmp.dir}/emma.coverage
|
</echo>
|
<!-- Repackage the product with coverage enabled scripts -->
|
<zip basedir="${tests.tmp.dir}/coverage-instr" destfile="${product.package}">
|
<zipfileset dir="${tests.tmp.dir}/coverage-instr"
|
includes="${product.name}/setup,${product.name}/uninstall,${product.name}/upgrade,${product.name}/bin/*,${product.name}/lib/*.sh"
|
filemode="755" dirmode="755" />
|
</zip>
|
<!-- <delete dir="${tests.tmp.dir}/coverage-instr"/> -->
|
</target>
|
<target name="coverage-report" if="coverage.on">
|
<delete dir="${tests.tmp.dir}/coverage/all" />
|
<mkdir dir="${tests.tmp.dir}/coverage/all" />
|
<emma enabled="${coverage.on}" >
|
<report >
|
<infileset dir="${tests.tmp.dir}" includes="**/*.em,**/*.ec" />
|
<sourcepath>
|
<dirset dir="${project.home}" >
|
<include name="src" />
|
</dirset>
|
</sourcepath>
|
<html outfile="${tests.tmp.dir}/coverage/all/index.html"
|
columns="name, method, line"
|
sort="+line, +name"
|
metrics="line:80"
|
/>
|
</report>
|
</emma>
|
</target>
|
<target name="restore-pkg" if="coverage.on">
|
<delete file="${product.package}"/>
|
<move file="${product.package}.nocov" tofile="${product.package}"/>
|
</target>
|
<target name="testwithcoverage" depends="coverage-on,coverage-instrument,restore-pkg,coverage-report"/>
|
|
</project>
|