1<project name="Targets to run Automated Tests Locally and Remotely" default="main" basedir="."> 2 3<!-- 4This script must be called with the ${tester} property set. 5 6The testing.properties file must contain definitions for all other properties in this script if they are not 7set in a calling script or command line. See test.properties.template for property descriptions. 8--> 9 10<property name="customTest" value="${tester}/customTest.xml" /> 11<property name="testing.properties" value="${tester}/testing.properties" /> 12<property file="${testing.properties}" /> 13<property name="dropLocation" value="${buildDirectory}" /> 14 15<target name="main"> 16 <antcall target="${testTarget}" /> 17</target> 18 19<!-- 20Targets for setting up and running tests remotely 21It is assumed that keys are set up on test machines to permit connections without user name and password prompts. 22--> 23<target name="runtests-remote" depends="setRemoteLoginClient,setRemoteCopyClient"> 24 <property name="testResults" value="${dropLocation}/${buildLabel}/testresults" /> 25 26 <exec dir="." executable="${loginClient}"> 27 <arg line="${testMachine} mkdir ${testDir}" /> 28 </exec> 29 30 <!--install the vm used for testing--> 31 <antcall target="installVmForRemote" /> 32 33 <!--set up the automated testing framework--> 34 <exec dir="." executable="${copyClient}"> 35 <arg line="${dropLocation}/${buildLabel}/${testFramework} ${testMachine}:${testDir}" /> 36 </exec> 37 <exec dir="." executable="${loginClient}"> 38 <arg line="${testMachine} unzip -o -qq ${testDir}/${testFramework} -d ${testDir}" /> 39 </exec> 40 <exec dir="." executable="${copyClient}"> 41 <arg line="${dropLocation}/${buildLabel}/${runtime} ${testMachine}:${executionDir}" /> 42 </exec> 43 44 <!--callback to custom script for post setup--> 45 <ant antfile="${customTest}" target="customSetup" dir="${basedir}"/> 46 47 <exec dir="." executable="${loginClient}"> 48 <arg line="${testMachine} ${testScript} ${args}" /> 49 </exec> 50 51 <!--${testResults} and ${testResults}/consolelogs must exist before rcp and scp copy operations. 52 Directories contents are copied flattened if the destination directories don't exist.--> 53 <mkdir dir="${testResults}/consolelogs" /> 54 55 <exec dir="." executable="${copyClient}"> 56 <arg line="-r ${testMachine}:${executionDir}/results/* ${testResults}"/> 57 </exec> 58 <!-- copy the console log from testing --> 59 <exec dir="." executable="${copyClient}"> 60 <arg line="-r ${testMachine}:${executionDir}/${consolelog} ${testResults}/consolelogs"/> 61 </exec> 62</target> 63 64<target name="setRemoteLoginClient"> 65 <!--use rsh if rsh is set, otherwise use default, ssh--> 66 <condition property="loginClient" value="rsh"> 67 <isset property="rsh" /> 68 </condition> 69 <!--default remote login client--> 70 <property name="loginClient" value="ssh" /> 71</target> 72 73<target name="setRemoteCopyClient"> 74 <!--use rcp if rsh is set, otherwise use default, scp--> 75 <condition property="copyClient" value="rcp"> 76 <isset property="rsh" /> 77 </condition> 78 <!--default remote copy client--> 79 <property name="copyClient" value="scp" /> 80</target> 81 82<target name="installVmForRemote" unless="skipVmInstall"> 83 <available file="${vmDest}" property="vmExists" /> 84 <antcall target="getVM" /> 85 86 <exec dir="." executable="${copyClient}"> 87 <arg line="${vmDest} ${testMachine}:${testDir}" /> 88 </exec> 89 90 <exec dir="." executable="${loginClient}"> 91 <arg line="${testMachine} ${vmInstallCommand}" /> 92 </exec> 93</target> 94 95 96<!-- 97 98Targets for setting up and running tests locally 99 100--> 101<target name="runtests-local"> 102 <delete dir="${testDir}" quiet="true"/> 103 <mkdir dir="${testDir}" /> 104 <property name="testResults" value="${dropLocation}/${buildLabel}/testresults" /> 105 106 <!--set up testing directory--> 107 <unzip src="${dropLocation}/${buildLabel}/${testFramework}" dest="${testDir}" /> 108 109 <!--install the vm used for testing--> 110 <antcall target="installVmForLocal" /> 111 112 <!--copy in the runtime to test--> 113 <copy todir="${executionDir}" file="${dropLocation}/${buildLabel}/${runtime}" /> 114 115 <!--callback to custom script for additional setup--> 116 <ant antfile="${customTest}" target="customSetup" dir="${basedir}" /> 117 118 <!--run the tests--> 119 <exec dir="${executionDir}" executable="${testExecutable}"> 120 <arg line="${args}" /> 121 </exec> 122 123 <mkdir dir="${testResults}" /> 124 <mkdir dir="${testResults}/consolelogs" /> 125 126 <copy todir="${testResults}"> 127 <fileset dir="${executionDir}/results" /> 128 </copy> 129 130 <copy todir="${testResults}/consolelogs" file="${executionDir}/${consolelog}" /> 131</target> 132 133<target name="installVmForLocal" unless="skipVmInstall"> 134 <available file="${vmDest}" property="vmExists" /> 135 <antcall target="getVM" /> 136 <exec dir="${testDir}" executable="${vmInstallExecutable}"> 137 <arg line="${vmInstallCommand}" /> 138 </exec> 139</target> 140 141<target name="getVM" unless="vmExists"> 142 <get src="${vmUrl}" dest="${vmDest}" usetimestamp="true"/> 143</target> 144 145</project>