cucumber cleanup, removed unused code
This commit is contained in:
parent
7e9614b9ec
commit
ec56478a3c
@ -3,7 +3,7 @@ Feature: Bike - Restricted access
|
||||
Reference: http://wiki.openstreetmap.org/wiki/Key:access
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Access tag hierachy on ways
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Bike - Squares and other areas
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
@square
|
||||
Scenario: Bike - Route along edge of a squares
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Barriers
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Barriers
|
||||
Then routability should be
|
||||
|
@ -3,7 +3,7 @@ Feature: Bike - Cycle tracks/lanes
|
||||
Reference: http://wiki.openstreetmap.org/wiki/Key:cycleway
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Cycle tracks/lanes should enable biking
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Bike - Destination only, no passing through
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Destination only street
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Bike - Handle ferry routes
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Ferry route
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Bike - Max speed restrictions
|
||||
|
||||
Background: Use specific speeds
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Respect maxspeeds when lower that way type speed
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Bike - Street names in instructions
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - A named street
|
||||
Given the node map
|
||||
|
@ -3,7 +3,7 @@ Feature: Bike - Oneway streets
|
||||
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Simple oneway
|
||||
Then routability should be
|
||||
|
@ -4,7 +4,7 @@ Feature: Bike - Turn restrictions
|
||||
Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
|
||||
|
||||
Background: Use car routing
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
@no_turning
|
||||
Scenario: Bike - No left turn
|
||||
|
@ -4,7 +4,7 @@ Platforms and railway/bus lines are connected using a relation rather that a way
|
||||
http://wiki.openstreetmap.org/wiki/Tag:public_transport%3Dstop_area
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Platforms tagged using public_transport
|
||||
Then routability should be
|
||||
|
@ -3,7 +3,7 @@ Feature: Bike - Handle ferry routes
|
||||
Bringing bikes on trains and subways
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Bringing bikes on trains
|
||||
Then routability should be
|
||||
|
@ -2,11 +2,11 @@
|
||||
Feature: Bike - Accessability of different way types
|
||||
|
||||
Background:
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
|
||||
Scenario: Bike - Basic access
|
||||
Bikes are allowed on footways etc because you can pull your bike at a lower speed.
|
||||
Given the speedprofile "bicycle"
|
||||
Given the profile "bicycle"
|
||||
Then routability should be
|
||||
| highway | forw |
|
||||
| (nil) | |
|
||||
|
@ -3,7 +3,7 @@ Feature: Car - Restricted access
|
||||
Reference: http://wiki.openstreetmap.org/wiki/Key:access
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Access tag hierachy on ways
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Barriers
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Barriers
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Destination only, no passing through
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Destination only street
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Handle ferry routes
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Use a ferry route
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Max speed restrictions
|
||||
|
||||
Background: Use specific speeds
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
Given a grid size of 1000 meters
|
||||
|
||||
Scenario: Car - Respect maxspeeds when lower that way type speed
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Street names in instructions
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - A named street
|
||||
Given the node map
|
||||
|
@ -3,7 +3,7 @@ Feature: Car - Oneway streets
|
||||
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Simple oneway
|
||||
Then routability should be
|
||||
|
@ -4,7 +4,7 @@ Feature: Car - Turn restrictions
|
||||
Note that if u-turns are allowed, turn restrictions can lead to suprising, but correct, routes.
|
||||
|
||||
Background: Use car routing
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
@no_turning
|
||||
Scenario: Car - No left turn
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Car - Accessability of different way types
|
||||
|
||||
Background:
|
||||
Given the speedprofile "car"
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Basic access
|
||||
Then routability should be
|
||||
|
@ -3,7 +3,7 @@ Feature: Foot - Oneway streets
|
||||
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
|
||||
|
||||
Background:
|
||||
Given the speedprofile "foot"
|
||||
Given the profile "foot"
|
||||
|
||||
Scenario: Foot - Walking should not be affected by oneways
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Foot - Accessability of different way types
|
||||
|
||||
Background:
|
||||
Given the speedprofile "foot"
|
||||
Given the profile "foot"
|
||||
|
||||
Scenario: Foot - Basic access
|
||||
Then routability should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Weird routings discovered
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Routing on a oneway roundabout
|
||||
Given the node map
|
||||
|
@ -1,5 +1,5 @@
|
||||
Given /^the speedprofile "([^"]*)"$/ do |profile|
|
||||
read_speedprofile profile
|
||||
Given /^the profile "([^"]*)"$/ do |profile|
|
||||
set_profile profile
|
||||
end
|
||||
|
||||
Given /^a grid size of (\d+) meters$/ do |meters|
|
||||
|
@ -1,14 +0,0 @@
|
||||
|
||||
When /^I preprocess data$/ do
|
||||
begin
|
||||
reprocess
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Then /^preparing should return code (\d+)$/ do |code|
|
||||
@process_error.class.should == OSRMError
|
||||
@process_error.process.should == 'osrm-prepare'
|
||||
@process_error.code.to_i.should == code.to_i
|
||||
end
|
@ -1,74 +0,0 @@
|
||||
require 'OSM/StreamParser'
|
||||
|
||||
class OSMTestParserCallbacks < OSM::Callbacks
|
||||
@@locations = nil
|
||||
|
||||
def self.locations
|
||||
if @@locations
|
||||
@@locations
|
||||
else
|
||||
#parse the test file, so we can later reference nodes and ways by name in tests
|
||||
@@locations = {}
|
||||
file = 'test/data/test.osm'
|
||||
callbacks = OSMTestParserCallbacks.new
|
||||
parser = OSM::StreamParser.new(:filename => file, :callbacks => callbacks)
|
||||
parser.parse
|
||||
puts @@locations
|
||||
end
|
||||
end
|
||||
|
||||
def node(node)
|
||||
@@locations[node.name] = [node.lat,node.lon]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Given /^the OSM file contains$/ do |string|
|
||||
file = 'data/test.osm'
|
||||
File.open( file, 'w') {|f| f.write(string) }
|
||||
|
||||
#convert from .osm to .osm.pbf, which is the format osrm reads
|
||||
system "osmosis --read-xml data/test.osm --write-pbf data/test.osm.pbf omitmetadata=true"
|
||||
end
|
||||
|
||||
Given /^the speedprofile contains$/ do |string|
|
||||
File.open( 'speedprofile.ini', 'w') {|f| f.write(string) }
|
||||
end
|
||||
|
||||
|
||||
|
||||
Given /^the data file "([^"]*)" is present$/ do |file|
|
||||
File.exists?(file).should == true
|
||||
end
|
||||
|
||||
When /^I run the extractor with "([^"]*)"$/ do |cmd|
|
||||
@response = `#{cmd}`
|
||||
#Dir.chdir @test_folder do
|
||||
# @response = IO.popen([cmd, :err=>[:child, :out]]) { |ls_io| ls_result_with_error = ls_io.read }
|
||||
#end
|
||||
end
|
||||
|
||||
When /^I run the preprocessor with "([^"]*)"$/ do |cmd|
|
||||
@response = `#{cmd}`
|
||||
end
|
||||
|
||||
Given /^the preprocessed files for "([^"]*)" are present and up to date$/ do |area|
|
||||
File.exists?("#{area}.osrm").should == true
|
||||
File.exists?("#{area}.osrm.names").should == true
|
||||
File.exists?("#{area}.osrm.restrictions").should == true
|
||||
File.exists?("#{area}.osrm.hsgr").should == true
|
||||
File.exists?("#{area}.osrm.nodes").should == true
|
||||
File.exists?("#{area}.osrm.edges").should == true
|
||||
File.exists?("#{area}.osrm.ramIndex").should == true
|
||||
File.exists?("#{area}.osrm.fileIndex").should == true
|
||||
File.exists?("#{area}.osrm.tiemstamp").should == true
|
||||
end
|
||||
|
||||
Then /^I should see the file "([^"]*)"$/ do |file|
|
||||
File.exists?(file).should == true
|
||||
end
|
||||
|
||||
When /^preprocessed files for "([^"]*)" has been removed$/ do |file|
|
||||
FileUtils.rm_r Dir["#{file}.*"], :secure => true
|
||||
end
|
||||
|
@ -21,3 +21,25 @@ Then /^response should be well-formed$/ do
|
||||
@json['transactionId'].class.should == String
|
||||
end
|
||||
|
||||
Then /^response should be a well-formed route$/ do
|
||||
step "response should be well-formed"
|
||||
@json['status_message'].class.should == String
|
||||
@json['route_summary'].class.should == Hash
|
||||
@json['route_geometry'].class.should == String
|
||||
@json['route_instructions'].class.should == Array
|
||||
@json['via_points'].class.should == Array
|
||||
end
|
||||
|
||||
When /^I preprocess data$/ do
|
||||
begin
|
||||
reprocess
|
||||
rescue OSRMError => e
|
||||
@process_error = e
|
||||
end
|
||||
end
|
||||
|
||||
Then /^preparing should return code (\d+)$/ do |code|
|
||||
@process_error.class.should == OSRMError
|
||||
@process_error.process.should == 'osrm-prepare'
|
||||
@process_error.code.to_i.should == code.to_i
|
||||
end
|
||||
|
40
features/step_definitions/routability.rb
Normal file
40
features/step_definitions/routability.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Then /^routability should be$/ do |table|
|
||||
build_ways_from_table table
|
||||
reprocess
|
||||
actual = []
|
||||
if table.headers&["forw","backw","bothw"] == []
|
||||
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
|
||||
end
|
||||
OSRMLauncher.new do
|
||||
table.hashes.each_with_index do |row,i|
|
||||
got = row.dup
|
||||
attempts = []
|
||||
['forw','backw','bothw'].each do |direction|
|
||||
if table.headers.include? direction
|
||||
if direction == 'forw' || direction == 'bothw'
|
||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}")
|
||||
elsif direction == 'backw' || direction == 'bothw'
|
||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
|
||||
end
|
||||
got[direction] = route_status response
|
||||
json = JSON.parse(response.body)
|
||||
if got[direction].empty? == false
|
||||
route = way_list json['route_instructions']
|
||||
if route != "w#{i}"
|
||||
got[direction] = "testing w#{i}, but got #{route}!?"
|
||||
elsif row[direction] =~ /\d+s/
|
||||
time = json['route_summary']['total_time']
|
||||
got[direction] = "#{time}s"
|
||||
end
|
||||
end
|
||||
if got[direction] != row[direction]
|
||||
attempts << { :attempt => direction, :query => @query, :response => response }
|
||||
end
|
||||
end
|
||||
end
|
||||
log_fail row,got,attempts if got != row
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
end
|
@ -1,179 +1,3 @@
|
||||
When /^I request a route from ([^"]+) to ([^"]+)$/ do |a,b|
|
||||
@response = request_route a,b
|
||||
#puts @response.body
|
||||
#@response
|
||||
end
|
||||
|
||||
When /^I request a route from "([^"]*)" to "([^"]*)"$/ do |a,b|
|
||||
locations = OSMTestParserCallbacks.locations
|
||||
raise "Locations hash is empty. To reference nodes by name, please preprocess the test file earlier in the test." unless locations
|
||||
raise "Unknown node: #{a}" unless locations[a]
|
||||
raise "Unknown node: #{b}" unless locations[b]
|
||||
@response = request_route "#{locations[a][0]},#{locations[a][1]}", "#{locations[b][0]},#{locations[b][1]}"
|
||||
end
|
||||
|
||||
Then /^response should be a well-formed route$/ do
|
||||
step "response should be well-formed"
|
||||
@json['status_message'].class.should == String
|
||||
@json['route_summary'].class.should == Hash
|
||||
@json['route_geometry'].class.should == String
|
||||
@json['route_instructions'].class.should == Array
|
||||
@json['via_points'].class.should == Array
|
||||
end
|
||||
|
||||
Then /^a route should be found$/ do
|
||||
@json['status'].should == 0
|
||||
@json['status_message'].should == "Found route between points"
|
||||
end
|
||||
|
||||
Then /^no route should be found$/ do
|
||||
@json['status'].should == 207
|
||||
@json['status_message'].should == "Cannot find route between points"
|
||||
end
|
||||
|
||||
Then /^I should get a valid response$/ do
|
||||
step "I should get a response"
|
||||
step "response should be valid JSON"
|
||||
step "response should be a well-formed route"
|
||||
#step "no error should be reported in terminal"
|
||||
end
|
||||
|
||||
Then /^I should get a route$/ do
|
||||
step "I should get a valid response"
|
||||
step "a route should be found"
|
||||
#puts @response.body
|
||||
end
|
||||
|
||||
Then /^I should not get a route$/ do
|
||||
step "I should get a valid response"
|
||||
step "no route should be found"
|
||||
end
|
||||
|
||||
Then /^the route should start at "([^']*)"$/ do |name|
|
||||
@json['route_summary']['start_point'].should == name
|
||||
end
|
||||
|
||||
Then /^the route should end at "([^']*)"$/ do |name|
|
||||
@json['route_summary']['end_point'].should == name
|
||||
end
|
||||
|
||||
Then /^distance should be between (\d+) and (\d+)$/ do |min,max|
|
||||
@json['route_summary']['total_distance'].to_i.should >= min.to_i
|
||||
@json['route_summary']['total_distance'].to_i.should <= max.to_i
|
||||
end
|
||||
|
||||
Then /^the distance should be close to (\d+)m$/ do |d|
|
||||
@json['route_summary']['total_distance'].to_i.should >= d.to_i*0.95
|
||||
@json['route_summary']['total_distance'].to_i.should <= d.to_i/0.95
|
||||
end
|
||||
|
||||
Then /^number of instructions should be (\d+)$/ do |n|
|
||||
@json['route_instructions'].size.should == n
|
||||
end
|
||||
|
||||
Then /^there should be 1 turn$/ do
|
||||
step 'there should be 1 turns'
|
||||
end
|
||||
|
||||
Then /^there should be (\d+) turns$/ do |n|
|
||||
@json['route_instructions'].map {|t| t.first}.select {|t| t =~ /^Turn/ }.size.should == n.to_i
|
||||
end
|
||||
|
||||
Then /^there should be more than (\d+) turn$/ do |n|
|
||||
@json['route_instructions'].map {|t| t.first}.select {|t| t =~ /^Turn/ }.size.should > n.to_i
|
||||
end
|
||||
|
||||
Then /^there should not be any turns$/ do
|
||||
(@json['route_instructions'].size-1).should == 0
|
||||
end
|
||||
|
||||
def sanitize_route route
|
||||
route.split(',').map{|w| w.strip}.reject(&:empty?).join(', ')
|
||||
end
|
||||
|
||||
def computed_route
|
||||
@json['route_instructions'].map { |r| r[1] }.reject(&:empty?).join(', ')
|
||||
end
|
||||
|
||||
Then /^the route should follow "([^"]*)"$/ do |route|
|
||||
sanitize_route(route).should == computed_route
|
||||
end
|
||||
|
||||
Then /^the route should not follow "([^"]*)"$/ do |route|
|
||||
sanitize_route(route).should_not == computed_route
|
||||
end
|
||||
|
||||
Then /^the route should include "([^"]*)"$/ do |route|
|
||||
sanitize_route(route).should =~ /#{computed_route}/
|
||||
end
|
||||
|
||||
Then /^the route should not include "([^"]*)"$/ do |route|
|
||||
sanitize_route(route).should_not =~ /#{computed_route}/
|
||||
end
|
||||
|
||||
Then /^the route should stay on "([^"]*)"$/ do |way|
|
||||
step "the route should start at \"#{way}\""
|
||||
step "the route should end at \"#{way}\""
|
||||
step "the route should follow \"#{way}\""
|
||||
step "there should not be any turns"
|
||||
end
|
||||
|
||||
When /^I route between "([^"]*)" and "([^"]*)"$/ do |from,to|
|
||||
reprocess
|
||||
Dir.chdir 'test' do
|
||||
from_node = name_node_hash[from]
|
||||
to_node = name_node_hash[to]
|
||||
a = "#{from_node.lon},#{from_node.lat}"
|
||||
b = "#{to_node.lon},#{to_node.lat}"
|
||||
@route = parse_response( request_route(a,b) )
|
||||
end
|
||||
end
|
||||
|
||||
Then /^"([^"]*)" should be returned$/ do |route|
|
||||
@route.should == route.split(',').join(',')
|
||||
end
|
||||
|
||||
Then /^routability should be$/ do |table|
|
||||
build_ways_from_table table
|
||||
reprocess
|
||||
actual = []
|
||||
if table.headers&["forw","backw","bothw"] == []
|
||||
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
|
||||
end
|
||||
OSRMLauncher.new do
|
||||
table.hashes.each_with_index do |row,i|
|
||||
got = row.dup
|
||||
attempts = []
|
||||
['forw','backw','bothw'].each do |direction|
|
||||
if table.headers.include? direction
|
||||
if direction == 'forw' || direction == 'bothw'
|
||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}")
|
||||
elsif direction == 'backw' || direction == 'bothw'
|
||||
response = request_route("#{ORIGIN[1]},#{ORIGIN[0]+(3+WAY_SPACING*i)*@zoom}","#{ORIGIN[1]},#{ORIGIN[0]+(1+WAY_SPACING*i)*@zoom}")
|
||||
end
|
||||
got[direction] = route_status response
|
||||
json = JSON.parse(response.body)
|
||||
if got[direction].empty? == false
|
||||
route = way_list json['route_instructions']
|
||||
if route != "w#{i}"
|
||||
got[direction] = "testing w#{i}, but got #{route}!?"
|
||||
elsif row[direction] =~ /\d+s/
|
||||
time = json['route_summary']['total_time']
|
||||
got[direction] = "#{time}s"
|
||||
end
|
||||
end
|
||||
if got[direction] != row[direction]
|
||||
attempts << { :attempt => direction, :query => @query, :response => response }
|
||||
end
|
||||
end
|
||||
end
|
||||
log_fail row,got,attempts if got != row
|
||||
actual << got
|
||||
end
|
||||
end
|
||||
table.routing_diff! actual
|
||||
end
|
||||
|
||||
When /^I route I should get$/ do |table|
|
||||
reprocess
|
||||
actual = []
|
||||
|
@ -1,10 +1,34 @@
|
||||
@stress @launch
|
||||
@stress
|
||||
Feature: Launching and shutting down
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Repeated launch and shutdown
|
||||
Scenario: Stress - 10km routing
|
||||
#osrm-routed hangs very often
|
||||
Given a grid size of 10000 meters
|
||||
Given the node map
|
||||
| h | a | b |
|
||||
| g | x | c |
|
||||
| f | e | d |
|
||||
|
||||
And the ways
|
||||
| nodes | highway |
|
||||
| xa | primary |
|
||||
| xb | primary |
|
||||
| xc | primary |
|
||||
| xd | primary |
|
||||
| xe | primary |
|
||||
| xf | primary |
|
||||
| xg | primary |
|
||||
| xh | primary |
|
||||
|
||||
When I route 100 times I should get
|
||||
| from | to | route |
|
||||
| x | h | xh |
|
||||
|
||||
Scenario: Stress - 10km routing
|
||||
#osrm-routed hangs sometimes
|
||||
Given a grid size of 10000 meters
|
||||
Given the node map
|
||||
| h | a | b |
|
||||
@ -31,4 +55,4 @@ Feature: Launching and shutting down
|
||||
| x | e | xe |
|
||||
| x | f | xf |
|
||||
| x | g | xg |
|
||||
| x | h | xh |
|
||||
| x | h | xh |
|
||||
|
@ -1,14 +1,14 @@
|
||||
def speedprofile
|
||||
@speedprofile ||= reset_speedprofile
|
||||
def profile
|
||||
@profile ||= reset_profile
|
||||
end
|
||||
|
||||
def reset_speedprofile
|
||||
@speedprofile = nil
|
||||
read_speedprofile DEFAULT_SPEEDPROFILE
|
||||
def reset_profile
|
||||
@profile = nil
|
||||
set_profile DEFAULT_SPEEDPROFILE
|
||||
end
|
||||
|
||||
def read_speedprofile profile
|
||||
@speedprofile = profile
|
||||
def set_profile profile
|
||||
@profile = profile
|
||||
end
|
||||
|
||||
def write_server_ini
|
||||
|
@ -116,7 +116,7 @@ def reset_data
|
||||
#clear_log
|
||||
#clear_data_files
|
||||
end
|
||||
reset_speedprofile
|
||||
reset_profile
|
||||
reset_osm
|
||||
@fingerprint = nil
|
||||
end
|
||||
@ -131,10 +131,6 @@ def reset_osm
|
||||
name_way_hash.clear
|
||||
@osm_str = nil
|
||||
@osm_hash = nil
|
||||
|
||||
##ID -1 causes trouble, so add a few nodes to avoid it
|
||||
#node = OSM::Node.new nil, OSM_USER, OSM_TIMESTAMP, 0,0
|
||||
#node = OSM::Node.new nil, OSM_USER, OSM_TIMESTAMP, 0,0
|
||||
@osm_id = 0
|
||||
end
|
||||
|
||||
@ -180,7 +176,6 @@ def convert_osm_to_pbf
|
||||
unless File.exist?("#{@osm_file}.osm.pbf")
|
||||
log_preprocess_info
|
||||
log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess
|
||||
#redirect stdout and stderr to a log file avoid output in the cucumber console
|
||||
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
|
||||
raise "Failed to convert to proto buffer format. Please see #{hash}.log for more info."
|
||||
end
|
||||
@ -210,7 +205,7 @@ def reprocess
|
||||
unless extracted?
|
||||
log_preprocess_info
|
||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
|
||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||
end
|
||||
@ -219,7 +214,7 @@ def reprocess
|
||||
unless prepared?
|
||||
log_preprocess_info
|
||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
|
||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
|
||||
end
|
||||
|
@ -11,8 +11,8 @@ def hash_of_file path
|
||||
return hash.hexdigest
|
||||
end
|
||||
|
||||
def speedprofile_hash
|
||||
@speedprofile_hash ||= hash_of_file "../profiles/#{@speedprofile}.lua"
|
||||
def profile_hash
|
||||
@profile_hash ||= hash_of_file "../profiles/#{@profile}.lua"
|
||||
end
|
||||
|
||||
def osm_hash
|
||||
@ -31,8 +31,8 @@ def bin_routed_hash
|
||||
@bin_routed_hash ||= hash_of_file '../osrm-routed'
|
||||
end
|
||||
|
||||
#combine state of data, speedprofile and binaries into a hash that identifies the exact test scenario
|
||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
||||
def fingerprint
|
||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{speedprofile_hash}-#{osm_hash}"
|
||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{osm_hash}"
|
||||
end
|
||||
|
||||
|
@ -14,7 +14,7 @@ def log_scenario_fail_info
|
||||
log "Failed scenario: #{@scenario_title}"
|
||||
log "Time: #{@scenario_time}"
|
||||
log "Fingerprint: #{@fingerprint}"
|
||||
log "Profile: #{@speedprofile}"
|
||||
log "Profile: #{@profile}"
|
||||
log
|
||||
log '```xml' #so output can be posted directly to github comment fields
|
||||
log osm_str.strip
|
||||
@ -51,7 +51,7 @@ def log_preprocess_info
|
||||
log '```', :preprocess
|
||||
log '', :preprocess
|
||||
log "== Profile:", :preprocess
|
||||
log @speedprofile, :preprocess
|
||||
log @profile, :preprocess
|
||||
log '', :preprocess
|
||||
@has_logged_preprocess_info = true
|
||||
end
|
||||
|
23
features/support/osm_parser.rb
Normal file
23
features/support/osm_parser.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require 'OSM/StreamParser'
|
||||
|
||||
class OSMTestParserCallbacks < OSM::Callbacks
|
||||
@@locations = nil
|
||||
|
||||
def self.locations
|
||||
if @@locations
|
||||
@@locations
|
||||
else
|
||||
#parse the test file, so we can later reference nodes and ways by name in tests
|
||||
@@locations = {}
|
||||
file = 'test/data/test.osm'
|
||||
callbacks = OSMTestParserCallbacks.new
|
||||
parser = OSM::StreamParser.new(:filename => file, :callbacks => callbacks)
|
||||
parser.parse
|
||||
puts @@locations
|
||||
end
|
||||
end
|
||||
|
||||
def node(node)
|
||||
@@locations[node.name] = [node.lat,node.lon]
|
||||
end
|
||||
end
|
@ -1,17 +0,0 @@
|
||||
require 'net/http'
|
||||
|
||||
HOST = "http://localhost:#{OSRM_PORT}"
|
||||
REQUEST_TIMEOUT = 1
|
||||
|
||||
def request_path path
|
||||
@query = path
|
||||
log path
|
||||
uri = URI.parse "#{HOST}/#{path}"
|
||||
Timeout.timeout(REQUEST_TIMEOUT) do
|
||||
Net::HTTP.get_response uri
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
raise "*** osrm-routed is not running."
|
||||
rescue Timeout::Error
|
||||
raise "*** osrm-routed did not respond."
|
||||
end
|
@ -1,6 +1,23 @@
|
||||
require 'net/http'
|
||||
|
||||
HOST = "http://localhost:#{OSRM_PORT}"
|
||||
REQUEST_TIMEOUT = 1
|
||||
DESTINATION_REACHED = 15 #OSRM instruction code
|
||||
|
||||
|
||||
def request_path path
|
||||
@query = path
|
||||
log path
|
||||
uri = URI.parse "#{HOST}/#{path}"
|
||||
Timeout.timeout(REQUEST_TIMEOUT) do
|
||||
Net::HTTP.get_response uri
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
raise "*** osrm-routed is not running."
|
||||
rescue Timeout::Error
|
||||
raise "*** osrm-routed did not respond."
|
||||
end
|
||||
|
||||
def request_route a,b
|
||||
request_path "viaroute?loc=#{a}&loc=#{b}&output=json&instructions=true&alt=true"
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Handle bad data in a graceful manner
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Empty dataset
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Basic Routing
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
@smallest
|
||||
Scenario: A single way with two nodes
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Compass bearing
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Bearing when going northwest
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Distance calculation
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: 100m distance
|
||||
Given a grid size of 100 meters
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Testbot - Handle ferry routes
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Testbot - Ferry duration, single node
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Routing close to the [0,0] origin
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: East-west oneways close to the origin
|
||||
Given the node locations
|
||||
|
@ -3,7 +3,7 @@ Feature: Penalties
|
||||
Testbot uses a signal penalty of 7s.
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Traffic signals should incur a delay, without changing distance
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Snap start/end point to the nearest way
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Snap to nearest protruding oneway
|
||||
Given the node map
|
||||
@ -98,7 +98,6 @@ Feature: Snap start/end point to the nearest way
|
||||
| b | x | xb |
|
||||
| c | x | xc |
|
||||
|
||||
@xx
|
||||
Scenario: Find edges within 1km, but not 10km
|
||||
Given a grid size of 1000 meters
|
||||
Given the node map
|
||||
@ -152,5 +151,4 @@ Feature: Snap start/end point to the nearest way
|
||||
| x | m | |
|
||||
| x | n | |
|
||||
| x | o | |
|
||||
| x | p | |
|
||||
|
||||
| x | p | |
|
@ -6,7 +6,7 @@ Secondary road: 18km/h = 18000m/3600s = 100m/20s
|
||||
Tertiary road: 12km/h = 12000m/3600s = 100m/30s
|
||||
|
||||
Background: Use specific speeds
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Basic travel time, 10m scale
|
||||
Given a grid size of 10 meters
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Turn directions/codes
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Turn directions
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Handling of UTF characters
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Streetnames with UTF characters
|
||||
Given the node map
|
||||
|
@ -2,7 +2,7 @@
|
||||
Feature: Choosing route based on length, speed, etc
|
||||
|
||||
Background:
|
||||
Given the speedprofile "testbot"
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Pick the geometrically shortest route, way types being equal
|
||||
Given the node map
|
||||
|
Loading…
Reference in New Issue
Block a user