summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-04-02 18:37:16 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-04-17 11:04:08 +0200
commitb88adc43bb6ffe914ca9303e3001624e36fd64fa (patch)
tree845fd9e4c746ae9b86679a0ec21640cccfeea825 /test
parentd9bf1d63768f1c3d660c3057d6d77c9b3b4a346d (diff)
downloadjustbuild-b88adc43bb6ffe914ca9303e3001624e36fd64fa.tar.gz
Compactification: Split large entries.
During garbage collection split and remove from the storage every entry that is larger than a threshold.
Diffstat (limited to 'test')
-rw-r--r--test/buildtool/storage/large_object_cas.test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp
index fe3b8e6d..96462329 100644
--- a/test/buildtool/storage/large_object_cas.test.cpp
+++ b/test/buildtool/storage/large_object_cas.test.cpp
@@ -425,6 +425,7 @@ static void TestExternal() noexcept {
// Test compactification of a storage generation.
// If there are objects in the storage that have an entry in
// the large CAS, they must be deleted during compactification.
+// All splitable objects in the generation must be split.
template <ObjectType kType>
static void TestCompactification() {
SECTION("Compactify") {
@@ -445,6 +446,17 @@ static void TestCompactification() {
auto result = kIsTree ? cas.SplitTree(digest) : cas.SplitBlob(digest);
REQUIRE(std::get_if<std::vector<bazel_re::Digest>>(&result) != nullptr);
+ // For trees the size must be increased to exceed the internal
+ // compactification threshold:
+ static constexpr auto ExceedThresholdSize =
+ kIsTree ? TestType::kLargeSize * 8 : TestType::kLargeSize;
+
+ // Create a large object that is to be split during compactification:
+ auto object_2 = TestType::Create(
+ cas, std::string(TestType::kLargeId) + "_2", ExceedThresholdSize);
+ REQUIRE(object_2);
+ auto& [digest_2, path_2] = *object_2;
+
// Ensure all entries are in the storage:
auto get_path = [](auto const& cas, bazel_re::Digest const& digest) {
return kIsTree ? cas.TreePath(digest)
@@ -453,6 +465,7 @@ static void TestCompactification() {
auto const& latest = Storage::Generation(0).CAS();
REQUIRE(get_path(latest, digest).has_value());
+ REQUIRE(get_path(latest, digest_2).has_value());
// Compactify the youngest generation:
// Generation rotation is disabled to exclude uplinking.
@@ -462,9 +475,11 @@ static void TestCompactification() {
// All entries must be deleted during compactification, and for blobs
// and executables there are no synchronized entries in the storage:
REQUIRE_FALSE(get_path(latest, digest).has_value());
+ REQUIRE_FALSE(get_path(latest, digest_2).has_value());
// All entries must be implicitly splicable:
REQUIRE(get_path(cas, digest).has_value());
+ REQUIRE(get_path(cas, digest_2).has_value());
}
}