Add MLD testing to cucumber tests
This commit is contained in:
@@ -179,7 +179,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
this.extractData = (p, callback) => {
|
||||
let stamp = p.processedCacheFile + '.extract';
|
||||
let stamp = p.processedCacheFile + '.stamp_extract';
|
||||
fs.exists(stamp, (exists) => {
|
||||
if (exists) return callback();
|
||||
|
||||
@@ -193,7 +193,7 @@ module.exports = function () {
|
||||
};
|
||||
|
||||
this.contractData = (p, callback) => {
|
||||
let stamp = p.processedCacheFile + '.contract';
|
||||
let stamp = p.processedCacheFile + '.stamp_contract';
|
||||
fs.exists(stamp, (exists) => {
|
||||
if (exists) return callback();
|
||||
|
||||
@@ -206,10 +206,39 @@ module.exports = function () {
|
||||
});
|
||||
};
|
||||
|
||||
this.partitionData = (p, callback) => {
|
||||
let stamp = p.processedCacheFile + '.stamp_partition';
|
||||
fs.exists(stamp, (exists) => {
|
||||
if (exists) return callback();
|
||||
|
||||
this.runBin('osrm-partition', util.format('%s %s', p.partitionArgs, p.processedCacheFile), p.environment, (err) => {
|
||||
if (err) {
|
||||
return callback(new Error(util.format('osrm-partition %s: %s', errorReason(err), err.cmd)));
|
||||
}
|
||||
fs.writeFile(stamp, 'ok', callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.customizeData = (p, callback) => {
|
||||
let stamp = p.processedCacheFile + '.stamp_customize';
|
||||
fs.exists(stamp, (exists) => {
|
||||
if (exists) return callback();
|
||||
|
||||
this.runBin('osrm-customize', util.format('%s %s', p.customizeArgs, p.processedCacheFile), p.environment, (err) => {
|
||||
if (err) {
|
||||
return callback(new Error(util.format('osrm-customize %s: %s', errorReason(err), err)));
|
||||
}
|
||||
fs.writeFile(stamp, 'ok', callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.extractAndContract = (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,
|
||||
partitionArgs: this.partitionArgs, customizeArgs: this.customizeArgs,
|
||||
profileFile: this.profileFile, inputCacheFile: this.inputCacheFile,
|
||||
processedCacheFile: this.processedCacheFile, environment: this.environment};
|
||||
let queue = d3.queue(1);
|
||||
@@ -218,6 +247,19 @@ module.exports = function () {
|
||||
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);
|
||||
};
|
||||
|
||||
this.writeAndLinkOSM = (callback) => {
|
||||
let queue = d3.queue(1);
|
||||
queue.defer(this.writeOSM.bind(this));
|
||||
@@ -232,10 +274,19 @@ module.exports = function () {
|
||||
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);
|
||||
};
|
||||
|
||||
this.reprocessAndLoadData = (callback) => {
|
||||
let queue = d3.queue(1);
|
||||
queue.defer(this.writeAndLinkOSM.bind(this));
|
||||
queue.defer(this.extractAndContract.bind(this));
|
||||
queue.defer((this.ROUTING_ALGORITHM === 'MLD' ?
|
||||
this.extractPartitionAndCustomize :
|
||||
this.extractAndContract).bind(this));
|
||||
queue.defer(this.osrmLoader.load.bind(this.osrmLoader), this.processedCacheFile);
|
||||
queue.awaitAll(callback);
|
||||
};
|
||||
|
||||
@@ -34,12 +34,12 @@ module.exports = function () {
|
||||
this.DEFAULT_LOAD_METHOD = 'datastore';
|
||||
this.DEFAULT_ORIGIN = [1,1];
|
||||
this.OSM_USER = 'osrm';
|
||||
this.OSM_GENERATOR = 'osrm-test';
|
||||
this.OSM_UID = 1;
|
||||
this.OSM_TIMESTAMP = '2000-01-01T00:00:00Z';
|
||||
this.WAY_SPACING = 100;
|
||||
this.DEFAULT_GRID_SIZE = 100; // meters
|
||||
this.ROUTING_ALGORITHM = 'CH';
|
||||
// get algorithm name from the command line profile argument
|
||||
this.ROUTING_ALGORITHM = process.argv[process.argv.indexOf('-p') + 1] === 'mld' ? 'MLD' : 'CH';
|
||||
|
||||
this.OSRM_PORT = process.env.OSRM_PORT && parseInt(process.env.OSRM_PORT) || 5000;
|
||||
this.HOST = 'http://127.0.0.1:' + this.OSRM_PORT;
|
||||
|
||||
@@ -35,6 +35,8 @@ module.exports = function () {
|
||||
this.queryParams = {};
|
||||
this.extractArgs = '';
|
||||
this.contractArgs = '';
|
||||
this.partitionArgs = '';
|
||||
this.customizeArgs = '';
|
||||
this.environment = Object.assign(this.DEFAULT_ENVIRONMENT);
|
||||
this.resetOSM();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user