2012-11-01 23:17:31 +01:00
|
|
|
var srcFolder = "../../../src/node_modules/";
|
|
|
|
var wd = require(srcFolder + "wd");
|
2012-11-03 16:55:14 +01:00
|
|
|
var async = require(srcFolder + "async");
|
2012-11-01 23:17:31 +01:00
|
|
|
|
|
|
|
var config = {
|
2013-12-05 08:41:29 +01:00
|
|
|
host: "ondemand.saucelabs.com"
|
2012-11-01 23:17:31 +01:00
|
|
|
, port: 80
|
|
|
|
, username: process.env.SAUCE_USER
|
2013-06-06 18:58:06 +02:00
|
|
|
, accessKey: process.env.SAUCE_ACCESS_KEY
|
2012-11-01 23:17:31 +01:00
|
|
|
}
|
|
|
|
|
2012-11-03 16:55:14 +01:00
|
|
|
var allTestsPassed = true;
|
2012-11-01 23:17:31 +01:00
|
|
|
|
2012-11-03 16:55:14 +01:00
|
|
|
var sauceTestWorker = async.queue(function (testSettings, callback) {
|
2018-07-09 22:09:02 +02:00
|
|
|
var browser = wd.promiseChainRemote(config.host, config.port, config.username, config.accessKey);
|
2012-11-03 16:55:14 +01:00
|
|
|
var name = process.env.GIT_HASH + " - " + testSettings.browserName + " " + testSettings.version + ", " + testSettings.platform;
|
|
|
|
testSettings.name = name;
|
2012-11-03 18:46:02 +01:00
|
|
|
testSettings["public"] = true;
|
|
|
|
testSettings["build"] = process.env.GIT_HASH;
|
2020-07-13 16:12:39 +02:00
|
|
|
testSettings["extendedDebugging"] = true; // console.json can be downloaded via saucelabs, don't know how to print them into output of the tests
|
|
|
|
testSettings["tunnelIdentifier"] = process.env.TRAVIS_JOB_NUMBER;
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-05-29 13:28:31 +02:00
|
|
|
browser.init(testSettings).get("http://localhost:9001/tests/frontend/", function(){
|
|
|
|
var url = "https://saucelabs.com/jobs/" + browser.sessionID;
|
|
|
|
console.log("Remote sauce test '" + name + "' started! " + url);
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-05-29 13:28:31 +02:00
|
|
|
//tear down the test excecution
|
2020-07-28 20:57:33 +02:00
|
|
|
var stopSauce = function(success,timesup){
|
|
|
|
clearInterval(getStatusInterval);
|
2020-05-29 13:28:31 +02:00
|
|
|
clearTimeout(timeout);
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-07-28 20:57:33 +02:00
|
|
|
browser.quit(function(){
|
|
|
|
if(!success){
|
|
|
|
allTestsPassed = false;
|
|
|
|
}
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-07-28 20:57:33 +02:00
|
|
|
// if stopSauce is called via timeout (in contrast to via getStatusInterval) than the log of up to the last
|
|
|
|
// five seconds may not be available here. It's an error anyway, so don't care about it.
|
|
|
|
var testResult = knownConsoleText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m')
|
|
|
|
.replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m');
|
|
|
|
testResult = testResult.split("\\n").map(function(line){
|
|
|
|
return "[" + testSettings.browserName + " " + testSettings.platform + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] " + line;
|
|
|
|
}).join("\n");
|
|
|
|
|
|
|
|
console.log(testResult);
|
|
|
|
if (timesup) {
|
2020-08-30 17:41:12 +02:00
|
|
|
console.log("[" + testSettings.browserName + " " + testSettings.platform + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] \x1B[31mFAILED\x1B[39m allowed test duration exceeded");
|
2020-07-28 20:57:33 +02:00
|
|
|
}
|
|
|
|
console.log("Remote sauce test '" + name + "' finished! " + url);
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-07-28 20:57:33 +02:00
|
|
|
callback();
|
|
|
|
});
|
2020-05-29 13:28:31 +02:00
|
|
|
}
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-07-13 16:12:39 +02:00
|
|
|
/**
|
2020-07-28 20:57:33 +02:00
|
|
|
* timeout if a test hangs or the job exceeds 9.5 minutes
|
|
|
|
* It's necessary because if travis kills the saucelabs session due to inactivity, we don't get any output
|
2020-07-13 16:12:39 +02:00
|
|
|
* @todo this should be configured in testSettings, see https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options#TestConfigurationOptions-Timeouts
|
|
|
|
*/
|
2020-05-29 13:28:31 +02:00
|
|
|
var timeout = setTimeout(function(){
|
2020-07-28 20:57:33 +02:00
|
|
|
stopSauce(false,true);
|
|
|
|
}, 570000); // travis timeout is 10 minutes, set this to a slightly lower value
|
2020-05-29 13:28:31 +02:00
|
|
|
|
|
|
|
var knownConsoleText = "";
|
|
|
|
var getStatusInterval = setInterval(function(){
|
|
|
|
browser.eval("$('#console').text()", function(err, consoleText){
|
|
|
|
if(!consoleText || err){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
knownConsoleText = consoleText;
|
|
|
|
|
|
|
|
if(knownConsoleText.indexOf("FINISHED") > 0){
|
2020-07-28 20:57:33 +02:00
|
|
|
let match = knownConsoleText.match(/FINISHED.*([0-9]+) tests passed, ([0-9]+) tests failed/);
|
|
|
|
// finished without failures
|
|
|
|
if (match[2] && match[2] == '0'){
|
2020-07-13 16:12:39 +02:00
|
|
|
stopSauce(true);
|
2020-07-28 20:57:33 +02:00
|
|
|
|
|
|
|
// finished but some tests did not return or some tests failed
|
|
|
|
} else {
|
2020-07-13 16:12:39 +02:00
|
|
|
stopSauce(false);
|
|
|
|
}
|
2020-05-29 13:28:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 5000);
|
|
|
|
});
|
|
|
|
|
2020-07-13 16:12:39 +02:00
|
|
|
}, 6); //run 6 tests in parrallel
|
2012-11-03 16:55:14 +01:00
|
|
|
|
2020-03-22 12:48:53 +01:00
|
|
|
// 1) Firefox on Linux
|
2012-11-03 16:55:14 +01:00
|
|
|
sauceTestWorker.push({
|
2020-07-17 14:28:24 +02:00
|
|
|
'platform' : 'Windows 7'
|
2012-11-01 23:17:31 +01:00
|
|
|
, 'browserName' : 'firefox'
|
2020-07-17 13:58:32 +02:00
|
|
|
, 'version' : '52.0'
|
2012-11-03 16:55:14 +01:00
|
|
|
});
|
2020-05-29 18:52:00 +02:00
|
|
|
|
2020-03-22 12:48:53 +01:00
|
|
|
// 2) Chrome on Linux
|
2012-11-03 16:55:14 +01:00
|
|
|
sauceTestWorker.push({
|
2020-07-17 14:40:13 +02:00
|
|
|
'platform' : 'Windows 7'
|
2020-07-13 16:12:39 +02:00
|
|
|
, 'browserName' : 'chrome'
|
2020-07-17 13:58:32 +02:00
|
|
|
, 'version' : '55.0'
|
2020-07-28 11:33:49 +02:00
|
|
|
, 'args' : ['--use-fake-device-for-media-stream']
|
2012-11-03 16:55:14 +01:00
|
|
|
});
|
2020-05-29 18:52:00 +02:00
|
|
|
|
2020-03-22 12:48:53 +01:00
|
|
|
// 3) Safari on OSX 10.15
|
2012-11-03 16:55:14 +01:00
|
|
|
sauceTestWorker.push({
|
2020-03-22 12:48:53 +01:00
|
|
|
'platform' : 'OS X 10.15'
|
|
|
|
, 'browserName' : 'safari'
|
2020-07-13 16:12:39 +02:00
|
|
|
, 'version' : '13.1'
|
|
|
|
});
|
|
|
|
|
|
|
|
// 4) Safari on OSX 10.14
|
|
|
|
sauceTestWorker.push({
|
|
|
|
'platform' : 'OS X 10.14'
|
|
|
|
, 'browserName' : 'safari'
|
|
|
|
, 'version' : '12.0'
|
2012-11-03 16:55:14 +01:00
|
|
|
});
|
2020-05-29 22:06:38 +02:00
|
|
|
// IE 10 doesn't appear to be working anyway
|
|
|
|
/*
|
2020-03-22 12:48:53 +01:00
|
|
|
// 4) IE 10 on Win 8
|
2012-11-03 16:55:14 +01:00
|
|
|
sauceTestWorker.push({
|
2020-03-22 12:48:53 +01:00
|
|
|
'platform' : 'Windows 8'
|
2012-11-03 16:55:14 +01:00
|
|
|
, 'browserName' : 'iexplore'
|
2020-03-22 12:48:53 +01:00
|
|
|
, 'version' : '10.0'
|
2012-11-03 16:55:14 +01:00
|
|
|
});
|
2020-05-29 22:06:38 +02:00
|
|
|
*/
|
2020-03-22 12:48:53 +01:00
|
|
|
// 5) Edge on Win 10
|
2012-11-03 16:55:14 +01:00
|
|
|
sauceTestWorker.push({
|
2020-03-22 12:48:53 +01:00
|
|
|
'platform' : 'Windows 10'
|
|
|
|
, 'browserName' : 'microsoftedge'
|
2020-07-13 16:12:39 +02:00
|
|
|
, 'version' : '83.0'
|
|
|
|
});
|
|
|
|
// 6) Firefox on Win 7
|
|
|
|
sauceTestWorker.push({
|
|
|
|
'platform' : 'Windows 7'
|
|
|
|
, 'browserName' : 'firefox'
|
|
|
|
, 'version' : '78.0'
|
2012-11-03 16:55:14 +01:00
|
|
|
});
|
2020-05-29 18:50:11 +02:00
|
|
|
|
2020-07-28 20:57:33 +02:00
|
|
|
sauceTestWorker.drain(function() {
|
|
|
|
process.exit(allTestsPassed ? 0 : 1);
|
|
|
|
});
|