summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-01 15:11:53 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-01 15:11:53 +0000
commit2634d3f67851ff602a69dec6ce00029de5fbaea7 (patch)
treedfae1e85c39aa31e59be1c83a35fa89d9f624d04 /searchcore/src/tests
parent179daa38c12471ec9de4e48ec91865c8a336d8a8 (diff)
Deinline large destructors and clean up some code based on clion hints.
Diffstat (limited to 'searchcore/src/tests')
-rw-r--r--searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp71
-rw-r--r--searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp30
-rw-r--r--searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp26
-rw-r--r--searchcore/src/tests/proton/reference/document_db_reference_resolver/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt1
-rw-r--r--searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt1
6 files changed, 67 insertions, 63 deletions
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 07167a91498..616bf9edf6a 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
@@ -181,7 +181,7 @@ struct AttributeManagerFixture
proton::AttributeManager::SP _msp;
proton::AttributeManager &_m;
ImportedAttributesRepoBuilder _builder;
- AttributeManagerFixture(BaseFixture &bf);
+ explicit AttributeManagerFixture(BaseFixture &bf);
~AttributeManagerFixture();
AttributeVector::SP addAttribute(const vespalib::string &name) {
return _m.addAttribute({name, INT32_SINGLE}, createSerialNum);
@@ -214,18 +214,21 @@ struct SequentialAttributeManager
{
SequentialAttributesInitializer initializer;
proton::AttributeManager mgr;
- SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec)
- : initializer(newSpec.getDocIdLimit()),
- mgr(currMgr, std::move(newSpec), initializer)
- {
- mgr.addInitializedAttributes(initializer.getInitializedAttributes());
- }
- ~SequentialAttributeManager() = default;
+ SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec);
+ ~SequentialAttributeManager();
};
+SequentialAttributeManager::SequentialAttributeManager(const AttributeManager &currMgr, AttrMgrSpec && newSpec)
+ : initializer(newSpec.getDocIdLimit()),
+ mgr(currMgr, std::move(newSpec), initializer)
+{
+ mgr.addInitializedAttributes(initializer.getInitializedAttributes());
+}
+SequentialAttributeManager::~SequentialAttributeManager() = default;
+
struct DummyInitializerTask : public InitializerTask
{
- virtual void run() override {}
+ void run() override {}
};
struct ParallelAttributeManager
@@ -240,12 +243,12 @@ struct ParallelAttributeManager
ExecutorThreadService master;
AttributeManagerInitializer::SP initializer;
- ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr,
+ ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager & baseAttrMgr,
const AttributesConfig &attrCfg, uint32_t docIdLimit);
~ParallelAttributeManager();
};
-ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager::SP baseAttrMgr,
+ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSerialNum, AttributeManager & baseAttrMgr,
const AttributesConfig &attrCfg, uint32_t docIdLimit)
: documentMetaStoreInitTask(std::make_shared<DummyInitializerTask>()),
bucketDbOwner(std::make_shared<bucketdb::BucketDBOwner>()),
@@ -256,7 +259,7 @@ ParallelAttributeManager::ParallelAttributeManager(search::SerialNum configSeria
masterExecutor(1),
master(masterExecutor),
initializer(std::make_shared<AttributeManagerInitializer>(configSerialNum, documentMetaStoreInitTask,
- documentMetaStore, *baseAttrMgr, attrCfg,
+ documentMetaStore, baseAttrMgr, attrCfg,
alloc_strategy,
fastAccessAttributesOnly, master, mgr))
{
@@ -389,7 +392,7 @@ TEST_F("require that predicate attributes are flushed and loaded", BaseFixture)
AttributeVector::SP a1 = am.addAttribute({"a1", AttributeUtils::getPredicateConfig()}, createSerialNum);
EXPECT_EQUAL(1u, a1->getNumDocs());
- auto &pa = static_cast<PredicateAttribute &>(*a1);
+ auto &pa = dynamic_cast<PredicateAttribute &>(*a1);
PredicateIndex &index = pa.getIndex();
uint32_t doc_id;
a1->addDoc(doc_id);
@@ -409,7 +412,7 @@ TEST_F("require that predicate attributes are flushed and loaded", BaseFixture)
AttributeVector::SP a1 = am.addAttribute({"a1", AttributeUtils::getPredicateConfig()}, createSerialNum); // loaded
EXPECT_EQUAL(2u, a1->getNumDocs());
- auto &pa = static_cast<PredicateAttribute &>(*a1);
+ auto &pa = dynamic_cast<PredicateAttribute &>(*a1);
PredicateIndex &index = pa.getIndex();
uint32_t doc_id;
a1->addDoc(doc_id);
@@ -441,9 +444,9 @@ TEST_F("require that reconfig can add attributes", Fixture)
f._m.addExtraAttribute(ex);
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a1", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a2", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a3", INT32_SINGLE));
+ newSpec.emplace_back("a1", INT32_SINGLE);
+ newSpec.emplace_back("a2", INT32_SINGLE);
+ newSpec.emplace_back("a3", INT32_SINGLE);
SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), f._m.getNumDocs(), 10));
std::vector<AttributeGuard> list;
@@ -466,7 +469,7 @@ TEST_F("require that reconfig can remove attributes", Fixture)
AttributeVector::SP a3 = f.addAttribute("a3");
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a2", INT32_SINGLE));
+ newSpec.emplace_back("a2", INT32_SINGLE);
SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 1, 10));
std::vector<AttributeGuard> list;
@@ -487,9 +490,9 @@ TEST_F("require that new attributes after reconfig are initialized", Fixture)
EXPECT_EQUAL(3u, a1->getNumDocs());
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a1", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a2", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a3", INT32_ARRAY));
+ newSpec.emplace_back("a1", INT32_SINGLE);
+ newSpec.emplace_back("a2", INT32_SINGLE);
+ newSpec.emplace_back("a3", INT32_ARRAY);
SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 3, 4));
AttributeGuard::UP a2ap = sam.mgr.getAttribute("a2");
@@ -521,7 +524,7 @@ TEST_F("require that removed attributes cannot resurrect", BaseFixture)
am1.reset();
AttrSpecList ns2;
- ns2.push_back(AttributeSpec("a1", INT32_SINGLE));
+ ns2.emplace_back("a1", INT32_SINGLE);
// 2 new documents added since a1 was removed
SequentialAttributeManager am3(am2.mgr, AttrMgrSpec(std::move(ns2), 5, 20));
@@ -555,7 +558,7 @@ TEST_F("require that removed fields can be pruned", Fixture)
f._m.flushAll(10);
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a2", INT32_SINGLE));
+ newSpec.emplace_back("a2", INT32_SINGLE);
SequentialAttributeManager sam(f._m, AttrMgrSpec(std::move(newSpec), 1, 11));
sam.mgr.pruneRemovedFields(11);
@@ -684,9 +687,9 @@ TEST_F("require that attributes can be initialized and loaded in sequence", Base
AttributeManagerFixture amf(f);
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a1", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a2", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a3", INT32_SINGLE));
+ newSpec.emplace_back("a1", INT32_SINGLE);
+ newSpec.emplace_back("a2", INT32_SINGLE);
+ newSpec.emplace_back("a3", INT32_SINGLE);
SequentialAttributeManager newMgr(amf._m, AttrMgrSpec(std::move(newSpec), 10, createSerialNum + 5));
@@ -723,7 +726,7 @@ TEST_F("require that attributes can be initialized and loaded in parallel", Base
attrCfg.attribute.push_back(createAttributeConfig("a2"));
attrCfg.attribute.push_back(createAttributeConfig("a3"));
- ParallelAttributeManager newMgr(createSerialNum + 5, amf._msp, attrCfg, 10);
+ ParallelAttributeManager newMgr(createSerialNum + 5, *amf._msp, attrCfg, 10);
AttributeGuard::UP a1 = newMgr.mgr->get()->getAttribute("a1");
TEST_DO(validateAttribute(*a1->get()));
@@ -811,12 +814,12 @@ TEST_F("require that attribute vector of wrong type is dropped", BaseFixture)
am1->addAttribute({"a5", predicate}, 5);
am1->addAttribute({"a6", predicate}, 6);
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a1", INT32_SINGLE));
- newSpec.push_back(AttributeSpec("a2", INT32_ARRAY));
- newSpec.push_back(AttributeSpec("a3", generic_tensor));
- newSpec.push_back(AttributeSpec("a4", dense_tensor));
- newSpec.push_back(AttributeSpec("a5", predicate));
- newSpec.push_back(AttributeSpec("a6", predicate2));
+ newSpec.emplace_back("a1", INT32_SINGLE);
+ newSpec.emplace_back("a2", INT32_ARRAY);
+ newSpec.emplace_back("a3", generic_tensor);
+ newSpec.emplace_back("a4", dense_tensor);
+ newSpec.emplace_back("a5", predicate);
+ newSpec.emplace_back("a6", predicate2);
SequentialAttributeManager am2(*am1, AttrMgrSpec(std::move(newSpec), 5, 20));
TEST_DO(assertCreateSerialNum(*am1, "a1", 1));
TEST_DO(assertCreateSerialNum(*am1, "a2", 2));
@@ -858,7 +861,7 @@ TEST_F("require that shrink flushtarget is handed over to new attribute manager"
auto am1 = f.make_manager();
am1->addAttribute({"a1", INT32_SINGLE}, 4);
AttrSpecList newSpec;
- newSpec.push_back(AttributeSpec("a1", INT32_SINGLE));
+ newSpec.emplace_back("a1", INT32_SINGLE);
auto am2 = am1->create(AttrMgrSpec(std::move(newSpec), 5, 20));
auto am3 = std::dynamic_pointer_cast<AttributeManager>(am2);
TEST_DO(assertShrinkTargetSerial(*am3, "a1", 3));
diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
index dbc0b890cba..c9262605274 100644
--- a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp
@@ -31,33 +31,31 @@ struct MySubDb
{
DocumentMetaStore _metaStore;
test::UserDocuments _docs;
- MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType)
- : _metaStore(bucketDB,
- DocumentMetaStore::getFixedName(),
- search::GrowStrategy(),
- subDbType),
- _docs()
- {
- }
+ MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType);
+ ~MySubDb();
void insertDocs(const test::UserDocuments &docs_) {
_docs = docs_;
- for (test::UserDocuments::Iterator itr = _docs.begin(); itr != _docs.end(); ++itr) {
- const test::BucketDocuments &bucketDocs = itr->second;
- for (size_t i = 0; i < bucketDocs.getDocs().size(); ++i) {
- const test::Document &testDoc = bucketDocs.getDocs()[i];
+ for (const auto & _doc : _docs) {
+ const test::BucketDocuments &bucketDocs = _doc.second;
+ for (const auto & testDoc : bucketDocs.getDocs()) {
_metaStore.put(testDoc.getGid(), testDoc.getBucket(),
testDoc.getTimestamp(), testDoc.getDocSize(), testDoc.getLid(), 0u);
}
}
}
- BucketId bucket(uint32_t userId) {
+ BucketId bucket(uint32_t userId) const {
return _docs.getBucket(userId);
}
- test::DocumentVector docs(uint32_t userId) {
+ test::DocumentVector docs(uint32_t userId) const {
return _docs.getGidOrderDocs(userId);
}
};
+MySubDb::MySubDb(std::shared_ptr<bucketdb::BucketDBOwner> bucketDB, SubDbType subDbType)
+ : _metaStore(std::move(bucketDB), DocumentMetaStore::getFixedName(), search::GrowStrategy(), subDbType),
+ _docs()
+{ }
+MySubDb::~MySubDb() = default;
struct MyChangedHandler : public IBucketStateChangedHandler
{
@@ -65,8 +63,8 @@ struct MyChangedHandler : public IBucketStateChangedHandler
BucketInfo::ActiveState _state;
MyChangedHandler() : _bucket(), _state(BucketInfo::NOT_ACTIVE) {}
- virtual void notifyBucketStateChanged(const document::BucketId &bucketId,
- storage::spi::BucketInfo::ActiveState newState) override {
+ void notifyBucketStateChanged(const document::BucketId &bucketId,
+ storage::spi::BucketInfo::ActiveState newState) override {
_bucket = bucketId;
_state = newState;
}
diff --git a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp
index 6aa17151942..fb29f968d61 100644
--- a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp
@@ -14,7 +14,6 @@ using search::SerialNum;
using searchcorespi::IFlushTarget;
using SimpleFlushHandler = test::DummyFlushHandler;
-using FlushCandidatesList = std::vector<FlushTargetCandidates>;
using Config = PrepareRestartFlushStrategy::Config;
const Config DEFAULT_CFG(2.0, 0.0, 4.0);
@@ -34,13 +33,13 @@ struct SimpleFlushTarget : public test::DummyFlushTarget
approxDiskBytes(approxDiskBytes_),
replay_operation_cost(replay_operation_cost_)
{}
- SerialNum getFlushedSerialNum() const override {
+ [[nodiscard]] SerialNum getFlushedSerialNum() const override {
return flushedSerial;
}
- uint64_t getApproxBytesToWriteToDisk() const override {
+ [[nodiscard]] uint64_t getApproxBytesToWriteToDisk() const override {
return approxDiskBytes;
}
- double get_replay_operation_cost() const override {
+ [[nodiscard]] double get_replay_operation_cost() const override {
return replay_operation_cost;
}
};
@@ -62,7 +61,8 @@ private:
}
public:
- ContextsBuilder() : _result(), _handlers() {}
+ ContextsBuilder() noexcept;
+ ~ContextsBuilder();
ContextsBuilder &add(const vespalib::string &handlerName,
const vespalib::string &targetName,
IFlushTarget::Type targetType,
@@ -97,9 +97,12 @@ public:
double replay_operation_cost = 0.0) {
return add("handler1", targetName, IFlushTarget::Type::GC, flushedSerial, approxDiskBytes, replay_operation_cost);
}
- FlushContext::List build() const { return _result; }
+ [[nodiscard]] FlushContext::List build() const { return _result; }
};
+ContextsBuilder::ContextsBuilder() noexcept = default;
+ContextsBuilder::~ContextsBuilder() = default;
+
class CandidatesBuilder
{
private:
@@ -110,7 +113,7 @@ private:
Config _cfg;
public:
- CandidatesBuilder(const FlushContext::List &sortedFlushContexts)
+ explicit CandidatesBuilder(const FlushContext::List &sortedFlushContexts)
: _sortedFlushContexts(&sortedFlushContexts),
_numCandidates(sortedFlushContexts.size()),
_candidates(),
@@ -142,10 +145,7 @@ public:
}
FlushTargetCandidates build() const {
setup_candidates();
- return FlushTargetCandidates(_candidates,
- _numCandidates,
- _tlsStats,
- _cfg);
+ return {_candidates, _numCandidates, _tlsStats, _cfg};
}
};
@@ -212,14 +212,14 @@ struct FlushStrategyFixture
{
flushengine::TlsStatsMap _tlsStatsMap;
PrepareRestartFlushStrategy strategy;
- FlushStrategyFixture(const Config &config)
+ explicit FlushStrategyFixture(const Config &config)
: _tlsStatsMap(defaultTransactionLogStats()),
strategy(config)
{}
FlushStrategyFixture()
: FlushStrategyFixture(DEFAULT_CFG)
{}
- FlushContext::List getFlushTargets(const FlushContext::List &targetList,
+ [[nodiscard]] FlushContext::List getFlushTargets(const FlushContext::List &targetList,
const flushengine::TlsStatsMap &tlsStatsMap) const {
flushengine::ActiveFlushStats active_flushes;
return strategy.getFlushTargets(targetList, tlsStatsMap, active_flushes);
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 c5081f27db6..aab02c2b48c 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,6 +5,7 @@ vespa_add_executable(searchcore_document_db_reference_resolver_test_app TEST
DEPENDS
searchcore_reference
searchcore_attribute
+ searchcore_test
searchlib_test
)
vespa_add_test(NAME searchcore_document_db_reference_resolver_test_app COMMAND searchcore_document_db_reference_resolver_test_app)
diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt
index 6ac416d2ce2..d9d6501af5e 100644
--- a/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt
+++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_handler/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_gid_to_lid_change_handler_test_app TEST
DEPENDS
searchcore_reference
searchcore_server
+ searchcore_test
)
vespa_add_test(NAME searchcore_gid_to_lid_change_handler_test_app COMMAND searchcore_gid_to_lid_change_handler_test_app)
diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt
index 30929059cab..6808258cbc8 100644
--- a/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt
+++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_registrator/CMakeLists.txt
@@ -5,5 +5,6 @@ vespa_add_executable(searchcore_gid_to_lid_change_registrator_test_app TEST
DEPENDS
searchcore_reference
searchcore_server
+ searchcore_test
)
vespa_add_test(NAME searchcore_gid_to_lid_change_registrator_test_app COMMAND searchcore_gid_to_lid_change_registrator_test_app)