mirror of https://gitee.com/bigwinds/arangodb
auto-locate directory to IResearch test resources (#8899)
alternatively, pick up the directory from environment variable `IRESEARCH_TEST_RESOURCE_DIR`
This commit is contained in:
parent
673b915594
commit
fb85af85c6
|
@ -359,9 +359,8 @@ TEST_CASE("IResearchExpressionFilterTest", "[iresearch][iresearch-expression-fil
|
|||
arangodb::velocypack::Builder testData;
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
testData = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
}
|
||||
auto testDataRoot = testData.slice();
|
||||
|
|
|
@ -543,7 +543,7 @@ SECTION("test_async_index") {
|
|||
try {
|
||||
irs::utf8_path resource;
|
||||
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
} catch (...) {
|
||||
|
@ -581,7 +581,7 @@ SECTION("test_async_index") {
|
|||
try {
|
||||
irs::utf8_path resource;
|
||||
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
} catch (...) {
|
||||
|
|
|
@ -215,7 +215,7 @@ TEST_CASE("IResearchQueryTestAggregate", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -238,7 +238,7 @@ TEST_CASE("IResearchQueryTestAnd", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -250,7 +250,7 @@ TEST_CASE("IResearchQueryTestComplexBoolean", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -239,7 +239,7 @@ TEST_CASE("IResearchQueryTestExists", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -1497,7 +1497,7 @@ TEST_CASE("IResearchQueryTestExistsStoreMaskPartially", "[iresearch][iresearch-q
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -218,7 +218,7 @@ TEST_CASE("IResearchQueryTestIn", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -254,7 +254,7 @@ TEST_CASE("IResearchQueryInRange", "[iresearch][iresearch-query]") {
|
|||
collection1 = collection;
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -482,7 +482,7 @@ TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-qu
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -508,7 +508,7 @@ TEST_CASE("IResearchQueryTestJoinDuplicateDataSource", "[iresearch][iresearch-qu
|
|||
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential_order.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -631,7 +631,7 @@ TEST_CASE("IResearchQueryTestJoin", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -657,7 +657,7 @@ TEST_CASE("IResearchQueryTestJoin", "[iresearch][iresearch-query]") {
|
|||
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential_order.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -255,7 +255,7 @@ TEST_CASE("IResearchQueryTestNumericTerm", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -283,7 +283,7 @@ TEST_CASE("IResearchQueryTestOptionsCollections", "[iresearch][iresearch-query]"
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -942,7 +942,7 @@ TEST_CASE("IResearchQueryTestOptionsWaitForSync", "[iresearch][iresearch-query]"
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -279,7 +279,7 @@ TEST_CASE("IResearchQueryTestOr", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -250,7 +250,7 @@ TEST_CASE("IResearchQueryTestPhrase", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -317,7 +317,7 @@ TEST_CASE("IResearchQueryScorer", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
@ -343,7 +343,7 @@ TEST_CASE("IResearchQueryScorer", "[iresearch][iresearch-query]") {
|
|||
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential_order.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -244,7 +244,7 @@ TEST_CASE("IResearchQueryTestStartsWith", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -285,7 +285,7 @@ TEST_CASE("IResearchQueryTestStringTerm", "[iresearch][iresearch-query]") {
|
|||
// insert into collections
|
||||
{
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -244,7 +244,7 @@ TEST_CASE("IResearchQueryTestTokens", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -218,7 +218,7 @@ TEST_CASE("IResearchQueryTestTraversal", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -215,7 +215,7 @@ TEST_CASE("IResearchQueryTestValue", "[iresearch][iresearch-query]") {
|
|||
REQUIRE((nullptr != collection));
|
||||
|
||||
irs::utf8_path resource;
|
||||
resource/=irs::string_ref(IResearch_test_resource_dir);
|
||||
resource/=irs::string_ref(arangodb::tests::testResourceDir);
|
||||
resource/=irs::string_ref("simple_sequential.json");
|
||||
|
||||
auto builder = arangodb::basics::VelocyPackHelper::velocyPackFromFile(resource.utf8());
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
#include "Aql/ExpressionContext.h"
|
||||
#include "Aql/Ast.h"
|
||||
#include "Aql/IResearchViewNode.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "ClusterEngine/ClusterEngine.h"
|
||||
#include "Random/RandomGenerator.h"
|
||||
#include "Basics/files.h"
|
||||
#include "RestServer/DatabasePathFeature.h"
|
||||
#include "V8/v8-utils.h"
|
||||
#include "VocBase/KeyGenerator.h"
|
||||
|
@ -50,6 +51,8 @@
|
|||
|
||||
#include "search/boolean_filter.hpp"
|
||||
|
||||
#include "3rdParty/iresearch/tests/tests_config.hpp"
|
||||
|
||||
#include <velocypack/Iterator.h>
|
||||
#include <velocypack/Parser.h>
|
||||
|
||||
|
@ -252,10 +255,46 @@ REGISTER_SCORER_JSON(CustomScorer, CustomScorer::make);
|
|||
namespace arangodb {
|
||||
namespace tests {
|
||||
|
||||
std::string testResourceDir;
|
||||
|
||||
static void findIResearchTestResources() {
|
||||
std::string toBeFound = basics::FileUtils::buildFilename("3rdParty", "iresearch", "tests", "resources");
|
||||
|
||||
// peek into environment variable first
|
||||
char const* dir = getenv("IRESEARCH_TEST_RESOURCE_DIR");
|
||||
if (dir != nullptr) {
|
||||
// environment variable set, so use it
|
||||
testResourceDir = std::string(dir);
|
||||
} else {
|
||||
// environment variable not set, so try to auto-detect the location
|
||||
testResourceDir = ".";
|
||||
do {
|
||||
if (basics::FileUtils::isDirectory(basics::FileUtils::buildFilename(testResourceDir, toBeFound))) {
|
||||
testResourceDir = basics::FileUtils::buildFilename(testResourceDir, toBeFound);
|
||||
return;
|
||||
}
|
||||
testResourceDir = basics::FileUtils::buildFilename(testResourceDir, "..");
|
||||
if (!basics::FileUtils::isDirectory(testResourceDir)) {
|
||||
testResourceDir = IResearch_test_resource_dir;
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
if (!basics::FileUtils::isDirectory(testResourceDir)) {
|
||||
LOG_TOPIC("45f9d", ERR, Logger::FIXME) << "unable to find directory for IResearch test resources. use environment variable IRESEARCH_TEST_RESOURCE_DIR to set it";
|
||||
}
|
||||
}
|
||||
|
||||
void init(bool withICU /*= false*/) {
|
||||
arangodb::transaction::Methods::clearDataSourceRegistrationCallbacks();
|
||||
ClusterEngine::Mocking = true;
|
||||
arangodb::RandomGenerator::initialize(arangodb::RandomGenerator::RandomType::MERSENNE);
|
||||
|
||||
// try to locate directory for iresearch test resource files
|
||||
if (testResourceDir.empty()) {
|
||||
findIResearchTestResources();
|
||||
}
|
||||
}
|
||||
|
||||
// @Note: once V8 is initialized all 'CATCH' errors will result in SIGILL
|
||||
|
|
|
@ -62,6 +62,8 @@ class ByExpression;
|
|||
|
||||
namespace tests {
|
||||
|
||||
extern std::string testResourceDir;
|
||||
|
||||
void init(bool withICU = false);
|
||||
|
||||
template <typename T, typename U>
|
||||
|
|
Loading…
Reference in New Issue