diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
commit | 7b25b3886ea95bc6495506fbe9472e45fcbde684 (patch) | |
tree | 0b93cb65dab437feb46720659a63b8f1ef48f7f4 /uitest/integration_base_files | |
parent | 8941056349e302e687e40e94c13709e75f256d73 (diff) | |
download | vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.tar.gz vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.zip |
Renamed tests -> uitest and tests/testbench -> uitest/src (#9299)
Diffstat (limited to 'uitest/integration_base_files')
-rw-r--r-- | uitest/integration_base_files/base.xml | 124 | ||||
-rw-r--r-- | uitest/integration_base_files/cleanup.sh | 26 | ||||
-rw-r--r-- | uitest/integration_base_files/lock_age.sh | 21 |
3 files changed, 171 insertions, 0 deletions
diff --git a/uitest/integration_base_files/base.xml b/uitest/integration_base_files/base.xml new file mode 100644 index 0000000000..f9c2ff3d6b --- /dev/null +++ b/uitest/integration_base_files/base.xml @@ -0,0 +1,124 @@ +<?xml version="1.0"?> +<project name="test" basedir="."> + <property file="deploy.properties" /> + <property name="lock" value="deploy/lock.file" /> + <property name="deployDir" value="deploy/${server}" /> + <property name="serverPort" value="8080" /> + <property name="war" value="demo.war" /> + <property name="startupSpawn" value="false" /> + <property name="JAVA_HOME" value="/usr/lib/jvm/default-java" /> + <property name="waitMinutes" value="3" /> + <property name="waitUrl" value="http://localhost:${serverPort}/demo/VAADIN/themes/reindeer/styles.css" /> + <property name="shutdownWait" value="10" /> + + + <target name="afterDeploy"> + <!-- Empty default --> + </target> + + <target name="beforeDeploy"> + <!-- Empty default --> + </target> + + <target name="deploy"> + <antcall target="beforeDeploy" /> + <echo message="${server}: Deploying ${war} to ${deployDir}/${autodeployDir}" /> + <copy file="${war}" todir="${deployDir}/${autodeployDir}"/> + <antcall target="afterDeploy" /> + </target> + + <target name="deployStatic"> + <unzip src="${war}" dest="${staticDeployDir}"> + <patternset> + <include name="VAADIN/**" /> + </patternset> + </unzip> + </target> + + <target name="unpack-server"> + <echo message="${server}: Unpacking ${server}.tar.gz" /> + <delete dir="${server}" /> + <exec executable="tar"> + <arg value="-xf"/> + <arg value="${server}.tar.gz"/> + </exec> + <move file="${server}" tofile="${deployDir}" /> + <echo message="Done." /> + </target> + + <target name="doStartup"> + <exec executable="./run.sh" spawn="${startupSpawn}"> + <env key="JAVA_HOME" value="${JAVA_HOME}" /> + </exec> + </target> + + <target name="startup"> + <antcall target="doStartup" /> + <echo message="${server}: Waiting for ${waitUrl} to become available." /> + <waitfor maxwait="${waitMinutes}" maxwaitunit="minute" checkevery="10000" timeoutproperty="timeout"> + <http url="${waitUrl}" /> + </waitfor> + <!-- Print load averages to get an indicator on whether the server still attempts to start up --> + <exec executable="uptime" /> + <fail if="timeout" message="${server} failed to deploy" /> + + <echo message="${server}: Demo deployed successfully." /> + </target> + + <target name="shutdown"> + <exec executable="./stop.sh" > + <env key="JAVA_HOME" value="${JAVA_HOME}" /> + </exec> + <sleep seconds="${shutdownWait}" /> + </target> + + <target name="force-shutdown"> + <exec executable="./cleanup.sh" /> + </target> + + <target name="check-port"> + <fail message="${server}: Something is still listening on port ${serverPort}"> + <condition> + <socket server="localhost" port="${serverPort}" /> + </condition> + </fail> + </target> + + <target name="check-lock"> + <available file="${lock}" property="lockAvailable" /> + <fail unless="lockAvailable" message="Instance is not locked!" /> + </target> + + <target name="get-lock"> + <mkdir dir="deploy" /> + <echo>${server}: Getting the lock</echo> + <exec executable="lockfile" failonerror="true"> + <!-- Check every 10 seconds --> + <arg value="-10" /> + <!-- Retry for 55 minutes (build server gives up after 60 minutes) --> + <arg value="-r330" /> + <arg value="${lock}" /> + </exec> + <echo>${server}: Got the lock</echo> + </target> + + <target name="clean"> + <delete dir="${deployDir}" failonerror="false" /> + </target> + + <target name="release-lock"> +<!-- <exec executable="rm"> + <arg value="-f" /> + <arg value="${lock}" /> + </exec> --> + <delete> + <fileset dir="." includes="${lock}" /> + </delete> + <echo>${server}: Released the lock</echo> + </target> + + <target name="startup-and-deploy" depends="check-lock,check-port,unpack-server,deploy,startup" /> + + <target name="shutdown-and-cleanup" depends="shutdown,clean,release-lock,force-shutdown" /> + +</project> diff --git a/uitest/integration_base_files/cleanup.sh b/uitest/integration_base_files/cleanup.sh new file mode 100644 index 0000000000..42fb5a434d --- /dev/null +++ b/uitest/integration_base_files/cleanup.sh @@ -0,0 +1,26 @@ +#! /bin/bash +echo checking and killing open servers + +# Find all java processes, except +# * grep, as we're running it +# * get-lock, as that one is just waiting for this cleanup to happen +# * shutdown-and-cleanup, as that could be the one we're running from +ps x | grep -E bin/java | grep -v grep | grep -v get-lock | grep -v shutdown-and-cleanup | awk '{print $1}' > temp + +#Read and kill processes marked to temp +while read line +do + kill -9 $line +done < temp + +#Remove temp +rm temp + +if [ -a /home/integration/demo.war ] + then + echo removing old demo.war + rm /home/integration/demo.war +fi + +echo Cleaning deploy dir +rm -rf /home/integration/deploy/* diff --git a/uitest/integration_base_files/lock_age.sh b/uitest/integration_base_files/lock_age.sh new file mode 100644 index 0000000000..115a8fef79 --- /dev/null +++ b/uitest/integration_base_files/lock_age.sh @@ -0,0 +1,21 @@ +#! /bin/bash +if lockfile -r0 -! /home/integration/deploy/lock.file &> /dev/null + then + # If we could not get the lock, check how old the lock file is + DATE=$(date +%s) + # What if the file is not there any more? + LOCK_AGE=$(stat -c %Z /home/integration/deploy/lock.file) + + AGE=$[($DATE - $LOCK_AGE)/60] + + if [ "$AGE" -gt "20" ] + then + echo lock.file is $AGE min old. + ./cleanup.sh +# else +# echo lock.file is $AGE min old. + fi + else + # If we got the lock, do a cleanup (releasing the lock) just in case something has still been left running + ./cleanup.sh &> /dev/null +fi |