aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-06-24 14:20:34 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-06-24 14:20:34 +0000
commitf1aabdd23474d31f7d104f9d9a115ff247f0e1ea (patch)
treef61db8ca3885db436d57c95ece4372ba2e341188 /searchcore
parent94563f45d4dbcc29499ff6cd82e0acbe1c050738 (diff)
Add test for upholding the docid limit.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index ee5d247b4ca..0b59a3c11ed 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -106,14 +106,15 @@ struct UnitDR : DocumentRetrieverBaseForTest {
Bucket bucket;
bool removed;
DocumentIdT docid;
+ DocumentIdT docIdLimit;
UnitDR()
: repo(), document(new Document(*DataType::DOCUMENT, DocumentId())),
- timestamp(0), bucket(), removed(false), docid(0) {}
+ timestamp(0), bucket(), removed(false), docid(0), docIdLimit(std::numeric_limits<uint32_t>::max()) {}
UnitDR(document::Document::UP d, Timestamp t, Bucket b, bool r)
- : repo(), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt) {}
+ : repo(), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), docIdLimit(std::numeric_limits<uint32_t>::max()) {}
UnitDR(const document::DocumentType &dt, document::Document::UP d, Timestamp t, Bucket b, bool r)
- : repo(dt), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt) {}
+ : repo(dt), document(std::move(d)), timestamp(t), bucket(b), removed(r), docid(++_docidCnt), docIdLimit(std::numeric_limits<uint32_t>::max()) {}
const document::DocumentTypeRepo &getDocumentTypeRepo() const override {
return repo;
@@ -134,6 +135,13 @@ struct UnitDR : DocumentRetrieverBaseForTest {
return Document::UP((lid == docid) ? document->clone() : 0);
}
+ uint32_t getDocIdLimit() const override {
+ return docIdLimit;
+ }
+ void setDocIdLimit(DocumentIdT limit) {
+ docIdLimit = limit;
+ }
+
CachedSelect::SP parseSelect(const vespalib::string &selection) const override {
CachedSelect::SP res(new CachedSelect);
res->set(selection, repo);
@@ -519,6 +527,25 @@ TEST("require that readconsistency::strong does commit") {
TEST_DO(verifyStrongReadConsistency(itr));
}
+TEST("require that docid limit is honoured") {
+ IDocumentRetriever::SP retriever = doc("doc:foo:1", Timestamp(2), bucket(5));
+ UnitDR & udr = dynamic_cast<UnitDR &>(*retriever);
+ udr.docid = 7;
+ DocumentIterator itr(bucket(5), document::AllFields(), selectAll(), newestV(), -1, false);
+ itr.add(retriever);
+ IterateResult res = itr.iterate(largeNum);
+ EXPECT_TRUE(res.isCompleted());
+ EXPECT_EQUAL(1u, res.getEntries().size());
+ TEST_DO(checkEntry(res, 0, Document(*DataType::DOCUMENT, DocumentId("doc:foo:1")), Timestamp(2)));
+
+ udr.setDocIdLimit(7);
+ DocumentIterator limited(bucket(5), document::AllFields(), selectAll(), newestV(), -1, false);
+ limited.add(retriever);
+ res = limited.iterate(largeNum);
+ EXPECT_TRUE(res.isCompleted());
+ EXPECT_EQUAL(0u, res.getEntries().size());
+}
+
TEST("require that remove entries can be iterated") {
DocumentIterator itr(bucket(5), document::AllFields(), selectAll(), newestV(), -1, false);
itr.add(rem("doc:foo:1", Timestamp(2), bucket(5)));