cuke: test speed, fix logging, clear log files on each run

This commit is contained in:
Emil Tin
2014-03-27 10:37:04 +01:00
parent cb1b824a75
commit 8b1f09d302
7 changed files with 71 additions and 25 deletions
-2
View File
@@ -7,8 +7,6 @@ OSM_GENERATOR = 'osrm-test'
OSM_UID = 1
TEST_FOLDER = 'test'
DATA_FOLDER = 'cache'
PREPROCESS_LOG_FILE = 'preprocessing.log'
LOG_FILE = 'fail.log'
OSM_TIMESTAMP = '2000-00-00T00:00:00Z'
DEFAULT_SPEEDPROFILE = 'bicycle'
WAY_SPACING = 100
+4
View File
@@ -16,3 +16,7 @@ else
puts "Using default port #{OSRM_PORT}"
end
AfterConfiguration do |config|
clear_log_files
end
+26 -7
View File
@@ -1,3 +1,19 @@
# logging
PREPROCESS_LOG_FILE = 'preprocessing.log'
LOG_FILE = 'fail.log'
def clear_log_files
Dir.chdir TEST_FOLDER do
# emptying existing files, rather than deleting and writing new ones makes it
# easier to use tail -f from the command line
`echo '' > #{OSRM_ROUTED_LOG_FILE}`
`echo '' > #{PREPROCESS_LOG_FILE}`
`echo '' > #{LOG_FILE}`
end
end
def log s='', type=nil
if type == :preprocess
file = PREPROCESS_LOG_FILE
@@ -24,17 +40,20 @@ def log_scenario_fail_info
@has_logged_scenario_info = true
end
def log_fail expected,actual,failed
def log_fail expected,got,attempts
log_scenario_fail_info
log "== "
log "Expected: #{expected}"
log "Got: #{actual}"
log "Got: #{got}"
log
failed.each do |fail|
log "Attempt: #{fail[:attempt]}"
log "Query: #{fail[:query]}"
log "Response: #{fail[:response].body}"
log
['route','forw','backw'].each do |direction|
if attempts[direction]
attempts[direction]
log "Direction: #{direction}"
log "Query: #{attempts[direction][:query]}"
log "Response: #{attempts[direction][:response].body}"
log
end
end
end
+1
View File
@@ -17,6 +17,7 @@ def request_path path, waypoints=[], options={}
params = (locs + options.to_param).join('&')
params = nil if params==""
uri = URI.parse ["#{HOST}/#{path}", params].compact.join('?')
@query = uri.to_s
Timeout.timeout(REQUEST_TIMEOUT) do
Net::HTTP.get_response uri
end