use super::CGroupBase;
use super::CGroupLimitsContext;
use super::CGroupMount;
use super::CGroupMounts;
use super::CGroupPath;
use super::cgroup_base_for_path;
use super::decode_mountinfo_path;
use super::limits_for_process;
use super::limits_for_process_with_context;
use super::parse_cgroup_mounts;
use super::parse_cgroup_path;
use super::read_table;
use super::read_table_key;
use super::v1_limits;
use super::v2_limits;
use std::collections::HashMap;
use std::fs::{create_dir_all, write};
use std::io::Write;
use std::path::{Path, PathBuf};
use tempfile::{NamedTempFile, tempdir};
#[test]
fn test_read_table() {
let mut file = NamedTempFile::new().unwrap();
writeln!(file, "KEY1:100 kB").unwrap();
writeln!(file, "KEY2:200 kB").unwrap();
writeln!(file, "KEY3:300 kB").unwrap();
writeln!(file, "KEY4:invalid").unwrap();
let file_path = file.path().to_str().unwrap();
let mut result = HashMap::new();
read_table(file_path, ':', |key, value| {
result.insert(key.to_string(), value);
});
assert_eq!(result.get("KEY1"), Some(&100));
assert_eq!(result.get("KEY2"), Some(&200));
assert_eq!(result.get("KEY3"), Some(&300));
assert_eq!(result.get("KEY4"), None);
let mut file = NamedTempFile::new().unwrap();
writeln!(file, "KEY1 400 MB").unwrap();
writeln!(file, "KEY2 500 GB").unwrap();
writeln!(file, "KEY3 600").unwrap();
let file_path = file.path().to_str().unwrap();
let mut result = HashMap::new();
read_table(file_path, ' ', |key, value| {
result.insert(key.to_string(), value);
});
assert_eq!(result.get("KEY1"), Some(&400));
assert_eq!(result.get("KEY2"), Some(&500));
assert_eq!(result.get("KEY3"), Some(&600));
let file = NamedTempFile::new().unwrap();
let file_path = file.path().to_str().unwrap();
let mut result = HashMap::new();
read_table(file_path, ':', |key, value| {
result.insert(key.to_string(), value);
});
assert!(result.is_empty());
let mut result = HashMap::new();
read_table("/nonexistent/file", ':', |key, value| {
result.insert(key.to_string(), value);
});
assert!(result.is_empty());
}
#[test]
fn test_read_table_key() {
let mut file = NamedTempFile::new().unwrap();
writeln!(file, "KEY1:100 kB").unwrap();
writeln!(file, "KEY2:200 kB").unwrap();
writeln!(file, "KEY3:300 kB").unwrap();
let file_path = file.path();
assert_eq!(read_table_key(file_path, "KEY1", ':'), Some(100));
assert_eq!(read_table_key(file_path, "KEY2", ':'), Some(200));
assert_eq!(read_table_key(file_path, "KEY3", ':'), Some(300));
assert_eq!(read_table_key(file_path, "KEY4", ':'), None);
let mut file = NamedTempFile::new().unwrap();
writeln!(file, "KEY1 400 kB").unwrap();
writeln!(file, "KEY2 500 kB").unwrap();
let file_path = file.path();
assert_eq!(read_table_key(file_path, "KEY1", ' '), Some(400));
assert_eq!(read_table_key(file_path, "KEY2", ' '), Some(500));
assert_eq!(
read_table_key(Path::new("/nonexistent/file"), "KEY1", ':'),
None
);
}
#[test]
fn test_v2_parent_limit() {
let root = tempdir().unwrap();
let parent = root.path().join("parent");
let child = parent.join("child");
create_dir_all(&child).unwrap();
write(root.path().join("memory.max"), "max").unwrap();
write(parent.join("memory.max"), "500").unwrap();
write(parent.join("memory.current"), "350").unwrap();
write(child.join("memory.max"), "max").unwrap();
write(child.join("memory.current"), "100").unwrap();
write(child.join("memory.stat"), "anon 30\n").unwrap();
let limits = v2_limits(
&child,
root.path(),
CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
},
)
.unwrap();
assert_eq!(limits.total_memory, 500);
assert_eq!(limits.free_memory, 150);
assert_eq!(limits.free_swap, 700);
assert_eq!(limits.rss, 30);
}
#[test]
fn test_v2_parent_free_memory() {
let root = tempdir().unwrap();
let parent = root.path().join("parent");
let child = parent.join("child");
create_dir_all(&child).unwrap();
write(root.path().join("memory.max"), "max").unwrap();
write(parent.join("memory.max"), "500").unwrap();
write(parent.join("memory.current"), "450").unwrap();
write(child.join("memory.max"), "200").unwrap();
write(child.join("memory.current"), "100").unwrap();
write(child.join("memory.stat"), "anon 30\n").unwrap();
let limits = v2_limits(
&child,
root.path(),
CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
},
)
.unwrap();
assert_eq!(limits.total_memory, 200);
assert_eq!(limits.free_memory, 50);
}
#[test]
fn test_v2_unlimited_memory() {
let root = tempdir().unwrap();
let child = root.path().join("child");
create_dir_all(&child).unwrap();
write(root.path().join("memory.max"), "max").unwrap();
write(root.path().join("memory.current"), "350").unwrap();
write(child.join("memory.max"), "max").unwrap();
write(child.join("memory.current"), "100").unwrap();
write(child.join("memory.stat"), "anon 30\n").unwrap();
let limits = v2_limits(
&child,
root.path(),
CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
},
);
assert!(limits.is_none());
}
#[test]
fn test_v1_parent_limit() {
let root = tempdir().unwrap();
let parent = root.path().join("parent");
let child = parent.join("child");
create_dir_all(&child).unwrap();
write(
root.path().join("memory.limit_in_bytes"),
u64::MAX.to_string(),
)
.unwrap();
write(parent.join("memory.limit_in_bytes"), "500").unwrap();
write(parent.join("memory.usage_in_bytes"), "350").unwrap();
write(child.join("memory.limit_in_bytes"), u64::MAX.to_string()).unwrap();
write(child.join("memory.usage_in_bytes"), "100").unwrap();
write(child.join("memory.stat"), "total_rss 30\n").unwrap();
let limits = v1_limits(
&child,
root.path(),
CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
},
)
.unwrap();
assert_eq!(limits.total_memory, 500);
assert_eq!(limits.free_memory, 150);
assert_eq!(limits.rss, 30);
}
#[test]
fn test_v1_unlimited_memory() {
let root = tempdir().unwrap();
let child = root.path().join("child");
create_dir_all(&child).unwrap();
write(
root.path().join("memory.limit_in_bytes"),
u64::MAX.to_string(),
)
.unwrap();
write(root.path().join("memory.usage_in_bytes"), "350").unwrap();
write(child.join("memory.limit_in_bytes"), u64::MAX.to_string()).unwrap();
write(child.join("memory.usage_in_bytes"), "100").unwrap();
write(child.join("memory.stat"), "total_rss 30\n").unwrap();
let limits = v1_limits(
&child,
root.path(),
CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
},
);
assert!(limits.is_none());
}
#[test]
fn test_hybrid_cgroup_uses_v1_memory_path_when_v2_is_unlimited() {
let root = tempdir().unwrap();
let v2_root = root.path().join("unified");
let v2_child = v2_root.join("system.slice/service.scope");
let v1_root = root.path().join("memory");
let v1_child = v1_root.join("memory.slice/service.scope");
let host_memory = 32 * 1024 * 1024 * 1024;
let cgroup_limit = 8 * 1024 * 1024 * 1024;
let cgroup_usage = 1024 * 1024 * 1024;
create_dir_all(&v2_child).unwrap();
create_dir_all(&v1_child).unwrap();
for ancestor in [v1_root.as_path(), v1_child.parent().unwrap()] {
write(ancestor.join("memory.limit_in_bytes"), u64::MAX.to_string()).unwrap();
}
write(v2_root.join("memory.max"), "max").unwrap();
write(v2_child.parent().unwrap().join("memory.max"), "max").unwrap();
write(v2_root.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(v2_child.join("memory.max"), "max").unwrap();
write(v2_child.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(v2_child.join("memory.stat"), "anon 1073741824\n").unwrap();
write(
v1_child.join("memory.limit_in_bytes"),
cgroup_limit.to_string(),
)
.unwrap();
write(
v1_child.join("memory.usage_in_bytes"),
cgroup_usage.to_string(),
)
.unwrap();
write(v1_child.join("memory.stat"), "total_rss 1073741824\n").unwrap();
let cgroup_path = parse_cgroup_path(
"0::/system.slice/service.scope\n\
11:memory:/memory.slice/service.scope\n",
);
let mountinfo = format!(
"30 23 0:25 / {} rw - cgroup cgroup rw,memory\n\
31 23 0:26 / {} rw - cgroup2 cgroup rw\n",
v1_root.display(),
v2_root.display(),
);
let cgroup_mounts = parse_cgroup_mounts(&mountinfo);
let limits = limits_for_process_with_context(
&cgroup_path,
&cgroup_mounts,
CGroupLimitsContext {
mem_total: host_memory,
swap_total: 0,
swap_free: 0,
},
)
.unwrap();
assert_eq!(limits.total_memory, cgroup_limit);
assert_eq!(limits.free_memory, cgroup_limit - cgroup_usage);
assert_eq!(limits.rss, cgroup_usage);
}
#[test]
fn test_mountinfo_resolves_v1_memory_path() {
let root = tempdir().unwrap();
let v1_mount = root.path().join("mounted-memory");
let v1_child = v1_mount.join("pod/container");
let host_memory = 32 * 1024 * 1024 * 1024;
let cgroup_limit = 8 * 1024 * 1024 * 1024;
let cgroup_usage = 1024 * 1024 * 1024;
create_dir_all(&v1_child).unwrap();
for ancestor in [v1_mount.as_path(), v1_child.parent().unwrap()] {
write(ancestor.join("memory.limit_in_bytes"), u64::MAX.to_string()).unwrap();
}
write(
v1_child.join("memory.limit_in_bytes"),
cgroup_limit.to_string(),
)
.unwrap();
write(
v1_child.join("memory.usage_in_bytes"),
cgroup_usage.to_string(),
)
.unwrap();
write(v1_child.join("memory.stat"), "total_rss 1073741824\n").unwrap();
let cgroup_path = parse_cgroup_path("11:memory:/kubepods/pod/container\n");
let mountinfo = format!(
"30 23 0:25 /kubepods {} rw,nosuid,nodev,noexec - cgroup cgroup rw,memory\n",
v1_mount.display(),
);
let cgroup_mounts = parse_cgroup_mounts(&mountinfo);
assert_eq!(
cgroup_base_for_path(
Path::new("kubepods/pod/container"),
&cgroup_mounts.v1_memory,
),
Some(CGroupBase::new(v1_child.clone(), v1_mount.clone()))
);
let limits = limits_for_process_with_context(
&cgroup_path,
&cgroup_mounts,
CGroupLimitsContext {
mem_total: host_memory,
swap_total: 0,
swap_free: 0,
},
)
.unwrap();
assert_eq!(limits.total_memory, cgroup_limit);
assert_eq!(limits.free_memory, cgroup_limit - cgroup_usage);
assert_eq!(limits.rss, cgroup_usage);
}
#[test]
fn test_process_cgroup_does_not_fall_back_to_v1_root() {
let root = tempdir().unwrap();
let v2_root = root.path().join("unified");
let v2_child = v2_root.join("system.slice/service.scope");
let v1_root = root.path().join("memory");
let host_memory = 32 * 1024 * 1024 * 1024;
let cgroup_limit = 8 * 1024 * 1024 * 1024;
let cgroup_usage = 1024 * 1024 * 1024;
create_dir_all(&v2_child).unwrap();
create_dir_all(&v1_root).unwrap();
write(v2_root.join("memory.max"), "max").unwrap();
write(v2_child.parent().unwrap().join("memory.max"), "max").unwrap();
write(v2_root.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(v2_child.join("memory.max"), "max").unwrap();
write(v2_child.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(v2_child.join("memory.stat"), "anon 1073741824\n").unwrap();
write(
v1_root.join("memory.limit_in_bytes"),
cgroup_limit.to_string(),
)
.unwrap();
write(
v1_root.join("memory.usage_in_bytes"),
cgroup_usage.to_string(),
)
.unwrap();
write(v1_root.join("memory.stat"), "total_rss 1073741824\n").unwrap();
let cgroup_path = parse_cgroup_path(
"0::/system.slice/service.scope\n\
11:memory:/kubepods/pod/container\n",
);
let mountinfo = format!(
"30 23 0:25 / {} rw - cgroup cgroup rw,memory\n\
31 23 0:26 / {} rw - cgroup2 cgroup rw\n",
v1_root.display(),
v2_root.display(),
);
let cgroup_mounts = parse_cgroup_mounts(&mountinfo);
let context = CGroupLimitsContext {
mem_total: host_memory,
swap_total: 0,
swap_free: 0,
};
assert_eq!(
v1_limits(&v1_root, &v1_root, context).unwrap().total_memory,
cgroup_limit,
);
let limits = limits_for_process_with_context(&cgroup_path, &cgroup_mounts, context);
assert!(limits.is_none());
}
#[test]
fn test_hybrid_cgroup_prefers_v1_memory_path_over_v2_limit() {
let root = tempdir().unwrap();
let v2_root = root.path().join("unified");
let v2_child = v2_root.join("system.slice/service.scope");
let v1_root = root.path().join("memory");
let v1_child = v1_root.join("memory.slice/service.scope");
let v2_limit = 32 * 1024 * 1024 * 1024;
let v1_limit = 8 * 1024 * 1024 * 1024;
let cgroup_usage = 1024 * 1024 * 1024;
create_dir_all(&v2_child).unwrap();
create_dir_all(&v1_child).unwrap();
for ancestor in [v1_root.as_path(), v1_child.parent().unwrap()] {
write(ancestor.join("memory.limit_in_bytes"), u64::MAX.to_string()).unwrap();
}
write(v2_root.join("memory.max"), v2_limit.to_string()).unwrap();
write(v2_root.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(
v2_child.parent().unwrap().join("memory.max"),
v2_limit.to_string(),
)
.unwrap();
write(
v2_child.parent().unwrap().join("memory.current"),
cgroup_usage.to_string(),
)
.unwrap();
write(v2_child.join("memory.max"), v2_limit.to_string()).unwrap();
write(v2_child.join("memory.current"), cgroup_usage.to_string()).unwrap();
write(v2_child.join("memory.stat"), "anon 1073741824\n").unwrap();
write(v1_child.join("memory.limit_in_bytes"), v1_limit.to_string()).unwrap();
write(
v1_child.join("memory.usage_in_bytes"),
cgroup_usage.to_string(),
)
.unwrap();
write(v1_child.join("memory.stat"), "total_rss 1073741824\n").unwrap();
let cgroup_path = parse_cgroup_path(
"0::/system.slice/service.scope\n\
11:memory:/memory.slice/service.scope\n",
);
let mountinfo = format!(
"30 23 0:25 / {} rw - cgroup cgroup rw,memory\n\
31 23 0:26 / {} rw - cgroup2 cgroup rw\n",
v1_root.display(),
v2_root.display(),
);
let cgroup_mounts = parse_cgroup_mounts(&mountinfo);
let limits = limits_for_process_with_context(
&cgroup_path,
&cgroup_mounts,
CGroupLimitsContext {
mem_total: v2_limit,
swap_total: 0,
swap_free: 0,
},
)
.unwrap();
assert_eq!(limits.total_memory, v1_limit);
assert_eq!(limits.free_memory, v1_limit - cgroup_usage);
assert_eq!(limits.rss, cgroup_usage);
}
fn write_memory_cgroup(path: &Path, v1: bool, limit: &str) {
create_dir_all(path).unwrap();
let (limit_file, usage_file, stat) = if v1 {
(
"memory.limit_in_bytes",
"memory.usage_in_bytes",
"total_rss 30\n",
)
} else {
("memory.max", "memory.current", "anon 30\n")
};
write(path.join(limit_file), limit).unwrap();
write(path.join(usage_file), "100").unwrap();
write(path.join("memory.stat"), stat).unwrap();
}
const CONTEXT: CGroupLimitsContext = CGroupLimitsContext {
mem_total: 2000,
swap_total: 1000,
swap_free: 700,
};
#[test]
fn test_memory_limit_read_errors() {
for v1 in [false, true] {
for level in ["", "parent", "parent/child"] {
for failure in ["missing", "malformed", "unreadable"] {
let root = tempdir().unwrap();
let child = root.path().join("parent/child");
write_memory_cgroup(root.path(), v1, "1000");
write_memory_cgroup(&root.path().join("parent"), v1, "500");
write_memory_cgroup(&child, v1, "200");
let limits = if v1 { v1_limits } else { v2_limits };
assert_eq!(
limits(&child, root.path(), CONTEXT).unwrap().total_memory,
200
);
let filename = if v1 {
"memory.limit_in_bytes"
} else {
"memory.max"
};
let path = root.path().join(level).join(filename);
std::fs::remove_file(&path).unwrap();
match failure {
"malformed" => write(&path, "invalid").unwrap(),
"unreadable" => create_dir_all(&path).unwrap(),
_ => {}
}
assert!(
limits(&child, root.path(), CONTEXT).is_none(),
"v1={v1}, level={level}, failure={failure}"
);
}
}
}
}
#[test]
fn test_v2_root_without_memory_max() {
let root = tempdir().unwrap();
let child = root.path().join("child");
write_memory_cgroup(&child, false, "200");
assert!(v2_limits(&child, root.path(), CONTEXT).is_none());
write(root.path().join("cgroup.controllers"), "memory\n").unwrap();
assert_eq!(
v2_limits(&child, root.path(), CONTEXT)
.unwrap()
.total_memory,
200
);
write(root.path().join("cgroup.type"), "domain\n").unwrap();
assert!(v2_limits(&child, root.path(), CONTEXT).is_none());
std::fs::remove_file(root.path().join("cgroup.type")).unwrap();
write(root.path().join("memory.max"), "invalid").unwrap();
assert!(v2_limits(&child, root.path(), CONTEXT).is_none());
std::fs::remove_file(root.path().join("memory.max")).unwrap();
create_dir_all(root.path().join("memory.max")).unwrap();
assert!(v2_limits(&child, root.path(), CONTEXT).is_none());
std::fs::remove_dir(root.path().join("memory.max")).unwrap();
write(child.join("cgroup.controllers"), "memory\n").unwrap();
std::fs::remove_file(child.join("memory.max")).unwrap();
assert!(v2_limits(&child, root.path(), CONTEXT).is_none());
}
#[test]
fn test_mountinfo_resolves_v2_memory_path() {
let root = tempdir().unwrap();
let mount = root.path().join("remapped-memory");
let child = mount.join("pod/container");
write_memory_cgroup(&mount, false, "1500");
write_memory_cgroup(&mount.join("pod"), false, "500");
write_memory_cgroup(&child, false, "1000");
let cgroup_path = parse_cgroup_path("0::/kubepods/pod/container\n");
let mounts = parse_cgroup_mounts(&format!(
"30 23 0:25 /kubepods {} rw - cgroup2 cgroup rw\n",
mount.display(),
));
assert_eq!(
cgroup_base_for_path(Path::new("kubepods/pod/container"), &mounts.v2),
Some(CGroupBase::new(child, mount)),
);
let limits = limits_for_process_with_context(&cgroup_path, &mounts, CONTEXT).unwrap();
assert_eq!(limits.total_memory, 500);
assert_eq!(limits.free_memory, 400);
assert_eq!(limits.rss, 30);
}
#[test]
fn test_process_limits_do_not_fall_back() {
for v1 in [false, true] {
let root = tempdir().unwrap();
let selected = root.path().join("selected");
let alternative = root.path().join("alternative");
let v2_root = root.path().join("unified");
write_memory_cgroup(&selected, v1, "1000");
write_memory_cgroup(&alternative, v1, "1000");
write_memory_cgroup(&alternative.join("child"), v1, "1000");
write_memory_cgroup(&v2_root, false, "1500");
write_memory_cgroup(&v2_root.join("child"), false, "1500");
let (membership, filesystem) = if v1 {
("0::/child\n11:memory:/child\n", "cgroup cgroup rw,memory")
} else {
("0::/child\n", "cgroup2 cgroup rw")
};
let membership = parse_cgroup_path(membership);
let mut mounts = parse_cgroup_mounts(&format!(
"30 23 0:25 / {} rw - {filesystem}\n\
31 23 0:25 / {} rw - {filesystem}\n\
32 23 0:26 / {} rw - cgroup2 cgroup rw\n",
selected.display(),
alternative.display(),
v2_root.display(),
));
assert!(limits_for_process_with_context(&membership, &mounts, CONTEXT).is_none());
write_memory_cgroup(&selected.join("child"), v1, "invalid");
assert!(limits_for_process_with_context(&membership, &mounts, CONTEXT).is_none());
if v1 {
mounts.v1_memory.clear();
} else {
mounts.v2.clear();
}
assert!(limits_for_process_with_context(&membership, &mounts, CONTEXT).is_none());
}
let proc_path = tempdir().unwrap();
write(proc_path.path().join("cgroup"), "0::/child\n").unwrap();
assert!(limits_for_process(proc_path.path()).is_none());
write(proc_path.path().join("mountinfo"), "invalid").unwrap();
assert!(limits_for_process(proc_path.path()).is_none());
}
#[test]
fn test_parse_cgroup_mounts() {
assert_eq!(
parse_cgroup_mounts(
"29 23 0:28 /kubepods\\040burstable /sys/fs/cgroup/memory\\040controller rw,nosuid,nodev,noexec - cgroup cgroup rw,memory\n\
30 23 0:29 / /sys/fs/cgroup rw,nosuid,nodev,noexec shared:1 master:2 propagate_from:3 unbindable x-extra:y- - cgroup2 cgroup rw\n\
31 23 0:30 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec - cgroup cgroup rw,cpu\n",
),
CGroupMounts {
v2: vec![CGroupMount {
root: PathBuf::new(),
mount_point: PathBuf::from("/sys/fs/cgroup"),
}],
v1_memory: vec![CGroupMount {
root: PathBuf::from("kubepods burstable"),
mount_point: PathBuf::from("/sys/fs/cgroup/memory controller"),
}],
}
);
}
#[test]
fn test_decode_mountinfo_path() {
assert_eq!(
decode_mountinfo_path("/sys/fs/cgroup/memory\\040controller"),
"/sys/fs/cgroup/memory controller"
);
assert_eq!(decode_mountinfo_path("tab\\011path"), "tab\tpath");
assert_eq!(decode_mountinfo_path("newline\\012path"), "newline\npath");
assert_eq!(
decode_mountinfo_path("backslash\\134path"),
"backslash\\path"
);
assert_eq!(decode_mountinfo_path("plain/path"), "plain/path");
assert_eq!(decode_mountinfo_path("trailing\\04"), "trailing\\04");
assert_eq!(decode_mountinfo_path("invalid\\099"), "invalid\\099");
}
#[test]
fn test_parse_cgroup_path_keeps_literal_path_bytes() {
assert_eq!(
parse_cgroup_path("11:memory:/kubepods\\040literal/a:b c\n0::/unified\\011path\n"),
CGroupPath {
v2: Some(PathBuf::from("unified\\011path")),
v1_memory: Some(PathBuf::from("kubepods\\040literal/a:b c")),
}
);
}
#[test]
fn test_parse_cgroup_path_v2() {
assert_eq!(
parse_cgroup_path("0::/user.slice/session.scope"),
CGroupPath {
v2: Some(PathBuf::from("user.slice/session.scope")),
v1_memory: None,
}
);
}
#[test]
fn test_parse_cgroup_path_v1_memory() {
assert_eq!(
parse_cgroup_path("12:cpuset:/\n11:memory:/system.slice/service.scope"),
CGroupPath {
v2: None,
v1_memory: Some(PathBuf::from("system.slice/service.scope")),
}
);
}
#[test]
fn test_parse_cgroup_path_hybrid() {
assert_eq!(
parse_cgroup_path("0::/system.slice/service.scope\n11:memory:/kubepods/pod/container\n"),
CGroupPath {
v2: Some(PathBuf::from("system.slice/service.scope")),
v1_memory: Some(PathBuf::from("kubepods/pod/container")),
}
);
}
#[test]
fn test_parse_cgroup_path_missing_memory_controller() {
assert_eq!(
parse_cgroup_path("12:cpuset:/\n10:cpu:/"),
CGroupPath::default()
);
}