summaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp')
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index b586b74ad00..326cfba97f4 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/document/base/documentid.h>
+#include <vespa/persistence/spi/bucket_limits.h>
#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h>
#include <vespa/searchcore/proton/bucketdb/checksumaggregators.h>
#include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h>
@@ -629,6 +630,31 @@ TEST(DocumentMetaStoreTest, gids_can_be_saved_and_loaded)
}
}
+TEST(DocumentMetaStoreTest, bucket_used_bits_are_lbounded_at_load_time)
+{
+ DocumentMetaStore dms1(createBucketDB());
+ dms1.constructFreeList();
+
+ constexpr uint32_t lid = 1;
+ GlobalId gid = createGid(lid);
+ BucketId bucketId(gid.convertToBucketId());
+ bucketId.setUsedBits(storage::spi::BucketLimits::MinUsedBits - 1);
+ uint32_t added_lid = addGid(dms1, gid, bucketId, Timestamp(1000));
+ ASSERT_EQ(added_lid, lid);
+
+ TuneFileAttributes tuneFileAttributes;
+ DummyFileHeaderContext fileHeaderContext;
+ AttributeFileSaveTarget saveTarget(tuneFileAttributes, fileHeaderContext);
+ ASSERT_TRUE(dms1.save(saveTarget, "documentmetastore2"));
+
+ DocumentMetaStore dms2(createBucketDB(), "documentmetastore2");
+ ASSERT_TRUE(dms2.load());
+ ASSERT_EQ(dms2.getNumDocs(), 2); // Incl. zero LID
+
+ BucketId expected_bucket(storage::spi::BucketLimits::MinUsedBits, gid.convertToBucketId().getRawId());
+ assertGid(gid, lid, dms2, expected_bucket, Timestamp(1000));
+}
+
TEST(DocumentMetaStore, stats_are_updated)
{
DocumentMetaStore dms(createBucketDB());