From c2263fec9b70b7f0292551e35f41d828355ef490 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Thu, 5 May 2016 18:36:30 +0200 Subject: [PATCH] One TIMEOUT to rule them all --- .travis.yml | 3 +-- features/step_definitions/options.js | 2 +- features/step_definitions/routing.js | 3 +-- features/support/config.js | 2 -- features/support/env.js | 29 +++------------------------- features/support/http.js | 2 +- features/support/launch_classes.js | 4 ++-- features/support/route.js | 2 +- 8 files changed, 10 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index af7be0f5d..680976577 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ matrix: - os: osx osx_image: xcode7.3 compiler: clang - env: CCOMPILER='clang' CXXCOMPILER='clang++' BUILD_TYPE='Debug' JOBS=1 + env: CCOMPILER='clang' CXXCOMPILER='clang++' BUILD_TYPE='Debug' JOBS=1 CUCUMBER_TIMEOUT=10000 # Release Builds - os: linux @@ -134,7 +134,6 @@ install: fi - mkdir build && pushd build - export CC=${CCOMPILER} CXX=${CXXCOMPILER} - - export OSRM_PORT=5000 OSRM_TIMEOUT=10000 - cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} -DCOVERAGE=${COVERAGE:-OFF} -DBUILD_TOOLS=1 -DENABLE_CCACHE=ON - echo "travis_fold:start:MAKE" - make --jobs=${JOBS} diff --git a/features/step_definitions/options.js b/features/step_definitions/options.js index 27d6fd3ab..166c3b34a 100644 --- a/features/step_definitions/options.js +++ b/features/step_definitions/options.js @@ -1,7 +1,7 @@ var assert = require('assert'); module.exports = function () { - this.When(/^I run "osrm\-routed\s?(.*?)"$/, { timeout: this.SHUTDOWN_TIMEOUT }, (options, callback) => { + this.When(/^I run "osrm\-routed\s?(.*?)"$/, { timeout: this.TIMEOUT }, (options, callback) => { this.runBin('osrm-routed', options, () => { callback(); }); diff --git a/features/step_definitions/routing.js b/features/step_definitions/routing.js index d48573e99..c3e679aa5 100644 --- a/features/step_definitions/routing.js +++ b/features/step_definitions/routing.js @@ -3,8 +3,7 @@ var d3 = require('d3-queue'); module.exports = function () { this.When(/^I route I should get$/, this.WhenIRouteIShouldGet); - // This is used to route 100 times; timeout for entire step is therefore set to 100 * STRESS_TIMEOUT - this.When(/^I route (\d+) times I should get$/, { timeout: 30000 }, (n, table, callback) => { + this.When(/^I route (\d+) times I should get$/, { timeout: 100 * this.TIMEOUT }, (n, table, callback) => { var q = d3.queue(1); for (var i=0; i { - this.DEFAULT_PORT = 5000; - // OSX builds on Travis hit a timeout of ~2000 from time to time - this.DEFAULT_TIMEOUT = 5000; - this.setDefaultTimeout(this.DEFAULT_TIMEOUT); + this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000; + this.TIMEOUT = process.env.CUCUMBER_TIMEOUT && parseInt(process.env.CUCUMBER_TIMEOUT) || 3000; + this.setDefaultTimeout(this.TIMEOUT); this.ROOT_FOLDER = process.cwd(); this.OSM_USER = 'osrm'; this.OSM_GENERATOR = 'osrm-test'; @@ -25,8 +24,6 @@ module.exports = function () { this.BIN_PATH = path.resolve(this.ROOT_FOLDER, 'build'); this.DEFAULT_INPUT_FORMAT = 'osm'; this.DEFAULT_ORIGIN = [1,1]; - this.LAUNCH_TIMEOUT = 1000; - this.SHUTDOWN_TIMEOUT = 10000; this.DEFAULT_LOAD_METHOD = 'datastore'; this.OSRM_ROUTED_LOG_FILE = path.resolve(this.TEST_FOLDER, 'osrm-routed.log'); this.ERROR_LOG_FILE = path.resolve(this.TEST_FOLDER, 'error.log'); @@ -51,26 +48,6 @@ module.exports = function () { console.info(util.format('Node Version', process.version)); if (parseInt(process.version.match(/v(\d)/)[1]) < 4) throw new Error('*** PLease upgrade to Node 4.+ to run OSRM cucumber tests'); - if (process.env.OSRM_PORT) { - this.OSRM_PORT = parseInt(process.env.OSRM_PORT); - // eslint-disable-next-line no-console - console.info(util.format('Port set to %d', this.OSRM_PORT)); - } else { - this.OSRM_PORT = this.DEFAULT_PORT; - // eslint-disable-next-line no-console - console.info(util.format('Using default port %d', this.OSRM_PORT)); - } - - if (process.env.OSRM_TIMEOUT) { - this.OSRM_TIMEOUT = parseInt(process.env.OSRM_TIMEOUT); - // eslint-disable-next-line no-console - console.info(util.format('Timeout set to %d', this.OSRM_TIMEOUT)); - } else { - this.OSRM_TIMEOUT = this.DEFAULT_TIMEOUT; - // eslint-disable-next-line no-console - console.info(util.format('Using default timeout %d', this.OSRM_TIMEOUT)); - } - fs.exists(this.TEST_FOLDER, (exists) => { if (!exists) throw new Error(util.format('*** Test folder %s doesn\'t exist.', this.TEST_FOLDER)); callback(); diff --git a/features/support/http.js b/features/support/http.js index 5da59c428..3ae2edc93 100644 --- a/features/support/http.js +++ b/features/support/http.js @@ -20,7 +20,7 @@ module.exports = function () { }; this.sendRequest = (baseUri, parameters, callback) => { - var limit = Timeout(this.OSRM_TIMEOUT, { err: { statusCode: 408 } }); + var limit = Timeout(this.TIMEOUT, { err: { statusCode: 408 } }); var runRequest = (cb) => { var params = this.paramsToString(parameters); diff --git a/features/support/launch_classes.js b/features/support/launch_classes.js index 38f3b313d..976f89ead 100644 --- a/features/support/launch_classes.js +++ b/features/support/launch_classes.js @@ -12,7 +12,7 @@ var OSRMBaseLoader = class { } launch (callback) { - var limit = Timeout(this.scope.LAUNCH_TIMEOUT, { err: this.scope.RoutedError('Launching osrm-routed timed out.') }); + var limit = Timeout(this.scope.TIMEOUT, { err: this.scope.RoutedError('Launching osrm-routed timed out.') }); var runLaunch = (cb) => { this.osrmUp(() => { @@ -24,7 +24,7 @@ var OSRMBaseLoader = class { } shutdown (callback) { - var limit = Timeout(this.scope.SHUTDOWN_TIMEOUT, { err: this.scope.RoutedError('Shutting down osrm-routed timed out.')}); + var limit = Timeout(this.scope.TIMEOUT, { err: this.scope.RoutedError('Shutting down osrm-routed timed out.')}); var runShutdown = (cb) => { this.osrmDown(cb); diff --git a/features/support/route.js b/features/support/route.js index 92d474927..99a683561 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -15,7 +15,7 @@ module.exports = function () { this.requestUrl = (path, callback) => { var uri = this.query = [this.HOST, path].join('/'), - limit = Timeout(this.OSRM_TIMEOUT, { err: { statusCode: 408 } }); + limit = Timeout(this.TIMEOUT, { err: { statusCode: 408 } }); function runRequest (cb) { request(uri, cb);