Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb815be5 authored by Bertrand SIMONNET's avatar Bertrand SIMONNET Committed by chrome-internal-fetch
Browse files

metrics: Fix metrics_uploader on VMs

metrics_uploader must be in testing mode so that it does not try to grab the
real hardware id (not available on VMs).

BUG=chromium:413256
TEST=FEATURES=test emerge-amd64-generic metrics.
TEST=platform_MetricsUploader succeeds on a gizmo VM.

Change-Id: I9e508c8661dfdb7933161b0d41ef4cf9bd7db2c6
Reviewed-on: https://chromium-review.googlesource.com/217760


Reviewed-by: default avatarBertrand Simonnet <bsimonnet@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: default avatarBertrand Simonnet <bsimonnet@chromium.org>
parent 51bf92a3
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ void MetricsDaemon::Run(bool run_as_daemon) {
}

void MetricsDaemon::RunUploaderTest() {
  upload_service_.reset(new UploadService(testing_));
  upload_service_->Init();
  upload_service_->UploadEvent();
}

@@ -311,7 +313,7 @@ void MetricsDaemon::Init(bool testing,
      g_timeout_add(kUpdateStatsIntervalMs, &HandleUpdateStatsTimeout, this);

  if (uploader_active) {
    upload_service_.reset(new UploadService());
    upload_service_.reset(new UploadService(testing_));
    upload_service_->Init();
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
  MetricsLibrary metrics_lib;
  metrics_lib.Init();
  MetricsDaemon daemon;
  daemon.Init(false,
  daemon.Init(FLAGS_uploader_test,
              FLAGS_uploader | FLAGS_uploader_test,
              &metrics_lib,
              MetricsMainDiskStatsPath(),
+4 −4
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@ const char* SystemProfileCache::kPersistentGUIDFile =
const char* SystemProfileCache::kPersistentSessionIdFilename =
    "Sysinfo.SessionId";

SystemProfileCache::SystemProfileCache()
SystemProfileCache::SystemProfileCache(bool testing)
    : initialized_(false),
      is_testing_(false),
      testing_(testing),
      session_id_(new chromeos_metrics::PersistentInteger(
          kPersistentSessionIdFilename)) {
}
@@ -49,7 +49,7 @@ bool SystemProfileCache::Initialize() {
  profile_.channel = ProtoChannelFromString(channel_string);

  profile_.client_id =
      is_testing_ ? "client_id_test" : GetPersistentGUID(kPersistentGUIDFile);
      testing_ ? "client_id_test" : GetPersistentGUID(kPersistentGUIDFile);

  // Increment the session_id everytime we initialize this. If metrics_daemon
  // does not crash, this should correspond to the number of reboots of the
@@ -105,7 +105,7 @@ std::string SystemProfileCache::GetPersistentGUID(const std::string& filename) {
bool SystemProfileCache::GetHardwareId(std::string* hwid) {
  CHECK(hwid);

  if (is_testing_) {
  if (testing_) {
    // if we are in test mode, we do not call crossystem directly.
    DLOG(INFO) << "skipping hardware id";
    *hwid = "";
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ struct SystemProfile {
// The cache is populated lazily. The only method needed is Populate.
class SystemProfileCache : public SystemProfileSetter {
 public:
  SystemProfileCache();
  explicit SystemProfileCache(bool testing);

  // Populates the ProfileSystem protobuf with system information.
  void Populate(metrics::ChromeUserMetricsExtension* profile_proto) override;
@@ -69,7 +69,7 @@ class SystemProfileCache : public SystemProfileSetter {
  bool GetHardwareId(std::string* hwid);

  bool initialized_;
  bool is_testing_;
  bool testing_;
  scoped_ptr<chromeos_metrics::PersistentInteger> session_id_;
  SystemProfile profile_;
};
+2 −2
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ DEFINE_string(metrics_file,

const int UploadService::kMaxFailedUpload = 10;

UploadService::UploadService()
    : system_profile_setter_(new SystemProfileCache()),
UploadService::UploadService(bool testing)
    : system_profile_setter_(new SystemProfileCache(testing)),
      histogram_snapshot_manager_(this),
      sender_(new HttpSender(FLAGS_server)) {
}
Loading