From ba2356d2ba994d529e376598f64e146d13747560 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 31 Mar 2014 16:05:09 +0200 Subject: [PATCH 1/5] cuke: optional timeout --- features/support/env.rb | 10 +++++++++- features/support/launch.rb | 6 ++---- features/support/locate.rb | 2 +- features/support/nearest.rb | 2 +- features/support/route.rb | 3 +-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/features/support/env.rb b/features/support/env.rb index 146838f386..2cbc4e46d2 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,7 +1,7 @@ require 'rspec/expectations' DEFAULT_PORT = 5000 - +DEFAULT_TIMEOUT = 2 puts "Ruby version #{RUBY_VERSION}" unless RUBY_VERSION.to_f >= 1.9 @@ -16,6 +16,14 @@ puts "Using default port #{OSRM_PORT}" end +if ENV["OSRM_TIMEOUT"] + OSRM_TIMEOUT = ENV["OSRM_TIMEOUT"].to_i + puts "Timeout set to #{OSRM_TIMEOUT}" +else + OSRM_TIMEOUT = DEFAULT_TIMEOUT + puts "Using default timeout #{OSRM_TIMEOUT}" +end + AfterConfiguration do |config| clear_log_files diff --git a/features/support/launch.rb b/features/support/launch.rb index 7dbaee168c..6699fb947f 100644 --- a/features/support/launch.rb +++ b/features/support/launch.rb @@ -1,8 +1,6 @@ require 'socket' require 'open3' -LAUNCH_TIMEOUT = 20 -SHUTDOWN_TIMEOUT = 20 OSRM_ROUTED_LOG_FILE = 'osrm-routed.log' class OSRMBackgroundLauncher @@ -21,7 +19,7 @@ def initialize input_file, &block private def launch - Timeout.timeout(LAUNCH_TIMEOUT) do + Timeout.timeout(OSRM_TIMEOUT) do osrm_up wait_for_connection end @@ -30,7 +28,7 @@ def launch end def shutdown - Timeout.timeout(SHUTDOWN_TIMEOUT) do + Timeout.timeout(OSRM_TIMEOUT) do osrm_down end rescue Timeout::Error diff --git a/features/support/locate.rb b/features/support/locate.rb index b7dc55f6d5..9007247034 100644 --- a/features/support/locate.rb +++ b/features/support/locate.rb @@ -3,7 +3,7 @@ def request_locate_url path @query = path uri = URI.parse "#{HOST}/#{path}" - Timeout.timeout(REQUEST_TIMEOUT) do + Timeout.timeout(OSRM_TIMEOUT) do Net::HTTP.get_response uri end rescue Errno::ECONNREFUSED => e diff --git a/features/support/nearest.rb b/features/support/nearest.rb index e371307357..77fc351a9e 100644 --- a/features/support/nearest.rb +++ b/features/support/nearest.rb @@ -3,7 +3,7 @@ def request_nearest_url path @query = path uri = URI.parse "#{HOST}/#{path}" - Timeout.timeout(REQUEST_TIMEOUT) do + Timeout.timeout(OSRM_TIMEOUT) do Net::HTTP.get_response uri end rescue Errno::ECONNREFUSED => e diff --git a/features/support/route.rb b/features/support/route.rb index 417ba0d49f..15dbf77a47 100644 --- a/features/support/route.rb +++ b/features/support/route.rb @@ -1,7 +1,6 @@ require 'net/http' HOST = "http://localhost:#{OSRM_PORT}" -REQUEST_TIMEOUT = 1 DESTINATION_REACHED = 15 #OSRM instruction code class Hash @@ -18,7 +17,7 @@ def request_path path, waypoints=[], options={} params = nil if params=="" uri = URI.parse ["#{HOST}/#{path}", params].compact.join('?') @query = uri.to_s - Timeout.timeout(REQUEST_TIMEOUT) do + Timeout.timeout(OSRM_TIMEOUT) do Net::HTTP.get_response uri end rescue Errno::ECONNREFUSED => e From 775627473afaed32e7f90bc29fdad1e39848633b Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 19 Mar 2014 18:03:38 +0100 Subject: [PATCH 2/5] remove .osm deprecation warning --- Extractor/XMLParser.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Extractor/XMLParser.cpp b/Extractor/XMLParser.cpp index e0deb29f50..26c31ebd2d 100644 --- a/Extractor/XMLParser.cpp +++ b/Extractor/XMLParser.cpp @@ -41,9 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include XMLParser::XMLParser(const char * filename, ExtractorCallbacks* ec, ScriptingEnvironment& se) : BaseParser(ec, se) { - SimpleLogger().Write(logWARNING) << - "Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf"; - inputReader = inputReaderFactory(filename); } From 72f41c5b4fe825b1ac336281a337ce7f6a0f6446 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 19 Mar 2014 18:03:38 +0100 Subject: [PATCH 3/5] check for empty input in extractor, same msg in prepare --- extractor.cpp | 5 +++++ prepare.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/extractor.cpp b/extractor.cpp index 5da11cc1c0..deae476a92 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -193,6 +193,11 @@ int main (int argc, char *argv[]) { (get_timestamp() - parsing_start_time) << " seconds"; + if( externalMemory.all_edges_list.empty() ) { + SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; + return -1; + } + externalMemory.PrepareData(output_file_name, restrictionsFileName); delete parser; diff --git a/prepare.cpp b/prepare.cpp index 08a116dcc2..5664a50358 100644 --- a/prepare.cpp +++ b/prepare.cpp @@ -236,17 +236,17 @@ int main (int argc, char *argv[]) { std::vector edgeList; NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternalNodeMapping, inputRestrictions); in.close(); - SimpleLogger().Write() << - inputRestrictions.size() << " restrictions, " << - bollardNodes.size() << " bollard nodes, " << - trafficLightNodes.size() << " traffic lights"; if( edgeList.empty() ) { - SimpleLogger().Write(logWARNING) << "The input data is broken. " - "It is impossible to do any turns in this graph"; + SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; return -1; } + SimpleLogger().Write() << + inputRestrictions.size() << " restrictions, " << + bollardNodes.size() << " bollard nodes, " << + trafficLightNodes.size() << " traffic lights"; + /*** * Building an edge-expanded graph from node-based input an turn restrictions */ From 220e7748a99fb2807f7b721d471f43e12a48b568 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Wed, 19 Mar 2014 18:03:38 +0100 Subject: [PATCH 4/5] cuke: use .osm by default, add tests for .pbf --- features/step_definitions/data.rb | 4 + features/support/data.rb | 13 ++- features/testbot/protobuffer.feature | 156 +++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 features/testbot/protobuffer.feature diff --git a/features/step_definitions/data.rb b/features/step_definitions/data.rb index 1e9fa7149e..d6cea41da9 100644 --- a/features/step_definitions/data.rb +++ b/features/step_definitions/data.rb @@ -2,6 +2,10 @@ set_profile profile end +Given(/^the import format "(.*?)"$/) do |format| + set_input_format format +end + Given /^a grid size of (\d+) meters$/ do |meters| set_grid_size meters end diff --git a/features/support/data.rb b/features/support/data.rb index c389e4e0ab..1d9522994c 100644 --- a/features/support/data.rb +++ b/features/support/data.rb @@ -13,7 +13,7 @@ DEFAULT_GRID_SIZE = 100 #meters PROFILES_PATH = '../profiles' BIN_PATH = '../build' - +DEFAULT_INPUT_FORMAT = 'osm' DEFAULT_ORIGIN = [1,1] class Location @@ -25,6 +25,15 @@ def initialize lon,lat end end +def set_input_format format + raise '*** Input format must be eiter "osm" or "pbf"' unless ['pbf','osm'].include? format.to_s + @input_format = format.to_s +end + +def input_format + @input_format || DEFAULT_INPUT_FORMAT +end + def sanitized_scenario_title @sanitized_scenario_title ||= @scenario_title.gsub /[^0-9A-Za-z.\-]/, '_' end @@ -244,8 +253,8 @@ def write_timestamp end def reprocess - use_pbf = true Dir.chdir TEST_FOLDER do + use_pbf = (input_format=='pbf') write_osm write_timestamp convert_osm_to_pbf if use_pbf diff --git a/features/testbot/protobuffer.feature b/features/testbot/protobuffer.feature new file mode 100644 index 0000000000..016a233bee --- /dev/null +++ b/features/testbot/protobuffer.feature @@ -0,0 +1,156 @@ +@routing @pbf +Feature: Importing protobuffer (.pbf) format +# Test normally read .osm, which is faster than .pbf files, +# since we don't need to use osmosis to first convert to .pbf +# The scenarios in this file test the ability to import .pbf files, +# including nodes, way, restictions, and a various special situations. + + Background: + Given the profile "testbot" + And the import format "pbf" + + Scenario: Testbot - Protobuffer import, nodes and ways + Given the node map + | | | | d | + | a | b | c | | + | | | | e | + + And the ways + | nodes | highway | oneway | + | abc | primary | | + | cd | primary | yes | + | ce | river | | + | de | primary | | + + When I route I should get + | from | to | route | + | d | c | de,ce | + | e | d | de | + + + Scenario: Testbot - Protobuffer import, turn restiction relations + Given the node map + | | n | | + | w | j | e | + | | s | | + + And the ways + | nodes | oneway | + | sj | yes | + | nj | -1 | + | wj | -1 | + | ej | -1 | + + And the relations + | type | way:from | way:to | node:via | restriction | + | restriction | sj | wj | j | no_left_turn | + + When I route I should get + | from | to | route | + | s | w | | + | s | n | sj,nj | + | s | e | sj,ej | + + + Scenario: Testbot - Protobuffer import, distances at longitude 45 + Given the node locations + | node | lat | lon | + | a | 80 | 45 | + | b | 0 | 45 | + + And the ways + | nodes | + | ab | + + When I route I should get + | from | to | route | distance | + | a | b | ab | 8905559m ~0.1% | + + Scenario: Testbot - Protobuffer import, distances at longitude 80 + Given the node locations + | node | lat | lon | + | a | 80 | 80 | + | b | 0 | 80 | + + And the ways + | nodes | + | ab | + + When I route I should get + | from | to | route | distance | + | a | b | ab | 8905559m ~0.1% | + + Scenario: Testbot - Protobuffer import, empty dataset + Given the node map + | | + + Given the ways + | nodes | + + When I preprocess data + Then "osrm-extract" should return code 255 + + + Scenario: Testbot - Protobuffer import, streetnames with UTF characters + Given the node map + | a | b | c | d | + + And the ways + | nodes | name | + | ab | Scandinavian København | + | bc | Japanese 東京 | + | cd | Cyrillic Москва | + + When I route I should get + | from | to | route | + | a | b | Scandinavian København | + | b | c | Japanese 東京 | + | c | d | Cyrillic Москва | + + Scenario: Testbot - Protobuffer import, bearing af 45 degree intervals + Given the node map + | b | a | h | + | c | x | g | + | d | e | f | + + And the ways + | nodes | + | xa | + | xb | + | xc | + | xd | + | xe | + | xf | + | xg | + | xh | + + When I route I should get + | from | to | route | compass | bearing | + | x | a | xa | N | 0 | + | x | b | xb | NW | 315 | + | x | c | xc | W | 270 | + | x | d | xd | SW | 225 | + | x | e | xe | S | 180 | + | x | f | xf | SE | 135 | + | x | g | xg | E | 90 | + | x | h | xh | NE | 45 | + + + Scenario: Testbot - Protobuffer import, rraffic signals should incur a delay + Given the node map + | a | b | c | + | d | e | f | + + And the nodes + | node | highway | + | e | traffic_signals | + + And the ways + | nodes | + | abc | + | def | + + When I route I should get + | from | to | route | time | distance | + | a | c | abc | 20s +-1 | 200m +-1 | + | d | f | def | 27s +-1 | 200m +-1 | From e73145d55855805acd1fd4b51392309bbbe0ba09 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 31 Mar 2014 16:50:46 +0200 Subject: [PATCH 5/5] travis: set osrm timeout to 60s --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89329c56c0..6bfc4dcf7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,8 +29,8 @@ cache: - bundler - apt env: - - CMAKEOPTIONS="-DCMAKE_BUILD_TYPE=Release" OSRM_PORT=5000 - - CMAKEOPTIONS="-DCMAKE_BUILD_TYPE=Debug" OSRM_PORT=5010 + - CMAKEOPTIONS="-DCMAKE_BUILD_TYPE=Release" OSRM_PORT=5000 OSRM_TIMEOUT=60 + - CMAKEOPTIONS="-DCMAKE_BUILD_TYPE=Debug" OSRM_PORT=5010 OSRM_TIMEOUT=60 notifications: irc: channels: