diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index 4addd056473..e25a97528c9 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 31a05486ac6..61996ca239b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/features/nearest/pick.feature b/features/nearest/pick.feature index fb66ef65421..dcdf5268c30 100644 --- a/features/nearest/pick.feature +++ b/features/nearest/pick.feature @@ -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 | diff --git a/features/step_definitions/matching.js b/features/step_definitions/matching.js index d7c62ee078a..c8afa583899 100644 --- a/features/step_definitions/matching.js +++ b/features/step_definitions/matching.js @@ -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) => { diff --git a/features/step_definitions/nearest.js b/features/step_definitions/nearest.js index ae4079b8dfa..49ec0775d63 100644 --- a/features/step_definitions/nearest.js +++ b/features/step_definitions/nearest.js @@ -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)) { diff --git a/features/step_definitions/trip.js b/features/step_definitions/trip.js index ab2f7c35ecf..0efbc2259f1 100644 --- a/features/step_definitions/trip.js +++ b/features/step_definitions/trip.js @@ -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(); diff --git a/features/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index c1340146fa0..92f4b8a6a2b 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -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 | \ No newline at end of file + | 3 | 1400.1 | 400 | 0 | + diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index f8e1b2738a1..2772ef03a91 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -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 | \ No newline at end of file + | 4321 | 1.00027,1,1.000135,1 | 15.02597 | 1.5 | 1.5 | 1.5 | + diff --git a/features/testbot/snap.feature b/features/testbot/snap.feature index 924e84f754c..f9a6fff81c0 100644 --- a/features/testbot/snap.feature +++ b/features/testbot/snap.feature @@ -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 | \ No newline at end of file + | x | p | xh,xh | diff --git a/features/testbot/trip.feature b/features/testbot/trip.feature index 840aadb9cf2..531ccaa48e4 100644 --- a/features/testbot/trip.feature +++ b/features/testbot/trip.feature @@ -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 diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index a93e49710ce..e95882f4656 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -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: diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index aff3c57dc2f..246cfe88ce2 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -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; diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 72cdea4e680..2c378e6e7d3 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -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: diff --git a/include/engine/api/trip_api.hpp b/include/engine/api/trip_api.hpp index 90e5e139120..9b82a016ed8 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -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: