Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-09-13 13:36:58 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-09-13 16:25:53 +0300
commit4b94c5b5527c062f85e0915bcb43fb6d590efb8c (patch)
tree10761fe8a0c7995dd041ac77008da4cadd6eaa99
parent79568ebc8ca641ab23c5ff7aee96d8a69309e92b (diff)
Adding an integration test on memory consumption while a fake edge is adding.
-rw-r--r--routing/road_graph.cpp6
-rw-r--r--routing/routing_integration_tests/CMakeLists.txt1
-rw-r--r--routing/routing_integration_tests/road_graph_tests.cpp49
-rw-r--r--routing/routing_integration_tests/routing_integration_tests.pro1
-rw-r--r--routing/routing_integration_tests/routing_test_tools.cpp10
-rw-r--r--routing/routing_integration_tests/routing_test_tools.hpp1
-rw-r--r--xcode/routing/routing.xcodeproj/project.pbxproj4
7 files changed, 63 insertions, 9 deletions
diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp
index ba1604f1a9..af70d082d3 100644
--- a/routing/road_graph.cpp
+++ b/routing/road_graph.cpp
@@ -32,12 +32,6 @@ void SplitEdge(Edge const & ab, Junction const & p, vector<Edge> & edges)
auto const & b = ab.GetEndJunction();
// No need to split the edge by its endpoints.
- // The "if" condition below fixes the issue which was reproduced if to call:
- // @TODO(bykoianko) It's necessary to write a routing integration test and remove comment below.
- // std::vector<std::pair<routing::Edge, routing::Junction>> sourceVicinity;
- // Junction j(PointD(50.732084512710564184, -1.2127983570098876953), feature::kDefaultAltitudeMeters);
- // FeaturesRoadGraph::FindClosestEdges(j.GetPoint(), 20, sourceVicinity);
- // FeaturesRoadGraph::AddFakeEdges(j, sourceVicinity);
if (a.GetPoint() == p.GetPoint() || b.GetPoint() == p.GetPoint())
return;
diff --git a/routing/routing_integration_tests/CMakeLists.txt b/routing/routing_integration_tests/CMakeLists.txt
index 539234a708..39f569c122 100644
--- a/routing/routing_integration_tests/CMakeLists.txt
+++ b/routing/routing_integration_tests/CMakeLists.txt
@@ -15,6 +15,7 @@ set(
get_altitude_test.cpp
online_cross_tests.cpp
pedestrian_route_test.cpp
+ road_graph_tests.cpp
route_test.cpp
routing_test_tools.cpp
routing_test_tools.hpp
diff --git a/routing/routing_integration_tests/road_graph_tests.cpp b/routing/routing_integration_tests/road_graph_tests.cpp
new file mode 100644
index 0000000000..7710d939cd
--- /dev/null
+++ b/routing/routing_integration_tests/road_graph_tests.cpp
@@ -0,0 +1,49 @@
+#include "testing/testing.hpp"
+
+#include "platform/local_country_file.hpp"
+
+#include "geometry/point2d.hpp"
+
+#include "indexer/classificator_loader.hpp"
+#include "indexer/feature_altitude.hpp"
+#include "indexer/index.hpp"
+#include "indexer/mwm_set.hpp"
+
+#include "routing_common/car_model.hpp"
+#include "routing/features_road_graph.hpp"
+#include "routing/road_graph.hpp"
+
+#include "routing_integration_tests/routing_test_tools.hpp"
+
+#include <vector>
+
+using namespace routing;
+using namespace integration;
+
+// The test on combinatorial explosion of number of fake edges at FeaturesRoadGraph.
+// It might happen when a lot of roads intersect at one point. For example,
+// http://www.openstreetmap.org/#map=19/50.73197/-1.21295
+UNIT_TEST(FakeEdgesCombinatorialExplosion)
+{
+ classificator::Load();
+
+ std::vector<LocalCountryFile> localFiles;
+ GetAllLocalFiles(localFiles);
+ TEST(!localFiles.empty(), ());
+
+ Index index;
+ for (auto const & file : localFiles)
+ {
+ auto const result = index.Register(file);
+ TEST_EQUAL(result.second, MwmSet::RegResult::Success, ());
+ }
+
+ FeaturesRoadGraph graph(index, IRoadGraph::Mode::ObeyOnewayTag,
+ make_shared<CarModelFactory>(CountryParentNameGetterFn()));
+ Junction const j(m2::PointD(MercatorBounds::FromLatLon(50.73208, -1.21279)), feature::kDefaultAltitudeMeters);
+ std::vector<std::pair<routing::Edge, routing::Junction>> sourceVicinity;
+ graph.FindClosestEdges(j.GetPoint(), 20 /* count */, sourceVicinity);
+ // In case of the combinatorial explosion mentioned above all the memory was consumed for
+ // FeaturesRoadGraph::m_fakeIngoingEdges and FeaturesRoadGraph::m_fakeOutgoingEdges fields.
+ graph.AddFakeEdges(j, sourceVicinity);
+}
diff --git a/routing/routing_integration_tests/routing_integration_tests.pro b/routing/routing_integration_tests/routing_integration_tests.pro
index e93b1c5482..2afd26dbad 100644
--- a/routing/routing_integration_tests/routing_integration_tests.pro
+++ b/routing/routing_integration_tests/routing_integration_tests.pro
@@ -30,6 +30,7 @@ SOURCES += \
get_altitude_test.cpp \
online_cross_tests.cpp \
pedestrian_route_test.cpp \
+ road_graph_tests.cpp \
route_test.cpp \
routing_test_tools.cpp \
street_names_test.cpp \
diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp
index bd9b608650..a12e9a2906 100644
--- a/routing/routing_integration_tests/routing_test_tools.cpp
+++ b/routing/routing_integration_tests/routing_test_tools.cpp
@@ -131,7 +131,7 @@ namespace integration
return unique_ptr<IRouter>(move(router));
}
- shared_ptr<VehicleRouterComponents> CreateAllMapsComponents(VehicleType vehicleType)
+ void GetAllLocalFiles(vector<LocalCountryFile> & localFiles)
{
// Setting stored paths from testingmain.cpp
Platform & pl = GetPlatform();
@@ -142,12 +142,16 @@ namespace integration
pl.SetResourceDir(options.m_resourcePath);
platform::migrate::SetMigrationFlag();
-
- vector<LocalCountryFile> localFiles;
platform::FindAllLocalMapsAndCleanup(numeric_limits<int64_t>::max() /* latestVersion */,
localFiles);
for (auto & file : localFiles)
file.SyncWithDisk();
+ }
+
+ shared_ptr<VehicleRouterComponents> CreateAllMapsComponents(VehicleType vehicleType)
+ {
+ vector<LocalCountryFile> localFiles;
+ GetAllLocalFiles(localFiles);
ASSERT(!localFiles.empty(), ());
return make_shared<VehicleRouterComponents>(localFiles, vehicleType);
}
diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp
index ff24268f88..beff191feb 100644
--- a/routing/routing_integration_tests/routing_test_tools.hpp
+++ b/routing/routing_integration_tests/routing_test_tools.hpp
@@ -92,6 +92,7 @@ private:
unique_ptr<IndexRouter> m_indexRouter;
};
+void GetAllLocalFiles(vector<LocalCountryFile> & localFiles);
void TestOnlineCrosses(ms::LatLon const & startPoint, ms::LatLon const & finalPoint,
vector<string> const & expected, IRouterComponents & routerComponents);
void TestOnlineFetcher(ms::LatLon const & startPoint, ms::LatLon const & finalPoint,
diff --git a/xcode/routing/routing.xcodeproj/project.pbxproj b/xcode/routing/routing.xcodeproj/project.pbxproj
index 5d5581ddea..68cc99233a 100644
--- a/xcode/routing/routing.xcodeproj/project.pbxproj
+++ b/xcode/routing/routing.xcodeproj/project.pbxproj
@@ -100,6 +100,7 @@
56CA09E61E30E73B00D05C9A /* index_graph_tools.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56CA09E11E30E73B00D05C9A /* index_graph_tools.hpp */; };
56CA09E71E30E73B00D05C9A /* restriction_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CA09E21E30E73B00D05C9A /* restriction_test.cpp */; };
56CA09E91E30F19800D05C9A /* libtraffic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56CA09E81E30F19800D05C9A /* libtraffic.a */; };
+ 56CA63071F61206700E6681B /* road_graph_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56CA63061F61206700E6681B /* road_graph_tests.cpp */; };
56CC5A371E3884960016AC46 /* cross_mwm_index_graph.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56CC5A361E3884960016AC46 /* cross_mwm_index_graph.hpp */; };
56D637D61E4B12AA00B86D7B /* cross_mwm_index_graph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56D637D51E4B12AA00B86D7B /* cross_mwm_index_graph.cpp */; };
56EA2FD51D8FD8590083F01A /* routing_helpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 56EA2FD41D8FD8590083F01A /* routing_helpers.hpp */; };
@@ -377,6 +378,7 @@
56CA09E11E30E73B00D05C9A /* index_graph_tools.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = index_graph_tools.hpp; sourceTree = "<group>"; };
56CA09E21E30E73B00D05C9A /* restriction_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = restriction_test.cpp; sourceTree = "<group>"; };
56CA09E81E30F19800D05C9A /* libtraffic.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtraffic.a; path = "/Users/vladimirbykoyanko/src_github_master/omim/xcode/traffic/../../../omim-build/xcode/Debug/libtraffic.a"; sourceTree = "<absolute>"; };
+ 56CA63061F61206700E6681B /* road_graph_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = road_graph_tests.cpp; sourceTree = "<group>"; };
56CC5A361E3884960016AC46 /* cross_mwm_index_graph.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cross_mwm_index_graph.hpp; sourceTree = "<group>"; };
56D637D51E4B12AA00B86D7B /* cross_mwm_index_graph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cross_mwm_index_graph.cpp; sourceTree = "<group>"; };
56EA2FD41D8FD8590083F01A /* routing_helpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = routing_helpers.hpp; sourceTree = "<group>"; };
@@ -911,6 +913,7 @@
567E9F721F5850460064CB96 /* bicycle_route_test.cpp */,
567E9F731F5850460064CB96 /* bicycle_turn_test.cpp */,
567E9F741F5850460064CB96 /* turn_test.cpp */,
+ 56CA63061F61206700E6681B /* road_graph_tests.cpp */,
67BD35AC1C69F086003AA26F /* cross_section_tests.cpp */,
67BD35AD1C69F086003AA26F /* online_cross_tests.cpp */,
67BD35B01C69F086003AA26F /* pedestrian_route_test.cpp */,
@@ -1247,6 +1250,7 @@
674F9BD21B0A580E00704FFA /* road_graph_router.cpp in Sources */,
5694CECE1EBA25F7004576D3 /* vehicle_mask.cpp in Sources */,
A1876BC61BB19C4300C9C743 /* speed_camera.cpp in Sources */,
+ 56CA63071F61206700E6681B /* road_graph_tests.cpp in Sources */,
0C45D7391F2F75500065C3ED /* routing_settings.cpp in Sources */,
0C5FEC691DDE193F0017688C /* road_index.cpp in Sources */,
0CF709361F05172200D5067E /* checkpoints.cpp in Sources */,