<!--
|
! 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
|
!
|
!
|
! Portions Copyright 2007 Sun Microsystems, Inc.
|
! -->
|
|
<project name="opends-staf-installer" 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>
|
|
<!-- installer wide settings - top -->
|
<property file="../../PRODUCT"/>
|
<property name="product.name"
|
value="${SHORT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}" />
|
<!-- this is the file where the default values are defined -->
|
<property file="staf-installer/staf-installer.properties" />
|
|
<!-- Define the os name in case we're on windows
|
why do this ?
|
the jvm returns different strings for os.name on different flavors
|
of windows ('Windows 2000', 'Windows 2003', 'Windows XP', ...)
|
-->
|
<condition property="os.myname" value="windows" else="${os.name}">
|
<os family="windows"/>
|
</condition>
|
|
<!-- Check if the current platform is supported -->
|
<condition property="platform.supported">
|
<available file="staf-installer/${os.myname}.properties"/>
|
</condition>
|
|
<!-- Load architecture specific properties
|
loading this one first allows to override common properties with platform
|
specific properties
|
-->
|
<property file="staf-installer/${os.myname}-${os.arch}-${sun.arch.data.model}.properties" />
|
<property file="staf-installer/${os.myname}-${os.arch}.properties" />
|
|
<!-- Load properties common to the OS regardless of architecture -->
|
<property file="staf-installer/${os.myname}.properties" />
|
|
<!-- Daily build properties -->
|
<tstamp>
|
<format property="todays.date" pattern="yyyyMMdd"/>
|
</tstamp>
|
<tstamp>
|
<format property="yesterdays.date" pattern="yyyyMMdd" offset="-24" unit="hour"/>
|
</tstamp>
|
<condition property="daily.date" value="${todays.date}" else="${yesterdays.date}">
|
<http url="${daily.build.url}/${todays.date}${daily.build.time}/${SHORT_NAME}/build/package/${product.name}.zip"/>
|
</condition>
|
<property name="daily.package.dir"
|
value="${staf.home}/daily-builds/${daily.date}"/>
|
<property name="daily.package"
|
value="${daily.package.dir}/${product.name}.zip"/>
|
<property name="daily.package.url"
|
value="${daily.build.url}/${daily.date}${daily.build.time}/${SHORT_NAME}/build/package/${product.name}.zip"/>
|
|
<!-- installer wide settings - bottom -->
|
|
<!-- Usage section - top -->
|
<!-- Default target => how to use this file -->
|
<target name="usage"
|
description="Gives a message that helps using this file">
|
<echo>Installer usage:
|
main targets=
|
usage : print this message
|
status : report if the staf is installed and running
|
bootstrap : install and start the staf
|
run-tests : run the functional tests (requires staf installed and started)
|
run-daily : run the functional tests on today's build
|
wipeout : stop and uninstall the staf
|
subtargets=
|
download : download the archives necessary to install the staf
|
install : install the staf
|
start : start the staf unless it is already running
|
stop : stop the staf if it is already running
|
uninstall : uninstall the staf if it is installed</echo>
|
</target>
|
<!-- Usage section - bottom -->
|
|
<!-- Downloader section - top -->
|
<target name="download-do-prepare-check-proxy">
|
<echo>Checking for proxy [${proxy.host}:${proxy.port}] as user [${proxy.user}].</echo>
|
<echo>Note: If these values do not match your environment, </echo>
|
<echo> please edit the following config file:</echo>
|
<echo> [${basedir}${file.separator}staf-installer${file.separator}staf-installer.properties]</echo>
|
<condition property="proxy.enabled">
|
<and>
|
<not>
|
<http url="${bits.download.url}"/>
|
</not>
|
<isreachable host="${proxy.host}" timeout="5"/>
|
</and>
|
</condition>
|
</target>
|
<target name="download-do-prepare-set-proxy" if="proxy.enabled" >
|
<echo>Proxy detected. Configuring.</echo>
|
<setproxy
|
proxyhost="${proxy.host}"
|
proxyport="${proxy.port}"
|
proxyuser="${proxy.user}"
|
proxypassword="${proxy.pass}"/>
|
</target>
|
<target
|
name="download-do-prepare"
|
depends="download-do-prepare-check-proxy,download-do-prepare-set-proxy">
|
<mkdir dir="${bits.download.dir}" />
|
</target>
|
<target name="download-do-failed" unless="bits.all.downloaded" >
|
<echo>Couldn't get the bits, sorry.</echo>
|
</target>
|
<target name="download-do-succeeded" if="bits.all.downloaded" >
|
<echo>Successfully downloaded all the archives needed for installation.</echo>
|
</target>
|
|
<target name="download-do-get-staf" unless="bits.staf.downloaded.before">
|
<get src="${bits.download.url}/${bits.staf.archive}"
|
dest="${bits.download.dir}/${bits.staf.archive}" />
|
<property name="bits.staf.downloaded" value="true"/>
|
</target>
|
|
<target name="download-do-get-stax" unless="bits.stax.downloaded.before">
|
<get src="${bits.download.url}/${bits.stax.archive}"
|
dest="${bits.download.dir}/${bits.stax.archive}" />
|
<property name="bits.stax.downloaded" value="true" />
|
</target>
|
|
<target name="download-do"
|
if="platform.supported"
|
depends="status-do,download-do-prepare,download-do-get-staf,download-do-get-stax">
|
<condition property="bits.all.downloaded" >
|
<and>
|
<or>
|
<isset property="bits.staf.downloaded"/>
|
<isset property="bits.staf.downloaded.before" />
|
</or>
|
<or>
|
<isset property="bits.stax.downloaded"/>
|
<isset property="bits.stax.downloaded.before" />
|
</or>
|
</and>
|
</condition>
|
<antcall target="download-do-succeeded" />
|
<antcall target="download-do-failed" />
|
</target>
|
|
<target name="download-dont" unless="platform.supported">
|
<echo>${os.myname}-${os.arch} is not a supported platform</echo>
|
</target>
|
|
<target name="download"
|
depends="status-do,download-do,download-dont"
|
description="Download the bits necessary to install staf"/>
|
|
<target name="download-daily" depends="status-do,download-do-prepare" unless="daily.package.downloaded">
|
<mkdir dir="${daily.package.dir}"/>
|
<get src="${daily.package.url}"
|
dest="${daily.package}"/>
|
</target>
|
|
<!-- Downloader section - bottom -->
|
|
<!-- Installation section - top -->
|
<target name="install-config" if="staf.install.successful">
|
<copy file="${staf.config.stubs}" tofile="${staf.config}">
|
<filterchain>
|
<expandproperties/>
|
</filterchain>
|
</copy>
|
</target>
|
|
<target name="install-stax" if="staf.install.successful">
|
<unzip
|
src="${bits.download.dir}/${bits.stax.archive}"
|
dest="${staf.install.dir}/services"/>
|
</target>
|
|
<target name="install-staf-jar"
|
description="deploy the staf bits"
|
if="staf.archive.is.jar">
|
<echo message="Installing staf, please wait, it'll take some time..." />
|
<java jar="${bits.download.dir}/${bits.staf.archive}" fork="true">
|
<arg value="-silent" />
|
<arg line="-W license.selection="Accept"" />
|
<arg line="-W stafinstalldirectory.defaultInstallLocation="${staf.install.dir}""/>
|
</java>
|
<condition property="staf.install.successful">
|
<available file="${staf.install.dir}/bin/STAF.cfg"/>
|
</condition>
|
</target>
|
|
<target name="install-staf-tar" if="staf.archive.is.tar">
|
<gunzip
|
src="${bits.download.dir}/${bits.staf.archive}"
|
dest="${bits.download.dir}"/>
|
<untar dest="${bits.download.dir}">
|
<fileset dir="${bits.download.dir}">
|
<include name="*.tar"/>
|
</fileset>
|
</untar>
|
<exec executable="${bits.download.dir}/staf/STAFInst">
|
<arg value="-source"/>
|
<arg value="${bits.download.dir}/staf"/>
|
<arg value="-target"/>
|
<arg value="${staf.install.dir}"/>
|
<arg value="-acceptlicense"/>
|
</exec>
|
<condition property="staf.install.successful">
|
<available file="${staf.install.dir}/bin/STAF.cfg"/>
|
</condition>
|
</target>
|
|
<target name="install-staf"
|
depends="install-staf-jar,install-staf-tar">
|
<fail unless="staf.install.successful" />
|
</target>
|
|
<target name="install-prepare" >
|
<mkdir dir="${staf.install.dir}"/>
|
<mkdir dir="${staf.install.dir}/services"/>
|
<mkdir dir="${staf.config.dir}"/>
|
</target>
|
|
<target name="install"
|
description="Perform framework installation"
|
depends="status-do,install-prepare,install-staf,install-stax,install-config"
|
if="bits.all.downloaded"/>
|
<!-- Installation section - bottom -->
|
|
<!-- Gui section - top -->
|
<target name="gui"
|
description="brings up the stax gui" >
|
<java classname="com.ibm.staf.service.stax.STAXMonitor"
|
classpath="${staf.install.dir}/services/stax/STAXMon.jar"
|
fork="true"
|
spawn="true"/>
|
</target>
|
<!-- Gui section - bottom -->
|
|
<!-- Run tests section - top -->
|
<target name="run-tests-prepare" depends="status-do" if="staf.running">
|
<condition property="staf.lib.dir"
|
value="${staf.install.dir}${file.separator}bin"
|
else="${staf.install.dir}${file.separator}lib">
|
<os family="windows"/>
|
</condition>
|
<taskdef name="staf" classname="com.ibm.staf.ant.taskdef.STAF">
|
<classpath>
|
<fileset dir="${staf.lib.dir}">
|
<include name="STAFAnt.jar"/>
|
<include name="JSTAF.jar"/>
|
</fileset>
|
</classpath>
|
</taskdef>
|
<!-- python config - top -->
|
<!-- 1. get a timestamp for step 3 -->
|
<tstamp>
|
<format property="tests.run.time" pattern="yyyy.MM.dd-HH.mm.ss"/>
|
</tstamp>
|
<condition property="product.package.path"
|
value="${daily.package.dir}"
|
else="${project.home}/build/package">
|
<isset property="tests.run.daily"/>
|
</condition>
|
<!-- make all the necessary directories for this test run -->
|
<mkdir dir="${staf.tmp.dir}"/>
|
<mkdir dir="${tests.run.dir}/${tests.run.time}"/>
|
<mkdir dir="${tests.run.dir}/${tests.run.time}/config"/>
|
<mkdir dir="${tests.run.dir}/${tests.run.time}/report"/>
|
<!-- 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}/server-logs"/>
|
|
<!-- 3. perform the config back up if necessary -->
|
<copy file="${tests.config}"
|
tofile="${tests.config.backup}"
|
overwrite="false"/>
|
<!-- 4. generate the timestamped 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>
|
<!-- 5. 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="/"/>
|
<!-- 6. copy the generated config in place of the previous one -->
|
<copy file="${tests.run.dir}/${tests.run.time}/config/${tests.config.file}"
|
tofile="${tests.config}"
|
overwrite="true"/>
|
<!-- python config - bottom -->
|
</target>
|
|
<target name="run-tests"
|
depends="status-do,run-tests-prepare"
|
if="staf.running">
|
<condition property="binary.extension" value=".exe" else="">
|
<or>
|
<os family="windows"/>
|
<os family="DOS"/>
|
</or>
|
</condition>
|
<property name="tests.request" value="EXECUTE FILE ${tests.xml} JOBNAME OpenDS_Functional_Tests SCRIPTFILE ${tests.config} SCRIPTFILE ${tests.python} WAIT CLEARLOGS"/>
|
<condition property="tests.replay.script" value="replay.bat" else="replay.sh">
|
<os family="windows"/>
|
</condition>
|
<echo>Generating replay script to allow you to re-execute the tests in the same conditions</echo>
|
<copy file="${staf.installer.dir}${file.separator}${tests.replay.script}"
|
tofile="${tests.run.dir}${file.separator}${tests.run.time}${file.separator}${tests.replay.script}">
|
<filterchain>
|
<expandproperties/>
|
</filterchain>
|
</copy>
|
<echo>Running tests. This will more than a while.</echo>
|
<!-- <staf location="LOCAL"
|
service="service"
|
request="list services"
|
/>
|
<staf location="LOCAL"
|
service="MISC"
|
request="VERSION"
|
resultPrefix="version"
|
throwBuildException="1"/>-->
|
|
<staf location="local"
|
service="STAX"
|
request="${tests.request}"
|
resultPrefix="staxjob"
|
throwBuildException="1"/>
|
<!-- restore the original config file to avoid it to be mistakenly commited
|
with the generated values -->
|
<copy file="${tests.config.backup}"
|
tofile="${tests.config}"
|
overwrite="true"/>
|
<delete file="${tests.config.backup}"/>
|
<echo file="${tests.run.dir}/last.run">${tests.run.time}</echo>
|
<echo>Saving server logs</echo>
|
<copy todir="${tests.run.dir}/${tests.run.time}/server-logs">
|
<fileset dir="${staf.tmp.dir}/${product.name}/logs"/>
|
</copy>
|
<echo>Saving Staf/Stax logs</echo>
|
<copy todir="${tests.run.dir}/${tests.run.time}/staf-logs">
|
<fileset dir="${staf.home}/logs"/>
|
</copy>
|
<delete dir="${staf.home}/logs" />
|
<echo>Saving report</echo>
|
<copy todir="${tests.run.dir}/${tests.run.time}/report">
|
<fileset dir="${staf.tmp.dir}">
|
<include name="r*"/>
|
</fileset>
|
</copy>
|
</target>
|
|
<target name="run-daily" depends="status-do,download-daily">
|
<property name="tests.run.daily" value="true"/>
|
<antcall target="run-tests"/>
|
</target>
|
<!-- Run tests section - bottom -->
|
|
<!-- Uninstallation section - top -->
|
<target name="uninstall-do"
|
description="Uninstall the staf"
|
if="staf.installed" >
|
<echo message="Uninstalling staf, please wait..." />
|
<java jar="${staf.install.dir}/_uninst/uninstall.jar" fork="true">
|
<arg value="-silent" />
|
</java>
|
<sleep seconds="5" />
|
<delete dir="${staf.install.dir}" />
|
</target>
|
|
|
<target name="uninstall-dont-not-installed" unless="staf.installed">
|
<echo>Staf is not installed.</echo>
|
</target>
|
<target name="uninstall-dont-running" if="staf.running">
|
<echo>Staf is running. Stop staf before uninstalling.</echo>
|
<echo>Use either the 'stop' or the 'wipeout' target.</echo>
|
</target>
|
<target
|
name="uninstall-dont"
|
depends="uninstall-dont-running,uninstall-dont-not-installed" />
|
|
<target name="uninstall" depends="status-do,uninstall-do,uninstall-dont">
|
</target>
|
<!-- Uninstallation section - bottom -->
|
|
<!-- Start section - top -->
|
<target name="start-do"
|
description="start the staf"
|
if="staf.installed"
|
unless="staf.running" >
|
<echo message="Starting staf ... on ${os.myname}" />
|
<condition
|
property="staf.executable"
|
value="${staf.install.dir}\bin\STAFProc.exe"
|
else="${staf.install.dir}/bin/STAFProc" >
|
<os family="windows"/>
|
</condition>
|
<echo>Running [${staf.executable}]</echo>
|
<property environment="env" />
|
<exec
|
dir="${staf.install.dir}/bin"
|
executable="${staf.executable}"
|
spawn="true">
|
<arg value="${staf.config}"/>
|
<env key="PATH" path="${java.home}${file.separator}bin${path.separator}${staf.install.dir}${file.separator}bin${path.separator}${env.PATH}"/>
|
<env key="LD_LIBRARY_PATH" path="${staf.install.dir}/lib"/>
|
<env key="CLASSPATH" path="${staf.install.dir}/bin/JSTAF.jar${path.separator}${env.CLASSPATH}"/>
|
<env key="STAFCONVDIR" value="${staf.install.dir}/codepage"/>
|
<env key="STAFCODEPAGE" value="LATIN_1"/>
|
<env key="STAF_INSTANCE_NAME" value="STAF"/>
|
</exec>
|
</target>
|
<target name="start-dont" if="staf.running">
|
<echo>Staf is already running.</echo>
|
</target>
|
<target name="start" depends="status-do">
|
<antcall target="start-do"/>
|
<antcall target="start-dont"/>
|
</target>
|
<!-- Start section - bottom -->
|
|
<!-- Stop section - top -->
|
<target name="stop-do" if="staf.running">
|
<echo>Stopping staf...</echo>
|
<condition
|
property="staf.executable"
|
value="${staf.install.dir}\bin\STAF.exe"
|
else="${staf.install.dir}/bin/STAF" >
|
<os family="windows"/>
|
</condition>
|
<exec
|
executable="${staf.executable}"
|
spawn="true" >
|
<arg line="local shutdown shutdown"/>
|
</exec>
|
<echo>staf has been instructed to close the shop.</echo>
|
<echo>Please allow some time as staf wipes the plate clean</echo>
|
</target>
|
<target name="stop-dont" unless="staf.running">
|
<echo>Staf is not running.</echo>
|
</target>
|
<target name="stop" depends="status-do">
|
<antcall target="stop-do"/>
|
<antcall target="stop-dont"/>
|
</target>
|
<!-- Stop section - bottom -->
|
|
<!-- Status section - top -->
|
<!-- Bits status section - top -->
|
<target name="status-archive-downloaded?" if="bits.all.downloaded.before">
|
<echo>Staf bits are ready to be installed. Use 'install' target.</echo>
|
</target>
|
<target name="status-archive-not-downloaded?" unless="bits.all.downloaded.before">
|
<echo>No staf bits found. Use the get-bits or bootstrap target.</echo>
|
</target>
|
<!-- Bits status section - bottom -->
|
|
<!-- Installation status section - top -->
|
<target name="status-staf-installed?" if="staf.installed">
|
<echo>Found staf installed in [${staf.install.dir}]</echo>
|
<antcall target="status-staf-running?" />
|
<antcall target="status-staf-not-running?" />
|
</target>
|
<target name="status-staf-not-installed?" unless="staf.installed">
|
<echo>Could not find staf installation.</echo>
|
<echo>Checking if the bits here and ready for installation...</echo>
|
<antcall target="status-archive-downloaded?" />
|
<antcall target="status-archive-not-downloaded?" />
|
</target>
|
<!-- Installation status section - bottom -->
|
|
<!-- Running status section - top -->
|
<target name="status-staf-running?" if="staf.running">
|
<echo>staf is listening on port [${staf.port.default}]</echo>
|
<echo>You're all set to run the functional tests.</echo>
|
</target>
|
<target name="status-staf-not-running?" unless="staf.running">
|
<echo>staf is NOT running. Use the 'start' target.</echo>
|
</target>
|
<!-- Running status section - bottom -->
|
|
|
<!-- Get status section - top -->
|
<target name="status-do" unless="status-do.already.run" >
|
<!-- check if the various archives needed have already been downloaded -->
|
<condition property="bits.staf.downloaded.before">
|
<available file="${bits.download.dir}/${bits.staf.archive}"/>
|
</condition>
|
<condition property="bits.stax.downloaded.before" >
|
<available file="${bits.download.dir}/${bits.stax.archive}" />
|
</condition>
|
<condition property="bits.all.downloaded.before">
|
<and>
|
<isset property="bits.staf.downloaded.before"/>
|
<isset property="bits.stax.downloaded.before"/>
|
</and>
|
</condition>
|
<available file="${daily.package}" property="daily.package.downloaded"/>
|
|
<available file="${staf.install.dir}"
|
type="dir"
|
property="staf.installed" />
|
|
<condition property="staf.running">
|
<socket port="${staf.port}" server="${host.name}"/>
|
</condition>
|
|
<condition property="staf.archive.is.jar">
|
<contains string="${bits.staf.archive}" substring=".jar"/>
|
</condition>
|
<condition property="staf.archive.is.tar">
|
<not>
|
<contains string="${bits.staf.archive}" substring=".jar"/>
|
</not>
|
</condition>
|
<property name="status-do.already.run" value="true"/>
|
</target>
|
<!-- Get status section - bottom -->
|
|
<!-- Status cli section - top -->
|
<target name="status" depends="status-do">
|
<condition property="is.platform.supported" value="yes" else="no" >
|
<isset property="platform.supported"/>
|
</condition>
|
<echo>Operating System Family - ${os.myname}</echo>
|
<echo>Operating System Name - ${os.name}</echo>
|
<echo>Operating System Version - ${os.version}</echo>
|
<echo>Machine Architecture - ${os.arch}</echo>
|
<echo>Platform Supported - ${is.platform.supported}</echo>
|
<echo>Java Version - ${java.version}</echo>
|
<antcall target="status-staf-installed?" />
|
<antcall target="status-staf-not-installed?" />
|
</target>
|
<!-- Status cli section - bottom -->
|
<!-- Status section - bottom -->
|
|
<!-- Macros section - top -->
|
<target name="bootstrap">
|
<antcall target="download" />
|
<antcall target="install" />
|
<antcall target="start" />
|
</target>
|
|
<target name="wipeout">
|
<antcall target="stop"/>
|
<sleep seconds="10"/>
|
<antcall target="uninstall"/>
|
</target>
|
<!-- Macros section - bottom -->
|
</project>
|