summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/grouping/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/grouping/grouping.cpp52
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp4
-rw-r--r--searchcore/src/tests/proton/common/CMakeLists.txt2
-rw-r--r--searchcore/src/tests/proton/document_iterator/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/matching/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp74
-rw-r--r--searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt1
10 files changed, 24 insertions, 114 deletions
diff --git a/searchcore/src/tests/grouping/CMakeLists.txt b/searchcore/src/tests/grouping/CMakeLists.txt
index 8108028c717..781f0cab66f 100644
--- a/searchcore/src/tests/grouping/CMakeLists.txt
+++ b/searchcore/src/tests/grouping/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_grouping_test_app TEST
DEPENDS
searchcore_grouping
searchcore_matching
+ searchlib_test
)
vespa_add_test(NAME searchcore_grouping_test_app COMMAND searchcore_grouping_test_app)
diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp
index 7e21fffe9fd..3f166ee9723 100644
--- a/searchcore/src/tests/grouping/grouping.cpp
+++ b/searchcore/src/tests/grouping/grouping.cpp
@@ -10,6 +10,7 @@
#include <vespa/searchcore/grouping/groupingmanager.h>
#include <vespa/searchcore/grouping/groupingsession.h>
#include <vespa/searchcore/proton/matching/sessionmanager.h>
+#include <vespa/searchlib/test/mock_attribute_context.h>
#include <iostream>
#include <vespa/log/log.h>
@@ -20,7 +21,7 @@ using namespace search::aggregation;
using namespace search::expression;
using namespace search::grouping;
using namespace search;
-
+using search::attribute::test::MockAttributeContext;
using proton::matching::SessionManager;
@@ -30,55 +31,8 @@ const uint32_t NUM_DOCS = 1000;
//-----------------------------------------------------------------------------
-class MyAttributeContext : public IAttributeContext
-{
-private:
- typedef std::map<string, IAttributeVector *> Map;
- Map _vectors;
-
-public:
- const IAttributeVector *get(const string &name) const {
- if (_vectors.find(name) == _vectors.end()) {
- return 0;
- }
- return _vectors.find(name)->second;
- }
- virtual const IAttributeVector *
- getAttribute(const string &name) const override {
- return get(name);
- }
- virtual const IAttributeVector *
- getAttributeStableEnum(const string &name) const override {
- return get(name);
- }
- virtual void
- getAttributeList(std::vector<const IAttributeVector *> & list) const override {
- Map::const_iterator pos = _vectors.begin();
- Map::const_iterator end = _vectors.end();
- for (; pos != end; ++pos) {
- list.push_back(pos->second);
- }
- }
- ~MyAttributeContext() {
- Map::iterator pos = _vectors.begin();
- Map::iterator end = _vectors.end();
- for (; pos != end; ++pos) {
- delete pos->second;
- }
- }
-
- //-------------------------------------------------------------------------
-
- void add(IAttributeVector *attr) {
- _vectors[attr->getName()] = attr;
- }
-};
-
-
-//-----------------------------------------------------------------------------
-
struct MyWorld {
- MyAttributeContext attributeContext;
+ MockAttributeContext attributeContext;
void basicSetup() {
// attribute context
diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
index bd539999b5d..b0bf905ba75 100644
--- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp
@@ -19,7 +19,7 @@
#include <vespa/searchcore/proton/test/attribute_utils.h>
#include <vespa/searchcore/proton/test/attribute_vectors.h>
#include <vespa/searchlib/attribute/attributefactory.h>
-#include <vespa/searchlib/attribute/i_attribute_functor.h>
+#include <vespa/searchcommon/attribute/i_attribute_functor.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/searchlib/attribute/imported_attribute_vector.h>
@@ -85,7 +85,7 @@ class MyAttributeFunctor : public search::attribute::IAttributeFunctor
public:
void
- operator()(const search::AttributeVector &attributeVector) override {
+ operator()(const search::attribute::IAttributeVector &attributeVector) override {
_names.push_back(attributeVector.getName());
}
diff --git a/searchcore/src/tests/proton/common/CMakeLists.txt b/searchcore/src/tests/proton/common/CMakeLists.txt
index 751314791a0..da0bc9b5b10 100644
--- a/searchcore/src/tests/proton/common/CMakeLists.txt
+++ b/searchcore/src/tests/proton/common/CMakeLists.txt
@@ -4,6 +4,7 @@ vespa_add_executable(searchcore_selectpruner_test_app TEST
selectpruner_test.cpp
DEPENDS
searchcore_pcommon
+ searchlib_test
)
vespa_add_test(NAME searchcore_selectpruner_test_app COMMAND searchcore_selectpruner_test_app)
vespa_add_executable(searchcore_cachedselect_test_app TEST
@@ -11,5 +12,6 @@ vespa_add_executable(searchcore_cachedselect_test_app TEST
cachedselect_test.cpp
DEPENDS
searchcore_pcommon
+ searchlib_test
)
vespa_add_test(NAME searchcore_cachedselect_test_app COMMAND searchcore_cachedselect_test_app)
diff --git a/searchcore/src/tests/proton/document_iterator/CMakeLists.txt b/searchcore/src/tests/proton/document_iterator/CMakeLists.txt
index 729bf09446f..27bd4cef68d 100644
--- a/searchcore/src/tests/proton/document_iterator/CMakeLists.txt
+++ b/searchcore/src/tests/proton/document_iterator/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_iterator_test_app TEST
DEPENDS
searchcore_persistenceengine
searchcore_pcommon
+ searchlib_test
)
vespa_add_test(NAME searchcore_document_iterator_test_app COMMAND searchcore_document_iterator_test_app)
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt
index 6769c964959..6b25971df83 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt
@@ -16,6 +16,7 @@ vespa_add_executable(searchcore_maintenancecontroller_test_app TEST
searchcore_proton_metrics
searchcore_util
searchcore_fconfig
+ searchlib_test
)
vespa_add_test(NAME searchcore_maintenancecontroller_test_app COMMAND searchcore_maintenancecontroller_test_app)
vespa_add_executable(searchcore_frozenbucketsmap_test_app TEST
diff --git a/searchcore/src/tests/proton/matching/CMakeLists.txt b/searchcore/src/tests/proton/matching/CMakeLists.txt
index 14f3960c43e..0fce2f6aca2 100644
--- a/searchcore/src/tests/proton/matching/CMakeLists.txt
+++ b/searchcore/src/tests/proton/matching/CMakeLists.txt
@@ -14,6 +14,7 @@ vespa_add_executable(searchcore_matching_test_app TEST
searchcore_grouping
searchcore_util
searchlib_searchlib_uca
+ searchlib_test
)
vespa_add_test(NAME searchcore_matching_test_app COMMAND searchcore_matching_test_app)
vespa_add_executable(searchcore_sessionmanager_test_app TEST
diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp
index 8d75c8b8d24..de6a452baf3 100644
--- a/searchcore/src/tests/proton/matching/matching_test.cpp
+++ b/searchcore/src/tests/proton/matching/matching_test.cpp
@@ -24,6 +24,7 @@
#include <vespa/searchlib/engine/searchrequest.h>
#include <vespa/searchlib/engine/docsumreply.h>
#include <vespa/searchlib/engine/searchreply.h>
+#include <vespa/searchlib/test/mock_attribute_context.h>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/searchlib/query/tree/querybuilder.h>
#include <vespa/searchlib/query/tree/stackdumpcreator.h>
@@ -49,6 +50,7 @@ using namespace search::query;
using namespace search::queryeval;
using namespace search;
+using search::attribute::test::MockAttributeContext;
using search::index::schema::DataType;
using storage::spi::Timestamp;
@@ -93,52 +95,6 @@ vespalib::string make_same_element_stack_dump(const vespalib::string &a1_term, c
const uint32_t NUM_DOCS = 1000;
-//-----------------------------------------------------------------------------
-
-class MyAttributeContext : public IAttributeContext
-{
-private:
- typedef std::map<string, IAttributeVector *> Map;
- Map _vectors;
-
-public:
- const IAttributeVector *get(const string &name) const {
- if (_vectors.find(name) == _vectors.end()) {
- return 0;
- }
- return _vectors.find(name)->second;
- }
- const IAttributeVector *
- getAttribute(const string &name) const override {
- return get(name);
- }
- const IAttributeVector *
- getAttributeStableEnum(const string &name) const override {
- return get(name);
- }
- void
- getAttributeList(std::vector<const IAttributeVector *> & list) const override {
- Map::const_iterator pos = _vectors.begin();
- Map::const_iterator end = _vectors.end();
- for (; pos != end; ++pos) {
- list.push_back(pos->second);
- }
- }
- ~MyAttributeContext() override {
- Map::iterator pos = _vectors.begin();
- Map::iterator end = _vectors.end();
- for (; pos != end; ++pos) {
- delete pos->second;
- }
- }
-
- //-------------------------------------------------------------------------
-
- void add(IAttributeVector *attr) {
- _vectors[attr->getName()] = attr;
- }
-};
-
struct EmptyConstantValueRepo : public proton::matching::IConstantValueRepo {
virtual vespalib::eval::ConstantValue::UP getConstant(const vespalib::string &) const override {
return std::make_unique<proton::matching::ErrorConstantValue>();
@@ -151,7 +107,7 @@ struct MyWorld {
Schema schema;
Properties config;
FakeSearchContext searchContext;
- MyAttributeContext attributeContext;
+ MockAttributeContext attributeContext;
SessionManager::SP sessionManager;
DocumentMetaStore metaStore;
MatchingStats matchingStats;
@@ -327,14 +283,10 @@ struct MyWorld {
}
};
- struct DummyAttributeExecutor : public IAttributeExecutor {
- void asyncForAttribute(const vespalib::string &, std::shared_ptr<IAttributeFunctor>) const override {}
- };
void verify_diversity_filter(SearchRequest::SP req, bool expectDiverse) {
Matcher::SP matcher = createMatcher();
search::fef::Properties overrides;
- DummyAttributeExecutor attrExec;
- auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, attrExec, metaStore, overrides);
+ auto mtf = matcher->create_match_tools_factory(*req, searchContext, attributeContext, metaStore, overrides);
auto diversity = mtf->createDiversifier();
EXPECT_EQUAL(expectDiverse, static_cast<bool>(diversity));
}
@@ -343,9 +295,8 @@ struct MyWorld {
Matcher::SP matcher = createMatcher();
SearchRequest::SP request = createSimpleRequest("f1", "spread");
search::fef::Properties overrides;
- DummyAttributeExecutor attrExec;
MatchToolsFactory::UP match_tools_factory = matcher->create_match_tools_factory(
- *request, searchContext, attributeContext, attrExec, metaStore, overrides);
+ *request, searchContext, attributeContext, metaStore, overrides);
MatchTools::UP match_tools = match_tools_factory->createMatchTools();
match_tools->setup_first_phase();
return match_tools->match_data().get_termwise_limit();
@@ -354,13 +305,12 @@ struct MyWorld {
SearchReply::UP performSearch(SearchRequest::SP req, size_t threads) {
Matcher::SP matcher = createMatcher();
SearchSession::OwnershipBundle owned_objects;
- owned_objects.search_handler.reset(new MySearchHandler(matcher));
- owned_objects.context.reset(new MatchContext(std::make_unique<MyAttributeContext>(),
- std::make_unique<FakeSearchContext>()));
+ owned_objects.search_handler = std::make_shared<MySearchHandler>(matcher);
+ owned_objects.context = std::make_unique<MatchContext>(std::make_unique<MockAttributeContext>(),
+ std::make_unique<FakeSearchContext>());
vespalib::SimpleThreadBundle threadBundle(threads);
- DummyAttributeExecutor attrExec;
SearchReply::UP reply = matcher->match(*req, threadBundle, searchContext, attributeContext,
- attrExec, *sessionManager, metaStore, std::move(owned_objects));
+ *sessionManager, metaStore, std::move(owned_objects));
matchingStats.add(matcher->getStats());
return reply;
}
@@ -392,14 +342,12 @@ struct MyWorld {
FeatureSet::SP getSummaryFeatures(DocsumRequest::SP req) {
Matcher::SP matcher = createMatcher();
- DummyAttributeExecutor attrExec;
- return matcher->getSummaryFeatures(*req, searchContext, attributeContext, attrExec, *sessionManager);
+ return matcher->getSummaryFeatures(*req, searchContext, attributeContext, *sessionManager);
}
FeatureSet::SP getRankFeatures(DocsumRequest::SP req) {
Matcher::SP matcher = createMatcher();
- DummyAttributeExecutor attrExec;
- return matcher->getRankFeatures(*req, searchContext, attributeContext, attrExec, *sessionManager);
+ return matcher->getRankFeatures(*req, searchContext, attributeContext, *sessionManager);
}
};
diff --git a/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt b/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt
index 00826843d9e..5dbe031d6aa 100644
--- a/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt
+++ b/searchcore/src/tests/proton/reference/document_db_reference/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_db_reference_test_app TEST
DEPENDS
searchcore_reference
searchcore_attribute
+ searchlib_test
)
vespa_add_test(NAME searchcore_document_db_reference_test_app COMMAND searchcore_document_db_reference_test_app)
diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt
index 1db6f2118b3..46fe9ac0781 100644
--- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt
+++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_document_db_reference_resolver_test_app TEST
DEPENDS
searchcore_reference
searchcore_attribute
+ searchlib_test
)
vespa_add_test(NAME searchcore_document_db_reference_resolver_test_app COMMAND searchcore_document_db_reference_resolver_test_app)