moz-grid-config/build.xml

162 строки
5.5 KiB
XML

<project name="selenium-grid" default="launch-node" basedir=".">
<property environment="env"/>
<exec executable="hostname" osfamily="unix" failifexecutionfails="false" outputproperty="env.COMPUTERNAME"/>
<property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/> <!-- Windows vs. Linux -->
<property file="${basedir}/${env.HOSTNAME}.properties" />
<property file="${basedir}/default.properties"/>
<target name="fetch-dependencies">
<mkdir dir="lib"/>
<get src="http://selenium.googlecode.com/files/selenium-server-standalone-${selenium.version}.jar"
dest="lib"
usetimestamp="true"
ignoreerrors="yes"/>
<available file="lib/selenium-server-standalone-${selenium.version}.jar" property="selenium.present"/>
<fail unless="selenium.present" message="Unable to locate lib/selenium-server-standalone-${selenium.version}.jar"/>
</target>
<target name="set-config">
<echo>os.name: ${os.name}</echo>
<condition property="node.configuration.file" value="mac.json">
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</condition>
<condition property="node.configuration.file" value="winvista.json">
<os name="Windows Vista"/>
</condition>
<condition property="node.configuration.file" value="win7.json">
<os name="Windows 7"/>
</condition>
<property name="node.configuration.file" value="default.json"/>
<echo>node.configuration.file: ${node.configuration.file}</echo>
</target>
<target name="set-hosts">
<!-- nodes that can't be addressed by hostname -->
<condition property="isNotAddressable">
<matches pattern="${nonaddressable.hostnames.regex}"
string="${env.HOSTNAME}"
casesensitive="false"/>
</condition>
<!-- production nodes -->
<condition property="isProduction">
<matches pattern="${production.hostnames.regex}"
string="${env.HOSTNAME}"
casesensitive="false"/>
</condition>
<!-- if this is a production node set the production hub host -->
<condition property="hub.host" value="${production.hub.host}">
<isset property="isProduction"/>
</condition>
<!-- otherwise set to localhost (unless overridden) -->
<property name="hub.host" value="localhost"/>
<!-- if this is a production node that can't be addressed then use IP -->
<condition property="node.host" value="IP">
<and>
<isset property="isProduction"/>
<isset property="isNotAddressable"/>
</and>
</condition>
<!-- if the hub is running on localhost then so must the node be -->
<condition property="node.host" value="localhost">
<matches pattern="localhost" string="${hub.host}"/>
</condition>
<!-- otherwise set to the hostname -->
<property name="node.host" value="${env.HOSTNAME}"/>
<echo>hub.host: ${hub.host}</echo>
<echo>node.host: ${node.host}</echo>
</target>
<path id="selenium.classpath">
<pathelement path="${basedir}/"/>
<fileset dir="${basedir}/lib">
<include name="selenium-server-standalone-${selenium.version}.jar"/>
</fileset>
<pathelement path="${java.class.path}/"/>
</path>
<!-- debug target to show variables -->
<target name="debug">
<echoproperties/>
</target>
<target name="launch-hub"
description="Launch Selenium Hub"
depends="fetch-dependencies">
<java classname="org.openqa.grid.selenium.GridLauncher"
classpathref="selenium.classpath"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="hub"/>
<arg value="-grid1Yml"/>
<arg value="grid_configuration.yml"/>
<arg value="-hubConfig"/>
<arg value="hub_configuration.json"/>
</java>
</target>
<target name="launch-node"
description="Launch Selenium Node"
depends="fetch-dependencies, set-config, set-hosts, launch-node-with-custom-profile, launch-node-without-custom-profile"/>
<target name="check-for-custom-profile">
<condition property="use.custom.profile">
<not>
<equals arg1="${custom.firefox.profile}" arg2="" />
</not>
</condition>
</target>
<target name="launch-node-with-custom-profile"
depends="check-for-custom-profile"
if="use.custom.profile">
<java classpathref="selenium.classpath"
classname="org.openqa.grid.selenium.GridLauncher"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="node"/>
<arg value="-hub"/>
<arg value="http://${hub.host}:${hub.port}/grid/register"/>
<arg value="-host"/>
<arg value="${node.host}"/>
<arg value="-nodeConfig"/>
<arg value="${node.configuration.file}"/>
<arg value="-firefoxProfileTemplate"/>
<arg value="${basedir}${file.separator}firefoxprofiles${file.separator}${custom.firefox.profile}"/>
<arg line="${rc.arguments}"/>
</java>
</target>
<target name="launch-node-without-custom-profile"
depends="check-for-custom-profile"
unless="use.custom.profile">
<java classpathref="remote-control.classpath"
classname="org.openqa.grid.selenium.GridLauncher"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="node"/>
<arg value="-hub"/>
<arg value="http://${hub.host}:${hub.port}/grid/register"/>
<arg value="-host"/>
<arg value="${node.host}"/>
<arg value="-nodeConfig"/>
<arg value="${node.configuration.file}"/>
<arg line="${rc.arguments}"/>
</java>
</target>
</project>