From 46d4b68f1d80e28fd50ece5976500742fcaef034 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Mon, 4 Sep 2023 16:36:39 +0200 Subject: [PATCH] tmp: test Signed-off-by: Mike Sul --- tests/nospace_test.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/nospace_test.cc b/tests/nospace_test.cc index 424ff10d..6619f4cc 100644 --- a/tests/nospace_test.cc +++ b/tests/nospace_test.cc @@ -263,8 +263,10 @@ TEST_F(NoSpaceTest, OstreeUpdateNoSpaceIfStaticDelta) { auto client = createLiteClient(); ASSERT_TRUE(targetsMatch(client->getCurrent(), getInitialTarget())); // Delta size is 3 + 1 = 4 blocks - setGenerateStaticDelta(3); + setGenerateStaticDelta(3, true); auto new_target = createTarget(); + const auto delta_size{getDeltaSize(getInitialTarget(), new_target)}; + getOsTreeRepo().removeDeltaStats(); { // The delta-based update if there is no stat/info about the delta, so the pre-pull verification // of the update size is not possible. Thus, the error originates in libostree; libostree does NOT @@ -318,17 +320,22 @@ TEST_F(NoSpaceTest, OstreeUpdateNoSpaceIfStaticDelta) { // but there is a moment during the delta-based pull when libostree has the delta file // on a file system + extracted files while it commits the extracted files to the repo. // So, it takes into account the delta file size + extracted objects during ostree objects committing, - // therefore we need 4% + 4% + ~ 10% (required)+ 3% (reserved) ~ 13% (at least 14 free blocks - // is required) + // therefore we need 4% + 4% + ~ 10% (required)+ 3% (reserved) ~ 13% (at least 13 free blocks + // is required, but just 12 is available) // - SetFreeBlockNumb(13, 100); + storage::Volume::UsageInfo usage_info{.size = {100 * 4096, 100}, .available = {(12 - 3) * 4096, 12 - 3}}; + std::stringstream expected_available; + usage_info.withRequired(delta_size); + LOG_ERROR << ">>>> Required: " << usage_info.required; + expected_available << usage_info.available; + SetFreeBlockNumb(12, 100); update(*client, getInitialTarget(), new_target, data::ResultCode::Numeric::kDownloadFailed, {DownloadResult::Status::DownloadFailed_NoSpace, "Insufficient storage available"}); ASSERT_TRUE(targetsMatch(client->getCurrent(), getInitialTarget())); const auto event_err_msg{getEventContext("EcuDownloadCompleted")}; ASSERT_TRUE(std::string::npos != event_err_msg.find("min-free-space-percent '3%' would be exceeded, at least")) << event_err_msg; - ASSERT_TRUE(std::string::npos != event_err_msg.find("available: 40960B 10%")) << event_err_msg; + ASSERT_TRUE(std::string::npos != event_err_msg.find(expected_available.str())) << event_err_msg; ASSERT_TRUE(std::string::npos != event_err_msg.find(OSTree::Sysroot::Config::ReservedStorageSpacePercentageOstreeParamName)); }