aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/index
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2018-10-31 20:48:43 +0100
committerTor Egge <tegge@oath.com>2019-01-08 18:30:29 +0000
commitd04167de8b9cba666c2f03a5e53f5d167c8b4b50 (patch)
tree28c1601c4fa5212beafe30bcd8ba296525603e77 /searchcore/src/tests/proton/index
parent21809401b2244eaf1caeae54e501d97990abe43d (diff)
Compact lid space on source selector.
Diffstat (limited to 'searchcore/src/tests/proton/index')
-rw-r--r--searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp18
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp20
2 files changed, 36 insertions, 2 deletions
diff --git a/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp b/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
index 0d9fe42b978..8f5d998b77a 100644
--- a/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
+++ b/searchcore/src/tests/proton/index/index_writer/index_writer_test.cpp
@@ -33,8 +33,11 @@ struct MyIndexManager : public test::MockIndexManager
SerialNum current;
SerialNum flushed;
SerialNum commitSerial;
+ uint32_t wantedLidLimit;
+ SerialNum compactSerial;
MyIndexManager() : puts(), removes(), current(0), flushed(0),
- commitSerial(0)
+ commitSerial(0),
+ wantedLidLimit(0), compactSerial(0)
{
}
std::string getPut(uint32_t lid) {
@@ -62,6 +65,10 @@ struct MyIndexManager : public test::MockIndexManager
virtual SerialNum getFlushedSerialNum() const override {
return flushed;
}
+ void compactLidSpace(uint32_t lidLimit, SerialNum serialNum) override {
+ wantedLidLimit = lidLimit;
+ compactSerial = serialNum;
+ }
};
struct Fixture
@@ -95,7 +102,7 @@ struct Fixture
}
};
-TEST_F("require that index adapter ignores old operations", Fixture)
+TEST_F("require that index writer ignores old operations", Fixture)
{
f.mim.flushed = 10;
f.put(8, 1);
@@ -110,6 +117,13 @@ TEST_F("require that commit is forwarded to index manager", Fixture)
EXPECT_EQUAL(10u, f.mim.commitSerial);
}
+TEST_F("require that compactLidSpace is forwarded to index manager", Fixture)
+{
+ f.iw.compactLidSpace(4, 2);
+ EXPECT_EQUAL(2u, f.mim.wantedLidLimit);
+ EXPECT_EQUAL(4u, f.mim.compactSerial);
+}
+
TEST_MAIN()
{
TEST_RUN_ALL();
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index c025bd257a2..d9f0a256faf 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -145,6 +145,14 @@ struct Fixture {
});
_writeService.indexFieldWriter().sync();
}
+ void removeDocument(uint32_t docId) {
+ SerialNum serialNum = ++_serial_num;
+ removeDocument(docId, serialNum);
+ }
+ void compactLidSpace(uint32_t lidLimit) {
+ SerialNum serialNum = ++_serial_num;
+ runAsIndex([&]() { _index_manager->compactLidSpace(lidLimit, serialNum); });
+ }
void assertStats(uint32_t expNumDiskIndexes,
uint32_t expNumMemoryIndexes,
SerialNum expLastiskIndexSerialNum,
@@ -715,6 +723,18 @@ TEST_F("require that indexes manager stats can be generated", Fixture)
TEST_DO(f.assertStats(1, 1, 1, 2));
}
+TEST_F("require that compactLidSpace works", Fixture)
+{
+ Schema empty_schema;
+ f.addDocument(1);
+ f.addDocument(2);
+ f.removeDocument(2);
+ auto fsc = f._index_manager->getMaintainer().getSourceCollection();
+ EXPECT_EQUAL(3u, fsc->getSourceSelector().getDocIdLimit());
+ f.compactLidSpace(2);
+ EXPECT_EQUAL(2u, fsc->getSourceSelector().getDocIdLimit());
+}
+
} // namespace
TEST_MAIN() {