Add data_version
field to responses of all plugins. (#5387)
This commit is contained in:
parent
972a848094
commit
928867c520
4
.github/workflows/osrm-backend.yml
vendored
4
.github/workflows/osrm-backend.yml
vendored
@ -469,9 +469,9 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{github.workspace}}/test/cache
|
||||
key: v2-test-${{ matrix.name }}-${{ github.sha }}
|
||||
key: v3-test-${{ matrix.name }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
v2-test-${{ matrix.name }}-
|
||||
v3-test-${{ matrix.name }}-
|
||||
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Unreleased
|
||||
- Changes from 5.26.0
|
||||
- API:
|
||||
- CHANGED: Add `data_version` field to responses of all services. [#5387](https://github.com/Project-OSRM/osrm-backend/pull/5387)
|
||||
- FIXED: Use Boost.Beast to parse HTTP request. [#6294](https://github.com/Project-OSRM/osrm-backend/pull/6294)
|
||||
- FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
|
||||
- Misc:
|
||||
|
@ -59,6 +59,31 @@ Feature: Locating Nearest node on a Way - pick closest way
|
||||
| 3 | u |
|
||||
| 4 | w |
|
||||
|
||||
Scenario: Nearest - inside a oneway triangle
|
||||
Given the node map
|
||||
"""
|
||||
c
|
||||
|
||||
y z
|
||||
0 1
|
||||
2 3 4
|
||||
a x u w b
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| ab | yes |
|
||||
| bc | yes |
|
||||
| ca | yes |
|
||||
|
||||
When I request nearest I should get
|
||||
| in | out |
|
||||
| 0 | y |
|
||||
| 1 | z |
|
||||
| 2 | x |
|
||||
| 3 | u |
|
||||
| 4 | w |
|
||||
|
||||
Scenario: Nearest - High lat/lon
|
||||
Given the node locations
|
||||
| node | lat | lon |
|
||||
@ -78,3 +103,30 @@ Feature: Locating Nearest node on a Way - pick closest way
|
||||
| x | a |
|
||||
| y | b |
|
||||
| z | c |
|
||||
|
||||
Scenario: Nearest - data version
|
||||
Given the node map
|
||||
"""
|
||||
c
|
||||
|
||||
y z
|
||||
0 1
|
||||
2 3 4
|
||||
a x u w b
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| ca |
|
||||
|
||||
And the extract extra arguments "--data_version cucumber_data_version"
|
||||
|
||||
When I request nearest I should get
|
||||
| in | out | data_version |
|
||||
| 0 | y | cucumber_data_version |
|
||||
| 1 | z | cucumber_data_version |
|
||||
| 2 | x | cucumber_data_version |
|
||||
| 3 | u | cucumber_data_version |
|
||||
| 4 | w | cucumber_data_version |
|
||||
|
@ -117,6 +117,10 @@ module.exports = function () {
|
||||
got.duration = duration.toString();
|
||||
}
|
||||
|
||||
if (headers.has('data_version')) {
|
||||
got.data_version = json.data_version || '';
|
||||
}
|
||||
|
||||
// if header matches 'a:*', parse out the values for *
|
||||
// and return in that header
|
||||
headers.forEach((k) => {
|
||||
|
@ -8,6 +8,7 @@ module.exports = function () {
|
||||
this.reprocessAndLoadData((e) => {
|
||||
if (e) return callback(e);
|
||||
var testRow = (row, ri, cb) => {
|
||||
|
||||
var inNode = this.findNodeByName(row.in);
|
||||
if (!inNode) throw new Error(util.format('*** unknown in-node "%s"', row.in));
|
||||
|
||||
@ -17,6 +18,7 @@ module.exports = function () {
|
||||
this.requestNearest(inNode, this.queryParams, (err, response) => {
|
||||
if (err) return cb(err);
|
||||
var coord;
|
||||
var headers = new Set(table.raw()[0]);
|
||||
|
||||
if (response.statusCode === 200 && response.body.length) {
|
||||
var json = JSON.parse(response.body);
|
||||
@ -25,6 +27,10 @@ module.exports = function () {
|
||||
|
||||
var got = { in: row.in, out: row.out };
|
||||
|
||||
if (headers.has('data_version')) {
|
||||
got.data_version = json.data_version || '';
|
||||
}
|
||||
|
||||
Object.keys(row).forEach((key) => {
|
||||
if (key === 'out') {
|
||||
if (this.FuzzyMatch.matchLocation(coord, outNode)) {
|
||||
|
@ -43,6 +43,10 @@ module.exports = function () {
|
||||
got.message = json.message;
|
||||
}
|
||||
|
||||
if (headers.has('data_version')) {
|
||||
got.data_version = json.data_version || '';
|
||||
}
|
||||
|
||||
if (headers.has('geometry')) {
|
||||
if (this.queryParams['geometries'] === 'polyline') {
|
||||
got.geometry = polyline.decode(json.trips[0].geometry).toString();
|
||||
|
@ -726,4 +726,5 @@ Feature: Basic Distance Matrix
|
||||
| | 1 | 2 | 3 |
|
||||
| 1 | 0 | 1000.1 | 1400.1 |
|
||||
| 2 | 1000.1 | 0 | 400 |
|
||||
| 3 | 1400.1 | 400 | 0 |
|
||||
| 3 | 1400.1 | 400 | 0 |
|
||||
|
||||
|
@ -21,8 +21,27 @@ Feature: Basic Map Matching
|
||||
| abcd | no |
|
||||
|
||||
When I match I should get
|
||||
| trace | timestamps | matchings |
|
||||
| ab1d | 0 1 2 3 | ad |
|
||||
| trace | timestamps | matchings | data_version |
|
||||
| ab1d | 0 1 2 3 | ad | |
|
||||
|
||||
Scenario: Data_version test on matching
|
||||
Given a grid size of 100 meters
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
|
||||
1
|
||||
"""
|
||||
|
||||
And the extract extra arguments "--data_version cucumber_data_version"
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| abcd | no |
|
||||
|
||||
When I match I should get
|
||||
| trace | timestamps | matchings | data_version |
|
||||
| ab1d | 0 1 2 3 | ad | cucumber_data_version |
|
||||
|
||||
Scenario: Testbot - Map matching with trace splitting
|
||||
Given the node map
|
||||
@ -792,4 +811,5 @@ Feature: Basic Map Matching
|
||||
When I match I should get
|
||||
| trace | geometry | a:distance | a:duration | a:weight | duration |
|
||||
| 2345 | 1.00018,1,1.000314,1 | 14.914666 | 1.4 | 1.4 | 1.4 |
|
||||
| 4321 | 1.00027,1,1.000135,1 | 15.02597 | 1.5 | 1.5 | 1.5 |
|
||||
| 4321 | 1.00027,1,1.000135,1 | 15.02597 | 1.5 | 1.5 | 1.5 |
|
||||
|
||||
|
@ -47,11 +47,31 @@ Feature: Snap start/end point to the nearest way
|
||||
| adb |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| 1 | b | adb,adb |
|
||||
| 2 | b | adb,adb |
|
||||
| 6 | b | aub,aub |
|
||||
| 7 | b | aub,aub |
|
||||
| from | to | route | data_version |
|
||||
| 1 | b | adb,adb | |
|
||||
| 2 | b | adb,adb | |
|
||||
| 6 | b | aub,aub | |
|
||||
| 7 | b | aub,aub | |
|
||||
|
||||
Scenario: Data_version check on nearest
|
||||
Given the node map
|
||||
"""
|
||||
4 5 6 7
|
||||
3 a u
|
||||
2
|
||||
1 d b
|
||||
"""
|
||||
|
||||
And the extract extra arguments "--data_version cucumber_data_version"
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| aub |
|
||||
| adb |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | data_version |
|
||||
| 1 | b | adb,adb | cucumber_data_version |
|
||||
|
||||
Scenario: Snap to edge right under start/end point
|
||||
Given the node map
|
||||
@ -182,4 +202,4 @@ Feature: Snap start/end point to the nearest way
|
||||
| x | m | xe,xe |
|
||||
| x | n | xf,xf |
|
||||
| x | o | xg,xg |
|
||||
| x | p | xh,xh |
|
||||
| x | p | xh,xh |
|
||||
|
@ -5,6 +5,24 @@ Feature: Basic trip planning
|
||||
Given the profile "testbot"
|
||||
Given a grid size of 10 meters
|
||||
|
||||
Scenario: Testbot - Trip: Invalid options (like was in test suite for a long time)
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
c d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| cb |
|
||||
| da |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips | code |
|
||||
| a | | InvalidOptions |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip between same waypoint
|
||||
Given the node map
|
||||
"""
|
||||
@ -20,8 +38,28 @@ Feature: Basic trip planning
|
||||
| da |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| a,a | aa |
|
||||
| waypoints | trips | code |
|
||||
| a,a | aa | Ok |
|
||||
|
||||
Scenario: Testbot - Trip: data version check
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
c d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| cb |
|
||||
| da |
|
||||
|
||||
And the extract extra arguments "--data_version cucumber_data_version"
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips | data_version | code |
|
||||
| a,a | aa | cucumber_data_version | Ok |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip with waypoints (less than 10)
|
||||
Given the node map
|
||||
@ -38,9 +76,9 @@ Feature: Basic trip planning
|
||||
| da |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips | durations |
|
||||
| a,b,c,d | abcda | 7.6 |
|
||||
| d,b,c,a | dbcad | 7.6 |
|
||||
| waypoints | trips | durations | code |
|
||||
| a,b,c,d | abcda | 7.6 | Ok |
|
||||
| d,b,c,a | dbcad | 7.6 | Ok |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip waypoints (more than 10)
|
||||
Given the node map
|
||||
|
@ -89,6 +89,11 @@ class MatchAPI final : public RouteAPI
|
||||
}
|
||||
response.values["matchings"] = std::move(routes);
|
||||
response.values["code"] = "Ok";
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = data_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -116,6 +116,11 @@ class NearestAPI final : public BaseAPI
|
||||
}
|
||||
|
||||
response.values["code"] = "Ok";
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = data_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
const NearestParameters ¶meters;
|
||||
|
@ -226,6 +226,11 @@ class TableAPI final : public BaseAPI
|
||||
}
|
||||
|
||||
response.values["code"] = "Ok";
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = data_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -87,6 +87,11 @@ class TripAPI final : public RouteAPI
|
||||
}
|
||||
response.values["trips"] = std::move(routes);
|
||||
response.values["code"] = "Ok";
|
||||
auto data_timestamp = facade.GetTimestamp();
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
response.values["data_version"] = data_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user