Commit 640793ee authored by Paul Moy's avatar Paul Moy Committed by Chromium LUCI CQ

chromebox_for_meetings: Add MeetDevicesDiagnostics methods

Add two new methods to the MeetDevicesDiagnostics Mojo interface, which
gather device and process-related information from cros_healthd. Meet
devices will use this information to debug crashes and improve
reliability.

Bug: b:174846892
Change-Id: Ie685c543b75c3b2b636cada5406397e5891d066d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586095Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Paul Moy <pmoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836674}
parent 43b30e7c
...@@ -2,4 +2,11 @@ include_rules = [ ...@@ -2,4 +2,11 @@ include_rules = [
"+chromeos/dbus/chromebox_for_meetings", "+chromeos/dbus/chromebox_for_meetings",
"+chromeos/components/chromebox_for_meetings/buildflags", "+chromeos/components/chromebox_for_meetings/buildflags",
"+chromeos/components/chromebox_for_meetings/features", "+chromeos/components/chromebox_for_meetings/features",
"+chromeos/services/cros_healthd/public/cpp",
] ]
specific_include_rules = {
"diagnostics_service_unittest\.cc": [
"+chromeos/dbus/cros_healthd",
]
}
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#include "chrome/browser/chromeos/chromebox_for_meetings/diagnostics/diagnostics_service.h" #include "chrome/browser/chromeos/chromebox_for_meetings/diagnostics/diagnostics_service.h"
#include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "chromeos/dbus/chromebox_for_meetings/cfm_hotline_client.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_hotline_client.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
namespace chromeos { namespace chromeos {
...@@ -41,6 +44,28 @@ bool DiagnosticsService::IsInitialized() { ...@@ -41,6 +44,28 @@ bool DiagnosticsService::IsInitialized() {
return g_info_service; return g_info_service;
} }
void DiagnosticsService::GetCrosHealthdTelemetry(
GetCrosHealthdTelemetryCallback callback) {
cros_healthd::ServiceConnection::GetInstance()->ProbeTelemetryInfo(
{cros_healthd::mojom::ProbeCategoryEnum::kNonRemovableBlockDevices,
cros_healthd::mojom::ProbeCategoryEnum::kCpu,
cros_healthd::mojom::ProbeCategoryEnum::kTimezone,
cros_healthd::mojom::ProbeCategoryEnum::kMemory,
cros_healthd::mojom::ProbeCategoryEnum::kFan,
cros_healthd::mojom::ProbeCategoryEnum::kStatefulPartition,
cros_healthd::mojom::ProbeCategoryEnum::kBluetooth,
cros_healthd::mojom::ProbeCategoryEnum::kSystem,
cros_healthd::mojom::ProbeCategoryEnum::kNetwork},
std::move(callback));
}
void DiagnosticsService::GetCrosHealthdProcessInfo(
uint32_t pid,
GetCrosHealthdProcessInfoCallback callback) {
cros_healthd::ServiceConnection::GetInstance()->ProbeProcessInfo(
static_cast<pid_t>(pid), std::move(callback));
}
bool DiagnosticsService::ServiceRequestReceived( bool DiagnosticsService::ServiceRequestReceived(
const std::string& interface_name) { const std::string& interface_name) {
if (interface_name != mojom::MeetDevicesDiagnostics::Name_) { if (interface_name != mojom::MeetDevicesDiagnostics::Name_) {
......
...@@ -28,6 +28,13 @@ class DiagnosticsService : public CfmObserver, ...@@ -28,6 +28,13 @@ class DiagnosticsService : public CfmObserver,
static DiagnosticsService* Get(); static DiagnosticsService* Get();
static bool IsInitialized(); static bool IsInitialized();
// mojom::MeetDevicesDiagnostics overrides:
void GetCrosHealthdTelemetry(
GetCrosHealthdTelemetryCallback callback) override;
void GetCrosHealthdProcessInfo(
uint32_t pid,
GetCrosHealthdProcessInfoCallback callback) override;
protected: protected:
// Forward |CfmObserver| implementation // Forward |CfmObserver| implementation
bool ServiceRequestReceived(const std::string& interface_name) override; bool ServiceRequestReceived(const std::string& interface_name) override;
......
...@@ -16,11 +16,14 @@ ...@@ -16,11 +16,14 @@
#include "base/test/mock_callback.h" #include "base/test/mock_callback.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h" #include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h"
#include "chromeos/dbus/cros_healthd/cros_healthd_client.h"
#include "chromeos/dbus/cros_healthd/fake_cros_healthd_client.h"
#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" #include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h"
#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" #include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h"
#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" #include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h"
#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h"
#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h" #include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
...@@ -40,6 +43,7 @@ class CfmDiagnosticsServiceTest : public ::testing::Test { ...@@ -40,6 +43,7 @@ class CfmDiagnosticsServiceTest : public ::testing::Test {
delete; delete;
void SetUp() override { void SetUp() override {
CrosHealthdClient::InitializeFake();
CfmHotlineClient::InitializeFake(); CfmHotlineClient::InitializeFake();
ServiceConnection::UseFakeServiceConnectionForTesting( ServiceConnection::UseFakeServiceConnectionForTesting(
&fake_service_connection_); &fake_service_connection_);
...@@ -49,6 +53,11 @@ class CfmDiagnosticsServiceTest : public ::testing::Test { ...@@ -49,6 +53,11 @@ class CfmDiagnosticsServiceTest : public ::testing::Test {
void TearDown() override { void TearDown() override {
DiagnosticsService::Shutdown(); DiagnosticsService::Shutdown();
CfmHotlineClient::Shutdown(); CfmHotlineClient::Shutdown();
CrosHealthdClient::Shutdown();
// Wait for cros_healthd's ServiceConnection to observe the destruction of
// the client.
cros_healthd::ServiceConnection::GetInstance()->FlushForTesting();
} }
FakeCfmHotlineClient* GetClient() { FakeCfmHotlineClient* GetClient() {
...@@ -125,6 +134,38 @@ TEST_F(CfmDiagnosticsServiceTest, GetDeviceInfoService) { ...@@ -125,6 +134,38 @@ TEST_F(CfmDiagnosticsServiceTest, GetDeviceInfoService) {
ASSERT_TRUE(details_remote.is_connected()); ASSERT_TRUE(details_remote.is_connected());
} }
// This test ensure that the diagnostics service can retrieve telemetry
// information from cros_healthd.
TEST_F(CfmDiagnosticsServiceTest, GetCrosHealthdTelemetry) {
auto response = cros_healthd::mojom::TelemetryInfo::New();
cros_healthd::FakeCrosHealthdClient::Get()
->SetProbeTelemetryInfoResponseForTesting(response);
base::RunLoop run_loop;
DiagnosticsService::Get()->GetCrosHealthdTelemetry(base::BindLambdaForTesting(
[&](cros_healthd::mojom::TelemetryInfoPtr info) {
EXPECT_EQ(info, response);
run_loop.Quit();
}));
run_loop.Run();
}
// This test ensure that the diagnostics service can retrieve process-specific
// information from cros_healthd.
TEST_F(CfmDiagnosticsServiceTest, GetCrosHealthdProcessInfo) {
auto response = cros_healthd::mojom::ProcessResult::NewProcessInfo(
cros_healthd::mojom::ProcessInfo::New());
cros_healthd::FakeCrosHealthdClient::Get()
->SetProbeProcessInfoResponseForTesting(response);
base::RunLoop run_loop;
DiagnosticsService::Get()->GetCrosHealthdProcessInfo(
/*pid=*/10, base::BindLambdaForTesting(
[&](cros_healthd::mojom::ProcessResultPtr info) {
EXPECT_EQ(info, response);
run_loop.Quit();
}));
run_loop.Run();
}
} // namespace } // namespace
} // namespace cfm } // namespace cfm
} // namespace chromeos } // namespace chromeos
include_rules = [ include_rules = [
"+chromeos/dbus", "+chromeos/dbus",
"+chromeos/services/cros_healthd/public/mojom",
"+mojo/core/embedder", "+mojo/core/embedder",
"+mojo/public", "+mojo/public",
] ]
...@@ -12,5 +12,8 @@ mojom("mojom") { ...@@ -12,5 +12,8 @@ mojom("mojom") {
"meet_devices_info.mojom", "meet_devices_info.mojom",
"meet_devices_logger.mojom", "meet_devices_logger.mojom",
] ]
public_deps = [ "//mojo/public/mojom/base" ] public_deps = [
"//chromeos/services/cros_healthd/public/mojom",
"//mojo/public/mojom/base",
]
} }
...@@ -4,7 +4,17 @@ ...@@ -4,7 +4,17 @@
module chromeos.cfm.mojom; module chromeos.cfm.mojom;
import "chromeos/services/cros_healthd/public/mojom/cros_healthd_probe.mojom";
// Interface defined by chromium specifically for the ChromeboxForMeetings // Interface defined by chromium specifically for the ChromeboxForMeetings
// platform to query system diagnostics of devices in the fleet. // platform to query system diagnostics of devices in the fleet.
interface MeetDevicesDiagnostics {}; interface MeetDevicesDiagnostics {
// Retrieves and forwards device telemetry from cros_healthd.
GetCrosHealthdTelemetry()
=> (chromeos.cros_healthd.mojom.TelemetryInfo telemetry);
// Retrieves information about a specific process from cros_healthd.
GetCrosHealthdProcessInfo(uint32 pid)
=> (chromeos.cros_healthd.mojom.ProcessResult process_info);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment