Add nodejs test for dataset name
This commit is contained in:
parent
2c80f76004
commit
0e8b8b4901
@ -47,7 +47,7 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
|
||||
if (region_id == storage::SharedRegionRegister::INVALID_REGION_ID)
|
||||
{
|
||||
throw util::exception(
|
||||
"Could not find shared memory region. Did you run osrm-datastore?");
|
||||
"Could not find shared memory region for \"" + dataset_name +"/data\". Did you run osrm-datastore?");
|
||||
}
|
||||
shared_region = &shared_register.GetRegion(region_id);
|
||||
region = *shared_region;
|
||||
@ -94,7 +94,7 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
|
||||
facade_factory =
|
||||
DataFacadeFactory<datafacade::ContiguousInternalMemoryDataFacade, AlgorithmT>(
|
||||
std::make_shared<datafacade::SharedMemoryAllocator>(region.shm_key));
|
||||
util::Log() << "updated facade to region " << region.shm_key << " with timestamp "
|
||||
util::Log() << "updated facade to region " << (int) region.shm_key << " with timestamp "
|
||||
<< region.timestamp;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
|
||||
{
|
||||
if (config.use_shared_memory)
|
||||
{
|
||||
util::Log(logDEBUG) << "Using shared memory with algorithm "
|
||||
util::Log(logDEBUG) << "Using shared memory with name \"" << config.dataset_name << "\" with algorithm "
|
||||
<< routing_algorithms::name<Algorithm>();
|
||||
facade_provider = std::make_unique<WatchingProvider<Algorithm>>(config.dataset_name);
|
||||
}
|
||||
|
@ -135,6 +135,22 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
||||
*v8::String::Utf8Value(Nan::To<v8::String>(memory_file).ToLocalChecked());
|
||||
}
|
||||
|
||||
auto dataset_name = params->Get(Nan::New("dataset_name").ToLocalChecked());
|
||||
if (dataset_name.IsEmpty())
|
||||
return engine_config_ptr();
|
||||
if (!dataset_name->IsUndefined())
|
||||
{
|
||||
if (dataset_name->IsString())
|
||||
{
|
||||
engine_config->dataset_name = *v8::String::Utf8Value(Nan::To<v8::String>(dataset_name).ToLocalChecked());
|
||||
}
|
||||
else
|
||||
{
|
||||
Nan::ThrowError("dataset_name needs to be a string");
|
||||
return engine_config_ptr();
|
||||
}
|
||||
}
|
||||
|
||||
if (!path->IsUndefined())
|
||||
{
|
||||
engine_config->storage_config =
|
||||
|
@ -63,7 +63,7 @@ class SharedMemory
|
||||
{
|
||||
shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_only, key);
|
||||
|
||||
util::Log(logDEBUG) << "opening " << shm.get_shmid() << " from id " << id;
|
||||
util::Log(logDEBUG) << "opening " << (int) shm.get_shmid() << " from id " << (int) id;
|
||||
|
||||
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_only);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace datafacade
|
||||
|
||||
SharedMemoryAllocator::SharedMemoryAllocator(storage::SharedRegionRegister::ShmKey data_shm_key)
|
||||
{
|
||||
util::Log(logDEBUG) << "Loading new data for region " << data_shm_key;
|
||||
util::Log(logDEBUG) << "Loading new data for region " << (int)data_shm_key;
|
||||
|
||||
BOOST_ASSERT(storage::SharedMemory::RegionExists(data_shm_key));
|
||||
m_large_memory = storage::makeSharedMemory(data_shm_key);
|
||||
|
@ -90,12 +90,17 @@ inline unsigned generateServerProgramOptions(const int argc,
|
||||
|
||||
// declare a group of options that will be allowed only on command line
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
generic_options.add_options() //
|
||||
("version,v", "Show version")("help,h", "Show this help message")(
|
||||
"verbosity,l",
|
||||
boost::program_options::value<std::string>(&config.verbosity)->default_value("INFO"),
|
||||
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str())(
|
||||
"trial", value<bool>(&trial)->implicit_value(true), "Quit after initialization");
|
||||
generic_options.add_options() //
|
||||
("version,v", "Show version") //
|
||||
("help,h", "Show this help message") //
|
||||
("verbosity,l",
|
||||
#ifdef NDEBUG
|
||||
boost::program_options::value<std::string>(&config.verbosity)->default_value("INFO"),
|
||||
#else
|
||||
boost::program_options::value<std::string>(&config.verbosity)->default_value("DEBUG"),
|
||||
#endif
|
||||
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str()) //
|
||||
("trial", value<bool>(&trial)->implicit_value(true), "Quit after initialization");
|
||||
|
||||
// declare a group of options that will be allowed on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
|
@ -100,9 +100,16 @@ test('constructor: autoswitches to CoreCH for a CH dataset if capable', function
|
||||
|
||||
test('constructor: throws if data doesn\'t match algorithm', function(assert) {
|
||||
assert.plan(3);
|
||||
assert.throws(function() { new OSRM({algorithm: 'CoreCH', path: monaco_mld_path}); }, 'CoreCH with MLD data');
|
||||
assert.ok(function() { new OSRM({algorithm: 'CoreCH', path: monaco_path}); }, 'CoreCH with CH data');
|
||||
assert.throws(function() { new OSRM({algorithm: 'MLD', path: monaco_path}); }, 'MLD with CH data');
|
||||
assert.throws(function() { new OSRM({algorithm: 'CoreCH', path: monaco_mld_path}); }, /Could not find any metrics for CH/, 'CoreCH with MLD data');
|
||||
assert.ok(new OSRM({algorithm: 'CoreCH', path: monaco_path}), 'CoreCH with CH data');
|
||||
assert.throws(function() { new OSRM({algorithm: 'MLD', path: monaco_path}); }, /Could not find any metrics for MLD/, 'MLD with CH data');
|
||||
});
|
||||
|
||||
test('constructor: throws if dataset_name is not a string', function(assert) {
|
||||
assert.plan(3);
|
||||
assert.throws(function() { new OSRM({dataset_name: 1337, path: monaco_mld_path}); }, /dataset_name needs to be a string/, 'Does not accept int');
|
||||
assert.ok(new OSRM({dataset_name: "", shared_memory: true}), 'Does accept string');
|
||||
assert.throws(function() { new OSRM({dataset_name: "unsued_name___", shared_memory: true}); }, /Could not find shared memory region/, 'Does not accept wrong name');
|
||||
});
|
||||
|
||||
test('constructor: parses custom limits', function(assert) {
|
||||
|
Loading…
Reference in New Issue
Block a user