tests.xml revision 5061
4638N/A<!--
3261N/A ! CDDL HEADER START
0N/A !
4638N/A ! The contents of this file are subject to the terms of the
0N/A ! Common Development and Distribution License, Version 1.0 only
0N/A ! (the "License"). You may not use this file except in compliance
0N/A ! with the License.
4638N/A !
0N/A ! You can obtain a copy of the license at
0N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
0N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0N/A ! See the License for the specific language governing permissions
0N/A ! and limitations under the License.
4638N/A !
0N/A ! When distributing Covered Code, include this CDDL HEADER in each
0N/A ! file and include the License file at
0N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4638N/A ! add the following below this CDDL HEADER, with the fields enclosed
2362N/A ! by brackets "[]" replaced with your own identifying information:
2362N/A ! Portions Copyright [yyyy] [name of copyright owner]
2362N/A !
0N/A ! CDDL HEADER END
0N/A !
0N/A !
0N/A ! Copyright 2008-2010 Sun Microsystems, Inc.
0N/A ! -->
0N/A<project name="tests">
0N/A
0N/A <description>
0N/A Execute the tests.
0N/A </description>
0N/A
0N/A <target name="specs">
0N/A <javac srcdir="${shared.dir}/java/parsingtool"
0N/A destdir="${shared.dir}/java/parsingtool"
0N/A debug="true"
0N/A debuglevel="lines,vars,source"
0N/A verbose="yes"
0N/A />
0N/A <delete dir="${logs.dir}/specs" failonerror="false"/>
0N/A <mkdir dir="${logs.dir}/specs"/>
0N/A <java classpath="${shared.dir}/java/parsingtool"
0N/A classname="GenerateOpenDSTestSpecs" fork="true">
0N/A <!-- uncomment "agentlib" if need debugger waiting for you
0N/A <jvmarg value="-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=7778"/>
0N/A -->
0N/A <arg value="${tests.dir}"/>
0N/A <arg value="${logs.dir}/specs"/>
0N/A <arg value="xml" />
0N/A </java>
0N/A </target>
0N/A
0N/A <target name="run">
0N/A <tstamp>
0N/A <format property="tests.timestamp" pattern="yyyyMMdd-HHmmss"/>
0N/A </tstamp>
0N/A <var name="tests.run.time" value="${remote.hostname}-${tests.timestamp}"/>
0N/A
0N/A <!-- clean up tmp dir -->
0N/A <if>
0N/A <equals arg1="${tests.mode}" arg2="local"/>
0N/A <then>
0N/A <delete dir="${tests.tmp.dir}"/>
0N/A <mkdir dir="${tests.tmp.dir}"/>
0N/A </then>
0N/A </if>
0N/A
0N/A <!-- make all the necessary directories for this test run -->
0N/A <mkdir dir="${tests.run.dir}/${tests.run.time}"/>
0N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/config"/>
0N/A <!-- these will serve for after-the-fact archiving the logs -->
2077N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/staf-logs"/>
0N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/logs"/>
0N/A
4638N/A <if>
0N/A <equals arg1="${test.plan.custom}" arg2=""/>
0N/A <then>
0N/A <if>
0N/A <equals arg1="${tests.type}" arg2="functional-tests"/>
0N/A <then>
0N/A <var name="test.plan.custom" value="${test.plan.functional.default}"/>
0N/A </then>
0N/A <else>
0N/A <var name="test.plan.custom" value="${test.plan.stress.default}"/>
0N/A </else>
0N/A </if>
0N/A </then>
0N/A </if>
0N/A
0N/A <!-- generate the config file that will be used for this run -->
0N/A <copy file="${tests.config.stubs}"
0N/A tofile="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}">
0N/A <filterchain>
0N/A <expandproperties/>
0N/A </filterchain>
0N/A </copy>
0N/A
0N/A <!-- generate the topology files that will be used for this run -->
0N/A <copy todir="${tests.run.dir}/${tests.run.time}/config">
0N/A <fileset dir="${tests.topology.dir}">
0N/A <include name="**/*.txt"/>
0N/A </fileset>
0N/A <filterchain>
0N/A <expandproperties/>
0N/A </filterchain>
4638N/A </copy>
4638N/A
0N/A <!-- this is a windows-specific measure to replace the windows file
4638N/A separator by a forward slash. Staf otherwise fails to find the files. -->
4638N/A <replace file="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}" token="\" value="/"/>
0N/A
0N/A <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"/>
0N/A
0N/A <echo>While the tests are running you may tail the job logs at</echo>
0N/A <echo>${staf.install.dir}/${staf.name}/logs/MACHINE/${host.name}</echo>
0N/A <echo>Running tests. This will take more than a while.</echo>
0N/A <property name="CLASSPATH" value="${staf.lib.dir}/JSTAF.jar:."/>
0N/A <exec
0N/A dir="${staf.bin.dir}"
0N/A executable="${staf.executable}"
0N/A >
0N/A <arg line="LOCAL STAX ${tests.request}"/>
0N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar:."/>
0N/A <env key="LD_LIBRARY_PATH" value="${staf.lib.dir}"/>
0N/A <env key="STAFCONVDIR" value="${staf.install.dir}/${staf.name}/codepage"/>
0N/A <env key="STAFCODEPAGE" value="LATIN_1"/>
0N/A </exec>
0N/A
0N/A <symlink link="${tests.run.dir}/latest" resource="${tests.run.time}" overwrite="true"/>
0N/A <echo>Report is available at</echo>
0N/A <echo>${tests.run.dir}/latest</echo>
0N/A </target>
0N/A
0N/A <target name="configure">
4638N/A <echo>* Tests configuration</echo>
4638N/A
0N/A <input message=" Run the tests on the local machine or on a remote machine?"
4638N/A defaultvalue="local"
0N/A validargs="local,remote"
4638N/A addproperty="tests.mode.input"/>
0N/A
0N/A <input message=" Enter local hostname:"
0N/A defaultvalue="${local.hostname}"
0N/A addproperty="local.hostname.input"/>
0N/A
0N/A <if>
0N/A <equals arg1="${tests.mode.input}" arg2="remote"/>
0N/A <then>
0N/A <input message=" Enter remote hostname:"
0N/A defaultvalue=""
0N/A addproperty="remote.hostname.input"/>
0N/A
0N/A <!-- Tests-defined values -->
0N/A <if>
0N/A <available file="${basedir}/${tests.type}-${local.hostname.input}-${remote.hostname.input}.properties"/>
0N/A <then>
0N/A <var file="${basedir}/${tests.type}-${local.hostname.input}-${remote.hostname.input}.properties"/>
0N/A </then>
0N/A </if>
0N/A </then>
0N/A <else>
0N/A <property name="remote.hostname.input" value="${local.hostname.input}"/>
0N/A
4638N/A <!-- Tests-defined values -->
4638N/A <if>
0N/A <available file="${basedir}/${tests.type}-${local.hostname.input}.properties"/>
4638N/A <then>
4638N/A <var file="${basedir}/${tests.type}-${local.hostname.input}.properties"/>
0N/A </then>
0N/A </if>
0N/A </else>
0N/A </if>
0N/A
0N/A <if>
0N/A <equals arg1="${tests.type}" arg2="stress-tests"/>
0N/A <then>
0N/A <input message=" Enter client hostname:"
4638N/A defaultvalue="${client.hostname}"
0N/A addproperty="client.hostname.input"/>
4638N/A
4638N/A <input message=" Enter ldclt path (on client machine):"
4638N/A defaultvalue="${ldclt.dir}"
4638N/A addproperty="ldclt.dir.input"/>
0N/A </then>
0N/A <else>
0N/A <property name="client.hostname.input" value="${client.hostname}"/>
0N/A <property name="ldclt.dir.input" value="${ldclt.dir}"/>
0N/A </else>
0N/A </if>
0N/A
0N/A <input message=" Enter path to logs directory:"
0N/A defaultvalue="${logs.dir}"
0N/A addproperty="logs.dir.input"/>
0N/A
0N/A <input message=" Enter path to OpenDS archive:"
0N/A defaultvalue="${opends.dir}"
0N/A addproperty="opends.dir.input"/>
0N/A
4638N/A <input message=" Enter OpenDS name:"
4638N/A defaultvalue="${opends.name}"
4638N/A addproperty="opends.name.input"/>
0N/A
0N/A <input message=" Enter java home:"
0N/A defaultvalue="${local.javahome}"
0N/A addproperty="local.javahome.input"/>
0N/A
0N/A <if>
0N/A <equals arg1="${tests.mode.input}" arg2="remote" />
0N/A <then>
4638N/A <input message=" Enter java home (on remote machine):"
0N/A defaultvalue="${remote.javahome}"
4638N/A addproperty="remote.javahome.input"/>
4638N/A </then>
0N/A <else>
4638N/A <property name="remote.javahome.input" value="${local.javahome.input}"/>
4638N/A </else>
0N/A </if>
0N/A
0N/A <if>
0N/A <equals arg1="${tests.mode.input}" arg2="remote" />
0N/A <then>
0N/A <input message=" Enter directory instance directory (on remote machine):"
0N/A defaultvalue="${instance.dir}"
0N/A addproperty="instance.dir.input"/>
0N/A </then>
0N/A <else>
0N/A <input message=" Enter directory instance directory:"
0N/A defaultvalue="${instance.dir}"
0N/A addproperty="instance.dir.input"/>
0N/A </else>
0N/A </if>
0N/A
0N/A <input message=" Enter OpenDMK lib directory:"
0N/A defaultvalue="${snmp.opendmk.lib.dir}"
0N/A addproperty="snmp.opendmk.lib.dir.input"/>
0N/A
0N/A <input message=" Use default directory instance?"
0N/A defaultvalue="${tests.default}"
0N/A validargs="true,false"
0N/A addproperty="tests.default.input"/>
0N/A <if>
0N/A <equals arg1="${tests.default.input}" arg2="false"/>
0N/A <then>
0N/A <input message=" Enter OpenDS ldap port:"
0N/A defaultvalue="${opends.port.ldap}"
0N/A addproperty="opends.port.ldap.input"/>
0N/A <input message=" Enter OpenDS admin port:"
0N/A defaultvalue="${opends.port.admin}"
0N/A addproperty="opends.port.admin.input"/>
0N/A <input message=" Enter OpenDS secure ldap port:"
0N/A defaultvalue="${opends.port.ldaps}"
0N/A addproperty="opends.port.ldaps.input"/>
0N/A <input message=" Enter OpenDS admin DN (also called root DN):"
0N/A defaultvalue="${opends.admin.dn}"
0N/A addproperty="opends.admin.dn.input"/>
0N/A <input message=" Enter OpenDS admin password:"
0N/A defaultvalue="${opends.admin.pwd}"
0N/A addproperty="opends.admin.pwd.input"/>
0N/A </then>
0N/A <else>
0N/A <property name="opends.port.ldap.input" value="${opends.port.ldap}"/>
0N/A <property name="opends.port.admin.input" value="${opends.port.admin}"/>
0N/A <property name="opends.port.ldaps.input" value="${opends.port.ldaps}"/>
0N/A <property name="opends.admin.dn.input" value="${opends.admin.dn}"/>
0N/A <property name="opends.admin.pwd.input" value="${opends.admin.pwd}"/>
0N/A </else>
0N/A </if>
0N/A
0N/A <input message=" Run tests using verbose mode?"
0N/A defaultvalue="${verbose.mode}"
0N/A validargs="true,false"
0N/A addproperty="verbose.mode.input"/>
0N/A
0N/A <echo>* Test plan configuration</echo>
0N/A <if>
0N/A <equals arg1="${test.plan.custom}" arg2=""/>
0N/A <then>
0N/A <echo> No previous customized test plan found.</echo>
0N/A <property name="prompt" value="y"/>
0N/A </then>
0N/A <else>
0N/A <echo> A previously customized test plan was detected:</echo>
0N/A <echo> ${test.plan.custom}</echo>
0N/A <echo></echo>
0N/A <input message=" Do you want to change the list of suites to run?"
0N/A validargs="y,n"
0N/A defaultvalue="n"
0N/A addproperty="prompt"/>
0N/A </else>
0N/A </if>
0N/A <if>
0N/A <equals arg1="${prompt}" arg2="y" />
0N/A <then>
0N/A <var name="test.plan.custom" value=""/>
0N/A <input message=" Do you want to execute all the tests?"
0N/A validargs="y,n"
0N/A defaultvalue="y"
0N/A addproperty="answer"/>
0N/A <if>
0N/A <equals arg1="${answer}" arg2="y" />
0N/A <then>
0N/A <if>
0N/A <equals arg1="${tests.type}" arg2="functional-tests"/>
0N/A <then>
0N/A <var name="test.plan.custom" value="${test.plan.functional.default}"/>
0N/A </then>
0N/A <else>
0N/A <var name="test.plan.custom" value="${test.plan.stress.default}"/>
0N/A </else>
0N/A </if>
0N/A </then>
0N/A <else>
0N/A <for param="item">
0N/A <dirset dir="${tests.dir}/testcases"
0N/A includes="*"
0N/A excludes="quickstart,sample">
0N/A <type type="dir"/>
0N/A </dirset>
0N/A
0N/A <sequential>
0N/A <var name="test" unset="true"/>
0N/A <var name="answer" unset="true"/>
0N/A
0N/A <basename property="test" file="@{item}"/>
0N/A <input message=" Do you want to execute ${test}?"
0N/A validargs="y,n"
0N/A defaultvalue="y"
0N/A addproperty="answer"/>
0N/A <if>
0N/A <equals arg1="${answer}" arg2="y" />
0N/A <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.type}-${local.hostname.input}-${remote.hostname.input}.properties"/>
</then>
<else>
<property name="property.file" value="${tests.type}-${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}
client.hostname=${client.hostname.input}
logs.dir=${logs.dir.input}
opends.dir=${opends.dir.input}
opends.name=${opends.name.input}
tests.tmp.dir=${instance.dir.input}
tests.default=${tests.default.input}
instance.bin=${instance.dir.input}
instance.dir=${instance.dir.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}
ldclt.dir=${ldclt.dir.input}
verbose.mode=${verbose.mode.input}
wc.type=tomcat
test.plan.custom=${test.plan.custom}
original.archive=${opends.dir.input}/${opends.name.input}.zip</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="${opends.dir}/${opends.name}.zip"
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/${opends.name}/lib/emma.jar"/>
<!-- move the original product package to make room for the coverage
enabled package
-->
<move file="${opends.dir}/${opends.name}.zip" tofile="${opends.dir}/${opends.name}.zip.nocov"/>
<!-- intrument the OpenDS java archive to gather coverage -->
<java classpath="${tests.tmp.dir}/coverage-instr/${opends.name}/lib/emma.jar"
classname="emma" fork="true">
<jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}/coverage-instr/${opends.name}/coverage.em" />
<arg value="instr" />
<arg value="-m" />
<arg value="overwrite" />
<arg value="-ix" />
<arg value="-org.opends.guitools.*" />
<arg value="-ix" />
<arg value="-org.opends.quicksetup.*" />
<arg value="-ix" />
<arg value="org.*" />
<arg value="-ix" />
<arg value="com.*" />
<arg value="-ip" />
<arg value="${tests.tmp.dir}/coverage-instr/${opends.name}/lib/OpenDS.jar:${tests.tmp.dir}/coverage-instr/${opends.name}/lib/extensions/snmp-mib2605.jar" />
</java>
<!-- Repackage the product with coverage enabled scripts -->
<zip basedir="${tests.tmp.dir}/coverage-instr" destfile="${opends.dir}/${opends.name}.zip">
<zipfileset dir="${tests.tmp.dir}/coverage-instr"
includes="${opends.name}/setup,${opends.name}/uninstall,${opends.name}/upgrade,${opends.name}/bin/*,${opends.name}/lib/*.sh"
filemode="755" dirmode="755" />
</zip>
<!-- <delete dir="${tests.tmp.dir}/coverage-instr"/> -->
</target>
<target name="restore-pkg" if="coverage.on">
<delete file="${opends.dir}/${opends.name}.zip"/>
<move file="${opends.dir}/${opends.name}.zip.nocov" tofile="${opends.dir}/${opends.name}.zip"/>
</target>
<target name="testwithcoverage" depends="coverage-on,coverage-instrument,run,restore-pkg"/>
</project>