cuke testing of timestamp api
This commit is contained in:
parent
a255f222ef
commit
b10b716733
1
Rakefile
1
Rakefile
@ -68,6 +68,7 @@ def write_server_ini osm_file
|
|||||||
ramIndex=#{osm_file}.osrm.ramIndex
|
ramIndex=#{osm_file}.osrm.ramIndex
|
||||||
fileIndex=#{osm_file}.osrm.fileIndex
|
fileIndex=#{osm_file}.osrm.fileIndex
|
||||||
namesData=#{osm_file}.osrm.names
|
namesData=#{osm_file}.osrm.names
|
||||||
|
timestamp=#{osm_file}.osrm.timestamp
|
||||||
EOF
|
EOF
|
||||||
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
||||||
end
|
end
|
||||||
|
@ -61,6 +61,7 @@ Given /^the preprocessed files for "([^"]*)" are present and up to date$/ do |ar
|
|||||||
File.exists?("#{area}.osrm.edges").should == true
|
File.exists?("#{area}.osrm.edges").should == true
|
||||||
File.exists?("#{area}.osrm.ramIndex").should == true
|
File.exists?("#{area}.osrm.ramIndex").should == true
|
||||||
File.exists?("#{area}.osrm.fileIndex").should == true
|
File.exists?("#{area}.osrm.fileIndex").should == true
|
||||||
|
File.exists?("#{area}.osrm.tiemstamp").should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see the file "([^"]*)"$/ do |file|
|
Then /^I should see the file "([^"]*)"$/ do |file|
|
||||||
|
24
features/step_definitions/requests.rb
Normal file
24
features/step_definitions/requests.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
When /^I request \/(.*)$/ do |path|
|
||||||
|
osrm_kill
|
||||||
|
reprocess
|
||||||
|
OSRMLauncher.new do
|
||||||
|
@response = request_path path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should get a response/ do
|
||||||
|
@response.code.should == "200"
|
||||||
|
@response.body.should_not == nil
|
||||||
|
@response.body.should_not == ''
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^response should be valid JSON$/ do
|
||||||
|
@json = JSON.parse @response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^response should be well-formed$/ do
|
||||||
|
@json['version'].class.should == Float
|
||||||
|
@json['status'].class.should == Fixnum
|
||||||
|
@json['transactionId'].class.should == String
|
||||||
|
end
|
||||||
|
|
@ -12,25 +12,13 @@ When /^I request a route from "([^"]*)" to "([^"]*)"$/ do |a,b|
|
|||||||
@response = request_route "#{locations[a][0]},#{locations[a][1]}", "#{locations[b][0]},#{locations[b][1]}"
|
@response = request_route "#{locations[a][0]},#{locations[a][1]}", "#{locations[b][0]},#{locations[b][1]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should get a response/ do
|
Then /^response should be a well-formed route$/ do
|
||||||
@response.code.should == "200"
|
step "response should be well-formed"
|
||||||
@response.body.should_not == nil
|
|
||||||
@response.body.should_not == ''
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^response should be valid JSON$/ do
|
|
||||||
@json = JSON.parse @response.body
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^response should be well-formed$/ do
|
|
||||||
@json['version'].class.should == Float
|
|
||||||
@json['status'].class.should == Fixnum
|
|
||||||
@json['status_message'].class.should == String
|
@json['status_message'].class.should == String
|
||||||
@json['route_summary'].class.should == Hash
|
@json['route_summary'].class.should == Hash
|
||||||
@json['route_geometry'].class.should == String
|
@json['route_geometry'].class.should == String
|
||||||
@json['route_instructions'].class.should == Array
|
@json['route_instructions'].class.should == Array
|
||||||
@json['via_points'].class.should == Array
|
@json['via_points'].class.should == Array
|
||||||
@json['transactionId'].class.should == String
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^a route should be found$/ do
|
Then /^a route should be found$/ do
|
||||||
@ -46,7 +34,7 @@ end
|
|||||||
Then /^I should get a valid response$/ do
|
Then /^I should get a valid response$/ do
|
||||||
step "I should get a response"
|
step "I should get a response"
|
||||||
step "response should be valid JSON"
|
step "response should be valid JSON"
|
||||||
step "response should be well-formed"
|
step "response should be a well-formed route"
|
||||||
#step "no error should be reported in terminal"
|
#step "no error should be reported in terminal"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
7
features/step_definitions/timestamp.rb
Normal file
7
features/step_definitions/timestamp.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Then /^I should get a valid timestamp/ do
|
||||||
|
step "I should get a response"
|
||||||
|
step "response should be valid JSON"
|
||||||
|
step "response should be well-formed"
|
||||||
|
@json['timestamp'].class.should == String
|
||||||
|
@json['timestamp'].should == OSM_TIMESTAMP
|
||||||
|
end
|
@ -23,6 +23,7 @@ edgesData=#{@osm_file}.osrm.edges
|
|||||||
ramIndex=#{@osm_file}.osrm.ramIndex
|
ramIndex=#{@osm_file}.osrm.ramIndex
|
||||||
fileIndex=#{@osm_file}.osrm.fileIndex
|
fileIndex=#{@osm_file}.osrm.fileIndex
|
||||||
namesData=#{@osm_file}.osrm.names
|
namesData=#{@osm_file}.osrm.names
|
||||||
|
timestamp=#{@osm_file}.osrm.timestamp
|
||||||
EOF
|
EOF
|
||||||
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
File.open( 'server.ini', 'w') {|f| f.write( s ) }
|
||||||
end
|
end
|
||||||
|
@ -198,9 +198,14 @@ def prepared?
|
|||||||
File.exist?("#{@osm_file}.osrm.hsgr")
|
File.exist?("#{@osm_file}.osrm.hsgr")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def write_timestamp
|
||||||
|
File.open( "#{@osm_file}.osrm.timestamp", 'w') {|f| f.write(OSM_TIMESTAMP) }
|
||||||
|
end
|
||||||
|
|
||||||
def reprocess
|
def reprocess
|
||||||
Dir.chdir TEST_FOLDER do
|
Dir.chdir TEST_FOLDER do
|
||||||
write_osm
|
write_osm
|
||||||
|
write_timestamp
|
||||||
convert_osm_to_pbf
|
convert_osm_to_pbf
|
||||||
unless extracted?
|
unless extracted?
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
|
14
features/support/request.rb
Normal file
14
features/support/request.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
require 'net/http'
|
||||||
|
|
||||||
|
HOST = 'http://localhost:5000'
|
||||||
|
|
||||||
|
def request_path path
|
||||||
|
@query = path
|
||||||
|
log path
|
||||||
|
uri = URI.parse "#{HOST}/#{path}"
|
||||||
|
Net::HTTP.get_response uri
|
||||||
|
rescue Errno::ECONNREFUSED => e
|
||||||
|
raise "*** osrm-routed is not running."
|
||||||
|
rescue Timeout::Error
|
||||||
|
raise "*** osrm-routed did not respond."
|
||||||
|
end
|
@ -1,17 +1,8 @@
|
|||||||
require 'net/http'
|
|
||||||
|
|
||||||
DESTINATION_REACHED = 15 #OSRM instruction code
|
DESTINATION_REACHED = 15 #OSRM instruction code
|
||||||
|
|
||||||
|
|
||||||
def request_route a,b
|
def request_route a,b
|
||||||
@query = "http://localhost:5000/viaroute?loc=#{a}&loc=#{b}&output=json&instructions=true&alt=false"
|
request_path "viaroute?loc=#{a}&loc=#{b}&output=json&instructions=true&alt=false"
|
||||||
#log @query
|
|
||||||
uri = URI.parse @query
|
|
||||||
Net::HTTP.get_response uri
|
|
||||||
rescue Errno::ECONNREFUSED => e
|
|
||||||
raise "*** osrm-routed is not running."
|
|
||||||
rescue Timeout::Error
|
|
||||||
raise "*** osrm-routed did not respond."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_response response
|
def parse_response response
|
||||||
|
12
features/timestamp/timestamp.feature
Normal file
12
features/timestamp/timestamp.feature
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@timestamp
|
||||||
|
Feature: Timestamp
|
||||||
|
|
||||||
|
Scenario: Request timestamp
|
||||||
|
Given the node map
|
||||||
|
| a | b |
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| ab |
|
||||||
|
When I request /timestamp
|
||||||
|
Then I should get a valid timestamp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user