From 35cd3a2c26dd732cd5045d61f1d85f8d66ac9a8b Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Mon, 4 Mar 2019 12:55:20 +0300 Subject: [PATCH 1/8] data_version field in all plugin responses --- include/engine/api/match_api.hpp | 5 +++++ include/engine/api/nearest_api.hpp | 5 +++++ include/engine/api/table_api.hpp | 5 +++++ include/engine/api/trip_api.hpp | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index 86a96c65b76..ea9d20d674b 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -49,6 +49,11 @@ class MatchAPI final : public RouteAPI response.values["tracepoints"] = MakeTracepoints(sub_matchings); 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 bb55b0634e5..8350e936475 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -85,6 +85,11 @@ class NearestAPI final : public BaseAPI response.values["code"] = "Ok"; response.values["waypoints"] = std::move(waypoints); + 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 7f94bfbe02c..544e54b66b6 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -93,6 +93,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 b65ac1970d5..c64b7858a04 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -45,6 +45,11 @@ class TripAPI final : public RouteAPI response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); 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: From 81fb2cc9dad462694b2fc18569a87ea470e8da52 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Mon, 4 Mar 2019 13:08:40 +0300 Subject: [PATCH 2/8] Cucumner tests for data_version in matching --- features/step_definitions/matching.js | 4 +++ features/testbot/distance_matrix.feature | 2 +- features/testbot/matching.feature | 25 +++++++++++++++--- features/testbot/snap.feature | 32 +++++++++++++++++++----- features/testbot/trip.feature | 2 +- 5 files changed, 54 insertions(+), 11 deletions(-) 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/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index 6ac1ce21bd4..4758669b1a6 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -722,4 +722,4 @@ Feature: Basic Distance Matrix When I request a travel distance matrix I should get | | 1 | 2 | | 1 | 0 | 1000.7 | - | 2 | 1000.7 | 0 | \ No newline at end of file + | 2 | 1000.7 | 0 | diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index 599afcb1dae..56e77edf6b7 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,4 @@ Feature: Basic Map Matching When I match I should get | trace | geometry | a:distance | a:duration | a:weight | duration | | 2345 | 1.00018,1,1.000315,1 | 15.013264 | 1.5 | 1.5 | 1.5 | - | 4321 | 1.00027,1,1.000135,1 | 15.013264 | 1.5 | 1.5 | 1.5 | \ No newline at end of file + | 4321 | 1.00027,1,1.000135,1 | 15.013264 | 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 c254f8d75ad..62d2cabd684 100644 --- a/features/testbot/trip.feature +++ b/features/testbot/trip.feature @@ -370,4 +370,4 @@ Feature: Basic trip planning When I plan a trip I should get | waypoints | trips | durations | geometry | | a,b,c,d | abcda | 7.6 | 1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009,1,1 | - | d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 | \ No newline at end of file + | d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 | From f2946163d6a3ca5660b23541980fb7562aff8a00 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 31 Jul 2019 13:20:59 +0300 Subject: [PATCH 3/8] More cucumber tests for the nearest plugin to restore coverage metric --- features/nearest/pick.feature | 52 ++++++++++++++++++++++++++++ features/step_definitions/nearest.js | 6 ++++ 2 files changed, 58 insertions(+) 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/nearest.js b/features/step_definitions/nearest.js index f5627b84266..65a34ede82e 100644 --- a/features/step_definitions/nearest.js +++ b/features/step_definitions/nearest.js @@ -5,6 +5,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)); @@ -14,6 +15,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); @@ -22,6 +24,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)) { From 977e2f0337b788e776aa1e70dfcf4ce553e97556 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 31 Jul 2019 15:50:14 +0300 Subject: [PATCH 4/8] version check for the trip plugin --- features/step_definitions/trip.js | 4 +++ features/testbot/trip.feature | 48 +++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/features/step_definitions/trip.js b/features/step_definitions/trip.js index e7204401890..5943c066362 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/trip.feature b/features/testbot/trip.feature index 62d2cabd684..bd3fe2cc361 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 | aa | InvalidOptions | + Scenario: Testbot - Trip: Roundtrip with one 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 | 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 From 9a96d6015a5730cf0929d54c084624da61321ab6 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Mon, 22 Aug 2022 18:00:25 +0200 Subject: [PATCH 5/8] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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: From 996320820e6f3dc8ef01421245714379164b527b Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Mon, 22 Aug 2022 18:12:31 +0200 Subject: [PATCH 6/8] Update distance_matrix.feature --- features/testbot/distance_matrix.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index 7c00c4c381a..92f4b8a6a2b 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -725,6 +725,6 @@ Feature: Basic Distance Matrix When I request a travel distance matrix I should get | | 1 | 2 | 3 | | 1 | 0 | 1000.1 | 1400.1 | - | 2 | 1000.7 | 0 | 400 | + | 2 | 1000.1 | 0 | 400 | | 3 | 1400.1 | 400 | 0 | From 40bc442283e5eb867d8a89a34c5a7fb22c4888c7 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Mon, 22 Aug 2022 18:13:11 +0200 Subject: [PATCH 7/8] update cache version --- .github/workflows/osrm-backend.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: | From 55289601ad467f768342b701653ebfe734fed0f5 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Mon, 22 Aug 2022 20:23:51 +0200 Subject: [PATCH 8/8] Update trip.feature --- features/testbot/trip.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/testbot/trip.feature b/features/testbot/trip.feature index e7efd5e0ff9..531ccaa48e4 100644 --- a/features/testbot/trip.feature +++ b/features/testbot/trip.feature @@ -21,7 +21,7 @@ Feature: Basic trip planning When I plan a trip I should get | waypoints | trips | code | - | a | aa | InvalidOptions | + | a | | InvalidOptions | Scenario: Testbot - Trip: Roundtrip between same waypoint Given the node map