diff --git a/src/composeappmanager.cc b/src/composeappmanager.cc index dbe936f9..09a09a95 100644 --- a/src/composeappmanager.cc +++ b/src/composeappmanager.cc @@ -248,7 +248,7 @@ DownloadResult ComposeAppManager::Download(const TufTarget& target) { return ostree_download_res; } - DownloadResult res{DownloadResult::Status::Ok, ""}; + DownloadResult res{ostree_download_res}; const Uptane::Target uptane_target{Target::fromTufTarget(target)}; if (cfg_.force_update) { diff --git a/src/rootfstreemanager.cc b/src/rootfstreemanager.cc index e6ce1eab..69221073 100644 --- a/src/rootfstreemanager.cc +++ b/src/rootfstreemanager.cc @@ -79,8 +79,16 @@ DownloadResult RootfsTreeManager::Download(const TufTarget& target) { LOG_INFO << "Fetching ostree commit " + target.Sha256Hash() + " from " + remote.baseUrl; pull_err = OstreeManager::pull(config.sysroot, remote.baseUrl, keys_, Target::fromTufTarget(target), nullptr, prog_cb, remote.isRemoteSet ? nullptr : remote.name.c_str(), remote.headers); + + storage::Volume::UsageInfo post_pull_usage_info{getUsageInfo()}; + if (post_pull_usage_info.isOk()) { + LOG_INFO << "Post pull storage usage info; " << post_pull_usage_info; + } else { + LOG_ERROR << "Failed to obtain storage usage statistic: " << post_pull_usage_info.err; + } if (pull_err.isSuccess()) { - res = {DownloadResult::Status::Ok, ""}; + res = {DownloadResult::Status::Ok, + "before ostree pull; " + pre_pull_usage_info.str() + "\nafter ostree pull; " + post_pull_usage_info.str()}; break; } diff --git a/tests/fixtures/liteclienttest.cc b/tests/fixtures/liteclienttest.cc index e7c67b27..2912b73e 100644 --- a/tests/fixtures/liteclienttest.cc +++ b/tests/fixtures/liteclienttest.cc @@ -545,6 +545,15 @@ class ClientTest :virtual public ::testing::Test { return ostree_repo_.getDeltaSize(to.custom_data()["delta-stats"]["sha256"].asString(), from.sha256Hash(), to.sha256Hash()); } + std::string getEventContext(const std::string& ev_id) { + for (const auto& ev: device_gateway_.getEvents()) { + if (ev_id == ev["eventType"]["id"].asString()) { + return ev["event"]["details"].asString(); + } + } + return ""; + } + protected: static const std::string branch; static const std::string hw_id; diff --git a/tests/nospace_test.cc b/tests/nospace_test.cc index 85ddac44..67243ed4 100644 --- a/tests/nospace_test.cc +++ b/tests/nospace_test.cc @@ -320,8 +320,7 @@ TEST_F(NoSpaceTest, OstreeUpdateNoSpaceIfStaticDeltaStats) { << ", available: " << usage_info.available; update(*client, getInitialTarget(), new_target, data::ResultCode::Numeric::kDownloadFailed, {DownloadResult::Status::DownloadFailed_NoSpace, "Insufficient storage available"}); - const auto events{device_gateway_.getEvents()}; - const std::string event_err_msg{events[events.size() - 1]["event"]["details"].asString()}; + const std::string event_err_msg{getEventContext("EcuDownloadCompleted")}; ASSERT_TRUE(std::string::npos != event_err_msg.find(expected_msg.str())) << event_err_msg; ASSERT_TRUE(std::string::npos != event_err_msg.find(OSTree::Sysroot::Config::ReservedStorageSpacePercentageDeltaParamName)) @@ -341,8 +340,7 @@ TEST_F(NoSpaceTest, OstreeUpdateNoSpaceIfStaticDeltaStats) { << ", available: " << usage_info.available; update(*client, getInitialTarget(), new_target, data::ResultCode::Numeric::kDownloadFailed, {DownloadResult::Status::DownloadFailed_NoSpace, "Insufficient storage available"}); - const auto events{device_gateway_.getEvents()}; - const std::string event_err_msg{events[events.size() - 1]["event"]["details"].asString()}; + const std::string event_err_msg{getEventContext("EcuDownloadCompleted")}; ASSERT_TRUE(std::string::npos != event_err_msg.find(expected_msg.str())) << event_err_msg; ASSERT_TRUE(std::string::npos != event_err_msg.find(OSTree::Sysroot::Config::ReservedStorageSpacePercentageOstreeParamName)) @@ -355,6 +353,9 @@ TEST_F(NoSpaceTest, OstreeUpdateNoSpaceIfStaticDeltaStats) { update(*client, getInitialTarget(), new_target); reboot(client); ASSERT_TRUE(targetsMatch(client->getCurrent(), new_target)); + const std::string msg{getEventContext("EcuDownloadCompleted")}; + ASSERT_TRUE(std::string::npos != msg.find("before ostree pull")) << msg; + ASSERT_TRUE(std::string::npos != msg.find("after ostree pull")) << msg; } UnsetFreeBlockNumb(); }