From 97c442482dea424b94ca36eda1fb76b9eee003da Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 14 Mar 2017 14:45:44 +0100 Subject: [PATCH] Prepare test data for both CH and MLD algorithms Leaving log files opened was intentional to avoid missing output that can appear `child.on('exit',...)`. With this approach cucumber tests hit locally maximum number of opened files, because node.js keeps all log files opened. --- features/step_definitions/data.js | 6 +----- features/support/data.js | 26 +++----------------------- features/support/run.js | 4 ++++ 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/features/step_definitions/data.js b/features/step_definitions/data.js index fe954335e..a46bb889b 100644 --- a/features/step_definitions/data.js +++ b/features/step_definitions/data.js @@ -269,14 +269,10 @@ module.exports = function () { this.writeAndLinkOSM(callback); }); - this.Given(/^the data has been (extract|contract)ed$/, (step, callback) => { + this.Given(/^the data has been (extract|contract|partition|customiz)ed$/, (step, callback) => { this.reprocess(callback); }); - this.Given(/^the data has been (partition|customiz)ed$/, (step, callback) => { - this.reprocessMLD(callback); - }); - this.Given(/^osrm\-routed is stopped$/, (callback) => { this.OSRMLoader.shutdown(callback); }); diff --git a/features/support/data.js b/features/support/data.js index 13cdebbc0..9dc9856d9 100644 --- a/features/support/data.js +++ b/features/support/data.js @@ -234,7 +234,7 @@ module.exports = function () { }); }; - this.extractAndContract = (callback) => { + this.extractContractPartitionAndCustomize = (callback) => { // a shallow copy of scenario parameters to avoid data inconsistency // if a cucumber timeout occurs during deferred jobs let p = {extractArgs: this.extractArgs, contractArgs: this.contractArgs, @@ -244,17 +244,6 @@ module.exports = function () { let queue = d3.queue(1); queue.defer(this.extractData.bind(this), p); queue.defer(this.contractData.bind(this), p); - queue.awaitAll(callback); - }; - - this.extractPartitionAndCustomize = (callback) => { - // a shallow copy of scenario parameters to avoid data inconsistency - // if a cucumber timeout occurs during deferred jobs - let p = {extractArgs: this.extractArgs, partitionArgs: this.partitionArgs, customizeArgs: this.customizeArgs, - profileFile: this.profileFile, inputCacheFile: this.inputCacheFile, - processedCacheFile: this.processedCacheFile, environment: this.environment}; - let queue = d3.queue(1); - queue.defer(this.extractData.bind(this), p); queue.defer(this.partitionData.bind(this), p); queue.defer(this.customizeData.bind(this), p); queue.awaitAll(callback); @@ -270,23 +259,14 @@ module.exports = function () { this.reprocess = (callback) => { let queue = d3.queue(1); queue.defer(this.writeAndLinkOSM.bind(this)); - queue.defer(this.extractAndContract.bind(this)); - queue.awaitAll(callback); - }; - - this.reprocessMLD = (callback) => { - let queue = d3.queue(1); - queue.defer(this.writeAndLinkOSM.bind(this)); - queue.defer(this.extractPartitionAndCustomize.bind(this)); + queue.defer(this.extractContractPartitionAndCustomize.bind(this)); queue.awaitAll(callback); }; this.reprocessAndLoadData = (callback) => { let queue = d3.queue(1); queue.defer(this.writeAndLinkOSM.bind(this)); - queue.defer((this.ROUTING_ALGORITHM === 'MLD' ? - this.extractPartitionAndCustomize : - this.extractAndContract).bind(this)); + queue.defer(this.extractContractPartitionAndCustomize.bind(this)); queue.defer(this.osrmLoader.load.bind(this.osrmLoader), this.processedCacheFile); queue.awaitAll(callback); }; diff --git a/features/support/run.js b/features/support/run.js index 4427814ad..2b4408f75 100644 --- a/features/support/run.js +++ b/features/support/run.js @@ -46,6 +46,10 @@ module.exports = function () { let child = child_process.execFile(cmd, opts, {maxBuffer: 1024 * 1024 * 1000, env: env}, callback); child.on('exit', function(code) { log.write(util.format('*** %s exited with code %d\n', bin, code)); + // remove listeners and close log file -> some tail messages can be lost + child.stdout.removeListener('data', child.logFunc); + child.stderr.removeListener('data', child.logFunc); + log.end(); }.bind(this)); this.setupOutputLog(child, log); return child;