cucumber cleanup, removed unused code
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user