Conversation
system_metrics_collector/src/system_metrics_collector/linux_process_cpu_measurement_node.cpp
Outdated
Show resolved
Hide resolved
system_metrics_collector/src/system_metrics_collector/linux_process_cpu_measurement_node.hpp
Show resolved
Hide resolved
..._metrics_collector/test/system_metrics_collector/test_linux_process_cpu_measurement_node.cpp
Show resolved
Hide resolved
..._metrics_collector/test/system_metrics_collector/test_linux_process_cpu_measurement_node.cpp
Outdated
Show resolved
Hide resolved
..._metrics_collector/test/system_metrics_collector/test_linux_process_cpu_measurement_node.cpp
Outdated
Show resolved
Hide resolved
|
||
double PeriodicMeasurement() override | ||
{ | ||
LinuxProcessCpuMeasurementNode::PeriodicMeasurement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this assume that the measurement works on the machine running the integration tests? Is that an assumption we can make? I would consider stubbing out the system specific calls and provide fake data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we can't make the measurement on the machine running the integration test, then it's something wrong with the way we're measuring or something is wrong with the test machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree: what happens if we need to support multiple platforms? There's no requirement that the build system is able to make these measurements, which is why many of the Linux specific functions are have been separately stubbed out and tested independently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is in test_LINUX_process_cpu_measurement_node.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is in
test_LINUX_process_cpu_measurement_node.cpp
Right, but the unit test makes the assumption that the machine running the test supports the linux specific measurements. I think it's important to point out none of the other Linux node tests make this assumption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's important to point out none of the other Linux node tests make this assumption.
And consequently some of the functions under
utilities.cpp
have no code coverage.
We can always add tests where not making system specific calls (e.g. GetPID). I need to understand the coverage, but the majority of the utilities functions have corresponding unit tests covering their different return cases (via test_utilities.cpp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry, not utilities.cpp
, but LinuxCpuMeasurementNode::MakeSingleMeasurement()
, LinuxProcessMemoryMeasurementNode::PeriodicMeasurement()
, and LinuxMemoryMeasurementNode::PeriodicMeasurement()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the point you're trying to make, because we can walk through the existing unit tests and go over how all of the non-specific system calls directly tested. Otherwise one could mock these classes solely to call these methods directly, but that kind of test exists for the superclass.
However, we're getting off topic here. Let's address the tests in this PR and improve coverage, etc in other issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how all of the non-specific system calls directly tested.
My point is why are we not testing system-specific calls?
Anyway yes, I'll disagree and commit™ to this PR comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been mocked out via overriding LinuxProcessCpuMeasurementNode::MakeSingleMeasurement()
.
system_metrics_collector/src/system_metrics_collector/linux_process_cpu_measurement_node.cpp
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
==========================================
+ Coverage 40.95% 41.09% +0.14%
==========================================
Files 28 33 +5
Lines 967 1039 +72
Branches 566 605 +39
==========================================
+ Hits 396 427 +31
- Misses 54 60 +6
- Partials 517 552 +35
Continue to review full report at Codecov.
|
system_metrics_collector/src/system_metrics_collector/linux_process_cpu_measurement_node.hpp
Outdated
Show resolved
Hide resolved
..._metrics_collector/test/system_metrics_collector/test_linux_process_cpu_measurement_node.cpp
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
system_metrics_collector/src/system_metrics_collector/linux_process_cpu_measurement_node.hpp
Outdated
Show resolved
Hide resolved
#include "utilities.hpp" | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "rcutils/logging_macros.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using logging utilities like those in rosbag2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a separate PR.
constexpr const char kTestTopic[] = "test_process_cpu_measure_topic"; | ||
} | ||
|
||
class TestLinuxProcessCpuMeasurementNode : public system_metrics_collector:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider calling this fake
and not test
. test
would be useful for a fixture where you use the fake (IMO).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I'm unsure if this comment was referring to the value of the kTestTopic
constant or the name of the class.
Anyway, I have renamed TestLinuxProcessCpuMeasurementNode
to MockLinuxProcessCpuMeasurementNode
, since mock
is a more accurate description than fake
.
..._metrics_collector/test/system_metrics_collector/test_linux_process_cpu_measurement_node.cpp
Outdated
Show resolved
Hide resolved
8332351
to
62efe92
Compare
Merged given passing tests and bypassing broken codecov. |
This implements the node that does per-process CPU usage collection.
Example debug output:
Example topic output: