Skip to content

Commit

Permalink
report error from container cpu usage monitor
Browse files Browse the repository at this point in the history
Signed-off-by: nix1n <nikhil.murari@hotstar.com>
  • Loading branch information
nix1n committed Jan 8, 2025
1 parent ca96425 commit 114f444
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,25 @@ TEST(ContainerCpuUsageMonitorTest, GetsErroneousStatsNumerator) {
ASSERT_TRUE(resource.hasError());
}

TEST(ContainerCpuUtilizationMonitorTest, ReportsError) {
envoy::extensions::resource_monitors::cpu_utilization::v3::CpuUtilizationConfig config;
config.set_mode(
envoy::extensions::resource_monitors::cpu_utilization::v3::CpuUtilizationConfig::CONTAINER);
auto stats_reader = std::make_unique<MockContainerStatsReader>();
EXPECT_CALL(*stats_reader, getCgroupStats())
.WillOnce(Return(CpuTimes{false, 0, 0}))
.WillOnce(Return(CpuTimes{false, 0, 0}))
.WillOnce(Return(CpuTimes{false, 0, 200}));
auto monitor = std::make_unique<CpuUtilizationMonitor>(config, std::move(stats_reader));

ResourcePressure resource;
monitor->updateResourceUsage(resource);
ASSERT_TRUE(resource.hasError());

monitor->updateResourceUsage(resource);
ASSERT_TRUE(resource.hasError());
}

} // namespace
} // namespace CpuUtilizationMonitor
} // namespace ResourceMonitors
Expand Down

0 comments on commit 114f444

Please sign in to comment.