303564  -  Run performance tests against the WTP
diff --git a/releng.wtpbuilder/distribution/wtp.tests/perfbuild.xml b/releng.wtpbuilder/distribution/wtp.tests/perfbuild.xml
new file mode 100644
index 0000000..4212b71
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.tests/perfbuild.xml
@@ -0,0 +1,382 @@
+<project
+    name="Build specific targets and properties"
+    default="runTest">
+    <!--
+        Note to be cross-platform, "environment variables" are only
+        appropriate for some variables, e.g. ones we set, since
+        properties are case sensitive, even if the environment variables
+        on your operating system are not, e.g. it will be ${env.Path}
+        not ${env.PATH} on Windows
+    -->
+    <property
+        environment="env"/>
+    <fail
+        message="testRoot must be set for this task"
+        unless="testRoot"/>
+    <!-- required to get proper value of dropinsFolder -->
+    <property
+        name="keyCfgFile"
+        value="${env.PROJECT_BUILDERS}/${projectname}/${env.RELENG}/maps/build.cfg"/>
+    <echo
+        level="info"
+        message="keyCfgFile: ${keyCfgFile}"/>
+    <property
+        file="${keyCfgFile}"/>
+    <!--
+        typcially already set, but in case of standalone tests, may not
+        be
+    -->
+    <property
+        name="buildLabel"
+        value="${buildType}-${buildId}-${timestamp}"/>
+
+
+    <!-- 
+      Steps to do after the build is done. 
+    -->
+    <target
+        name="test">
+        <dirname
+            file="${ant.file}"
+            property="currentDirectory"/>
+        <ant
+            antfile="${ant.file}"
+            target="runTest"
+            dir="${currentDirectory}"/>
+    </target>
+
+    <!-- 
+        Steps to do to test the build results
+    -->
+    <target
+        name="runTest">
+        <dirname
+            file="${ant.file}"
+            property="test.component.dir"/>
+        <ant
+            antfile="${wtp.builder.home}/scripts/build/label.xml"/>
+        <property
+            file="${buildDirectory}/label.properties"/>
+        <property
+            file="${wtp.builder.home}/build.properties"/>
+        <fail
+            message="testRoot must be set for this task"
+            unless="testRoot"/>
+        <mkdir
+            dir="${testRoot}"/>
+
+        <!-- if results already exist, delete them -->
+        <delete
+            dir="${testRoot}/results"
+            failOnError="false"/>
+        <mkdir
+            dir="${testRoot}/results"/>
+        <mkdir
+            dir="${testRoot}/results/consolelogs"/>
+        <copy
+            todir="${testRoot}"
+            overwrite="true">
+            <fileset
+                dir="${test.component.dir}/testScripts"/>
+        </copy>
+        <echo
+            message="BASEOS: ${env.BASEOS}   BASEWS: ${env.BASEWS}   BASEARCH: ${env.BASEARCH} "/>
+        <!--
+            for this distribution, dependencies come from releng. Assume
+            no subdirectory, if not otherwise set (bug 285383).
+        -->
+        <property
+            name="env.DEP_DIR"
+            value=""/>
+        <property
+            name="dependency.properties"
+            value="${buildDirectory}/maps/${env.RELENG}${env.DEP_DIR}/maps/dependencies.properties"/>
+        <available
+            file="${dependency.properties}"
+            property="dependency.properties.exists"/>
+        <fail
+            message="dependency file not found: ${dependency.properties}"
+            unless="dependency.properties.exists"/>
+        <ant
+            antfile="${test.component.dir}/testdependency.xml"
+            target="get">
+            <property
+                name="base.install.dir"
+                value="${testRoot}"/>
+        </ant>
+        <antcall
+            target="unzipTests"/>
+        <antcall
+            target="runTestEclipse">
+            <param
+                name="testTarget"
+                value="all"/>
+        </antcall>
+        <antcall
+            target="postRunTestEclipse">
+            <param
+                name="testTarget"
+                value="all"/>
+        </antcall>
+    </target>
+    <target
+        name="unzipTests">
+        <!--
+            unzip the builds and junit tests we use 'unzip' here, so we
+            can continue on error, if desired. (such as if zip was not
+            created, due to other failures or options).
+        -->
+        <exec
+            dir="${buildDirectory}/${buildLabel}"
+            executable="unzip"
+            failonerror="true">
+            <arg
+                line="-o -qq wtp-sdk-${buildLabel}.zip -d ${testRoot}${dropinsFolder}"/>
+        </exec>
+        <exec
+            dir="${buildDirectory}/${buildLabel}"
+            executable="unzip"
+            failonerror="false">
+            <arg
+                line="-o -qq wtp-wst-Automated-Tests-${buildLabel}.zip -d ${testRoot}${dropinsFolder}"/>
+        </exec>
+        <exec
+            dir="${buildDirectory}/${buildLabel}"
+            executable="unzip"
+            failonerror="false">
+            <arg
+                line="-o -qq wtp-jst-Automated-Tests-${buildLabel}.zip -d ${testRoot}${dropinsFolder}"/>
+        </exec>
+        <exec
+            dir="${buildDirectory}/${buildLabel}"
+            executable="unzip"
+            failonerror="false">
+            <arg
+                line="-o -qq wtp-jpt-sdk-${buildLabel}.zip -d ${testRoot}${dropinsFolder}"/>
+        </exec>
+        <exec
+            dir="${buildDirectory}/${buildLabel}"
+            executable="unzip"
+            failonerror="true">
+            <arg
+                line="-o -qq wtp-jpt-Automated-Tests-${buildLabel}.zip -d ${testRoot}${dropinsFolder}"/>
+        </exec>
+    </target>
+    <!--
+        time out may need to be set/adjust for api or performance tests?
+        This testTimeLimit is the whole, overall limit on tests. There's
+        a shorter one for individual suites. some common values, of
+        milliseconds to more recognizable units: 
+        18000000: 5 hours
+        14400000: 4 hours
+        7200000: 2 hours 
+        3600000: 1 hour  
+        1800000: 30 minutes 
+        600000: 10 minutes
+    -->
+    <property
+        name="testTimeLimit"
+        value="36000000"/>
+    <property
+        name="testFailOnError"
+        value="false"/>
+    <target
+        name="runTestEclipse"
+        description="Run our JUnit's within an instance of antRunner">
+        <property
+            name="test-vm"
+            value="${env.JAVA_6_HOME}/bin/java"/>
+       <!--
+            set path to eclipse folder. If local folder, use '.';
+            otherwise, use c:\path\to\eclipse or /path/to/eclipse/
+        -->
+        <property
+            name="eclipse.home"
+            value="${testRoot}"/>
+        <echo
+            message="testTarget: ${testTarget}"/>
+        <!--
+            can not pass in empty values in jvmargs so if not testBundle
+            specified, we'll pass a junk (unused) value
+        -->
+        <condition
+            property="testBundleParam"
+            value="-DtestBundle=${testBundle}"
+            else="-Dunused=nouse">
+            <isset
+                property="testBundle"/>
+        </condition>
+        <echo
+            message="Running junits"/>
+        <!--
+            If there is not exactly one launcher in the stack, we'd best
+            fail fast, since we are not expecting that, and may indicate
+            an installation that would produce unpredictable results
+        -->
+        <!--
+            requires ant 1.7, and at this point, we're running 1.6 from
+            eclipse ... <condition property="expectedNumberOfLaunchers">
+            <resourcecount when="equal" count="1" > <fileset
+            dir="${testRoot}/eclipse/plugins"> <include
+            name="org.eclipse.equinox.launcher_*.jar" /> </fileset>
+            </resourcecount> </condition> <fail message="Did not find
+            expected number of launcher jars. Check installation."
+            unless="expectedNumberOfLaunchers" />
+        -->
+        <!--
+            Remember: using dash 'debug' for org.eclipse.ant.core.antRunner
+            produces ant debug info to be output ... which is a TON of
+            stuff. Even 'verbose' is a bit too much.
+        -->
+        <echo
+            message="eclipse.launcher: ${eclipse.launcher}"/>
+        <java
+            taskname="unit-test-masterprocess"
+            fork="true"
+            resultProperty="wtpmasterjunitresult"
+            failonerror="false"
+            timeout="${testTimeLimit}"
+            dir="${testRoot}/eclipse"
+            jvm="${env.JAVA_6_HOME}/bin/java"
+            classname="org.eclipse.equinox.launcher.Main">
+            <classpath>
+                <fileset
+                    dir="${testRoot}/eclipse/plugins">
+                    <include
+                        name="org.eclipse.equinox.launcher_*.jar"/>
+                </fileset>
+            </classpath>
+            <jvmarg
+                value="-Dosgi.ws=${env.BASEWS}"/>
+            <jvmarg
+                value="-Dosgi.os=${env.BASEOS}"/>
+            <jvmarg
+                value="-Dosgi.arch=${env.BASEARCH}"/>
+            <jvmarg
+                value="-Dws=${env.BASEWS}"/>
+            <jvmarg
+                value="-Dos=${env.BASEOS}"/>
+            <jvmarg
+                value="-Darch=${env.BASEARCH}"/>
+            <jvmarg
+                value="-DbuildBranch=${buildBranch}"/>
+            <jvmarg
+                value="-DbuildType=${buildType}"/>
+            <jvmarg
+                value="-DbuildId=${buildId}"/>
+            <jvmarg
+                value="-Dprojectname=${projectname}"/>
+            <jvmarg
+                value="-Djava.io.tmpdir=${env.RECOMMENDED_TMP_DIR}"/>
+            <jvmarg
+            	value="-Dorg.eclipse.jst.server.tomcat.50=${testRoot}/jakarta-tomcat-5.0.28"/>
+            <jvmarg
+                value="${testBundleParam}"/>
+            <arg
+                value="-nosplash"/>
+            <arg
+                value="-consolelog"/>
+            <arg
+                value="-data"/>
+            <arg
+                value="${testRoot}/overallTestWorkspace"/>
+            <arg
+                value="-application"/>
+            <arg
+                value="org.eclipse.ant.core.antRunner"/>
+            <arg
+                value="-logger"/>
+            <arg
+                value="org.apache.tools.ant.DefaultLogger"/>
+            <arg
+                value="-file"/>
+            <arg
+                value="${testRoot}/perftest.xml"/>
+            <arg
+                value="${testTarget}"/>
+
+            <!--  make sure our forked env has a DISPLAY -->
+            <env
+                key="DISPLAY"
+                value="${env.DISPLAY}"/>
+            <redirector
+                output="${testRoot}/results/fullOutput.txt"
+                error="${testRoot}/results/fullErrorLog.txt"/>
+            <jvmarg
+                value="-Dbuild.home=${env.BUILD_HOME}"/>
+            <jvmarg
+                value="-DbuildDirectory=${buildDirectory}"/>
+            <jvmarg
+                value="-DbuildLabel=${buildLabel}"/>
+            <jvmarg
+                value="-DbaseLocation=${baseLocation}"/>
+            <jvmarg
+                value="-DtestRoot=${testRoot}"/>
+            <jvmarg
+                value="-DtestDir=${testRoot}"/>
+            <jvmarg
+                value="-DeclipseBuilderDirectory=${pde.builder.path}"/>
+            <!-- IBM_JAVA_OPTIONS contains JIT work arounds for bug 284441 -->
+            <env
+                key="IBM_JAVA_OPTIONS"
+                value="-Xjit:{org/eclipse/wst/html/core/internal/contenttype/HTMLHeadTokenizer.primGetNextToken()Ljava/lang/String;}(disableLookahead),{org/eclipse/jst/jsp/core/internal/parser/internal/JSPTokenizer.primGetNextToken()Ljava/lang/String;}(disableLookahead)"/>
+        </java>
+        <echo
+            message="wtpmasterjunitresult ${wtpmasterjunitresult}"/>
+    </target>
+    <target
+        name="postRunTestEclipse">
+        <copy
+            todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testLogs"
+            overwrite="true"
+            failonerror="false">
+            <fileset
+                dir="${testRoot}/results">
+                <include
+                    name="*output.txt"/>
+            </fileset>
+        </copy>
+        <copy
+            todir="${buildDirectory}/${buildLabel}/testResults/consolelogs/testSysErrorLogs"
+            overwrite="true"
+            failonerror="false">
+            <fileset
+                dir="${testRoot}/results">
+                <include
+                    name="*error.txt"/>
+            </fileset>
+        </copy>
+        <copy
+            file="${testRoot}/results/fullOutput.txt"
+            toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
+            overwrite="true"
+            failonerror="false">
+        </copy>
+        <copy
+            file="${testRoot}/results/fullErrorLog.txt"
+            toDir="${buildDirectory}/${buildLabel}/testResults/consolelogs/full"
+            overwrite="true"
+            failonerror="false">
+        </copy>
+        <copy
+            todir="${buildDirectory}/${buildLabel}/testResults/xml"
+            overwrite="true"
+            failonerror="false">
+            <fileset
+                dir="${testRoot}/results/xml">
+                <include
+                    name="*.xml"/>
+            </fileset>
+        </copy>
+        <copy
+            todir="${buildDirectory}/${buildLabel}/testResults/html"
+            overwrite="true"
+            failonerror="false">
+            <fileset
+                dir="${testRoot}/results/html">
+                <include
+                    name="*.html"/>
+            </fileset>
+        </copy>
+    </target>
+</project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/distribution/wtp.tests/testScripts/perftest.xml b/releng.wtpbuilder/distribution/wtp.tests/testScripts/perftest.xml
new file mode 100644
index 0000000..59c2fea
--- /dev/null
+++ b/releng.wtpbuilder/distribution/wtp.tests/testScripts/perftest.xml
@@ -0,0 +1,156 @@
+<project
+    name="Automated Eclipse Testing"
+    default="all"
+    basedir=".">
+    <property
+        environment="env"/>
+    <!-- required to get proper value of dropinsFolder -->
+    <property
+        name="keyCfgFile"
+        value="${env.PROJECT_BUILDERS}/${projectname}/${env.RELENG}/maps/build.cfg"/>
+    <echo
+        level="info"
+        message="keyCfgFile: ${keyCfgFile}"/>
+    <property
+        file="${keyCfgFile}"/>
+    <echo
+        level="info"
+        message="starting Automated Eclipse Testing"/>
+    <echo
+        level="info"
+        message="ant file basedir: ${basedir}"/>
+    <echo
+        level="info"
+        message="testRoot: ${testRoot}"/>
+    <fail
+        message="testRoot must be set"
+        unless="testRoot"/>
+
+    <!--properties file containing the some server name properties -->
+    <property
+        file="${testRoot}/testServer.properties"/>
+
+    <!--properties file containing the build information-->
+    <property
+        file="${buildDirectory}/label.properties"/>
+    <!-- required to get proper value of dropinsFolder -->
+    <property
+        name="keyCfgFile"
+        value="${env.PROJECT_BUILDERS}/${projectname}/${env.RELENG}/maps/build.cfg"/>
+    <echo
+        level="info"
+        message="keyCfgFile: ${keyCfgFile}"/>
+    <property
+        file="${keyCfgFile}"/>
+
+    <!--
+        name that can be added to report name to identify which platform
+        tests results come from
+    -->
+    <property
+        name="platform"
+        value=""/>
+
+    <!-- TODO: The framework apps might need this. But we should elmimnate if posslbe. -->
+    <property
+        name="eclipse-home"
+        value="${testRoot}"/>
+    <!--
+        The directory that will contain the xml and html results from
+        the tests that are run
+    -->
+    <property
+        name="results"
+        value="${testRoot}/results"/>
+    <property
+        name="library-file"
+        value="${testRoot}/wtp-junit-tests.xml"/>
+
+    <!-- jonas install directory -->
+    <!-- TODO: why do this twice? Here and in init? -->
+    <property
+        name="jonas432Dir"
+        value="${testRoot}/${jonas432DirName}"/>
+    <target
+        name="init">
+        <antcall
+            target="setPropertyJOnAS432Dir"/>
+    </target>
+    <target
+        name="setPropertyJOnAS432Dir"
+        unless="jonas432Dir">
+        <property
+            name="jonas432Dir"
+            value="${testRoot}/${jonas432DirName}"/>
+    </target>
+	<target
+	        name="all"
+	        depends="init,runOneTestBundle"
+	        unless="testBundle">
+	        <echo
+	            level="info"
+	            message="Starting Unit Tests"/>
+	        <!--
+	            unlike other ant tasks, subant defaults to false for
+	            inheritall!
+	        -->
+	        <subant
+	            target="performance"
+	            inheritall="true"
+	            failonerror="false">
+	            <fileset
+	                dir="${eclipse-home}/eclipse/plugins/">
+	                <include
+	                    name="**/test.xml"/>
+	            </fileset>
+	        </subant>
+	        <echo
+	            level="info"
+	            message="Ended Unit Tests"/>
+	    </target>
+    <!--
+        by making 'all' the default, and "runOneTestBundle" as its
+        'depends' we can effectively control which is ran based on
+        whether or not 'testBundle' has been defined by caller. If so,
+        only that one is ran, otherwise, all of them are. Note, in many
+        cases a collection of tests could be ran, by specifying a
+        partial bundle name. for example, specifying
+        "org.eclipse.jst.jsp" would execute the 3 JSP tests:
+        org.eclipse.jst.jsp.core.tests,
+        org.eclipse.jst.jsp.tests.encoding,
+        org.eclipse.jst.jsp.ui.tests.
+    -->
+    <target
+        name="runOneTestBundle"
+        depends="init"
+        if="testBundle">
+        <echo
+            level="info"
+            message="Starting Unit Tests for one test bundle"/>
+        <!--
+            unlike other ant tasks, subant defaults to false for
+            inheritall!
+        -->
+        <subant
+            target="performance"
+            inheritall="true">
+            <fileset
+                dir="${eclipse-home}/plugins/">
+                <include
+                    name="**/${testBundle}*/test.xml"/>
+            </fileset>
+        </subant>
+        <echo
+            level="info"
+            message="Finished Unit Tests for one test bundle"/>
+    </target>
+    <target
+        name="genHtml"
+        description="Generates HTML results with provided JUNIT.XSL provided"
+        unless="genHtml.disable">
+        <xslt
+            style="JUNIT.XSL"
+            basedir="${results}/xml"
+            destdir="${results}/html"/>
+    </target>
+</project>
\ No newline at end of file
diff --git a/releng.wtpbuilder/scripts/standaloneTest/runtest.bat b/releng.wtpbuilder/scripts/standaloneTest/runtest.bat
index c239a9f..14ad43a 100644
--- a/releng.wtpbuilder/scripts/standaloneTest/runtest.bat
+++ b/releng.wtpbuilder/scripts/standaloneTest/runtest.bat
@@ -68,6 +68,9 @@
 REM                   (or exported from Eclipse) into a directory named 'webtools.releng' which is immediately under the BUILD_HOME directory.
 REM                   It is assume this batch file, then, is in the BUILD_HOME directory.
 
+REM whatever the user chose, we're going to need the releng data, so run checkout every time
+
+echo Running standalonecheckout.xml
 call ant ^
      -Dprojectname=wtp-R3.2.0-I ^
      -DbuildType=I ^
@@ -77,7 +80,17 @@
      -Dbuild.stream=R3.2.0 ^
      -DbuildBranch=R3.2.0 ^
      -f standalonecheckout.xml
+     
+REM check to see what the user chose. Default is help. 
 
+if x%1==x-functional goto func
+if x%1==x-both goto func
+if x%1==x-performance goto perf
+goto hlp
+
+:func
+
+echo Running standaloneTest.xml
 call ant  ^
      -Dprojectname=wtp-R3.2.0-I ^
      -Dbuild.committers=true   ^
@@ -89,6 +102,26 @@
      -DtestBundle=org.eclipse.jst.jsp ^
      -f standaloneTest.xml
 
+REM Only 2 ways to get here are func or both. If func then exit, otherwise must be both, so continue to perf tests. 
+if x%1==x-functional goto exit
 
+:perf
+echo Running standalonePerfTest.xml
+call ant  ^
+     -Dprojectname=wtp-R3.2.0-I ^
+     -Dbuild.committers=true   ^
+     -DbuildType=I ^
+     -DbuildId=3.2.0 ^
+     -Dtimestamp=20091116075243 ^
+     -Dbuild.stream=R3.2.0 ^
+     -DbuildBranch=R3.2.0 ^
+     -DtestBundle=org.eclipse.jst.jsp ^
+     -f standalonePerfTest.xml
+goto exit
 
+:hlp
+echo Use -performance for performance tests, -funtional for function tests, -both for both, or anything else for this message
+echo
+echo At this time, to run the performance tests it is necessary to to manually install the eclipse test plugins to the WTP install you want to test.
+:exit
 ENDLOCAL