Skip to content

Commit

Permalink
Add overrideConfig for export server (#5280)
Browse files Browse the repository at this point in the history
* add ovverideConfig

* Jenkins should run node-export tests

* missed spot needed for make target

Co-authored-by: Brian Hatchl <[email protected]>
  • Loading branch information
maxgrossman and brianhatchl authored Mar 9, 2022
1 parent 0c8fcde commit 8613a93
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ help:
@echo "js-schema - Build the Javascript schema files."
@echo "osmapidb - If configured '--with-services', then build a clean copy of an OSM API database."
@echo "translations-test - Run the mocha translations tests. Should take less than five minutes."
@echo "node-export-test - Run the mocha node export tests. Should take less than five minutes."
@echo "services-build - If configured '--with-services', then build the web services."
@echo "services-clean - If configured '--with-services', then clean the web services. This will not modify the DB."
@echo "services-clean-coverage - If configured '--with-services', then remove the web services test code coverage report output."
Expand Down Expand Up @@ -111,7 +112,7 @@ ui-build:

ui-test:
scripts/HootEnv.sh $(MAKE) -f Makefile.hoot ui-test

ui2x-test:
scripts/HootEnv.sh $(MAKE) -f Makefile.hoot ui2x-test

Expand All @@ -130,6 +131,9 @@ js-schema:
translations-test:
scripts/HootEnv.sh $(MAKE) -f Makefile.hoot translations-test

node-export-test:
scripts/HootEnv.sh $(MAKE) -f Makefile.hoot node-export-test

services-build:
$(MAKE) -f Makefile.hoot services-build

Expand Down
16 changes: 11 additions & 5 deletions node-export-server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ function zipOutput(hash,output,outFile,outDir,outZip,isFile,format,cb) {
/**
* Builds the hootenanny command(s) from parts of provided request.
*/
function buildCommand(paramschema, queryOverrideTags, querybbox, querypoly, isFile, input, outDir, outFile, doCrop, ignoreSourceIds, ignoreConf) {
function buildCommand(params, queryOverrideTags, querybbox, querypoly, isFile, input, outDir, outFile, doCrop, ignoreSourceIds, ignoreConf) {
var paramschema = params.schema;
var command = '', overrideTags = null;
if (queryOverrideTags) {
if (queryOverrideTags === 'true') { //if it's true
Expand All @@ -345,6 +346,9 @@ function buildCommand(paramschema, queryOverrideTags, querybbox, querypoly, isFi
if (!ignoreConf)
command += ' -C NodeExport.conf';

if (config.datasources[params.datasource].overrideConfig)
command += ' -C ' + config.datasources[params.datasource].overrideConfig

var convertOpts = [];
var bboxOption = '';
if (bbox) bboxOption = ' -D ' + bbox_param + '=' + bbox;
Expand Down Expand Up @@ -399,6 +403,8 @@ function buildCommand(paramschema, queryOverrideTags, querybbox, querypoly, isFi
return command;
};

exports.buildCommand = buildCommand

/**
* Manages request to the node-export service.
* If provided job does not yet exist, kicks off the job and returns the hash to the user.
Expand Down Expand Up @@ -528,17 +534,17 @@ function doExport(req, res, hash, input) {
var ringOutDir = appDir + ringOutput;
var ringOutFile = ringOutDir + '.osm';

multiCommand += buildCommand('OSM', req.query.overrideTags, null, polyString, isFile, input, ringOutDir, ringOutFile, doCrop);
multiCommand += buildCommand({schema:'OSM'}, req.query.overrideTags, null, polyString, isFile, input, ringOutDir, ringOutFile, doCrop);
multiCommand += ' && ';

rings.push(ringOutFile);
}

//here we merge the rings into a single osm file and create a new id sequence (to avoid negative id collisions).
multiCommand += buildCommand('OSM', req.query.overrideTags, null, null, true, rings.join(' '), outDir, tempOsmFile, false, true);
multiCommand += buildCommand({schema:'OSM'}, req.query.overrideTags, null, null, true, rings.join(' '), outDir, tempOsmFile, false, true);
//if we need to make a shapefile/geodatabase or our ourput schema is not OSM, then we add a second command that'll do so.
if (!isFile || req.params.schema !== 'OSM')
multiCommand += ' && ' + buildCommand(req.params.schema, req.query.overrideTags, null, null, isFile, tempOsmFile, outDir, outFile, false, false, true);
multiCommand += ' && ' + buildCommand(req.params, req.query.overrideTags, null, null, isFile, tempOsmFile, outDir, outFile, false, false, true);

console.log(multiCommand);
child = exec(multiCommand, function(error, stdout, stderr) {
Expand All @@ -562,7 +568,7 @@ function doExport(req, res, hash, input) {
}
})
} else {
var command = buildCommand(req.params.schema, req.params.tagOverrides, req.query.bbox, req.query.poly, isFile, input, outDir, outFile, Number(req.query.crop));
var command = buildCommand(req.params, req.params.tagOverrides, req.query.bbox, req.query.poly, isFile, input, outDir, outFile, Number(req.query.crop));
console.log(command);
child = exec(command, {cwd: hootHome},
function(error, stdout, stderr) {
Expand Down
18 changes: 16 additions & 2 deletions node-export-server/test/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion scripts/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pipeline {
stage("Core Tests") {
when { expression { return params.Core_tests } }
steps {
// Unfortunately, the code coverage report generation slows down tests and results in a lot of "Waiting
// Unfortunately, the code coverage report generation slows down tests and results in a lot of "Waiting
// for process to finish..." messages to be displayed that you wouldn't see otherwise. So, we may want
// to make a change that runs this as --error here or increase the wait time when generating the report.
sh "vagrant ssh ${params.Box} -c 'cd hoot; source ./SetupEnv.sh; hoot version --debug; bin/HootTest --error --glacial --diff --parallel ${params.show_names}'"
Expand All @@ -174,6 +174,12 @@ pipeline {
sh "vagrant ssh ${params.Box} -c 'cd hoot; make -sj`nproc` translations-test'"
}
}
stage("Node Export Tests") {
when { expression { return params.Services_tests } }
steps {
sh "vagrant ssh ${params.Box} -c 'cd hoot; make -sj`nproc` node-export-test'"
}
}
stage("Core Coverage") {
when {
anyOf {
Expand Down

0 comments on commit 8613a93

Please sign in to comment.