1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<project name="Targets to run Automated Tests Locally and Remotely" default="main" basedir=".">
2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<!--
4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollThis script must be called with the ${tester} property set.
5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollThe testing.properties file must contain definitions for all other properties in this script if they are not
7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollset in a calling script or command line.  See test.properties.template for property descriptions.
8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll-->
9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<property name="customTest" value="${tester}/customTest.xml" />
11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<property name="testing.properties" value="${tester}/testing.properties" />
12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<property file="${testing.properties}" />
13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<property name="dropLocation" value="${buildDirectory}" />
14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="main">
16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<antcall target="${testTarget}" />
17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<!--
20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollTargets for setting up and running tests remotely
21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollIt is assumed that keys are set up on test machines to permit connections without user name and password prompts.
22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll-->
23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="runtests-remote" depends="setRemoteLoginClient,setRemoteCopyClient">
24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<property name="testResults" value="${dropLocation}/${buildLabel}/testresults" />
25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${loginClient}">
27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${testMachine} mkdir ${testDir}" />
28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--install the vm used for testing-->
31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<antcall target="installVmForRemote" />
32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--set up the automated testing framework-->
34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${copyClient}">
35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${dropLocation}/${buildLabel}/${testFramework} ${testMachine}:${testDir}" />
36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${loginClient}">
38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${testMachine} unzip -o -qq ${testDir}/${testFramework} -d ${testDir}" />
39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${copyClient}">
41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${dropLocation}/${buildLabel}/${runtime} ${testMachine}:${executionDir}" />
42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--callback to custom script for post setup-->
45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<ant antfile="${customTest}" target="customSetup" dir="${basedir}"/>
46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${loginClient}">
48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${testMachine} ${testScript} ${args}" />
49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--${testResults} and ${testResults}/consolelogs must exist before rcp and scp copy operations.
52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	  Directories contents are copied flattened if the destination directories don't exist.-->
53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<mkdir dir="${testResults}/consolelogs" />
54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${copyClient}">
56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="-r ${testMachine}:${executionDir}/results/* ${testResults}"/>
57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--  copy the console log from testing  -->
59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${copyClient}">
60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="-r ${testMachine}:${executionDir}/${consolelog} ${testResults}/consolelogs"/>
61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="setRemoteLoginClient">
65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--use rsh if rsh is set, otherwise use default, ssh-->
66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<condition property="loginClient" value="rsh">
67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<isset property="rsh" />
68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</condition>
69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--default remote login client-->
70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<property name="loginClient" value="ssh" />	
71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="setRemoteCopyClient">
74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--use rcp if rsh is set, otherwise use default, scp-->
75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<condition property="copyClient" value="rcp">
76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<isset property="rsh" />
77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</condition>
78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--default remote copy client-->
79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<property name="copyClient" value="scp" />	
80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="installVmForRemote" unless="skipVmInstall">
83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<available file="${vmDest}" property="vmExists" />
84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<antcall target="getVM" />
85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${copyClient}">
87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${vmDest} ${testMachine}:${testDir}" />
88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="." executable="${loginClient}">
91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${testMachine} ${vmInstallCommand}" />
92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<!--
97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollTargets for setting up and running tests locally
99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll-->
101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="runtests-local">
102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<delete dir="${testDir}" quiet="true"/>
103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<mkdir dir="${testDir}" />
104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<property name="testResults" value="${dropLocation}/${buildLabel}/testresults" />
105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--set up testing directory-->
107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<unzip src="${dropLocation}/${buildLabel}/${testFramework}" dest="${testDir}" />
108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--install the vm used for testing-->
110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<antcall target="installVmForLocal" />
111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	
112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--copy in the runtime to test-->
113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<copy todir="${executionDir}" file="${dropLocation}/${buildLabel}/${runtime}" />
114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--callback to custom script for additional setup-->
116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<ant antfile="${customTest}" target="customSetup" dir="${basedir}" />
117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<!--run the tests-->
119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="${executionDir}" executable="${testExecutable}">
120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll  		<arg line="${args}" />
121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<mkdir dir="${testResults}" />
124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<mkdir dir="${testResults}/consolelogs" />
125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<copy todir="${testResults}">
127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<fileset dir="${executionDir}/results" />
128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</copy>
129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<copy todir="${testResults}/consolelogs" file="${executionDir}/${consolelog}" />
131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="installVmForLocal" unless="skipVmInstall">
134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<available file="${vmDest}" property="vmExists" />
135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<antcall target="getVM" />
136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<exec dir="${testDir}" executable="${vmInstallExecutable}">	
137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		<arg line="${vmInstallCommand}" />
138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	</exec>
139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll<target name="getVM" unless="vmExists">
142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	<get src="${vmUrl}" dest="${vmDest}" usetimestamp="true"/>
143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</target>
144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll</project>