<!--
! 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-2010 Sun Microsystems, Inc.
! Portions Copyright 2011-2013 ForgeRock AS
! -->
<project name="opends-staf-tests" basedir="../.." default="usage">
<description>
Installer ant file for the staf platform
This allows tests that need a running instance of staf to easily
get one and hides all the complexity under the hood
</description>
<!-- ################## -->
<!-- # ANT PROPERTIES # -->
<!-- ################## -->
<!-- Display ant properties -->
<target name="properties">
<echoproperties/>
</target>
<!-- ######## -->
<!-- # INIT # -->
<!-- ######## -->
<!-- Initialise variables -->
<target name="global-init">
<!-- Define project.home variable -->
<dirname file="${basedir}/.." property="project.home"/>
<!-- Default value for product.name variable -->
<property file="${project.home}/PRODUCT"/>
<property name="product.short.name"
value="${SHORT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${POINT_VERSION}"/>
<!-- Define antfile.dir variable -->
<property name="antfile.dir" value="${basedir}/shared/ant"/>
<!-- Load ant-contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset dir="${project.home}/ext/ant/lib">
<include name="*/*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- User environment -->
<property environment="env"/>
<!-- Check if the current platform is supported -->
<switch value="${os.name}">
<case value="SunOS">
<!-- Solaris system -->
<switch value="${os.arch}">
<case value="sparc">
<!-- Solaris sparc 32 bit -->
<property name="os.myname" value="solaris-sparc"/>
</case>
<case value="sparcv9">
<!-- Solaris sparc 64 bit -->
<property name="os.myname" value="solaris-sparc64"/>
</case>
<case value="x86">
<!-- Solaris x86 -->
<property name="os.myname" value="solaris-x86"/>
</case>
<case value="amd64">
<!-- Solaris amd64 -->
<property name="os.myname" value="solaris-x64-64"/>
</case>
</switch>
<exec executable="uname" outputproperty="host.name">
<arg line="-n"/>
</exec>
<property name="extension.binary" value=""/>
<property name="extension.shell" value=""/>
<property name="var.path" value="PATH"/>
</case>
<case value="Linux">
<!-- Linux system -->
<switch value="${os.arch}">
<case value="i386">
<!-- Linux i386 -->
<property name="os.myname" value="linux"/>
</case>
<case value="amd64">
<!-- Linux amd64 -->
<property name="os.myname" value="linux-amd64"/>
</case>
</switch>
<exec executable="uname" outputproperty="host.name">
<arg line="-n"/>
</exec>
<property name="extension.binary" value=""/>
<property name="extension.shell" value=""/>
<property name="var.path" value="PATH"/>
</case>
<case value="Mac OS X">
<!-- MacOSX system -->
<switch value="${os.arch}">
<case value="x86_64">
<!-- Linux i386 -->
<property name="os.myname" value="macosx-universal"/>
</case>
</switch>
<exec executable="uname" outputproperty="host.name">
<arg line="-n"/>
</exec>
<property name="extension.binary" value=""/>
<property name="extension.shell" value=""/>
<property name="var.path" value="PATH"/>
</case>
<default>
<osfamily property="os.family"/>
<if>
<equals arg1="${os.family}" arg2="windows"/>
<then>
<!-- Windows system -->
<property name="os.myname" value="win32"/>
<property name="host.name" value="${env.COMPUTERNAME}"/>
<property name="extension.binary" value=".exe"/>
<property name="extension.shell" value=".bat"/>
<property name="var.path" value="Path"/>
</then>
<else>
<fail>"Unsupported platform. ${os.name} - ${os.arch}"</fail>
</else>
</if>
</default>
</switch>
<!-- Define tmp.dir variable -->
<property name="tmp.dir" value="${java.io.tmpdir}/temp_files/${host.name}"/>
<!-- Default value for staf.type -->
<if>
<not>
<isset property="staf.type"/>
</not>
<then>
<property name="staf.type" value="controller"/>
</then>
</if>
<!-- Default value for tests.type -->
<if>
<not>
<isset property="tests.type"/>
</not>
<then>
<property name="tests.type" value="functional-tests"/>
</then>
</if>
<!-- Default values for build environment -->
<property file="${antfile.dir}/build.properties"/>
<!-- User-defined values -->
<if>
<available file="${basedir}/user.properties"/>
<then>
<var file="${basedir}/user.properties"/>
</then>
</if>
<!-- Tests-defined values -->
<if>
<available file="${env.CONFIG_FILE}"/>
<then>
<var file="${env.CONFIG_FILE}"/>
</then>
<else>
<if>
<available file="${basedir}/${tests.type}-${local.hostname}.properties"/>
<then>
<var file="${basedir}/${tests.type}-${local.hostname}.properties"/>
</then>
</if>
</else>
</if>
<!-- Set value for tests.config.file variable depending on tests.mode -->
<if>
<equals arg1="${tests.mode}" arg2="remote"/>
<then>
<property name="tests.config.file" value="config-${local.hostname}-${remote.hostname}.py"/>
</then>
<else>
<property name="tests.config.file" value="config-${local.hostname}.py"/>
</else>
</if>
<!-- Set value for email.subject variable depending on tests.type -->
<if>
<equals arg1="${tests.type}" arg2="functional-tests"/>
<then>
<property name="email.subject"
value="Functional tests: ${opends.name} ${remote.hostname} ${tests.os.string} ${tests.jvm.string}"/>
</then>
<else>
<property name="email.subject"
value="Stress tests: ${opends.name} ${remote.hostname} ${tests.os.string} ${tests.jvm.string}"/>
</else>
</if>
<!-- Set value for variables which depends on user configuration -->
<var name="staf.name" value="STAF-v${staf.version}-${os.myname}"/>
<var name="staf.install.dir" value="${repository.dir}/install"/>
<var name="staf.config.dir" value="${repository.dir}/configs"/>
<var name="staf.config.file" value="${staf.config.dir}/staf-${staf.type}-${host.name}.cfg"/>
<var name="staf.bin.dir" value="${staf.install.dir}/${staf.name}/bin"/>
<var name="staf.daemon" value="${staf.bin.dir}/STAFProc${extension.binary}"/>
<var name="staf.executable" value="${staf.bin.dir}/STAF${extension.binary}"/>
<var name="archives.dir" value="${repository.dir}/archives"/>
<var name="tests.run.dir" value="${logs.dir}"/>
<if>
<equals arg1="${os.family}" arg2="windows"/>
<then>
<!-- Windows system -->
<property name="staf.archive"
value="STAF${staf.version}-setup-${os.myname}.exe"/>
<property name="staf.lib.dir" value="${staf.install.dir}/${staf.name}/bin"/>
</then>
<else>
<!-- Other systems -->
<property name="staf.archive"
value="STAF${staf.version}-${os.myname}.tar.gz"/>
<property name="staf.lib.dir" value="${staf.install.dir}/${staf.name}/lib"/>
</else>
</if>
<var name="stax.name" value="STAX-v${stax.version}"/>
<var name="stax.archive" value="STAXV${stax.version}.zip"/>
<var name="email.name" value="Email-v${email.version}"/>
<var name="email.archive" value="EmailV${email.version}.zip"/>
<var name="event.name" value="Event-v${event.version}"/>
<var name="event.archive" value="EventV${event.version}.zip"/>
<var name="eventmanager.name" value="EventManager-v${eventmanager.version}"/>
<var name="eventmanager.archive" value="EventManagerV${eventmanager.version}.zip"/>
<var name="http.name" value="HTTP-v${http.version}"/>
<var name="http.archive" value="HTTPV${http.version}.zip"/>
<var name="tomcat.url" value="http://archive.apache.org/dist/tomcat/tomcat-6/v${tomcat.version}/bin"/>
<var name="tomcat.archive" value="apache-tomcat-${tomcat.version}.zip"/>
<var name="glassfish.url" value="http://download.java.net/glassfish/${glassfish.version}/release"/>
<var name="glassfish.archive" value="glassfish-${glassfish.version}.zip"/>
<var name="sunwebserver.archive" value="sjsws-${sunwebserver.version}-${os.myname}.zip"/>
<switch value="${wc.type}">
<case value="glassfish">
<!-- Glassfish webcontainer -->
<var name="wc.url" value="${glassfish.url}"/>
<var name="wc.archive" value="${glassfish.archive}"/>
<var name="wc.version" value="${glassfish.version}"/>
</case>
<case value="sunwebserver">
<!-- SunWebserver webcontainer -->
<var name="wc.url" value="${sunwebserver.url}"/>
<var name="wc.archive" value="${sunwebserver.archive}"/>
<var name="wc.version" value="${sunwebserver.version}"/>
</case>
<default>
<!-- Tomcat webcontainer -->
<var name="wc.url" value="${tomcat.url}"/>
<var name="wc.archive" value="${tomcat.archive}"/>
<var name="wc.version" value="${tomcat.version}"/>
</default>
</switch>
</target>
<!-- ######### -->
<!-- # USAGE # -->
<!-- ######### -->
<!-- Display usage -->
<target name="usage"
depends="global-init">
<ant antfile="${antfile.dir}/usage.xml" target="usage"/>
</target>
<!-- ############# -->
<!-- # CONFIGURE # -->
<!-- ############# -->
<!-- Configure user variables -->
<target name="user-configure"
depends="global-init">
<ant antfile="${antfile.dir}/user.xml" target="configure"/>
</target>
<!-- ######### -->
<!-- # PROXY # -->
<!-- ######### -->
<!-- Check proxy -->
<target name="proxy-check"
depends="global-init">
<ant antfile="${antfile.dir}/proxy.xml" target="check"/>
</target>
<!-- Set proxy -->
<target name="proxy-set"
depends="global-init,proxy-check">
<ant antfile="${antfile.dir}/proxy.xml" target="set"/>
</target>
<!-- ############ -->
<!-- # DOWNLOAD # -->
<!-- ############ -->
<!-- Download dependencies -->
<target name="dependencies-download"
depends="global-init,proxy-set">
<ant antfile="${antfile.dir}/dependencies.xml" target="download"/>
</target>
<!-- Remove current dependencies -->
<target name="dependencies-remove"
depends="global-init">
<ant antfile="${antfile.dir}/dependencies.xml" target="remove"/>
</target>
<!-- Remove old dependencies -->
<target name="dependencies-removeold"
depends="global-init">
<ant antfile="${antfile.dir}/dependencies.xml" target="removeold"/>
</target>
<!-- Remove all dependencies -->
<target name="dependencies-removeall"
depends="global-init">
<ant antfile="${antfile.dir}/dependencies.xml" target="removeall"/>
</target>
<!-- ######## -->
<!-- # STAF # -->
<!-- ######## -->
<target name="set-controller-type">
<property name="staf.type" value="controller"/>
</target>
<target name="set-slave-type">
<property name="staf.type" value="slave"/>
</target>
<!-- Install STAF and STAF services -->
<target name="staf-install"
depends="global-init,dependencies-download">
<ant antfile="${antfile.dir}/staf.xml" target="install"/>
</target>
<!-- Uninstall STAF and STAF services -->
<target name="staf-uninstall"
depends="global-init,staf-stop">
<ant antfile="${antfile.dir}/staf.xml" target="uninstall"/>
</target>
<!-- Start STAF -->
<target name="staf-start">
<antcall target="staf-controller-start"/>
</target>
<target name="staf-controller-start"
depends="set-controller-type,global-init,staf-install">
<var name="staf.type" value="controller"/>
<ant antfile="${antfile.dir}/staf.xml" target="start"/>
</target>
<target name="staf-slave-start"
depends="set-slave-type,global-init,staf-install">
<var name="staf.type" value="slave"/>
<ant antfile="${antfile.dir}/staf.xml" target="start"/>
</target>
<!-- Stop STAF -->
<target name="staf-stop"
depends="global-init">
<ant antfile="${antfile.dir}/staf.xml" target="stop"/>
</target>
<!-- Status STAF -->
<target name="staf-status"
depends="global-init">
<ant antfile="${antfile.dir}/staf.xml" target="status"/>
</target>
<!-- Start STAF GUI -->
<target name="staf-gui"
depends="global-init,staf-start">
<ant antfile="${antfile.dir}/staf.xml" target="gui"/>
</target>
<!-- Display STAF JVM logs -->
<target name="staf-jvmlogs"
depends="global-init,staf-start">
<ant antfile="${antfile.dir}/staf.xml" target="jvmlogs"/>
</target>
<!-- ######### -->
<!-- # TESTS # -->
<!-- ######### -->
<!-- generate tests specs -->
<target name="tests-specs"
depends="set-func-type,global-init">
<ant antfile="${antfile.dir}/tests.xml" target="specs"/>
</target>
<target name="set-func-type">
<property name="tests.type" value="functional-tests"/>
</target>
<target name="set-stress-type">
<property name="tests.type" value="stress-tests"/>
</target>
<!-- Configure tests to run -->
<target name="tests-configure">
<antcall target="tests-func-configure"/>
</target>
<!-- Configure functional tests to run -->
<target name="tests-func-configure"
depends="set-func-type,global-init">
<ant antfile="${antfile.dir}/tests.xml" target="configure"/>
</target>
<!-- Configure stress tests to run -->
<target name="tests-stress-configure"
depends="set-stress-type,global-init">
<ant antfile="${antfile.dir}/tests.xml" target="configure"/>
</target>
<!-- Run tests -->
<target name="tests-run">
<antcall target="tests-func-run"/>
</target>
<!-- Run functional tests -->
<target name="tests-func-run"
depends="set-func-type,global-init,opends-build,staf-start">
<ant antfile="${antfile.dir}/tests.xml" target="run"/>
</target>
<target name="tests-func-coverage"
depends="set-func-type,global-init,opends-build,staf-start">
<ant antfile="${antfile.dir}/tests.xml" target="testwithcoverage"/>
</target>
<!-- Run stress tests -->
<target name="tests-stress-run"
depends="set-stress-type,global-init,opends-build,staf-start">
<ant antfile="${antfile.dir}/tests.xml" target="run"/>
</target>
<!-- ########## -->
<!-- # OPENDS # -->
<!-- ########## -->
<!-- Build OpenDS zip -->
<target name="opends-build"
depends="global-init">
<ant antfile="${antfile.dir}/opends.xml" target="build"/>
</target>
</project>