Merge pull request #1231 from Project-OSRM/testing/smarter_caching
smarter caching of test files
This commit is contained in:
commit
6b9b2c1468
7
Rakefile
7
Rakefile
@ -181,3 +181,10 @@ end
|
|||||||
desc "Stop, reprocess and restart."
|
desc "Stop, reprocess and restart."
|
||||||
task :update => [:down,:process,:up] do
|
task :update => [:down,:process,:up] do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc "Remove test cache files."
|
||||||
|
task :sweep do
|
||||||
|
system "rm test/cache/*"
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@extract @options @files
|
@extract @options @files
|
||||||
Feature: osrm-extract command line options: files
|
Feature: osrm-extract command line options: files
|
||||||
# expansions:
|
# expansions:
|
||||||
# {base} => path to current input file
|
# {osm_base} => path to current input file
|
||||||
# {profile} => path to current profile script
|
# {profile} => path to current profile script
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
@ -14,12 +14,12 @@ Feature: osrm-extract command line options: files
|
|||||||
And the data has been saved to disk
|
And the data has been saved to disk
|
||||||
|
|
||||||
Scenario: osrm-extract - Passing base file
|
Scenario: osrm-extract - Passing base file
|
||||||
When I run "osrm-extract {base}.osm --profile {profile}"
|
When I run "osrm-extract {osm_base}.osm --profile {profile}"
|
||||||
Then stderr should be empty
|
Then stderr should be empty
|
||||||
And it should exit with code 0
|
And it should exit with code 0
|
||||||
|
|
||||||
Scenario: osrm-extract - Order of options should not matter
|
Scenario: osrm-extract - Order of options should not matter
|
||||||
When I run "osrm-extract --profile {profile} {base}.osm"
|
When I run "osrm-extract --profile {profile} {osm_base}.osm"
|
||||||
Then stderr should be empty
|
Then stderr should be empty
|
||||||
And it should exit with code 0
|
And it should exit with code 0
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@prepare @options @files
|
@prepare @options @files
|
||||||
Feature: osrm-prepare command line options: files
|
Feature: osrm-prepare command line options: files
|
||||||
# expansions:
|
# expansions:
|
||||||
# {base} => path to current input file
|
# {extracted_base} => path to current extracted input file
|
||||||
# {profile} => path to current profile script
|
# {profile} => path to current profile script
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
@ -14,12 +14,12 @@ Feature: osrm-prepare command line options: files
|
|||||||
And the data has been extracted
|
And the data has been extracted
|
||||||
|
|
||||||
Scenario: osrm-prepare - Passing base file
|
Scenario: osrm-prepare - Passing base file
|
||||||
When I run "osrm-prepare {base}.osrm --profile {profile}"
|
When I run "osrm-prepare {extracted_base}.osrm --profile {profile}"
|
||||||
Then stderr should be empty
|
Then stderr should be empty
|
||||||
And it should exit with code 0
|
And it should exit with code 0
|
||||||
|
|
||||||
Scenario: osrm-prepare - Order of options should not matter
|
Scenario: osrm-prepare - Order of options should not matter
|
||||||
When I run "osrm-prepare --profile {profile} {base}.osrm"
|
When I run "osrm-prepare --profile {profile} {extracted_base}.osrm"
|
||||||
Then stderr should be empty
|
Then stderr should be empty
|
||||||
And it should exit with code 0
|
And it should exit with code 0
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ Feature: osrm-routed command line options: files
|
|||||||
# For testing program options, the --trial option is used, which causes osrm-routed to quit
|
# For testing program options, the --trial option is used, which causes osrm-routed to quit
|
||||||
# immediately after initialization. This makes testing easier and faster.
|
# immediately after initialization. This makes testing easier and faster.
|
||||||
#
|
#
|
||||||
# The {base} part of the options to osrm-routed will be expanded to the actual base path of
|
# The {prepared_base} part of the options to osrm-routed will be expanded to the actual base path of
|
||||||
# the preprocessed file.
|
# the prepared input file.
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# Since we're not using osmr-datastore for all testing, osrm-routed is kept running.
|
# Since we're not using osmr-datastore for all testing, osrm-routed is kept running.
|
||||||
@ -22,7 +22,7 @@ Feature: osrm-routed command line options: files
|
|||||||
And the data has been prepared
|
And the data has been prepared
|
||||||
|
|
||||||
Scenario: osrm-routed - Passing base file
|
Scenario: osrm-routed - Passing base file
|
||||||
When I run "osrm-routed {base}.osrm --trial"
|
When I run "osrm-routed {prepared_base}.osrm --trial"
|
||||||
Then stdout should contain /^\[info\] starting up engines/
|
Then stdout should contain /^\[info\] starting up engines/
|
||||||
And stdout should contain /\d{1,2}\.\d{1,2}\.\d{1,2}/
|
And stdout should contain /\d{1,2}\.\d{1,2}\.\d{1,2}/
|
||||||
And stdout should contain /compiled at/
|
And stdout should contain /compiled at/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
When /^I request locate I should get$/ do |table|
|
When /^I request locate I should get$/ do |table|
|
||||||
reprocess
|
reprocess
|
||||||
actual = []
|
actual = []
|
||||||
OSRMLoader.load(self,"#{@osm_file}.osrm") do
|
OSRMLoader.load(self,"#{prepared_file}.osrm") do
|
||||||
table.hashes.each_with_index do |row,ri|
|
table.hashes.each_with_index do |row,ri|
|
||||||
in_node = find_node_by_name row['in']
|
in_node = find_node_by_name row['in']
|
||||||
raise "*** unknown in-node '#{row['in']}" unless in_node
|
raise "*** unknown in-node '#{row['in']}" unless in_node
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
When /^I request nearest I should get$/ do |table|
|
When /^I request nearest I should get$/ do |table|
|
||||||
reprocess
|
reprocess
|
||||||
actual = []
|
actual = []
|
||||||
OSRMLoader.load(self,"#{@osm_file}.osrm") do
|
OSRMLoader.load(self,"#{prepared_file}.osrm") do
|
||||||
table.hashes.each_with_index do |row,ri|
|
table.hashes.each_with_index do |row,ri|
|
||||||
in_node = find_node_by_name row['in']
|
in_node = find_node_by_name row['in']
|
||||||
raise "*** unknown in-node '#{row['in']}" unless in_node
|
raise "*** unknown in-node '#{row['in']}" unless in_node
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
When /^I request \/(.*)$/ do |path|
|
When /^I request \/(.*)$/ do |path|
|
||||||
reprocess
|
reprocess
|
||||||
OSRMLoader.load(self,"#{@osm_file}.osrm") do
|
OSRMLoader.load(self,"#{prepared_file}.osrm") do
|
||||||
@response = request_path path
|
@response = request_path path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ Then /^routability should be$/ do |table|
|
|||||||
if table.headers&["forw","backw","bothw"] == []
|
if table.headers&["forw","backw","bothw"] == []
|
||||||
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
|
raise "*** routability tabel must contain either 'forw', 'backw' or 'bothw' column"
|
||||||
end
|
end
|
||||||
OSRMLoader.load(self,"#{@osm_file}.osrm") do
|
OSRMLoader.load(self,"#{prepared_file}.osrm") do
|
||||||
table.hashes.each_with_index do |row,i|
|
table.hashes.each_with_index do |row,i|
|
||||||
output_row = row.dup
|
output_row = row.dup
|
||||||
attempts = []
|
attempts = []
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
When /^I route I should get$/ do |table|
|
When /^I route I should get$/ do |table|
|
||||||
reprocess
|
reprocess
|
||||||
actual = []
|
actual = []
|
||||||
OSRMLoader.load(self,"#{@osm_file}.osrm") do
|
OSRMLoader.load(self,"#{prepared_file}.osrm") do
|
||||||
table.hashes.each_with_index do |row,ri|
|
table.hashes.each_with_index do |row,ri|
|
||||||
if row['request']
|
if row['request']
|
||||||
got = {'request' => row['request'] }
|
got = {'request' => row['request'] }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require 'OSM/objects' #osmlib gem
|
require 'OSM/objects' #osmlib gem
|
||||||
require 'OSM/Database'
|
require 'OSM/Database'
|
||||||
require 'builder'
|
require 'builder'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
class Location
|
class Location
|
||||||
attr_accessor :lon,:lat
|
attr_accessor :lon,:lat
|
||||||
@ -155,7 +156,10 @@ def reset_data
|
|||||||
end
|
end
|
||||||
reset_profile
|
reset_profile
|
||||||
reset_osm
|
reset_osm
|
||||||
@fingerprint = nil
|
@fingerprint_osm = nil
|
||||||
|
@fingerprint_extract = nil
|
||||||
|
@fingerprint_prepare = nil
|
||||||
|
@fingerprint_route = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_osm_id
|
def make_osm_id
|
||||||
@ -205,20 +209,30 @@ def osm_str
|
|||||||
@osm_str
|
@osm_str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def osm_file
|
||||||
|
@osm_file ||= "#{DATA_FOLDER}/#{fingerprint_osm}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def extracted_file
|
||||||
|
@extracted_file ||= "#{osm_file}_#{fingerprint_extract}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def prepared_file
|
||||||
|
@prepared_file ||= "#{osm_file}_#{fingerprint_extract}_#{fingerprint_prepare}"
|
||||||
|
end
|
||||||
|
|
||||||
def write_osm
|
def write_osm
|
||||||
#write .oms file if needed
|
|
||||||
Dir.mkdir DATA_FOLDER unless File.exist? DATA_FOLDER
|
Dir.mkdir DATA_FOLDER unless File.exist? DATA_FOLDER
|
||||||
@osm_file = "#{DATA_FOLDER}/#{sanitized_scenario_title}_#{fingerprint}"
|
unless File.exist?("#{osm_file}.osm")
|
||||||
unless File.exist?("#{@osm_file}.osm")
|
File.open( "#{osm_file}.osm", 'w') {|f| f.write(osm_str) }
|
||||||
File.open( "#{@osm_file}.osm", 'w') {|f| f.write(osm_str) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_osm_to_pbf
|
def convert_osm_to_pbf
|
||||||
unless File.exist?("#{@osm_file}.osm.pbf")
|
unless File.exist?("#{osm_file}.osm.pbf")
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Converting #{@osm_file}.osm to protobuffer format...", :preprocess
|
log "== Converting #{osm_file}.osm to protobuffer format...", :preprocess
|
||||||
unless system "osmosis --read-xml #{@osm_file}.osm --write-pbf #{@osm_file}.osm.pbf omitmetadata=true >>#{PREPROCESS_LOG_FILE} 2>&1"
|
unless system "osmosis --read-xml #{osm_file}.osm --write-pbf #{osm_file}.osm.pbf omitmetadata=true >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||||
raise OsmosisError.new $?, "osmosis exited with code #{$?.exitstatus}"
|
raise OsmosisError.new $?, "osmosis exited with code #{$?.exitstatus}"
|
||||||
end
|
end
|
||||||
log '', :preprocess
|
log '', :preprocess
|
||||||
@ -227,25 +241,26 @@ end
|
|||||||
|
|
||||||
def extracted?
|
def extracted?
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
File.exist?("#{@osm_file}.osrm") &&
|
File.exist?("#{extracted_file}.osrm") &&
|
||||||
File.exist?("#{@osm_file}.osrm.names") &&
|
File.exist?("#{extracted_file}.osrm.names") &&
|
||||||
File.exist?("#{@osm_file}.osrm.restrictions")
|
File.exist?("#{extracted_file}.osrm.restrictions")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepared?
|
def prepared?
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
File.exist?("#{@osm_file}.osrm.hsgr")
|
File.exist?("#{prepared_file}.osrm.hsgr")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_timestamp
|
def write_timestamp
|
||||||
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
File.open( "#{prepared_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbf?
|
def pbf?
|
||||||
input_format=='pbf'
|
input_format=='pbf'
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_input_data
|
def write_input_data
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
write_osm
|
write_osm
|
||||||
@ -257,23 +272,43 @@ end
|
|||||||
def extract_data
|
def extract_data
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
log "== Extracting #{osm_file}.osm...", :preprocess
|
||||||
unless system "#{BIN_PATH}/osrm-extract #{@osm_file}.osm#{'.pbf' if pbf?} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
unless system "#{BIN_PATH}/osrm-extract #{osm_file}.osm#{'.pbf' if pbf?} --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||||
end
|
end
|
||||||
log '', :preprocess
|
begin
|
||||||
|
["osrm","osrm.names","osrm.restrictions"].each do |file|
|
||||||
|
File.rename "#{osm_file}.#{file}", "#{extracted_file}.#{file}"
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
raise FileError.new nil, "failed to rename data file after extracting."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_data
|
def prepare_data
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
log "== Preparing #{extracted_file}.osm...", :preprocess
|
||||||
unless system "#{BIN_PATH}/osrm-prepare #{@osm_file}.osrm --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
unless system "#{BIN_PATH}/osrm-prepare #{extracted_file}.osrm --profile #{PROFILES_PATH}/#{@profile}.lua >>#{PREPROCESS_LOG_FILE} 2>&1"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||||
end
|
end
|
||||||
|
begin
|
||||||
|
["osrm.hsgr","osrm.fileIndex","osrm.geometry","osrm.nodes","osrm.ramIndex"].each do |file|
|
||||||
|
File.rename "#{extracted_file}.#{file}", "#{prepared_file}.#{file}"
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
raise FileError.new nil, "failed to rename data file after preparing."
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
["osrm.names","osrm.edges","osrm.restrictions"].each do |file|
|
||||||
|
FileUtils.cp "#{extracted_file}.#{file}", "#{prepared_file}.#{file}"
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
raise FileError.new nil, "failed to copy data file after preparing."
|
||||||
|
end
|
||||||
log '', :preprocess
|
log '', :preprocess
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -31,6 +31,12 @@ class OSRMError < StandardError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class FileError < OSRMError
|
||||||
|
def initialize code, msg
|
||||||
|
super 'fileutil', code, msg, PREPROCESS_LOG_FILE, 5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class OsmosisError < OSRMError
|
class OsmosisError < OSRMError
|
||||||
def initialize code, msg
|
def initialize code, msg
|
||||||
super 'osmosis', code, msg, PREPROCESS_LOG_FILE, 40
|
super 'osmosis', code, msg, PREPROCESS_LOG_FILE, 40
|
||||||
|
@ -32,18 +32,32 @@ def lua_lib_hash
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bin_extract_hash
|
def bin_extract_hash
|
||||||
bin_extract_hash ||= hash_of_files "#{BIN_PATH}/osrm-extract#{EXE}"
|
@bin_extract_hash ||= hash_of_files "#{BIN_PATH}/osrm-extract#{EXE}"
|
||||||
|
@bin_extract_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin_prepare_hash
|
def bin_prepare_hash
|
||||||
bin_prepare_hash ||= hash_of_files "#{BIN_PATH}/osrm-prepare#{EXE}"
|
@bin_prepare_hash ||= hash_of_files "#{BIN_PATH}/osrm-prepare#{EXE}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin_routed_hash
|
def bin_routed_hash
|
||||||
bin_routed_hash ||= hash_of_files "#{BIN_PATH}/osrm-routed#{EXE}"
|
@bin_routed_hash ||= hash_of_files "#{BIN_PATH}/osrm-routed#{EXE}"
|
||||||
end
|
end
|
||||||
|
|
||||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
# combine state of data, profile and binaries into a hashes that identifies
|
||||||
def fingerprint
|
# the exact test situation at different stages, so we can later skip steps when possible.
|
||||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{lua_lib_hash}-#{osm_hash}"
|
def fingerprint_osm
|
||||||
|
@fingerprint_osm ||= Digest::SHA1.hexdigest "#{osm_hash}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def fingerprint_extract
|
||||||
|
@fingerprint_extract ||= Digest::SHA1.hexdigest "#{profile_hash}-#{lua_lib_hash}-#{bin_extract_hash}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def fingerprint_prepare
|
||||||
|
@fingerprint_prepare ||= Digest::SHA1.hexdigest "#{bin_prepare_hash}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def fingerprint_route
|
||||||
|
@fingerprint_route ||= Digest::SHA1.hexdigest "#{bin_routed_hash}"
|
||||||
end
|
end
|
@ -29,7 +29,10 @@ def log_scenario_fail_info
|
|||||||
log "========================================="
|
log "========================================="
|
||||||
log "Failed scenario: #{@scenario_title}"
|
log "Failed scenario: #{@scenario_title}"
|
||||||
log "Time: #{@scenario_time}"
|
log "Time: #{@scenario_time}"
|
||||||
log "Fingerprint: #{@fingerprint}"
|
log "Fingerprint osm stage: #{@fingerprint_osm}"
|
||||||
|
log "Fingerprint extract stage: #{@fingerprint_extract}"
|
||||||
|
log "Fingerprint prepare stage: #{@fingerprint_prepare}"
|
||||||
|
log "Fingerprint route stage: #{@fingerprint_route}"
|
||||||
log "Profile: #{@profile}"
|
log "Profile: #{@profile}"
|
||||||
log
|
log
|
||||||
log '```xml' #so output can be posted directly to github comment fields
|
log '```xml' #so output can be posted directly to github comment fields
|
||||||
@ -41,6 +44,7 @@ def log_scenario_fail_info
|
|||||||
end
|
end
|
||||||
|
|
||||||
def log_fail expected,got,attempts
|
def log_fail expected,got,attempts
|
||||||
|
return
|
||||||
log_scenario_fail_info
|
log_scenario_fail_info
|
||||||
log "== "
|
log "== "
|
||||||
log "Expected: #{expected}"
|
log "Expected: #{expected}"
|
||||||
|
@ -2,11 +2,20 @@ def run_bin bin, options
|
|||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
opt = options.dup
|
opt = options.dup
|
||||||
|
|
||||||
if opt.include? '{base}'
|
if opt.include? '{osm_base}'
|
||||||
raise "*** {base} is missing" unless @osm_file
|
raise "*** {osm_base} is missing" unless osm_file
|
||||||
opt.gsub! "{base}", "#{@osm_file}"
|
opt.gsub! "{osm_base}", "#{osm_file}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if opt.include? '{extracted_base}'
|
||||||
|
raise "*** {extracted_base} is missing" unless extracted_file
|
||||||
|
opt.gsub! "{extracted_base}", "#{extracted_file}"
|
||||||
|
end
|
||||||
|
|
||||||
|
if opt.include? '{prepared_base}'
|
||||||
|
raise "*** {prepared_base} is missing" unless prepared_file
|
||||||
|
opt.gsub! "{prepared_base}", "#{prepared_file}"
|
||||||
|
end
|
||||||
if opt.include? '{profile}'
|
if opt.include? '{profile}'
|
||||||
opt.gsub! "{profile}", "#{PROFILES_PATH}/#{@profile}.lua"
|
opt.gsub! "{profile}", "#{PROFILES_PATH}/#{@profile}.lua"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user