Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add limitations to timeouts #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/authenticator/formAuthenticator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

var _ = require('lodash');
var webdriver = require('selenium-webdriver');

/**
Expand All @@ -22,6 +23,16 @@ function FormAuthenticator(config,instanceConfig,logger,statisticsCollector){
this.idpSelector = instanceConfig.idpSelector;
this.redirectUrl = instanceConfig.redirectUrl;
this.statisticsCollector = statisticsCollector;

var authorizationButtonTimeout = instanceConfig.authorizationButtonTimeout;
if (_.isString(authorizationButtonTimeout)) {
authorizationButtonTimeout = parseInt(authorizationButtonTimeout, 10);
}
if (Number.isInteger(authorizationButtonTimeout) && authorizationButtonTimeout >= 0) {
this.authorizationButtonTimeout = authorizationButtonTimeout;
} else {
this.authorizationButtonTimeout = 0;
}
}

/**
Expand Down
61 changes: 33 additions & 28 deletions src/uiveri5.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,36 +126,41 @@ function run(config) {
// disable default jasmine console reporter
protractorArgv.jasmineNodeOpts.print = function() {};

// copy timeouts
if (config.timeouts){
if (config.timeouts.getPageTimeout){
var getPageTimeout = config.timeouts.getPageTimeout;
if(_.isString(getPageTimeout)){
getPageTimeout = parseInt(getPageTimeout,10);
}
logger.debug('Setting getPageTimeout: ' + getPageTimeout);
protractorArgv.getPageTimeout = getPageTimeout;
}
if (config.timeouts.allScriptsTimeout){
var allScriptsTimeout = config.timeouts.allScriptsTimeout;
if(_.isString(allScriptsTimeout)){
allScriptsTimeout = parseInt(allScriptsTimeout,10);
config.timeouts = config.timeouts || {};

var pageRedirectDelta = 100;
var defaultTimeouts = {
getPageTimeout: 10000,
allScriptsTimeout: 11000,
defaultTimeoutInterval: 30000,
waitForUI5Delta: 200,
waitForUI5PollingInterval: 400
};

function copyTimeoutFromConfig(name, minValue, path) {
minValue = minValue || 0;
path = (path ? path + '.' : '') + name;
if (!_.isUndefined(config.timeouts[name])) {
var value = config.timeouts[name];
if (_.isString(value)) {
value = parseInt(value, 10);
}
logger.debug('Setting allScriptsTimeout: ' + allScriptsTimeout);
protractorArgv.allScriptsTimeout = allScriptsTimeout;
}
if (config.timeouts.defaultTimeoutInterval){
var defaultTimeoutInterval = config.timeouts.defaultTimeoutInterval;
if(_.isString(defaultTimeoutInterval)){
defaultTimeoutInterval = parseInt(defaultTimeoutInterval,10);
if (Number.isInteger(value) && value > minValue) {
logger.debug('Setting ' + name + ': ' + value);
} else {
value = defaultTimeouts[name];
logger.debug(name + ' should be an integer > ' + minValue + '. Setting ' + name + ' to the default value: ' + value);
}
logger.debug('Setting defaultTimeoutInterval: ' + defaultTimeoutInterval);
protractorArgv.jasmineNodeOpts.defaultTimeoutInterval = defaultTimeoutInterval;
_.set(protractorArgv, path, value);
}
}

var ui5SyncDelta = config.timeouts && config.timeouts.waitForUI5Delta;
var waitForUI5Timeout = ui5SyncDelta > 0 ? (config.timeouts.allScriptsTimeout - ui5SyncDelta) : 0;
copyTimeoutFromConfig('waitForUI5Delta', 100);
copyTimeoutFromConfig('waitForUI5PollingInterval', 100);
copyTimeoutFromConfig('getPageTimeout', pageRedirectDelta);
copyTimeoutFromConfig('allScriptsTimeout', config.timeouts.waitForUI5Delta);
copyTimeoutFromConfig('defaultTimeoutInterval', protractorArgv.allScriptsTimeout, 'jasmineNodeOpts');


proxyquire('protractor/built/browser', {
'./clientsidescripts': clientsidescripts
Expand Down Expand Up @@ -345,8 +350,8 @@ function run(config) {

browser._loadUI5Dependencies = function () {
return browser.executeAsyncScriptHandleErrors('loadUI5Dependencies', {
waitForUI5Timeout: waitForUI5Timeout,
waitForUI5PollingInterval: config.timeouts.waitForUI5PollingInterval,
waitForUI5Timeout: protractorArgv.allScriptsTimeout - protractorArgv.waitForUI5Delta,
waitForUI5PollingInterval: protractorArgv.waitForUI5PollingInterval,
ClassicalWaitForUI5: ClassicalWaitForUI5,
useClassicalWaitForUI5: config.useClassicalWaitForUI5
});
Expand Down Expand Up @@ -599,7 +604,7 @@ function run(config) {
throw new Error('Could not match target url that is neither string nor regexp');
}
});
}, browser.getPageTimeout - 100,'Waiting for redirection to complete, target url: ' + targetUrl);
}, browser.getPageTimeout - pageRedirectDelta,'Waiting for redirection to complete, target url: ' + targetUrl);
// 10ms delta is necessary or webdriver crashes and the process stops without exit status
}
};
Expand Down