-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration test: cgroup v1 network tests, fix to memory tests #516
Integration test: cgroup v1 network tests, fix to memory tests #516
Conversation
Codecov Report
@@ Coverage Diff @@
## main #516 +/- ##
==========================================
- Coverage 61.08% 60.84% -0.25%
==========================================
Files 85 87 +2
Lines 12416 12677 +261
==========================================
+ Hits 7584 7713 +129
- Misses 4832 4964 +132 |
It's very ironic that the code coverage drops when adding tests. I wonder if we can exclude the integration tests crate from the code coverage reports. |
I made another PR to ignore coverage reports for the integration tests: #517 |
const CGROUP_MEMORY_LIMIT: &str = "memory.limit_in_bytes"; | ||
const CGROUP_MEMORY_SWAPPINESS: &str = "memory.swappiness"; | ||
const CGROUP_MEMORY_LIMIT: &str = "/sys/fs/cgroup/memory/memory.limit_in_bytes"; | ||
const CGROUP_MEMORY_SWAPPINESS: &str = "/sys/fs/cgroup/memory/memory.swappiness"; |
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.
👍
let interfaces = datalink::interfaces(); | ||
|
||
// Gets the loopback interface, or defaults to "lo" | ||
let lo_if_name = interfaces.get(0).map_or_else(|| "lo", |iface| &iface.name); | ||
// Gets the first ethernet interface, or defaults to "eth0" | ||
let eth_if_name = interfaces | ||
.get(1) | ||
.map_or_else(|| "eth0", |iface| &iface.name); |
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.
It is better to check about interfaces
in can_run()
?
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 is what the runtime tools tests are currently doing, they check the interfaces and default them to lo
and eth0
. As far as I can tell the tests may still pass if the interfaces aren't found.
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 wish they explained the reasoning for setting a default more in the comment. It seems the rationale here, based on this commit message is to allow the test to run on systems with different interface names. For example as far as I can tell on every system the first interface is loopback (lo), and then on many systems the second interface may actually be something other than eth0
. In fact on my system I do not have eth0
, and the second interface is wlp0s20f3
, probably because I don't have an ethernet interface on my laptop.
When I run the test with "eth0" explicitly set as the interface on my laptop the test does in fact fail. So I think you're right, we should probably add this to can_run
.
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.
Take a look at the latest revision.
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.
Looks good
I have implemented a similar test to the oci-spec runtime tools, and I've verified that it is passing consistently. I also noticed that the cgroups path for memory was not set correctly and included the fix in this PR. I also verified the change the memory cgroups test is passing consistently. I also made sure both are able to fail, as I suspect the memory cgroup test wasn't even running before because the wrong path was set for the
can_run
check.