TT#5496 ngcp-csc test environment without PhantomJS

Add new Dockerfile and testrunner script to switch from PhantomJS
to Chromium for End-to-End tests.

Change-Id: If561965d2fac5bd63791163cd584a66f71df03b1
changes/85/9385/11
Markus Danek 9 years ago
parent e4f9d3830a
commit 68aa47fd9d

@ -135,7 +135,6 @@ sencha web start
```
makes the build available at **localhost:1841**
## Watch changes
sencha app watch
@ -147,7 +146,6 @@ http://docs.sencha.com/cmd/
and regarding ExtJS
http://docs.sencha.com/extjs/6.2.0/
## Tests
Install all Node.js dependencies in *ngcp-csc/t/* with ```npm install```.
@ -156,14 +154,14 @@ Install all Node.js dependencies in *ngcp-csc/t/* with ```npm install```.
Make sure that selenium-server and the NGCP-CSC application is running.
Karma test: ```npm run test-karma```
WebdriverIO test: ```npm run test-karma```
*Change the path to your local PhantomJS executable in wdio.conf.js.*
```
npm test
```
### Docker
Create and run Docker Image (see instructions inside the Dockerfile).
Run inside Docker: ```cd /code && sencha app build -c && ./t/testrunner```
Inside docker:
```cd /code && /opt/Sencha/Cmd/sencha app build -c && ./t/testrunner```

@ -0,0 +1 @@
/opt/Sencha/Cmd/sencha

@ -5,31 +5,43 @@ FROM docker.mgm.sipwise.com/sipwise-jessie:latest
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2016-10-27
ENV REFRESHED_AT 2016-11-16
RUN echo "deb https://deb.sipwise.com/autobuild/ release-trunk-jessie main" >>/etc/apt/sources.list
RUN apt-get update
RUN apt-get install --assume-yes \
chromium \
curl \
default-jre-headless \
devscripts \
nodejs \
nodejs-legacy \
npm \
libgconf-2-4 \
openjdk-7-jre-headless \
sencha-cmd \
unzip \
xterm
xvfb
RUN adduser --disabled-password --gecos=Selenium-User selenium
WORKDIR /home/selenium
RUN wget -O selenium-server-standalone-2.53.1.jar http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
RUN ln -s selenium-server-standalone-2.53.1.jar selenium-server-standalone.jar
RUN wget -O chromedriver_linux64.zip https://deb.sipwise.com/files/chromedriver_linux64_2.25.zip && unzip chromedriver_linux64.zip
ADD xvfb-chromium /usr/bin/xvfb-chromium
RUN ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome
RUN ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser
# Needs to be removed when sipwise node.js backport is available
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN apt-get install -y nodejs
RUN echo "cd /code && /opt/Sencha/Cmd/sencha app build -c && ./t/testrunner" >/root/.bash_history
WORKDIR /home/selenium
RUN ln -s /home/selenium/chromedriver /usr/bin/chromedriver
COPY jenkins_docker_run /home/selenium/
WORKDIR /home/selenium/
################################################################################
# Instructions for usage
@ -43,5 +55,5 @@ WORKDIR /home/selenium
# % docker run --rm -i -t -v $(pwd)/..:/code:rw docker.mgm.sipwise.com/ngcp-csc-jessie:latest bash
#
# Inside docker:
# cd /code && sencha app build -c && ./t/testrunner
# cd /code && /opt/Sencha/Cmd/sencha app build -c && ./t/testrunner
################################################################################

@ -0,0 +1,33 @@
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'../../ext/build/ext-all-debug.js', '../specs/app_test.js', '../specs/karma-*.js'
],
browsers: ['Chrome'],
plugins: [
'karma-jasmine', 'karma-chrome-launcher', 'karma-junit-reporter'
],
exclude: [],
preprocessors: {},
reporters: [
'progress', 'junit'
],
junitReporter: {
outputDir: '../',
outputFile: undefined,
suite: '',
useBrowserName: true,
nameFormatter: undefined,
classNameFormatter: undefined,
properties: {}
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: true,
concurrency: Infinity
})
}

@ -0,0 +1,30 @@
exports.config = {
specs: ['./specs/wdio-*.js'],
exclude: [],
maxInstances: 10,
capabilities: [
{
maxInstances: 5,
browserName: 'chrome',
}
],
sync: true,
logLevel: 'silent',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: 'http://localhost:1841',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'jasmine',
reporters: [
'spec', 'junit'
],
reporterOptions: {
outputDir: '../'
},
jasmineNodeOpts: {
defaultTimeoutInterval: 10000,
expectationResultHandler: function(passed, assertion) {}
}
}

@ -1,4 +1,4 @@
#!/bin/bash
# This script is used for running the tests with proper arguments
# from within Jenkins
cd /code && sencha app build -c && ./t/testrunner
cd /code && /opt/Sencha/Cmd/sencha app build -c && ./t/testrunner

@ -1,72 +0,0 @@
// Karma configuration
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'../ext/build/ext-all-debug.js', 'app_test.js',
//{pattern: 'app/data/*.json', included: false},
'karma/*.js'
],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [
'progress', 'junit'
],
// the default configuration
junitReporter: {
outputDir: '', // results will be saved as $outputDir/$browserName.xml
outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: true, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {} // key value pair of properties to add to the <properties> section of the report
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}

@ -1,25 +1,22 @@
{
"name": "ngcp-csc",
"description": "Sipwise ngcp-csc tests",
"version": "1.0.0",
"version": "1.0.1",
"author": "Markus Danek <mdanek@sipwise.com>",
"private": "true",
"scripts": {
"test-karma": "karma start karma.conf.js",
"test-wdio": "wdio wdio.conf.js"
"test": "karma start config/karma.conf.js && wdio config/wdio.conf.js"
},
"dependencies": {
"install": "^0.8.1",
"jasmine": "^2.5.2",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"phantomjs-prebuilt": "^2.1.13",
"karma-junit-reporter": "^1.1.0",
"selenium-standalone": "^5.7.2",
"wdio-jasmine-framework": "^0.2.6",
"webdriverio": "^4.2.16"
},
"devDependencies": {
"karma-junit-reporter": "^1.1.0",
"wdio-junit-reporter": "^0.1.0",
"wdio-spec-reporter": "0.0.3"
"wdio-spec-reporter": "0.0.3",
"webdriverio": "^4.2.16"
}
}

@ -1,7 +1,5 @@
#!/bin/bash
export PATH="$PATH:/opt/Sencha/Cmd/"
if ! [ -f /.dockerenv ] && ! grep -q 'devices:/docker' /proc/1/cgroup ; then
echo "Not running inside docker, exiting to avoid data damage." >&2
exit 1
@ -16,7 +14,7 @@ PASSWORD="selenium"
pkill -f '/usr/bin/java -jar /home/selenium/selenium-server-standalone.jar' || true
# NOTE: this could silently fail because selenium-server-standalone.jar is missing a daemonize option
DISPLAY=:99 /usr/bin/java -jar /home/selenium/selenium-server-standalone.jar -trustAllSSLCertificates -log /home/selenium/selenium.log &
DISPLAY=:98 /usr/bin/java -jar /home/selenium/selenium-server-standalone.jar -trustAllSSLCertificates -log /home/selenium/selenium.log &
sleep 5
@ -27,18 +25,18 @@ echo "Selenium server log file available at /home/selenium/selenium.log"
cp -Rf . /tmp/code
cd /tmp/code/t/
rm -rf node_modules node_modules
npm install
echo "Starting karma test"
./node_modules/karma/bin/karma start karma.conf.js
echo "Starting Karma test"
cd /tmp/code/t/
./node_modules/karma/bin/karma start config/karma.conf.js
echo "Starting webdriverio test"
echo "Starting WebdriverIO test"
cd /tmp/code/
sencha web start &
/opt/Sencha/Cmd/sencha web start &
sleep 5
cd /tmp/code/t
./node_modules/.bin/wdio wdio.conf.js
cd /tmp/code/t/
./node_modules/.bin/wdio config/wdio.conf.js
echo "Finished test execution, test execution returned with exit code."
echo "################################################################################"

@ -1,199 +0,0 @@
exports.config = {
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
// directory is where your package.json resides, so `wdio` will be called from there.
//
specs: [
'./wdio/*.js'
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
// First, you can define how many instances should be started at the same time. Let's
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
// files and you set maxInstances to 10, all spec files will get tested at the same time
// and 30 processes will get spawned. The property handles how many capabilities
// from the same test should run tests.
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
capabilities: [{
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
// grid with only 5 firefox instance available you can make sure that not more than
// 5 instance gets started at a time.
maxInstances: 5,
//
browserName: 'phantomjs',
"phantomjs.binary.path": "/tmp/code/t/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs" // Docker path
// "phantomjs.binary.path": "/usr/local/bin/phantomjs" // Local path
}],
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
// By default WebdriverIO commands are executed in a synchronous way using
// the wdio-sync package. If you still want to run your tests in an async way
// e.g. using promises you can set the sync option to false.
sync: true,
//
// Level of logging verbosity: silent | verbose | command | data | result | error
logLevel: 'silent',
//
// Enables colors for log output.
coloredLogs: true,
//
// Saves a screenshot to a given path if a command fails.
screenshotPath: './errorShots/',
//
// Set a base URL in order to shorten url command calls. If your url parameter starts
// with "/", then the base url gets prepended.
baseUrl: 'http://localhost:1841',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
//
// Default timeout in milliseconds for request
// if Selenium Grid doesn't send response
connectionRetryTimeout: 90000,
//
// Default request retries count
connectionRetryCount: 3,
//
// Initialize the browser instance with a WebdriverIO plugin. The object should have the
// plugin name as key and the desired plugin options as properties. Make sure you have
// the plugin installed before running any tests. The following plugins are currently
// available:
// WebdriverCSS: https://github.com/webdriverio/webdrivercss
// WebdriverRTC: https://github.com/webdriverio/webdriverrtc
// Browserevent: https://github.com/webdriverio/browserevent
// plugins: {
// webdrivercss: {
// screenshotRoot: 'my-shots',
// failedComparisonsRoot: 'diffs',
// misMatchTolerance: 0.05,
// screenWidth: [320,480,640,1024]
// },
// webdriverrtc: {},
// browserevent: {}
// },
//
// Test runner services
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
// services: ['phantomjs'],
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber
// see also: http://webdriver.io/guide/testrunner/frameworks.html
//
// Make sure you have the wdio adapter package for the specific framework installed
// before running any tests.
framework: 'jasmine',
//
// Test reporter for stdout.
// The only one supported by default is 'dot'
// see also: http://webdriver.io/guide/testrunner/reporters.html
reporters: ['spec', 'junit'],
//
reporterOptions: {
outputDir: './'
},
// Options to be passed to Jasmine.
jasmineNodeOpts: {
//
// Jasmine default timeout
defaultTimeoutInterval: 10000,
//
// The Jasmine framework allows interception of each assertion in order to log the state of the application
// or website depending on the result. For example, it is pretty handy to take a screenshot every time
// an assertion fails.
expectationResultHandler: function(passed, assertion) {
// do something
}
},
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
//
// Gets executed once before all workers get launched.
// onPrepare: function (config, capabilities) {
// },
//
// Gets executed before test execution begins. At this point you can access all global
// variables, such as `browser`. It is the perfect place to define custom commands.
// before: function (capabilities, specs) {
// },
//
// Hook that gets executed before the suite starts
// beforeSuite: function (suite) {
// },
//
// Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
// beforeEach in Mocha)
// beforeHook: function () {
// },
//
// Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
// afterEach in Mocha)
// afterHook: function () {
// },
//
// Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
// beforeTest: function (test) {
// },
//
// Runs before a WebdriverIO command gets executed.
// beforeCommand: function (commandName, args) {
// },
//
// Runs after a WebdriverIO command gets executed
// afterCommand: function (commandName, args, result, error) {
// },
//
// Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
// afterTest: function (test) {
// },
//
// Hook that gets executed after the suite has ended
// afterSuite: function (suite) {
// },
//
// Gets executed after all tests are done. You still have access to all global variables from
// the test.
// after: function (result, capabilities, specs) {
// },
//
// Gets executed after all workers got shut down and the process is about to exit. It is not
// possible to defer the end of the process using a promise.
// onComplete: function(exitCode) {
// }
}

@ -0,0 +1,22 @@
#!/bin/bash
_kill_procs() {
kill -TERM $chromium
wait $chromium
kill -TERM $xvfb
}
trap _kill_procs SIGTERM
XVFB_WHD=${XVFB_WHD:-1280x720x16}
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
xvfb=$!
export DISPLAY=:99
chromium --no-sandbox $@ &
chromium=$!
wait $chromium
wait $xvfb
Loading…
Cancel
Save