From 62f506aefc18dd5125b03e6215877b031656d0ed Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Mon, 22 Apr 2024 13:25:26 +0200 Subject: Compactification: Remove invalid entries from the storage. During compactification, invalid entries must be deleted. --- test/buildtool/storage/large_object_cas.test.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/buildtool/storage') diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp index 96462329..10414748 100644 --- a/test/buildtool/storage/large_object_cas.test.cpp +++ b/test/buildtool/storage/large_object_cas.test.cpp @@ -457,6 +457,18 @@ static void TestCompactification() { REQUIRE(object_2); auto& [digest_2, path_2] = *object_2; + // After an interuption of a build process intermediate unique files may + // be present in the storage. To ensure compactification deals with them + // properly, a "unique" file is created: + auto invalid_object = TestType::Create( + cas, std::string(TestType::kLargeId) + "_3", ExceedThresholdSize); + REQUIRE(invalid_object); + auto& [invalid_digest, invalid_path] = *invalid_object; + + auto unique_path = CreateUniquePath(invalid_path); + REQUIRE(unique_path); + REQUIRE(FileSystemManager::Rename(invalid_path, *unique_path)); + // Ensure all entries are in the storage: auto get_path = [](auto const& cas, bazel_re::Digest const& digest) { return kIsTree ? cas.TreePath(digest) @@ -466,6 +478,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()); + REQUIRE(FileSystemManager::IsFile(*unique_path)); // Compactify the youngest generation: // Generation rotation is disabled to exclude uplinking. @@ -476,8 +489,9 @@ static void TestCompactification() { // 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()); + REQUIRE_FALSE(FileSystemManager::IsFile(*unique_path)); - // All entries must be implicitly splicable: + // All valid entries must be implicitly spliceable: REQUIRE(get_path(cas, digest).has_value()); REQUIRE(get_path(cas, digest_2).has_value()); } -- cgit v1.2.3