Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use osrm-datastore for testing, keep osrm-routed runnning #889

Merged
merged 8 commits into from
Oct 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion features/options/routed/files.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@routed @options @files
@routed @options @files @todo
Feature: osrm-routed command line options: files
# Normally when launching osrm-routed, it will keep running as a server until it's shut down.
# For testing program options, the --trial option is used, which causes osrm-routed to quit
Expand All @@ -7,6 +7,11 @@ Feature: osrm-routed command line options: files
# The {base} part of the options to osrm-routed will be expanded to the actual base path of
# the preprocessed file.

# TODO
# Since we're not using osmr-datastore for all testing, osrm-routed is kept running.
# This means this test fails because osrm-routed is already running.
# It probably needs to be rewritten to first quit osrm-routed.

Background:
Given the profile "testbot"
And the node map
Expand Down
16 changes: 16 additions & 0 deletions features/step_definitions/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,19 @@
@process_error = e
end
end

Given /^osrm\-routed is stopped$/ do
begin
OSRMLoader.shutdown
rescue OSRMError => e
@process_error = e
end
end

Given /^data is loaded directly/ do
@load_method = 'directly'
end

Given /^data is loaded with datastore$/ do
@load_method = 'datastore'
end
2 changes: 1 addition & 1 deletion features/step_definitions/locate.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
When /^I request locate I should get$/ do |table|
reprocess
actual = []
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
OSRMLoader.load(self,"#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
in_node = find_node_by_name row['in']
raise "*** unknown in-node '#{row['in']}" unless in_node
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/nearest.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
When /^I request nearest I should get$/ do |table|
reprocess
actual = []
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
OSRMLoader.load(self,"#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
in_node = find_node_by_name row['in']
raise "*** unknown in-node '#{row['in']}" unless in_node
Expand Down
6 changes: 5 additions & 1 deletion features/step_definitions/options.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
When(/^I run "osrm\-routed\s?(.*?)"$/) do |options|
begin
Timeout.timeout(1) { run_bin 'osrm-routed', options }
Timeout.timeout(SHUTDOWN_TIMEOUT) { run_bin 'osrm-routed', options }
rescue Timeout::Error
raise "*** osrm-routed didn't quit. Maybe the --trial option wasn't used?"
end
Expand All @@ -14,6 +14,10 @@
run_bin 'osrm-prepare', options
end

When(/^I run "osrm\-datastore\s?(.*?)"$/) do |options|
run_bin 'osrm-datastore', options
end

Then /^it should exit with code (\d+)$/ do |code|
expect(@exit_code).to eq( code.to_i )
end
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
When /^I request \/(.*)$/ do |path|
reprocess
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
OSRMLoader.load(self,"#{@osm_file}.osrm") do
@response = request_path path
end
end
Expand Down Expand Up @@ -43,4 +43,4 @@
expect(@process_error.is_a?(OSRMError)).to eq(true)
expect(@process_error.process).to eq(binary)
expect(@process_error.code.to_i).to eq(code.to_i)
end
end
2 changes: 1 addition & 1 deletion features/step_definitions/routability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_routability_row i
if table.headers&["forw","backw","bothw"] == []
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
end
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
OSRMLoader.load(self,"#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,i|
output_row = row.dup
attempts = []
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/routing.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
When /^I route I should get$/ do |table|
reprocess
actual = []
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
OSRMLoader.load(self,"#{@osm_file}.osrm") do
table.hashes.each_with_index do |row,ri|
if row['request']
got = {'request' => row['request'] }
Expand Down
15 changes: 10 additions & 5 deletions features/support/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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
Expand All @@ -21,7 +22,7 @@ def input_format
end

def sanitized_scenario_title
@sanitized_scenario_title ||= @scenario_title.gsub /[^0-9A-Za-z.\-]/, '_'
@sanitized_scenario_title ||= @scenario_title.to_s.gsub /[^0-9A-Za-z.\-]/, '_'
end

def set_grid_size meters
Expand Down Expand Up @@ -225,13 +226,17 @@ def convert_osm_to_pbf
end

def extracted?
File.exist?("#{@osm_file}.osrm") &&
File.exist?("#{@osm_file}.osrm.names") &&
File.exist?("#{@osm_file}.osrm.restrictions")
Dir.chdir TEST_FOLDER do
File.exist?("#{@osm_file}.osrm") &&
File.exist?("#{@osm_file}.osrm.names") &&
File.exist?("#{@osm_file}.osrm.restrictions")
end
end

def prepared?
File.exist?("#{@osm_file}.osrm.hsgr")
Dir.chdir TEST_FOLDER do
File.exist?("#{@osm_file}.osrm.hsgr")
end
end

def write_timestamp
Expand Down
30 changes: 29 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rspec/expectations'


DEFAULT_PORT = 5000
DEFAULT_TIMEOUT = 2

ROOT_FOLDER = Dir.pwd
OSM_USER = 'osrm'
OSM_GENERATOR = 'osrm-test'
Expand All @@ -17,6 +17,26 @@
BIN_PATH = File.join ROOT_FOLDER, 'build'
DEFAULT_INPUT_FORMAT = 'osm'
DEFAULT_ORIGIN = [1,1]
LAUNCH_TIMEOUT = 1
SHUTDOWN_TIMEOUT = 10
DEFAULT_LOAD_METHOD = 'datastore'
OSRM_ROUTED_LOG_FILE = 'osrm-routed.log'

if ENV['OS']==/Windows.*/ then
TERMSIGNAL='TERM'
else
TERMSIGNAL=9
end


def log_time_and_run cmd
log_time cmd
`#{cmd}`
end

def log_time cmd
puts "[#{Time.now.strftime('%Y-%m-%d %H:%M:%S:%L')}] #{cmd}"
end


puts "Ruby version #{RUBY_VERSION}"
Expand Down Expand Up @@ -44,6 +64,7 @@
raise "*** Test folder #{TEST_FOLDER} doesn't exist."
end


if ENV['OS']=~/Windows.*/ then
EXE='.exe'
QQ='"'
Expand All @@ -53,5 +74,12 @@
end

AfterConfiguration do |config|
if OSRMLoader::OSRMBaseLoader.new.osrm_up?
raise "*** osrm-routed is already running."
end
clear_log_files
end

at_exit do
OSRMLoader::OSRMBaseLoader.new.shutdown
end
4 changes: 4 additions & 0 deletions features/support/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

STRESS_TIMEOUT = 300


Before do |scenario|

# feature name
case scenario
when Cucumber::Ast::Scenario
Expand All @@ -18,13 +20,15 @@
@scenario_title = scenario.scenario_outline.name
end

@load_method = DEFAULT_LOAD_METHOD
@query_params = {}
@scenario_time = Time.now.strftime("%Y-%m-%dT%H:%m:%SZ")
reset_data
@has_logged_preprocess_info = false
@has_logged_scenario_info = false
set_grid_size DEFAULT_GRID_SIZE
set_origin DEFAULT_ORIGIN

end

Around('@stress') do |scenario, block|
Expand Down
Loading