Integrate last change on test suite. rename specific files
--- a/.hgignore Sat Apr 19 17:00:40 2014 +0200
+++ b/.hgignore Wed Apr 30 12:02:50 2014 +0200
@@ -20,7 +20,6 @@
test-suite/node_modules
test-suite/workspace.info*.js
test-suite/clean-testserver.sh
-test-suite/karma.conf.full.js
-test-suite/start-test-suite-full.sh
-test-suite/start-testserver.sh
-
+test-suite/karma.conf.dev.js
+test-suite/start-test-suite-dev.sh
+test-suite/start-testserver.sh
\ No newline at end of file
--- a/.hgsubstate Sat Apr 19 17:00:40 2014 +0200
+++ b/.hgsubstate Wed Apr 30 12:02:50 2014 +0200
@@ -1,6 +1,6 @@
-6691c2faded01d273672b4db36f5a8651d3a934f dev/modules/apt
-cd2e1d97e94da67c184a3a121b4493898fabe4a8 dev/modules/concat
-5c36913dcda630f5244e0ecc885e3b436973d45a dev/modules/nginx
-400a82d7e0f7374b61962364cb95315d0b5ee0d0 dev/modules/postgresql
-ab981422a67636441f1bfebaaade36aa690f1f25 dev/modules/stdlib
+dcac07e03420afa9401429186aa41d0dde8c5b63 dev/modules/apt
+ca37c46b39e91b8c8e62c1d399a6d7a0c4981ee9 dev/modules/concat
+fbb71f222b27e4c9466c7075038e58bd204ed706 dev/modules/nginx
+b550d4ba6ed8c000cfd7ca5e152149fb59ea8e1f dev/modules/postgresql
+62e8c1d76902e6f22cb9f7b3abd43e757b4130a3 dev/modules/stdlib
743e2a3facfd7b9596983bca0f5afef8336ea525 dev/modules/supervisord
--- a/dev/clean_dev.sh Sat Apr 19 17:00:40 2014 +0200
+++ b/dev/clean_dev.sh Wed Apr 30 12:02:50 2014 +0200
@@ -8,10 +8,10 @@
pushd "$ROOTPATH" > /dev/null
-rm -rfv .installed.cfg .mr.developer.cfg parts/ eggs/ develop-eggs/ bin/ \
+rm -rf .installed.cfg .mr.developer.cfg parts/ eggs/ develop-eggs/ bin/ \
src/cm/settings_local.py test-suite/workspace.info*.js \
- test-suite/{clean-testserver.sh,karma.conf.full.js} \
- test-suite/{start-test-suite-full.sh,start-testserver.sh}
+ test-suite/{clean-testserver.sh,karma.conf.dev.js} \
+ test-suite/{start-test-suite-dev.sh,start-testserver.sh}
find . -name '*.pyc' -or -name '*.egg-info' | xargs rm -rvf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/files/karma.conf.dev.js Wed Apr 30 12:02:50 2014 +0200
@@ -0,0 +1,50 @@
+// Karma configuration
+// Generated on Wed Jan 29 2014 15:32:16 GMT+0100 (CET)
+
+
+// SID: get WORKSPACE_URL configuration from one single file to customize
+var W = require ('./workspace.info.dev.js');
+
+module.exports = function(config) {
+ config.set({
+ // list of files or patterns to load in the browser, from current directory
+ files: [
+ {pattern: 'tests/**/*.js', included: true}
+ ],
+ // list of files to exclude
+ exclude: [ ],
+ // Start these browsers, currently available:
+ // - Firefox ; Safari (only Mac; run `npm install karma-safari-launcher` first)
+ // - Chrome ; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
+ // - PhantomJS ; IE (only Windows; run `npm install karma-ie-launcher` first)
+ browsers: W.BROWSERS,
+ // frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
+ frameworks: ['mocha', 'karma-e2e-dsl'],
+ // SID: Karma will start and run somewhere else than '/', to allow proxying '/'
+ urlRoot: '/karma/',
+ // SID: directive added on karma-e2e-dsl purpose. Map of path-proxy pairs.
+ proxies: {
+ '/': W.WORKSPACE_URL
+ },
+ client: {
+ mocha: {
+ ui: 'tdd'
+ },
+ W: W // SID: exports the variable in the test execution browser window
+ },
+ // test results reporter to use : 'dots', 'progress', 'junit', 'growl', 'coverage'
+ reporters: ['progress'],
+ // web server port
+ port: 9876,
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+ // level of logging : config.LOG_DISABLE || _ERROR || _WARN || _INFO || _DEBUG
+ logLevel: config.LOG_INFO,
+ // If browser does not capture in given timeout [ms], kill it
+ captureTimeout: 20000,
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: false,
+ // Continuous Integration mode : if true, it capture browsers, run tests and exit
+ singleRun: true,
+ });
+};
--- a/dev/modules/sysconfig/files/karma.conf.full.js Sat Apr 19 17:00:40 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-// Karma configuration
-// Generated on Wed Jan 29 2014 15:32:16 GMT+0100 (CET)
-
-
-// SID: get WORKSPACE_URL configuration from one single file to customize
-var w = require ('./workspace.info.full.js');
-
-module.exports = function(config) {
- config.set({
- // list of files or patterns to load in the browser, from current directory
- files: [
- {pattern: 'tests/**/*.js', included: true}
- ],
- // list of files to exclude
- exclude: [ ],
- // Start these browsers, currently available:
- // - Firefox ; Safari (only Mac; run `npm install karma-safari-launcher` first)
- // - Chrome ; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
- // - PhantomJS ; IE (only Windows; run `npm install karma-ie-launcher` first)
- browsers: w.BROWSERS,
- // frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
- frameworks: ['mocha', 'karma-e2e-dsl'],
- // SID: Karma will start and run somewhere else than '/', to allow proxying '/'
- urlRoot: '/karma/',
- // SID: directive added on karma-e2e-dsl purpose. Map of path-proxy pairs.
- proxies: {
- '/': w.WORKSPACE_URL
- },
- client: {
- mocha: {
- ui: 'tdd'
- },
- w: w // SID: exports the variable in the test execution browser window
- },
- // test results reporter to use : 'dots', 'progress', 'junit', 'growl', 'coverage'
- reporters: ['progress'],
- // web server port
- port: 9876,
- // enable / disable colors in the output (reporters and logs)
- colors: true,
- // level of logging : config.LOG_DISABLE || _ERROR || _WARN || _INFO || _DEBUG
- logLevel: config.LOG_INFO,
- // If browser does not capture in given timeout [ms], kill it
- captureTimeout: 20000,
- // enable / disable watching file and executing tests whenever any file changes
- autoWatch: false,
- // Continuous Integration mode : if true, it capture browsers, run tests and exit
- singleRun: true,
- });
-};
--- a/dev/modules/sysconfig/manifests/testserver_init.pp Sat Apr 19 17:00:40 2014 +0200
+++ b/dev/modules/sysconfig/manifests/testserver_init.pp Wed Apr 30 12:02:50 2014 +0200
@@ -24,9 +24,9 @@
content => template('sysconfig/workspace.info.js.erb','sysconfig/url.workspace.info.js.erb'),
}
- file { 'karma_workspace_info_full':
+ file { 'karma_workspace_info_dev':
ensure => 'present',
- path => "/srv/comt/test-suite/workspace.info.full.js",
+ path => "/srv/comt/test-suite/workspace.info.dev.js",
replace => 'no',
owner => 'vagrant',
group => 'vagrant',
@@ -44,24 +44,24 @@
source => 'puppet:///modules/sysconfig/clean-testserver.sh'
}
- file { 'karma.conf.full.js':
+ file { 'karma.conf.dev.js':
ensure => 'present',
- path => "/srv/comt/test-suite/karma.conf.full.js",
+ path => "/srv/comt/test-suite/karma.conf.dev.js",
replace => 'no',
owner => 'vagrant',
group => 'vagrant',
mode => 644,
- source => 'puppet:///modules/sysconfig/karma.conf.full.js'
+ source => 'puppet:///modules/sysconfig/karma.conf.dev.js'
}
- file { 'start-test-suite-full.sh':
+ file { 'start-test-suite-dev.sh':
ensure => 'present',
- path => "/srv/comt/test-suite/start-test-suite-full.sh",
+ path => "/srv/comt/test-suite/start-test-suite-dev.sh",
replace => 'no',
owner => 'vagrant',
group => 'vagrant',
mode => 755,
- content => template('sysconfig/start-test-suite-full.sh.erb'),
+ content => template('sysconfig/start-test-suite-dev.sh.erb'),
}
file { 'start-testserver.sh':
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/start-test-suite-dev.sh.erb Wed Apr 30 12:02:50 2014 +0200
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+echo "---------------------"
+echo "Starting test server"
+
+DEV_FOLDER="<%= @vagrant_base_path %>"
+
+pushd "$DEV_FOLDER" > /dev/null
+vagrant ssh -c "/srv/comt/test-suite/start-testserver.sh"
+popd > /dev/null
+
+
+TESTSERVER_STARTED=True
+WORKSPACE_INFO="workspace.info.dev.js"
+
+echo "---------------------"
+echo "Starting karma tests"
+. ./start-test-suite.sh ./karma.conf.dev.js $@
+
+echo "---------------------"
+echo "stopping test server + output test server logs"
+
+read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N)" -n 1 -r -t 5
+echo # (optional) move to a new line
+
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ exit 0
+fi
+
+pushd "$DEV_FOLDER" > /dev/null
+vagrant ssh -c "/srv/comt/test-suite/clean-testserver.sh"
+popd /dev/null
--- a/dev/modules/sysconfig/templates/start-test-suite-full.sh.erb Sat Apr 19 17:00:40 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-echo "---------------------"
-echo "Starting test server"
-
-DEV_FOLDER="<%= @vagrant_base_path %>"
-
-pushd "$DEV_FOLDER" > /dev/null
-vagrant ssh -c "/srv/comt/test-suite/start-testserver.sh"
-popd > /dev/null
-
-CONNECTION_TIMEOUT=10
-TESTSERVER_START_TIMEOUT=15
-TESTSERVER_LOOP_WAIT=5
-TESTSERVER_WAIT_LOOP_NB=10
-
-SERVER_IP=`grep WORKSPACE_URL workspace.info.full.js | tail -n -1 | cut -d: -f2 | tr -d " //"`
-SERVER_PORT=`grep WORKSPACE_URL ./workspace.info.full.js | tail -n -1 | cut -d: -f3 | tr -d " ');"`
-
-if [[ -x `which nc` ]]; then
- SERVER_TEST_CMD="nc -G $CONNECTION_TIMEOUT -z $SERVER_IP $SERVER_PORT"
-elif [[ -x `which curl` ]]; then
- SERVER_TEST_CMD="curl -m $CONNECTION_TIMEOUT --output /dev/null --silent --head --fail http://$SERVER_IP:$SERVER_PORT"
-elif [[ -x `which wget` ]]; then
- SERVER_TEST_CMD="wget --timeout=$CONNECTION_TIMEOUT -q --spider http://$SERVER_IP:$SERVER_PORT"
-fi
-echo "$SERVER_TEST_CMD"
-
-echo "---------------------"
-if [[ -z "$SERVER_TEST_CMD" ]]; then
- echo "Waiting $TESTSERVER_START_TIMEOUT seconds to let test server start"
- sleep $TESTSERVER_START_TIMEOUT
-else
- for i in $(seq 1 $TESTSERVER_WAIT_LOOP_NB); do
- echo "waiting $TESTSERVER_LOOP_WAIT seconds to let the test server $SERVER_IP:$SERVER_PORT start"
- sleep $TESTSERVER_LOOP_WAIT
- if $SERVER_TEST_CMD; then
- break
- fi
- done
- if [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
- echo "could not start test server $SERVER_IP:$SERVER_PORT"
- exit 1
- fi
-fi
-
-echo "---------------------"
-echo "Starting karma tests"
-. ./start-test-suite.sh ./karma.conf.full.js $@
-
-echo "---------------------"
-echo "stopping test server + output test server logs"
-
-pushd "$DEV_FOLDER" > /dev/null
-vagrant ssh -c "/srv/comt/test-suite/clean-testserver.sh"
-popd /dev/null
--- a/dev/modules/sysconfig/templates/start-testserver.sh.erb Sat Apr 19 17:00:40 2014 +0200
+++ b/dev/modules/sysconfig/templates/start-testserver.sh.erb Wed Apr 30 12:02:50 2014 +0200
@@ -6,7 +6,7 @@
pushd "$ROOTPATH" > /dev/null
-nohup bin/django testserver --noinput --addrport=0.0.0.0:<%= @testserver_port %> initial_data roles_generic test_content > $TMPFILE 2>&1 &
+nohup bin/django testserver --noinput --addrport=0.0.0.0:<%= @testserver_port %> initial_data roles_generic test_suite > $TMPFILE 2>&1 &
echo "$!|$TMPFILE" > /tmp/testserver.pid
cat /tmp/testserver.pid
--- a/test-suite/start-test-suite.sh Sat Apr 19 17:00:40 2014 +0200
+++ b/test-suite/start-test-suite.sh Wed Apr 30 12:02:50 2014 +0200
@@ -1,13 +1,36 @@
#!/bin/bash
-echo "Starting test server"
TESTSERVER_LOGS="/tmp/django_test_server_logs.`date +%F_%T`"
-cd ..
-nohup ./bin/django testserver --noinput localhost:8000 initial_data roles_generic test_suite > $TESTSERVER_LOGS 2>&1 &
-TESTSERVER_PID=$!
-cd "test-suite"
+if [ -z "$WORKSPACE_INFO" ]; then
+ WORKSPACE_INFO="workspace.info.js"
+fi
+
+WORKSPACE_URL_LINE=`grep -v '^[[:space:]]*//' "$WORKSPACE_INFO" | grep WORKSPACE_URL | head -n 1`
+echo "Workspace_url_line : $WORKSPACE_URL_LINE"
+
+SERVER_IP=`echo "$WORKSPACE_URL_LINE" | sed "s|^.*http://\([-._[:alnum:]]*\).*$|\1|"`
+if [ "$SERVER_IP" = "$WORKSPACE_URL_LINE" ]; then
+ echo "No ip found in WORKSPACE_URL, using localhost"
+ SERVER_IP="127.0.0.1"
+fi
+
+SERVER_PORT=`echo "$WORKSPACE_URL_LINE" | sed "s|^.*http://[-._[:alnum:]]*:\([0-9]*\).*$|\1|"`
+if [ "$SERVER_PORT" = "$WORKSPACE_URL_LINE" ]; then
+ echo "No port found in WORKSPACE_URL, using 80"
+ SERVER_PORT="80"
+fi
+
+echo "Test server : $SERVER_IP:$SERVER_PORT"
+
+if [ -z "$TESTSERVER_STARTED" ]; then
+ echo "Starting test server"
+ cd ..
+ nohup ./bin/django testserver --noinput localhost:$SERVER_PORT initial_data roles_generic test_suite > $TESTSERVER_LOGS 2>&1 &
+ TESTSERVER_PID=$!
+ cd "test-suite"
+fi
# Exports browsers _BIN variables for karma
export CHROME_BIN=`which chromium`
@@ -44,9 +67,6 @@
TESTSERVER_LOOP_WAIT=5
TESTSERVER_WAIT_LOOP_NB=5
-SERVER_IP=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://\([-._[:alnum:]]*\):.*$|\1|"`
-SERVER_PORT=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://[-._[:alnum:]]*:\([0-9]*\)/.*$|\1|"`
-
if [[ -x `which nc` ]]; then
SERVER_TEST_CMD="nc -w $CONNECTION_TIMEOUT -z $SERVER_IP $SERVER_PORT"
elif [[ -x `which curl` ]]; then
@@ -61,14 +81,16 @@
echo "No http tool available so blindly waiting $TESTSERVER_START_WAIT seconds to let test server start"
sleep $TESTSERVER_START_WAIT
else
+ SERVER_STARTED=false
for i in $(seq 1 $TESTSERVER_WAIT_LOOP_NB); do
echo "and waiting $TESTSERVER_LOOP_WAIT seconds"
sleep $TESTSERVER_LOOP_WAIT
if $SERVER_TEST_CMD; then
+ SERVER_STARTED=true
break
fi
done
- if [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
+ if ! $SERVER_STARTED && [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
echo "timeouted waiting for test server $SERVER_IP:$SERVER_PORT to start"
exit 1
fi
@@ -78,11 +100,14 @@
echo "$KARMA start $@"
"$KARMA" start $@
-read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N)" -n 1 -r -t 5
-echo # (optional) move to a new line
-if [[ $REPLY =~ ^[Yy]$ ]]; then
- exit 0
+if [ -z "$TESTSERVER_STARTED" ]; then
+ read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N)" -n 1 -r -t 5
+ echo # (optional) move to a new line
+
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ exit 0
+ fi
+
+ kill $TESTSERVER_PID
fi
-
-kill $TESTSERVER_PID