From a1298e6edd26ea788c2ab4cf813ab8a2a93ee115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Thu, 6 Jun 2013 16:05:55 +0200 Subject: [PATCH 1/6] Add dummy test case for casperjs The dummy test only checks whether our build server has the correct title when called. Also the i2w-config.js toolkit is provided to help testing correct paths refs #4213 --- test/frontend/cases/static-page-test.js | 19 +++++ test/frontend/casperjs.config | 5 ++ test/frontend/i2w-config.js | 107 ++++++++++++++++++++++++ test/frontend/regression/test.txt | 1 + 4 files changed, 132 insertions(+) create mode 100644 test/frontend/cases/static-page-test.js create mode 100644 test/frontend/casperjs.config create mode 100644 test/frontend/i2w-config.js create mode 100755 test/frontend/regression/test.txt diff --git a/test/frontend/cases/static-page-test.js b/test/frontend/cases/static-page-test.js new file mode 100644 index 000000000..b77496f86 --- /dev/null +++ b/test/frontend/cases/static-page-test.js @@ -0,0 +1,19 @@ +/** +* +* This test simply checks the icinga build server and tests +* if the title is correct +**/ +i2w = require('./i2w-config'); + +var casper = i2w.getTestEnv(); + +casper.start("http://build.icinga.org/jenkins"); + +casper.then(function() { + this.test.assertTitle("icinga-web test [Jenkins]", "The jenkins page"); +}); + +casper.run(function() { + this.test.done(); +}); + diff --git a/test/frontend/casperjs.config b/test/frontend/casperjs.config new file mode 100644 index 000000000..69c9d4a3b --- /dev/null +++ b/test/frontend/casperjs.config @@ -0,0 +1,5 @@ +{ + "host": "localhost", + "port": 80, + "path": "icinga2-web" +} diff --git a/test/frontend/i2w-config.js b/test/frontend/i2w-config.js new file mode 100644 index 000000000..7d54a1a00 --- /dev/null +++ b/test/frontend/i2w-config.js @@ -0,0 +1,107 @@ +/** +* Tools for setting up the casperjs tests +* mainly setting host, port and path path +**/ + +// load config files +var fs = require('fs'); +var env = require('system').env; +var args = require('system').args; +var utils = require('utils'); + + +var configFile = fs.absolute('./casperjs.config'); +var host = null; +var port = null; +var path = null; +var verbose = false; + + +if (typeof(env.CASPERJS_HOST) === "string") + host = env.CASPERJS_HOST; +if (typeof(env.CASPERJS_PORT) === "string") + port = parseInt(env.CASPERJS_PORT, 10); +if (typeof(env.CASPERJS_PATH) === "string") + path = env.CASPERJS_PATH; + + +for (var i=0;i Date: Thu, 6 Jun 2013 16:07:32 +0200 Subject: [PATCH 2/6] Add testrunner for frontend tests This runner should conform to our runner specification refs #4213 refs #4244 --- test/frontend/runtest.sh | 115 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100755 test/frontend/runtest.sh diff --git a/test/frontend/runtest.sh b/test/frontend/runtest.sh new file mode 100755 index 000000000..bbe84f300 --- /dev/null +++ b/test/frontend/runtest.sh @@ -0,0 +1,115 @@ +#!/bin/sh + +set -o nounset + +pushd `dirname $0` > /dev/null +DIR=`pwd` +popd > /dev/null +CASPER=$(which casperjs) +INCLUDE="" +EXCLUDE="" +VERBOSE=0 +BUILD=0 + +if [ ! -x $CASPER ]; then + echo "CasperJS is not installed but required to run frontend tests\n"\ +"Take a look at http://casperjs.org/installation.html to see how the installation works for your system" + exit 1 +fi; + +PARAM="0" +for arg in $@;do + if [ ! "$PARAM" == "0" ]; then + export $PARAM=$arg + PARAM="0" + continue + fi; + case $arg in + --verbose) + VERBOSE=1 + ;; + --include) + PARAM="INCLUDE" + continue + ;; + --exclude) + PARAM="EXCLUDE" + continue + ;; + --build) + BUILD=1 + continue + ;; + **) + if [ "$arg" != "--help" ]; then + echo "Unknown option $arg" + fi; + echo "Testrunner for interface tests: ./$0 [--verbose] [--include %include%] [--exclude %exclude%] [--build]" + echo "\t\t --verbose \t\t\t Print verbose output when testing" + echo "\t\t --include %filelist%\t\t Include only files matching this patterns" + echo "\t\t --exclude %filelist%\t\t Exclude files matching this patterns" + echo "\t\t --build \t\t\t Write test results to ../../build/log/casper_results.xml" + echo "\t\t --help \t\t\t Print this message" + exit 1 + + esac; +done; + +EXEC="$CASPER test" + +# +# If build is set, the results are written for our jenkins server +# +if [ $BUILD -eq 1 ];then + mkdir -p $DIR/../../build/log + EXEC="$EXEC --xunit=$DIR/../../build/log/casper_results.xml" +fi; +if [ "$PARAM" != "0" ]; then + echo "Missing parameter for $PARAM" + exit 1 +fi; + +cd $DIR +FILELIST="" +# +# Default : Run regression and cases directory +# +if [ "$INCLUDE" == "" -a "$EXCLUDE" == "" ];then + FILELIST="./cases ./regression" +fi; + +# +# Include patterns set with the --include directive +# +if [ "$INCLUDE" != "" ];then + NAME="\(" + GLUE="" + for INC in $INCLUDE;do + NAME="$NAME${GLUE}${INC}.*js" + GLUE="\|" + done; + NAME=$NAME"\)$" + FILELIST=`find . | grep "$NAME"` +fi; + +# +# Exclude patterns that match the include directive +# +if [ "$EXCLUDE" != "" ];then + NAME="\(" + GLUE="" + for EXC in $EXCLUDE;do + NAME="$NAME${GLUE}${EXC}.*js" + GLUE="\|" + done; + NAME=$NAME"\)$" + if [ "$FILELIST" == "" ]; then + FILELIST=`find .|grep ".*js$"` + fi + FILELIST=`echo $FILELIST | grep -v "$NAME"` +fi; + +echo $EXEC $FILELIST +$EXEC $FILELIST + +exit 0 From 26644b091b90c8ae565063afa9aff5156552ade2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Thu, 6 Jun 2013 16:13:16 +0200 Subject: [PATCH 3/6] Renamed runtest to runtests.sh --- test/frontend/{runtest.sh => runtests.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/frontend/{runtest.sh => runtests.sh} (100%) diff --git a/test/frontend/runtest.sh b/test/frontend/runtests.sh similarity index 100% rename from test/frontend/runtest.sh rename to test/frontend/runtests.sh From b253c4c0699715ae88c1b56103a80a23cacb7763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Thu, 6 Jun 2013 16:13:16 +0200 Subject: [PATCH 4/6] Renamed runtest to runtests.sh refs #4213 --- test/frontend/{runtest.sh => runtests.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/frontend/{runtest.sh => runtests.sh} (100%) diff --git a/test/frontend/runtest.sh b/test/frontend/runtests.sh similarity index 100% rename from test/frontend/runtest.sh rename to test/frontend/runtests.sh From 3e4ae41e8ab322f60c2b5bfb76b65f1243c6416a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Fri, 7 Jun 2013 10:34:39 +0200 Subject: [PATCH 5/6] Rename runtests.sh to runtest As we have different executables for executing the runtests scripts, runtests.sh is now renamed to runtests in order to stay consistent over all testrunners refs #4213 refs #4244 --- test/frontend/{runtests.sh => runtests} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/frontend/{runtests.sh => runtests} (99%) diff --git a/test/frontend/runtests.sh b/test/frontend/runtests similarity index 99% rename from test/frontend/runtests.sh rename to test/frontend/runtests index bbe84f300..ecfc1babc 100755 --- a/test/frontend/runtests.sh +++ b/test/frontend/runtests @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh set -o nounset From 6f80d410b8a3b140973f21f323ed80340d1c9559 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Fri, 7 Jun 2013 15:09:31 +0200 Subject: [PATCH 6/6] Integrate javascript frontend/component tests Fix output and make smaller refs 4213 --- test/frontend/runtests | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/frontend/runtests b/test/frontend/runtests index ecfc1babc..4e913ea72 100755 --- a/test/frontend/runtests +++ b/test/frontend/runtests @@ -44,14 +44,14 @@ for arg in $@;do if [ "$arg" != "--help" ]; then echo "Unknown option $arg" fi; - echo "Testrunner for interface tests: ./$0 [--verbose] [--include %include%] [--exclude %exclude%] [--build]" - echo "\t\t --verbose \t\t\t Print verbose output when testing" - echo "\t\t --include %filelist%\t\t Include only files matching this patterns" - echo "\t\t --exclude %filelist%\t\t Exclude files matching this patterns" - echo "\t\t --build \t\t\t Write test results to ../../build/log/casper_results.xml" - echo "\t\t --help \t\t\t Print this message" + printf "%b" "Testrunner for interface tests\n\n" + printf "%b" "Usage: ./$0 [--verbose] [--include %include%] [--exclude %exclude%] [--build]\n\n" + printf "%b" " --verbose \t\t\t Print verbose output when testing\n" + printf "%b" " --include %filelist%\t\t Include only files matching this patterns\n" + printf "%b" " --exclude %filelist%\t\t Exclude files matching this patterns\n" + printf "%b" " --build \t\t\t Write test results to ../../build/log/casper_results.xml\n" + printf "%b" " --help \t\t\t Print this message\n\n" exit 1 - esac; done;