8000 Merge pull request #4899 from arangodb/bug-fix/internal-issue-#344.8.1 · Sandychuang/arangodb@5d78cf8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d78cf8

Browse files
author
Andrey Abramov
authored
Merge pull request arangodb#4899 from arangodb/bug-fix/internal-issue-#344.8.1
manually-merge: add more tests, backport some miscellaneous fixes
2 parents 34fb55d + a553410 commit 5d78cf8

File tree

11 files changed

+726
-56
lines changed

11 files changed

+726
-56
lines changed

3rdParty/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ if (USE_IRESEARCH)
153153
set(IRESEARCH_EXCLUDE_STATIC_THIRD_PARTY_LIBS TRUE) # disable linking in of 3rd party libraries automatically
154154
find_package(IResearch REQUIRED) # set IRESEARCH_BUILD_DIR
155155

156+
set(CMAKE_MACOSX_RPATH ON) # suppress cmake warning (use same value as cmake default)
156157
set(CMAKE_MODULE_PATH_ORIGINAL ${CMAKE_MODULE_PATH}) # remember CMAKE_MODULE_PATH
157158
list(APPEND CMAKE_MODULE_PATH
158159
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" # cmake overrides (must be first)

3rdParty/iresearch/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ if(MSVC)
289289
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
290290
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
291291
COMMAND ${CMAKE_COMMAND} -E make_directory iql
292-
COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy iql/parser.yy || bison --graph --report=all -o iql/parser.cc ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
292+
COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy iql/parser.yy || bison --graph --report=all -Wnone -o iql/parser.cc ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
293293
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy iql/parser.yy
294294
)
295295
else()
@@ -298,7 +298,7 @@ else()
298298
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
299299
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
300300
COMMAND ${CMAKE_COMMAND} -E make_directory iql
301-
COMMAND bison --graph --report=all -o iql/parser.cc ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
301+
COMMAND bison --graph --report=all -Wnone -o iql/parser.cc ${CMAKE_CURRENT_SOURCE_DIR}/iql/parser.yy
302302
)
303303
endif()
304304

3rdParty/iresearch/core/analysis/text_token_stream.cpp

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,25 @@ irs::analysis::analyzer::ptr construct(
256256
}
257257
}
258258

259-
// interpret the cache_key as a locale name
260-
std::string locale_name(cache_key.c_str(), cache_key.size());
261-
auto locale = irs::locale_utils::locale(locale_name);
262-
ignored_words_t buf;
259+
try {
260+
// interpret the cache_key as a locale name
261+
std::string locale_name(cache_key.c_str(), cache_key.size());
262+
auto locale = irs::locale_utils::locale(locale_name);
263+
ignored_words_t buf;
263264

264-
if (!get_ignored_words(buf, locale)) {
265-
IR_FRMT_WARN("Failed to retrieve 'ignored_words' while constructing text_token_stream with cache key: %s", cache_key.c_str());
265+
if (!get_ignored_words(buf, locale)) {
266+
IR_FRMT_WARN("Failed to retrieve 'ignored_words' while constructing text_token_stream with cache key: %s", cache_key.c_str());
266267

267-
return nullptr;
268+
return nullptr;
269+
}
270+
271+
return construct(cache_key, locale, std::move(buf));
272+
} catch (...) {
273+
IR_FRMT_ERROR("Caught error while constructing text_token_stream cache key: %s", cache_key.c_str());
274+
IR_LOG_EXCEPTION();
268275
}
269276

270-
return construct(cache_key, locale, std::move(buf));
277+
return nullptr;
271278
}
272279

273280
////////////////////////////////////////////////////////////////////////////////
@@ -409,34 +416,41 @@ irs::analysis::analyzer::ptr make_json(const irs::string_ref& args) {
409416
return nullptr;
410417
}
411418

412-
static const rapidjson::Value empty;
413-
auto locale = irs::locale_utils::locale(json["locale"].GetString());
414-
auto& ignored_words = json.HasMember("ignored_words") ? json["ignored_words"] : empty;
415-
auto& ignored_words_path = json.HasMember("ignored_words_path") ? json["ignored_words_path"] : empty;
419+
try {
420+
static const rapidjson::Value empty;
421+
auto locale = irs::locale_utils::locale(json["locale"].GetString());
422+
auto& ignored_words = json.HasMember("ignored_words") ? json["ignored_words"] : empty;
423+
auto& ignored_words_path = json.HasMember("ignored_words_path") ? json["ignored_words_path"] : empty;
424+
425+
if (!ignored_words.IsArray()) {
426+
return ignored_words_p F438 ath.IsString()
427+
? construct(args, locale, ignored_words_path.GetString())
428+
: construct(args, locale)
429+
;
430+
}
416431

417-
if (!ignored_words.IsArray()) {
418-
return ignored_words_path.IsString()
419-
? construct(args, locale, ignored_words_path.GetString())
420-
: construct(args, locale)
421-
;
422-
}
432+
ignored_words_t buf;
423433

424-
ignored_words_t buf;
434+
for (auto itr = ignored_words.Begin(), end = ignored_words.End(); itr != end; ++itr) {
435+
if (!itr->IsString()) {
436+
IR_FRMT_WARN("Non-string value in 'ignored_words' while constructing text_token_stream from jSON arguments: %s", args.c_str());
425437

426-
for (auto itr = ignored_words.Begin(), end = ignored_words.End(); itr != end; ++itr) {
427-
if (!itr->IsString()) {
428-
IR_FRMT_WARN("Non-string value in 'ignored_words' while constructing text_token_stream from jSON arguments: %s", args.c_str());
438+
return nullptr;
439+
}
429440

430-
return nullptr;
441+
buf.emplace(itr->GetString());
431442
}
432443

433-
buf.emplace(itr->GetString());
444+
return ignored_words_path.IsString()
445+
? construct(args, locale, ignored_words_path.GetString(), std::move(buf))
446+
: construct(args, locale, std::move(buf))
447+
;
448+
} catch (...) {
449+
IR_FRMT_ERROR("Caught error while constructing text_token_stream from jSON arguments: %s", args.c_str());
450+
IR_LOG_EXCEPTION();
434451
}
435452

436-
return ignored_words_path.IsString()
437-
? construct(args, locale, ignored_words_path.GetString(), std::move(buf))
438-
: construct(args, locale, std::move(buf))
439-
;
453+
return nullptr;
440454
}
441455

442456
////////////////////////////////////////////////////////////////////////////////

3rdParty/iresearch/core/utils/file_utils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ inline int path_stats(file_stat_t& info, const file_path_t path) {
7878
auto parts = irs::file_utils::path_parts(path);
7979

8080
return file_stat(
81-
parts.basename.null() ? std::wstring(parts.dirname).c_str() : path,
81+
parts.basename.empty() ? std::wstring(parts.dirname).c_str() : path,
8282
&info
8383
);
8484
#else
@@ -517,7 +517,7 @@ bool exists(bool& result, const file_path_t file) NOEXCEPT {
517517

518518
result = 0 == path_stats(info, file);
519519

520-
if (!result) {
520+
if (!result && ENOENT != errno) {
521521
auto path = boost::locale::conv::utf_to_utf<char>(file);
522522

523523
IR_FRMT_ERROR("Failed to get stat, error %d path: %s", errno, path.c_str());
@@ -532,16 +532,16 @@ bool exists_directory(bool& result, const file_path_t name) NOEXCEPT {
532532

533533
result = 0 == path_stats(info, name);
534534

535-
if (!result) {
536-
auto path = boost::locale::conv::utf_to_utf<char>(name);
537-
538-
IR_FRMT_ERROR("Failed to get stat, error %d path: %s", errno, path.c_str());
539-
} else {
535+
if (result) {
540536
#ifdef _WIN32
541537
result = (info.st_mode & _S_IFDIR) > 0;
542538
#else
543539
result = (info.st_mode & S_IFDIR) > 0;
544540
#endif
541+
} else if (ENOENT != errno) {
542+
auto path = boost::locale::conv::utf_to_utf<char>(name);
543+
544+
IR_FRMT_ERROR("Failed to get stat, error %d path: %s", errno, path.c_str());
545545
}
546546

547547
return true;
@@ -553,16 +553,16 @@ bool exists_file(bool& result, const file_path_t name) NOEXCEPT {
553553

554554
result = 0 == path_stats(info, name);
555555

556-
if (!result) {
557-
auto path = boost::locale::conv::utf_to_utf<char>(name);
558-
559-
IR_FRMT_ERROR("Failed to get stat, error %d path: %s", errno, path.c_str());
560-
} else {
556+
if (result) {
561557
#ifdef _WIN32
562558
result = (info.st_mode & _S_IFREG) > 0;
563559
#else
564560
result = (info.st_mode & S_IFREG) > 0;
565561
#endif
562+
} else if (ENOENT != errno) {
563+
auto path = boost::locale::conv::utf_to_utf<char>(name);
564+
565+
IR_FRMT_ERROR("Failed to get stat, error %d path: %s", errno, path.c_str());
566566
}
567567

568568
return true;

Documentation/DocuBlocks/Rest/Views/get_api_view_properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@RESTURLPARAMETERS
88

99
@RESTDESCRIPTION
10-
TBD
10+
Returns an object containing the definition of the view identified by *view-name*.
1111

1212
@RESTURLPARAM{view-name,string,required}
1313
The name of the view.

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ if (USE_IRESEARCH)
4848
IResearch/ExpressionContextMock.cpp
4949
IResearch/VelocyPackHelper-test.cpp
5050
IResearch/ExecutionBlockMock-test.cpp
51+ Utils/CollectionNameResolver-test.cpp
5152
VocBase/LogicalDataSource-test.cpp
53+
VocBase/vocbase-test.cpp
5254
)
5355
endif ()
5456

tests/IResearch/IResearchIndex-test.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,19 @@ SECTION("test_async_index") {
374374
// populate collections asynchronously
375375
{
376376
std::thread thread0([collection0, &resThread0]()->void {
377-
irs::utf8_path resource;
378-
resource/=irs::string_ref(IResearch_test_resource_dir);
379-
resource/=irs::string_ref("simple_sequential.json");
377+
arangodb::velocypack::Builder builder;
378+
379+
try {
380+
irs::utf8_path resource;
381+
382+
resource/=irs::string_ref(IResearch_test_resource_dir);
383+
resource/=irs::string_ref("simple_sequential.json");
384+
builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
385+
} catch (...) {
386+
return; // velocyPackFromFile(...) may throw exception
387+
}
380388

381389
auto doc = arangodb::velocypack::Parser::fromJson("{ \"seq\": 40, \"same\": \"xyz\", \"duplicated\": \"abcd\" }");
382-
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
383390
auto slice = builder.slice();
384391
resThread0 = slice.isArray();
385392
if (!resThread0) return;
@@ -405,12 +412,19 @@ SECTION("test_async_index") {
405412
});
406413

407414
std::thread thread1([collection1, &resThread1]()->void {
408-
irs::utf8_path resource;
409-
resource/=irs::string_ref(IResearch_test_resource_dir);
410-
resource/=irs::string_ref("simple_sequential.json");
415+
arangodb::velocypack::Builder builder;
416+
417+
try {
418+
irs::utf8_path resource;
419+
420+
resource/=irs::string_ref(IResearch_test_resource_dir);
421+
resource/=irs::string_ref("simple_sequential.json");
422+
builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
423+
} catch (...) {
424+
return; // velocyPackFromFile(...) may throw exception
425+
}
411426

412427
auto doc = arangodb::velocypack::Parser::fromJson("{ \"seq\": 50, \"same\": \"xyz\", \"duplicated\": \"abcd\" }");
413-
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
414428
auto slice = builder.slice();
415429
resThread1 = slice.isArray();
416430
if (!resThread1) return;
@@ -627,4 +641,4 @@ SECTION("test_fields") {
627641

628642
// -----------------------------------------------------------------------------
629643
// --SECTION-- END-OF-FILE
630-
// -----------------------------------------------------------------------------
644+
// -----------------------------------------------------------------------------

tests/IResearch/IResearchLinkMeta-test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ SECTION("test_inheritDefaults") {
188188

189189
analyzers.start();
190190

191-
defaults._fields["abc"] = std::move(arangodb::iresearch::IResearchLinkMeta());
191+
defaults._fields["abc"] = arangodb::iresearch::IResearchLinkMeta();
192192
defaults._includeAllFields = true;
193193
defaults._trackListPositions = true;
194194
defaults._analyzers.clear();
195195
defaults._analyzers.emplace_back(analyzers.ensure("empty"));
196-
defaults._fields["abc"]->_fields["xyz"] = std::move(arangodb::iresearch::IResearchLinkMeta());
196+
defaults._fields["abc"]->_fields["xyz"] = arangodb::iresearch::IResearchLinkMeta();
197197

198198
auto json = arangodb::velocypack::Parser::fromJson("{}");
199199
CHECK(true == meta.init(json->slice(), tmpString, defaults));
@@ -410,8 +410,8 @@ SECTION("test_writeCustomizedValues") {
410410
auto& overrideNone = *(meta._fields["c"]->_fields["none"]);
411411

412412
overrideAll._fields.clear(); // do not inherit fields to match jSon inheritance
413-
overrideAll._fields["x"] = std::move(arangodb::iresearch::IResearchLinkMeta());
414-
overrideAll._fields["y"] = std::move(arangodb::iresearch::IResearchLinkMeta());
413+
overrideAll._fields["x"] = arangodb::iresearch::IResearchLinkMeta();
414+
overrideAll._fields["y"] = arangodb::iresearch::IResearchLinkMeta();
415415
overrideAll._includeAllFields = false;
416416
overrideAll._trackListPositions = false;
417417
overrideAll._analyzers.clear();

tests/IResearch/IResearchQueryExists-test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "Enterprise/Ldap/LdapFeature.h"
3131
#endif
3232

33+
#include "Basics/files.h"
3334
#include "V8/v8-globals.h"
3435
#include "VocBase/LogicalCollection.h"
3536
#include "VocBase/LogicalView.h"
@@ -132,6 +133,13 @@ struct IResearchQuerySetup {
132133
analyzers->emplace("test_analyzer", "TestAnalyzer", "abc"); // cache analyzer
133134
analyzers->emplace("test_csv_analyzer", "TestDelimAnalyzer", ","); // cache analyzer
134135

136+
auto* dbPathFeature = arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabasePathFeature>("DatabasePath");
137+
irs::utf8_path testFilesystemPath;
138+
139+
testFilesystemPath /= TRI_GetTempPath();
140+
testFilesystemPath /= std::string("arangodb_tests.") + std::to_string(TRI_microtime());
141+
const_cast<std::string&>(dbPathFeature->directory()) = testFilesystemPath.utf8();
142+
135143
// suppress log messages since tests check error conditions
136144
arangodb::LogTopic::setLogLevel(arangodb::Logger::FIXME.name(), arangodb::LogLevel::ERR); // suppress WARNING DefaultCustomTypeHandler called
137145
arangodb::LogTopic::setLogLevel(arangodb::iresearch::IResearchFeature::IRESEARCH.name(), arangodb::LogLevel::FATAL);

0 commit comments

Comments
 (0)
0