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.
This commit is contained in:
Michael Krasnyk 2017-03-14 14:45:44 +01:00
parent 6586737835
commit 97c442482d
No known key found for this signature in database
GPG Key ID: 49C12AD0F43D2108
3 changed files with 8 additions and 28 deletions

View File

@ -269,14 +269,10 @@ module.exports = function () {
this.writeAndLinkOSM(callback); 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.reprocess(callback);
}); });
this.Given(/^the data has been (partition|customiz)ed$/, (step, callback) => {
this.reprocessMLD(callback);
});
this.Given(/^osrm\-routed is stopped$/, (callback) => { this.Given(/^osrm\-routed is stopped$/, (callback) => {
this.OSRMLoader.shutdown(callback); this.OSRMLoader.shutdown(callback);
}); });

View File

@ -234,7 +234,7 @@ module.exports = function () {
}); });
}; };
this.extractAndContract = (callback) => { this.extractContractPartitionAndCustomize = (callback) => {
// a shallow copy of scenario parameters to avoid data inconsistency // a shallow copy of scenario parameters to avoid data inconsistency
// if a cucumber timeout occurs during deferred jobs // if a cucumber timeout occurs during deferred jobs
let p = {extractArgs: this.extractArgs, contractArgs: this.contractArgs, let p = {extractArgs: this.extractArgs, contractArgs: this.contractArgs,
@ -244,17 +244,6 @@ module.exports = function () {
let queue = d3.queue(1); let queue = d3.queue(1);
queue.defer(this.extractData.bind(this), p); queue.defer(this.extractData.bind(this), p);
queue.defer(this.contractData.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.partitionData.bind(this), p);
queue.defer(this.customizeData.bind(this), p); queue.defer(this.customizeData.bind(this), p);
queue.awaitAll(callback); queue.awaitAll(callback);
@ -270,23 +259,14 @@ module.exports = function () {
this.reprocess = (callback) => { this.reprocess = (callback) => {
let queue = d3.queue(1); let queue = d3.queue(1);
queue.defer(this.writeAndLinkOSM.bind(this)); queue.defer(this.writeAndLinkOSM.bind(this));
queue.defer(this.extractAndContract.bind(this)); queue.defer(this.extractContractPartitionAndCustomize.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.awaitAll(callback); queue.awaitAll(callback);
}; };
this.reprocessAndLoadData = (callback) => { this.reprocessAndLoadData = (callback) => {
let queue = d3.queue(1); let queue = d3.queue(1);
queue.defer(this.writeAndLinkOSM.bind(this)); queue.defer(this.writeAndLinkOSM.bind(this));
queue.defer((this.ROUTING_ALGORITHM === 'MLD' ? queue.defer(this.extractContractPartitionAndCustomize.bind(this));
this.extractPartitionAndCustomize :
this.extractAndContract).bind(this));
queue.defer(this.osrmLoader.load.bind(this.osrmLoader), this.processedCacheFile); queue.defer(this.osrmLoader.load.bind(this.osrmLoader), this.processedCacheFile);
queue.awaitAll(callback); queue.awaitAll(callback);
}; };

View File

@ -46,6 +46,10 @@ module.exports = function () {
let child = child_process.execFile(cmd, opts, {maxBuffer: 1024 * 1024 * 1000, env: env}, callback); let child = child_process.execFile(cmd, opts, {maxBuffer: 1024 * 1024 * 1000, env: env}, callback);
child.on('exit', function(code) { child.on('exit', function(code) {
log.write(util.format('*** %s exited with code %d\n', bin, 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)); }.bind(this));
this.setupOutputLog(child, log); this.setupOutputLog(child, log);
return child; return child;