tests.xml revision 3832
7321N/A<!--
7321N/A ! CDDL HEADER START
7321N/A !
7321N/A ! The contents of this file are subject to the terms of the
7321N/A ! Common Development and Distribution License, Version 1.0 only
7321N/A ! (the "License"). You may not use this file except in compliance
7321N/A ! with the License.
7321N/A !
7321N/A ! You can obtain a copy of the license at
7321N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
7321N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
7321N/A ! See the License for the specific language governing permissions
7321N/A ! and limitations under the License.
7321N/A !
7321N/A ! When distributing Covered Code, include this CDDL HEADER in each
7321N/A ! file and include the License file at
7321N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
7321N/A ! add the following below this CDDL HEADER, with the fields enclosed
7321N/A ! by brackets "[]" replaced with your own identifying information:
7321N/A ! Portions Copyright [yyyy] [name of copyright owner]
7321N/A !
7321N/A ! CDDL HEADER END
7321N/A !
7321N/A !
7321N/A ! Copyright 2008 Sun Microsystems, Inc.
7321N/A ! -->
7321N/A<project name="tests">
7321N/A <description>
7321N/A Execute the tests.
7321N/A </description>
7321N/A
7321N/A <target name="run">
7321N/A <tstamp>
7321N/A <format property="tests.run.time" pattern="yyyy.MM.dd-HH.mm.ss"/>
7321N/A </tstamp>
7321N/A
7321N/A <!-- clean up some -->
7321N/A <delete dir="${tests.tmp.dir}"/>
7321N/A
7321N/A <!-- make all the necessary directories for this test run -->
7321N/A <mkdir dir="${tests.tmp.dir}"/>
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}"/>
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/config"/>
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/report"/>
7321N/A <!-- these will serve for after-the-fact archiving the logs -->
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/staf-logs"/>
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/server-logs"/>
7321N/A <mkdir dir="${tests.run.dir}/${tests.run.time}/coverage"/>
7321N/A
7321N/A <delete file="${test.plan.default}"/>
7321N/A <for list="${test.plan.list}" param="item">
7321N/A <sequential>
7321N/A <echo file="${test.plan.default}" append="true">@{item}
7321N/A</echo>
7321N/A </sequential>
7321N/A </for>
7321N/A
7321N/A <!-- generate the timestamped config file that will be used for this run -->
7321N/A <copy file="${tests.config.stubs}"
7321N/A tofile="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}">
7321N/A <filterchain>
7321N/A <expandproperties/>
7321N/A </filterchain>
7321N/A </copy>
7321N/A
7321N/A <!-- this is a windows-specific measure to replace the windows file
7321N/A separator by a forward slash. Staf otherwise fails to find the files. -->
7321N/A <replace file="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}" token="\" value="/"/>
7321N/A
7321N/A <property name="tests.request" value="EXECUTE FILE ${tests.xml} JOBNAME OpenDS_Functional_Tests SCRIPTFILE ${tests.run.dir}/${tests.run.time}/config/${tests.config.file} WAIT CLEARLOGS"/>
7321N/A
7321N/A <echo>While the tests are running you may tail the job logs at</echo>
7321N/A <echo>${staf.install.dir}/logs/MACHINE/${host.name}</echo>
7321N/A <echo>Running tests. This will take more than a while.</echo>
7321N/A <property name="CLASSPATH" value="${staf.lib.dir}/JSTAF.jar${path.separator}${e.CLASSPATH}"/>
7321N/A <exec
7321N/A dir="${staf.bin.dir}"
7321N/A executable="${staf.executable}"
7321N/A >
7321N/A <arg line="LOCAL STAX ${tests.request}"/>
7321N/A <env key="CLASSPATH" path="${staf.lib.dir}/JSTAF.jar${path.separator}${e.CLASSPATH}"/>
7321N/A <env key="LD_LIBRARY_PATH" value="${staf.lib.dir}"/>
7321N/A <env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
7321N/A <env key="STAFCODEPAGE" value="LATIN_1"/>
7321N/A </exec>
7321N/A
7321N/A <symlink link="${tests.run.dir}/latest" resource="${tests.run.time}" overwrite="true"/>
7321N/A <if>
7321N/A <available file="${tests.tmp.dir}/${product.name}/logs"/>
7321N/A <then>
7321N/A <echo>Saving server logs</echo>
7321N/A <copy todir="${tests.run.dir}/${tests.run.time}/server-logs">
7321N/A <fileset dir="${tests.tmp.dir}/${product.name}/logs"/>
7321N/A </copy>
7321N/A </then>
7321N/A </if>
7321N/A <echo>Saving Staf/Stax logs</echo>
7321N/A <copy todir="${tests.run.dir}/${tests.run.time}/staf-logs">
7321N/A <fileset dir="${staf.install.dir}/logs"/>
7321N/A </copy>
7321N/A <delete dir="${staf.install.dir}/logs"/>
7321N/A <echo>Saving report</echo>
7321N/A <copy todir="${tests.run.dir}/${tests.run.time}/report">
7321N/A <fileset dir="${tests.tmp.dir}">
7321N/A <include name="r*"/>
7321N/A </fileset>
7321N/A </copy>
7321N/A <delete file="${tests.tmp.dir}/percentage.properties"/>
7321N/A </target>
7321N/A
7321N/A <target name="configure">
7321N/A <condition property="already.customized" value="true" else="false">
7321N/A <available file="${test.plan.custom}" />
7321N/A </condition>
7321N/A <if>
7321N/A <equals arg1="${already.customized}" arg2="true" />
7321N/A <then>
7321N/A <input message="A previously customized test plan was detected. Do you want to change the list of suites to run?" validargs="y,n" defaultvalue="n" addproperty="prompt.do" />
7321N/A </then>
7321N/A <else>
7321N/A <echo>No previous customized test plan found.</echo>
7321N/A <property name="prompt.do" value="y" />
7321N/A </else>
7321N/A </if>
7321N/A <if>
7321N/A <equals arg1="${prompt.do}" arg2="y" />
7321N/A <then>
7321N/A <delete file="${test.plan.custom}" />
7321N/A
7321N/A <for param="item">
7321N/A <dirset dir="${tests.dir}/testcases"
7321N/A includes="*">
7321N/A <type type="dir"/>
7321N/A </dirset>
7321N/A <sequential>
7321N/A <var name="test" unset="true"/>
7321N/A <var name="answer" unset="true"/>
7321N/A
7321N/A <basename property="test" file="@{item}"/>
7321N/A <input message="Do you want to execute ${test}?" validargs="y,n" defaultvalue="y" addproperty="answer"/>
7321N/A <if>
7321N/A <equals arg1="${answer}" arg2="y" />
7321N/A <then>
7321N/A <echo file="${test.plan.custom}" append="true">${test}
7321N/A</echo>
7321N/A </then>
7321N/A </if>
7321N/A </sequential>
7321N/A </for>
7321N/A </then>
7321N/A </if>
7321N/A </target>
7321N/A
7321N/A <target name="send-mail-prepare">
7321N/A <condition property="test.successful">
7321N/A <available file="${tests.tmp.dir}/my-report.html"/>
7321N/A </condition>
7321N/A <condition property="email.send">
7321N/A <equals arg1="${email.enabled}" arg2="y"
7321N/A casesensitive="false" trim="true"/>
7321N/A </condition>
7321N/A </target>
7321N/A <target name="send-mail-get-percentage" depends="send-mail-prepare" if="test.successful">
7321N/A <echo>test report found.Proceeding...</echo>
7321N/A <delete file="${tests.tmp.dir}/percentage.properties"/>
7321N/A <copy file="${tests.tmp.dir}/my-report.html" tofile="${tests.tmp.dir}/percentage.properties">
7321N/A <filterchain>
7321N/A <linecontains>
7321N/A <contains value='font size="+2'/>
7321N/A </linecontains>
7321N/A <tokenfilter>
7321N/A <replaceregex pattern=".*font size=.+2..(.*\d+)%/font.*" replace="test.percentage=\1"/>
7321N/A </tokenfilter>
7321N/A </filterchain>
7321N/A </copy>
7321N/A <property file="${tests.tmp.dir}/percentage.properties"/>
7321N/A <echo>Test Success Rate: ${test.percentage}%</echo>
7321N/A </target>
7321N/A <target name="send-mail" if="email.send" depends="send-mail-get-percentage">
7321N/A <condition property="email.send.noauth">
7321N/A <or>
7321N/A <not>
7321N/A <isset property="email.server.user"/>
7321N/A </not>
7321N/A <not>
7321N/A <length string="${email.server.user}" when="greater"
7321N/A trim="true" length="0"/>
7321N/A </not>
7321N/A </or>
7321N/A </condition>
7321N/A <condition property="email.file"
7321N/A value="${tests.tmp.dir}/my-report.html"
7321N/A else="staf-installer/failure.html">
7321N/A <available file="${tests.tmp.dir}/my-report.html"/>
7321N/A </condition>
7321N/A <condition property="email.subject"
7321N/A value="FT - Run - ${daily.date} - ${os.name} - ${os.arch} - ${test.percentage}%"
7321N/A else="FT - Failed -${daily.date} - ${os.name} - ${os.arch}">
7321N/A <available file="${tests.tmp.dir}/my-report.html"/>
7321N/A </condition>
7321N/A <antcall target="send-mail-noauth"/>
7321N/A <antcall target="send-mail-withauth"/>
7321N/A </target>
7321N/A <target name="send-mail-noauth" if="email.send.noauth">
7321N/A <mail from="${email.from}"
7321N/A tolist="${email.to}"
7321N/A subject="${email.subject}"
7321N/A mailhost="${email.server.host}"
7321N/A mailport="${email.server.port}"
7321N/A messagefile="${email.file}"
7321N/A messagemimetype="text/html" />
7321N/A </target>
7321N/A <target name="send-mail-withauth" unless="email.send.noauth">
7321N/A <mail from="${email.from}"
7321N/A tolist="${email.to}"
7321N/A subject="${email.subject}"
7321N/A mailhost="${email.server.host}"
7321N/A mailport="${email.server.port}"
7321N/A user="${email.server.user}"
7321N/A password="${email.server.pwd}"
7321N/A messagefile="${email.file}"
7321N/A messagemimetype="text/html" />
7321N/A </target>
7321N/A <target name="coverage-init">
7321N/A <path id="emma.lib">
7321N/A <pathelement location="${project.home}/ext/emma/lib/emma.jar" />
7321N/A <pathelement location="${project.home}/ext/emma/lib/emma_ant.jar" />
7321N/A </path>
7321N/A <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
7321N/A </target>
7321N/A <target name="coverage-on" depends="coverage-init">
7321N/A <property name="coverage.on" value="true"/>
7321N/A </target>
7321N/A <target name="coverage-instrument" if="coverage.on">
7321N/A <delete dir="${tests.tmp.dir}/coverage-instr" />
7321N/A <mkdir dir="${tests.tmp.dir}/coverage-instr" />
7321N/A <!-- unzip the original package in a temporary location to make the
7321N/A changes necessary so that the coverage tool is called
7321N/A -->
7321N/A <unzip src="${product.package}"
7321N/A dest="${tests.tmp.dir}/coverage-instr"/>
7321N/A
7321N/A <!-- Add emma in the package along with the other librairies
7321N/A this has the advantage of being automatically picked up by the scripts
7321N/A -->
7321N/A <copy file="${project.home}/ext/emma/lib/emma.jar"
7321N/A tofile="${tests.tmp.dir}/coverage-instr/${product.name}/lib/emma.jar"/>
7321N/A
7321N/A <!-- move the original product package to make room for the coverage
7321N/A enabled package
7321N/A -->
7321N/A <move file="${product.package}" tofile="${product.package}.nocov"/>
7321N/A
7321N/A <!-- intrument the OpenDS java archive to gather coverage -->
7321N/A <java classpath="${tests.tmp.dir}${file.separator}coverage-instr${file.separator}${product.name}${file.separator}lib${file.separator}emma.jar"
7321N/A classname="emma" fork="true">
<jvmarg value="-Demma.metadata.out.file=${tests.tmp.dir}${file.separator}coverage-instr${file.separator}${product.name}${file.separator}coverage.em" />
<arg value="instr" />
<arg value="-m" />
<arg value="overwrite" />
<arg value="-ip" />
<arg value="${tests.tmp.dir}${file.separator}coverage-instr${file.separator}${product.name}${file.separator}lib${file.separator}OpenDS.jar:${tests.tmp.dir}${file.separator}coverage-instr${file.separator}${product.name}${file.separator}lib${file.separator}extensions${file.separator}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"/>
<!-- Run tests section - bottom -->
</project>