Add version information to install plan and GetStatus.
As per the TODO this information is useful for debugging and testing
changes i.e. I'd like to know what version I'm updating to. GetStatus
already supports getting this version but we never populate the field.
BUG=chromium:264505
TEST=Unittests + ran update_engine_client -update which uses GetStatus
to communicate status.
Change-Id: I5332e2f206d92aedba509cd5469e9610c88bcd03
Reviewed-on: https://gerrit.chromium.org/gerrit/63675
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/install_plan.h b/install_plan.h
index c2f523e..3ec9d55 100644
--- a/install_plan.h
+++ b/install_plan.h
@@ -39,6 +39,7 @@
bool is_resume;
bool is_full_update;
std::string download_url; // url to download from
+ std::string version; // version we are installing.
uint64_t payload_size; // size of the payload
std::string payload_hash; // SHA256 hash of the payload
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index d0853c8..2acc803 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -67,6 +67,7 @@
}
install_plan_.download_url = current_url;
+ install_plan_.version = response.version;
// Fill up the other properties based on the response.
install_plan_.payload_size = response.size;
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index d5831d4..c3efb8b 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -144,6 +144,7 @@
EXPECT_EQ(0, stat(test_deadline_file.c_str(), &deadline_stat));
EXPECT_EQ(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
deadline_stat.st_mode);
+ EXPECT_EQ(in.version, install_plan.version);
}
{
OmahaResponse in;
@@ -162,6 +163,7 @@
string deadline;
EXPECT_TRUE(utils::ReadFile(test_deadline_file, &deadline) &&
deadline.empty());
+ EXPECT_EQ(in.version, install_plan.version);
}
{
OmahaResponse in;
@@ -181,6 +183,7 @@
string deadline;
EXPECT_TRUE(utils::ReadFile(test_deadline_file, &deadline));
EXPECT_EQ("some-deadline", deadline);
+ EXPECT_EQ(in.version, install_plan.version);
}
}
@@ -192,6 +195,7 @@
EXPECT_EQ("", install_plan.download_url);
EXPECT_EQ("", install_plan.payload_hash);
EXPECT_EQ("", install_plan.install_path);
+ EXPECT_EQ("", install_plan.version);
}
TEST_F(OmahaResponseHandlerActionTest, RollbackVersionTest) {
@@ -212,11 +216,13 @@
EXPECT_EQ("", install_plan.download_url);
EXPECT_EQ("", install_plan.payload_hash);
EXPECT_EQ("", install_plan.install_path);
+ EXPECT_EQ("", install_plan.version);
// Version isn't blacklisted.
in.version = version_ok;
EXPECT_TRUE(DoTest(in, "/dev/sda5", "", &install_plan));
EXPECT_EQ(in.payload_urls[0], install_plan.download_url);
+ EXPECT_EQ(version_ok, install_plan.version);
}
TEST_F(OmahaResponseHandlerActionTest, HashChecksForHttpTest) {
@@ -232,6 +238,7 @@
EXPECT_EQ(in.payload_urls[0], install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.payload_hash);
EXPECT_TRUE(install_plan.hash_checks_mandatory);
+ EXPECT_EQ(in.version, install_plan.version);
}
TEST_F(OmahaResponseHandlerActionTest, HashChecksForHttpsTest) {
@@ -247,6 +254,7 @@
EXPECT_EQ(in.payload_urls[0], install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.payload_hash);
EXPECT_FALSE(install_plan.hash_checks_mandatory);
+ EXPECT_EQ(in.version, install_plan.version);
}
TEST_F(OmahaResponseHandlerActionTest, HashChecksForBothHttpAndHttpsTest) {
@@ -263,6 +271,7 @@
EXPECT_EQ(in.payload_urls[0], install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.payload_hash);
EXPECT_TRUE(install_plan.hash_checks_mandatory);
+ EXPECT_EQ(in.version, install_plan.version);
}
TEST_F(OmahaResponseHandlerActionTest, ChangeToMoreStableChannelTest) {
diff --git a/update_attempter.cc b/update_attempter.cc
index 0f8abfb..5755fb4 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -788,8 +788,7 @@
CHECK(action == response_handler_action_.get());
const InstallPlan& plan = response_handler_action_->install_plan();
last_checked_time_ = time(NULL);
- // TODO(adlr): put version in InstallPlan
- new_version_ = "0.0.0.0";
+ new_version_ = plan.version;
new_payload_size_ = plan.payload_size;
SetupDownload();
SetupCpuSharesManagement();