summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/index/indexmanager_test.cpp
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-11-03 22:00:25 +0100
committerTor Egge <Tor.Egge@online.no>2021-11-03 22:00:25 +0100
commit8e996033594317202d92c5f9bf6141570fe7f6f0 (patch)
treedaee37ed45ad8d2fdc348d0b1b3bddf5e380e01c /searchcore/src/tests/proton/index/indexmanager_test.cpp
parent9c3f28fbbdbf5b8be36f994b38f4980ebe7c3e8d (diff)
Add DocumentInverterCollection.
Diffstat (limited to 'searchcore/src/tests/proton/index/indexmanager_test.cpp')
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index 84cf0e3655f..8e41323e461 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -21,6 +21,8 @@
#include <vespa/searchlib/test/index/mock_field_length_inspector.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/io/fileutil.h>
+#include <vespa/vespalib/util/destructor_callbacks.h>
+#include <vespa/vespalib/util/gate.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/time.h>
@@ -96,6 +98,12 @@ Document::UP buildDocument(DocBuilder &doc_builder, int id,
return doc_builder.endDocument();
}
+void push_documents_and_wait(search::memoryindex::DocumentInverter &inverter) {
+ vespalib::Gate gate;
+ inverter.pushDocuments(std::make_shared<vespalib::GateCallback>(gate));
+ gate.await();
+}
+
std::shared_ptr<vespalib::IDestructorCallback> emptyDestructorCallback;
struct IndexManagerTest : public ::testing::Test {
@@ -142,10 +150,11 @@ struct IndexManagerTest : public ::testing::Test {
Document::UP addDocument(uint32_t docid);
void resetIndexManager();
void removeDocument(uint32_t docId, SerialNum serialNum) {
+ vespalib::Gate gate;
runAsIndex([&]() { _index_manager->removeDocument(docId, serialNum);
- _index_manager->commit(serialNum, emptyDestructorCallback);
+ _index_manager->commit(serialNum, std::make_shared<vespalib::GateCallback>(gate));
});
- _writeService.indexFieldWriter().sync_all();
+ gate.await();
}
void removeDocument(uint32_t docId) {
SerialNum serialNum = ++_serial_num;
@@ -182,10 +191,11 @@ IndexManagerTest::addDocument(uint32_t id)
{
Document::UP doc = buildDocument(_builder, id, "foo");
SerialNum serialNum = ++_serial_num;
+ vespalib::Gate gate;
runAsIndex([&]() { _index_manager->putDocument(id, *doc, serialNum);
_index_manager->commit(serialNum,
- emptyDestructorCallback); });
- _writeService.indexFieldWriter().sync_all();
+ std::make_shared<vespalib::GateCallback>(gate)); });
+ gate.await();
return doc;
}
@@ -407,9 +417,7 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated)
Document::UP doc = addDocument(docid);
inverter.invertDocument(docid, *doc);
- invertThreads->sync_all();
- inverter.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>());
- pushThreads->sync_all();
+ push_documents_and_wait(inverter);
index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size;
/// Must account for both docid 0 being reserved and the extra after.
@@ -426,9 +434,7 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated)
inverter.invertDocument(docid + 10, *doc);
doc = addDocument(docid + 100);
inverter.invertDocument(docid + 100, *doc);
- invertThreads->sync_all();
- inverter.pushDocuments(std::shared_ptr<vespalib::IDestructorCallback>());
- pushThreads->sync_all();
+ push_documents_and_wait(inverter);
index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size;
/// Must account for both docid 0 being reserved and the extra after.
selector_size = (docid + 100 + 1) * sizeof(Source);