Skip to content

Add integration tests for cgroup v2 and systemd #3605

Open
1 of 1 issue completed
Open

Description

@saku3

Create cgroup v2 and systemd integration tests similar to #361.

  • It seems that cgroup v2 tests are not covered by runtime-tools.
  • runc tests may be useful as a reference.

https://github.com/opencontainers/runc/blob/main/tests/integration/cgroups.bats

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. self-assigned this
    on Aug 24, 2026
  2. ARMeeru commented on Sep 10, 2026

    @ARMeeru
    Contributor

    Is it open to claim? The v2 integration tests are exactly the gap the runc-compat suite keeps tripping over: resources.unified, swap, blkio weight and hugetlb are all skipped there today.

    My plan, following the reference you pointed at:

    • Port the coverage of runc's cgroups.bats into the contest harness as v2 tests, one controller per module (memory, pids, cpu, cpuset, io/blkio, hugetlb, devices), using the same file layout the existing v1-relative PRs used (tests/cgroups/<name>.rs + mod.rs wiring).
    • Each test runs the same OCI spec under a reference runc and under youki, asserting the v2 cgroupfs state from inside the container (the runtimetest binary pattern), so divergences surface per-controller rather than as one monolithic check.
    • Controllers in order: memory, pids, cpu, cpuset first (highest usage); blkio/io, hugetlb, devices after. Happy to reorder if some are already considered done.

    One question before I start: is contest the right home for these, or would you rather see them in the integration crate? The closed v1 PRs used contest, so that's my default.

    Will send the first controller as a draft PR so the shape gets reviewed early.

  3. saku3 commented on Sep 11, 2026

    @saku3
    MemberAuthor

    @ARMeeru
    Thank you.

    This test is open to claim, and contest is the right place to add the tests.

    @ARMeeru @tommady
    It would be helpful if you could let us know in advance which parts you plan to work on, so we can coordinate and avoid duplicate work.

  4. ARMeeru commented on Sep 11, 2026

    @ARMeeru
    Contributor

    @ARMeeru Thank you.

    This test is open to claim, and contest is the right place to add the tests.

    @ARMeeru @tommady It would be helpful if you could let us know in advance which parts you plan to work on, so we can coordinate and avoid duplicate work.

    Planning to cover these in order: memory, pids, cpu, cpuset first, then blkio/io, hugetlb, and devices.

    All tests will go in contest under tests/contest/contest/src/tests/cgroups/v2/, following the existing layout. Each test runs the same spec under a reference runc and under youki, asserting the v2 cgroupfs state from inside the container.

    Will start with memory and check in here before moving to the next controller so that I know what tommady picked up.

  5. assigned and unassigned on Sep 11, 2026
  6. ARMeeru commented on Sep 11, 2026

    @ARMeeru
    Contributor

    Two questions before I add more, so I don't build in a direction you don't want.

    File layout: should the v2 memory tests go in a standalone memory_v2.rs next to the existing memory.rs, or would you rather I move the memory tests into a cgroups/memory/ module with v1.rs and v2.rs to mirror cgroups/cpu/? I have the standalone file in the PR now; the module move is a pure rename if you prefer it.

    Scope: the PR covers the three mappings (limit to memory.max, reservation to memory.low, and the swap - limit conversion into memory.swap.max). Should the two rejection paths (a swap value without a limit, and a swap value below the limit) be part of this PR, or a separate one? I left them out to keep this one small.

  7. saku3 commented on Sep 11, 2026

    @saku3
    MemberAuthor

    I think adding memory_v2.rs is fine.

    Personally, I'd like to eventually remove the v1 tests and have only v2 and systemd tests, so I think a directory structure like the following would be ideal:

    tests/cgroups/
    ├── mod.rs
    │
    ├── cpu.rs
    ├── cpuset.rs
    ├── memory.rs
    ├── pids.rs
    ├── io.rs
    ├── hugetlb.rs
    ├── devices.rs
    ├── unified.rs
    │
    └── systemd/
        ├── mod.rs
    ...
    
  8. ARMeeru commented on Sep 12, 2026

    @ARMeeru
    Contributor

    Noted on #3727 as well, thank you.

    One coordination point from my side: the memory tests in #3725 are unaffected by the v1 removal except for the cgroup_v1_memory registration in main.rs, which sits next to the lines #3727 deletes, so I expect a small rebase conflict there.

    Once #3727 merges, I'll rebase onto it and rename my file to memory.rs, matching the flat per-controller layout you described. I'll hold off until then so I'm not building on an unmerged branch.

  9. 3 remaining items

  10. saku3 commented on Sep 21, 2026

    @saku3
    MemberAuthor

    One question: your layout from the 11th lists hugetlb.rs flat under tests/cgroups/. Move the three tests there as part of the migration, or keep the tlb/ directory and only switch the checks? I would move them, but either works.

    I agree. I think we should move them too.

  11. ARMeeru commented on Oct 17, 2026

    @ARMeeru
    Contributor

    @saku3 status since the last check-in, for the coordination this thread set up:

    Merged: memory (#3725), pids (#3741), hugetlb (#3752), cpuset (#3779) and unified (#3806) from me, and io from aayush0325 (#3731). cpu already had v2 coverage, and systemd/ arrived with #3721. The io work also covered the per-device BFQ weight test from runc's suite.

    Of the layout sketched on Sep 11, the one piece left without a test group is the cgroupfs devices controller. @t-akashi your rust_oci_test branch carries a cgroup v2 devices group (6e982da); now that #3721 turned the feature on by default, do you plan to send it? Happy to leave it with you. If you would rather pass it on, I'll pick the work up and rework it against what #3721 added.

    The one runc cgroups.bats test with no coverage left is per-device multiple iops through unified; I'll take that next. With devices in and that landed, every test in the reference suite has a home here.

  12. changed the title [-]Add integration tests for cgroup v2[/-] [+]Add integration tests for cgroup v2 and systemd[/+] on Oct 17, 2026
  13. t-akashi commented on Oct 18, 2026

    @t-akashi
    Contributor

    @t-akashi your rust_oci_test branch carries a cgroup v2 devices group (6e982da); now that #3721 turned the feature on by default, do you plan to send it? Happy to leave it with you.

    Thank you for heads-up.
    I'll try to rework my patch onto the latest (0.7.1).
    Give me some time.

  14. t-akashi commented on Oct 20, 2026

    @t-akashi
    Contributor

    @ARMeeru

    27. > @t-akashi your rust_oci_test branch carries a cgroup v2 devices group (6e982da); now that #3721 turned the feature on by default, do you plan to send it? Happy to leave it with you.

     Thank you for heads-up.
     I'll try to rework my patch onto the latest (0.7.1).
     Give me some time.
    

    After looking at my commit (6e982da), I concluded that we don't need this test case.
    Basically it tests one scenario which, I think, is already covered by a few of your tests
    (that is, test_whitelist_rules and test_redundant_deny_preserves_devices_access).
    It also have two variants, an absolute path and a relative path for the "CgroupsPath", but it doesn't make sense as
    youki supports only a particular format of "[slice]:[prefix]:[name] (crates/libcgroups/src/systemd/manager.rs).

    You can ignore this commit.

  15. ARMeeru commented on Nov 25, 2026

    @ARMeeru
    Contributor

    @saku3 Status update from current main and the latest runc nightly:

    The controller groups from the proposed layout are now present, except for a dedicated cgroupfs devices.rs. The per-device multiple-IOPS unified test is enabled and passes.

    For the device scope, test_whitelist_rules and test_redundant_deny_preserves_device_access pass --systemd-cgroup, so they cover the systemd driver only. The enabled runc device tests exercise cgroupfs instead. Is that runc coverage sufficient for this issue, or would you prefer a dedicated contest devices group?

    Two related runc tests are red in the nightly:

    • update cgroup v2 resources via unified map gets cpu.weight 17 where the pinned runc test expects 4. Current youki uses the newer quadratic shares-to-weight mapping, while the pinned runc helper uses the linear mapping. This needs test-baseline triage.
    • update devices [minimal transition rules] fails during create because the device BPF parser rejects the a in the test's rwa access rule.

    I suggest tracking those separately from this umbrella so this one stays about test coverage. Once we settle the device-scope question and have the failures tracked, would you be comfortable closing it?

  16. saku3 commented on Nov 25, 2026

    @saku3
    MemberAuthor

    Thank you for update.
    I'd like to add cgroupfs device tests to contest. Once those are in place, I think we can close this issue.

  17. added a commit that references this issue on Nov 27, 2026
    b4e2277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions