add functional tests for cgroup v2 in gcs#2664
Open
jiechen0826 wants to merge 1 commit intomicrosoft:mainfrom
Open
add functional tests for cgroup v2 in gcs#2664jiechen0826 wants to merge 1 commit intomicrosoft:mainfrom
jiechen0826 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Signed-off-by: Jie Chen <jiechen3@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds functional end-to-end tests for cgroup operations in the GCS, covering both v1 and v2 hierarchies. These tests run inside the UVM as part of the GCS test binary and exercise the full cgroup stats pipeline regardless of which cgroup version the kernel provides.
Motivation
The GCS cgroup code path had no dedicated functional test coverage. As we migrate UVM images from cgroup v1 to v2 (e.g., Ubuntu 24.04), we need a regression gate that validates stats collection, resource limits, CPU throttling, and OOM monitoring work correctly on both cgroup versions.
Changes
New:
test/gcs/cgroup_test.go(7 tests)TestCgroupVersionDetectionIsCgroupV2()matches actual/sys/fs/cgroupfilesystem layoutTestContainerStats_CgroupMetricsTestContainerStats_MemoryLimitTestContainerExec_CgroupIsolation/containers/<id>cgroup pathTestMultipleContainers_IndependentStatsTestContainerStats_CPUThrottlingTestOOMEventFD_ContainerKillOomKill=1and fires eventfdModified:
internal/guest/cgroup/cgroup.goLoadManager(cgroupPath string) (Manager, error)— loads an existing cgroup (created by the runtime) as aManager, supporting both v1 and v2. Used by tests to inspect container cgroups.Modified:
test/gcs/main_test.gosetup()to handle both cgroup v1 and v2 when joining the root cgroup. Previously only used the v1 API (cgroups.Load), which fails on v2-only kernels.Testing
All 7 tests pass in a Hyper-V LCOW UVM with cgroup v2 (Ubuntu 24.04 rootfs):
--- PASS: TestCgroupVersionDetection (0.00s)
--- PASS: TestContainerStats_CgroupMetrics (2.07s)
--- PASS: TestContainerStats_MemoryLimit (2.09s)
--- PASS: TestContainerExec_CgroupIsolation (2.17s)
--- PASS: TestMultipleContainers_IndependentStats (4.17s)
--- PASS: TestContainerStats_CPUThrottling (4.15s)
--- PASS: TestOOMEventFD_ContainerKill (2.83s)
PASS