Skip to content

Commit

Permalink
By request, CI tests restored in new location
Browse files Browse the repository at this point in the history
Beware, these tests were original written for MXUNIT and for verisions of ACF/Railo not suppoted by this implementation of CFSelenium.

They are here as a starting point for others to take forward.
  • Loading branch information
richardherbert committed Jun 8, 2017
1 parent 7ccf9b8 commit bc9f111
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 0 deletions.
95 changes: 95 additions & 0 deletions _tests/ci/HttpAntRunner.cfc
@@ -0,0 +1,95 @@
<cfcomponent output="true">
<cfsetting enablecfoutputonly="false" showdebugoutput="false">
<cfprocessingdirective suppresswhitespace="true">

<cffunction name="run" access="remote" output="true" returntype="void" hint="Generates and prints HTML, JUnit style XML, or XML data based on a directory of tests.">
<cfargument name="type" type="string" hint="Specifies the type to run: TestCase(testcase) or Directory Path (dir)" required="true" />
<cfargument name="value" type="string" hint="The value for the type: com.foo.MyTestCase or C:/my/tests/" required="true" />
<cfargument name="packagename" type="string" hint="The package name for JUnitReportTask" required="false" default="mxunit.testresults" />
<cfargument name="outputformat" type="string" hint="Valid Values: HTML,XML, or JUNITXML" required="false" default="junitxml" />
<cfargument name="recurse" required="false" default="true" hint="whether to recurse down the directory tree">
<cfargument name="excludes" required="false" default="" hint="List of files to exclude if type is DIR">
<cfargument name="componentPath" required="false" hint="performance improver: pass the cfc-notation. See DirectoryTestSuite for details." default="">

<cfset var suite = createObject("component","mxunit.framework.TestSuite").TestSuite()/>
<cfset var results = createObject("component","mxunit.framework.TestResult").TestResult()/>
<cfscript>
if(arguments.type is "testcase"){
suite = createObject("component","mxunit.framework.TestSuite").TestSuite();
suite.addAll(arguments.value);
results = suite.run();
}
if(arguments.type is "dir"){
//To Do: add args for recursion, includes, and excludes
if(not isBoolean(arguments.recurse)){
arguments.recurse = false;
}

results = createObject("component","mxunit.runner.DirectoryTestSuite").run(directory=arguments.value, componentPath=arguments.componentPath, recurse=arguments.recurse, excludes=arguments.excludes);
}
//package name for JUnit reports
results.setPackage(arguments.packagename);
</cfscript>
<!--- Read by Ant client and used to print summary to stdout --->
<cfcookie name="mxunit_summary" value="#results.testRuns#,#results.testErrors#,#results.testFailures#,#results.totalExecutionTime#" />
<!--- write the cookie first --->
<cfheader statuscode="200" statustext="OK">
<cfset printResults(arguments.outputformat,results) />
<cfreturn />
</cffunction>

<cffunction name="printResults" access="private">
<cfargument name="type">
<cfargument name="results">
<cfoutput>
<cfswitch expression="#type#">
<cfcase value="html">
#trim(arguments.results.getHTMLResults())#
</cfcase>
<cfcase value="xml">
#trim(arguments.results.getXMLResults())#
</cfcase>
<cfcase value="junitxml">
#trim(arguments.results.getJUnitXMLResults())#
</cfcase>
<cfdefaultcase>#trim(arguments.results.getJUnitXMLResults())#</cfdefaultcase>
</cfswitch>
</cfoutput>
</cffunction>

<cffunction name="runFast" access="remote" output="true" returntype="void" hint="Generates and prints HTML, JUnit style XML, or XML data based on a directory of tests.">
<cfargument name="type" type="string" hint="Specifies the type to run: TestCase(testcase) or Directory Path (dir)" required="true" />
<cfargument name="value" type="string" hint="The value for the type: com.foo.MyTestCase or C:/my/tests/" required="true" />
<cfargument name="packagename" type="string" hint="The package name for JUnitReportTask" required="false" default="mxunit.testresults" />
<cfargument name="outputformat" type="string" hint="Valid Values: HTML,XML, or JUNITXML" required="false" default="junitxml" />
<cfargument name="recurse" required="false" default="true" hint="whether to recurse down the directory tree">
<cfargument name="excludes" required="false" default="" hint="List of files to exclude if type is DIR">
<cfargument name="componentPath" required="false" hint="performance improver: pass the cfc-notation. See DirectoryTestSuite for details." default="">

<cfset var suite = createObject("component","mxunit.framework.TestSuite").TestSuite()/>
<cfset var results = createObject("component","mxunit.framework.TestResult").TestResult()/>
<cfscript>
if(arguments.type is "testcase"){
suite = createObject("component","mxunit.framework.TestSuite").TestSuite();
suite.addAll(arguments.value);
results = suite.run();
}
if(arguments.type is "dir"){
//To Do: add args for recursion, includes, and excludes
if(not isBoolean(arguments.recurse)){
arguments.recurse = false;
}

results = createObject("component","DirectoryTestSuite").run(directory=arguments.value, componentPath=arguments.componentPath, recurse=arguments.recurse, excludes=arguments.excludes);
}
//package name for JUnit reports
results.setPackage(arguments.packagename);
</cfscript>
<!--- Read by Ant client and used to print summary to stdout --->
<cfcookie name="mxunit_summary" value="#results.testRuns#,#results.testErrors#,#results.testFailures#,#results.totalExecutionTime#" />
<!--- write the cookie first
<cfset printResults(arguments.outputformat,results) /> --->
<cfreturn />
</cffunction>
</cfprocessingdirective>
</cfcomponent>
Binary file added _tests/ci/mxunit-ant.jar
Binary file not shown.
Binary file added _tests/ci/mxunit-output-ant.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions _tests/ci/scripts/acf9-control.sh
@@ -0,0 +1,10 @@
pushd $WORK_DIR/jrun4/bin > /dev/null
case $1 in
start)
./jrun -start cfusion>/dev/null&
;;
stop)
./jrun -stop cfusion>/dev/null&
;;
esac
popd > /dev/null
28 changes: 28 additions & 0 deletions _tests/ci/scripts/ci-helper-acf.sh
@@ -0,0 +1,28 @@
#!/bin/bash
# WORK_DIR and BUILD_DIR must be set!

CONTROL_SCRIPT='coldfusion10/cfusion/bin/coldfusion'

MY_DIR=`dirname $0`
source $MY_DIR/ci-helper-base.sh $1 $2

case $1 in
install)
mv mxunit* coldfusion10/cfusion/wwwroot/mxunit

echo "Fixing ACF install directory..."
grep -rl "/opt/coldfusion10/" . | xargs -n 1 sed -i "s#/opt/coldfusion10/#$WORK_DIR/coldfusion10/#g"

ln -s $BUILD_DIR coldfusion10/cfusion/wwwroot/$2

sed -i "s/8500/$SERVER_PORT/g" coldfusion10/cfusion/runtime/conf/server.xml
;;
start|stop)
;;
*)
echo "Usage: $0 {install|start|stop}"
exit 1
;;
esac

exit 0
26 changes: 26 additions & 0 deletions _tests/ci/scripts/ci-helper-acf9.sh
@@ -0,0 +1,26 @@
#!/bin/bash
# WORK_DIR and BUILD_DIR must be set!

MY_DIR=`dirname $0`
CONTROL_SCRIPT="`pwd`/$MY_DIR/acf9-control.sh"
source $MY_DIR/ci-helper-base.sh $1 $2

case $1 in
install)
mv mxunit* jrun4/servers/cfusion/cfusion-ear/cfusion-war/mxunit

echo "Fixing ACF install directory..."
grep -rl "/opt/jrun4/" . | xargs -n 1 sed -i "s#/opt/jrun4/#$WORK_DIR/jrun4/#g"

ln -s $BUILD_DIR jrun4/servers/cfusion/cfusion-ear/cfusion-war/$2
sed -i "s/8300/$SERVER_PORT/g" jrun4/servers/cfusion/SERVER-INF/jrun.xml
;;
start|stop)
;;
*)
echo "Usage: $0 {install|start|stop}"
exit 1
;;
esac

exit 0
83 changes: 83 additions & 0 deletions _tests/ci/scripts/ci-helper-base.bat
@@ -0,0 +1,83 @@
@echo off

REM WORK_DIR and BUILD_DIR must be set!
if NOT defined WORK_DIR (
echo "WORK_DIR must be set!"
exit 1
)

if NOT defined BUILD_DIR (
set BUILD_DIR=%BASE_DIR%
)

echo "Working directory: %WORK_DIR%, Build directory: %BUILD_DIR%"

if NOT "%1"=="install" (
if NOT exist %WORK_DIR% (
echo "Working directory doesn't exist and this isn't an install!"
exit 1
) else (
cd %WORK_DIR%
)
) else (
REM if only one argument
if NOT exist %WORK_DIR% (
REM create work directory
mkdir %WORK_DIR%
)
if "%2"=="" (
echo "usage: %0 install PROJECTNAME";
exit 1
)
)
if "%1"=="install" (
call:download_and_extract %PLATFORM_URL%
call:download_and_extract %MXUNIT_URL%
) else (
REM no "else if in batch file logic"
REM so need to do a convoluted method to handle it
if NOT "%1"=="start" (
if NOT "%1"=="stop" (
echo "Usage: %0 {install|start|stop}"
exit 1
)
)
)

goto:eof


REM FUNCTIONS SECTION

REM function for downloading and extracting files
:download_and_extract
SETLOCAL
set urlString=%1
for %%F in (%urlString%) do set FILENAME=%%~nxF
REM determine whether local or remote file
set FIRST_CHAR=%urlString:~0,1%
if "%FIRST_CHAR%"=="/" (
echo Copying %1 to %WORK_DIR%/%FILENAME%
copy %1 %WORK_DIR%/%FILENAME%
) else (
REM make sure file does not already exist
if NOT exist %WORK_DIR%/%FILENAME% (
echo Downloading %1 to %WORK_DIR%/%FILENAME%
cscript /nologo %TEST_DIR%/ci/scripts/wget.js %1 %WORK_DIR%/%FILENAME%
)
)

for %%F in (%urlString%) do set FILENAME_EXT=%%~xF

if %FILENAME_EXT%==.zip (
echo unzipping %WORK_DIR%/%FILENAME%
unzip -q %WORK_DIR%/%FILENAME% -d %WORK_DIR%
) else (
echo untarring %WORK_DIR%/%FILENAME%
REM untar goes here
)

echo deleting %WORK_DIR%\%FILENAME%
DEL %WORK_DIR%\%FILENAME%
ENDLOCAL
GOTO:EOF
96 changes: 96 additions & 0 deletions _tests/ci/scripts/ci-helper-base.sh
@@ -0,0 +1,96 @@
#!/bin/bash
# WORK_DIR and BUILD_DIR must be set!
if [ ! -n "$WORK_DIR" ]; then
echo "WORK_DIR must be set!"
exit 1
fi

if [ ! -n "$BUILD_DIR" ]; then
BUILD_DIR=`pwd`
fi

echo "Working directory: $WORK_DIR, Build directory: $BUILD_DIR"

if [ ! "$1" == "install" ]; then

if [ ! -d $WORK_DIR ]; then
echo "Working directory doesn't exist and this isn't an install!"
exit 1
else
cd $WORK_DIR
fi
else
if [ ! -n "$2" ]; then
echo "usage: $0 install PROJECTNAME";
exit 1
fi
fi

WGET_OPTS="-nv"

function download_and_extract {
FILENAME=`echo $1|awk '{split($0,a,"/"); print a[length(a)]}'`
if [[ "$1" == /* ]]; then
echo "Copying $1 to $FILENAME"
cp $1 $FILENAME
else
echo "Downloading $1 to $FILENAME"
wget $WGET_OPTS $1 -O $FILENAME
fi

if [[ "$FILENAME" == *zip ]]; then
unzip -q $FILENAME
else
tar -zxf $FILENAME
fi
rm $FILENAME
result=$FILENAME
}


if [ ! -n "$SERVER_PORT" ]; then
SERVER_PORT="8500"
fi

HEALTHCHECK_URL="http://localhost:$SERVER_PORT"


case $1 in
install)
if [ -d $WORK_DIR ]; then
rm -rf $WORK_DIR
fi

mkdir -p $WORK_DIR
cd $WORK_DIR

download_and_extract $PLATFORM_URL
download_and_extract $MXUNIT_URL
;;
start)
if [ ! -f $CONTROL_SCRIPT ]; then
echo "Control script does not exist!"
exit 1
fi
echo "Starting server... ($HEALTHCHECK_URL)"
$CONTROL_SCRIPT start&
until [ "`curl --connect-timeout 2 -m 2 -s -o /dev/null -w "%{http_code}" $HEALTHCHECK_URL`" == "200" ]
do
echo "Waiting for server to start..."
sleep 2
done
;;
stop)
echo "Stopping server..."
$CONTROL_SCRIPT stop
while curl --connect-timeout 2 --max-time 2 -s $HEALTHCHECK_URL>/dev/null
do
echo "Waiting for server to stop..."
sleep 1
done
;;
*)
echo "Usage: $0 {install|start|stop}"
exit 1
;;
esac
36 changes: 36 additions & 0 deletions _tests/ci/scripts/ci-helper-railo.bat
@@ -0,0 +1,36 @@
@echo off

REM get current path of batch file scripts
for /f %%i in ("%0") do set curpath=%%~dpi
call %curpath%ci-helper-base.bat %1 %2

if "%1"=="install" (
move %WORK_DIR%\railo-express* %WORK_DIR%\railo
move %WORK_DIR%\mxunit* %WORK_DIR%\railo\webapps\www\mxunit

REM if nothing passed in for build directory, use scripts directory
if "%BUILD_DIR%"=="" (
set BUILD_DIR=%BASE_DIR%
)

echo creating symlink to scripts directory %BUILD_DIR% railo\webapps\www\%2
mklink /D %WORK_DIR%\railo\webapps\www\%2 %BUILD_DIR%
) else (
REM no "else if in batch file logic"
REM so need to do a convoluted method to handle it
if "%1"=="start" (
echo changing dir to %WORK_DIR%\railo
cd %WORK_DIR%\railo
echo starting server
cmd /k start.bat
) else (
if "%1"=="stop" (
echo changing dir to %WORK_DIR%\railo
cd %WORK_DIR%\railo
echo stopping server
cmd /c stop.bat
) else (
echo "Usage: %MY_DIR% (install|start|stop)"
)
)
)

0 comments on commit bc9f111

Please sign in to comment.