Conversation
571eb6c to
daede0d
Compare
|
Thanks for your contribution. |
acdbb94 to
8394e04
Compare
|
Added memory tests. |
0525481 to
2eef6ac
Compare
| return nil | ||
| } | ||
|
|
||
| func getPageUsageByNUMAV2(path string) (cgroups.PageUsageByNUMA, error) { |
There was a problem hiding this comment.
nit: no need to have V2 in the function name, this package only contains cgroup v2 code.
|
|
||
| type parseError = fscommon.ParseError | ||
|
|
||
| func malformedLine(path, file, line string) error { |
There was a problem hiding this comment.
You copied the function over, without copying its docstring.
Perhaps it's better to move it to fscommon and make it available for all cgroups code?
There was a problem hiding this comment.
If you do something like this, please make it as a separate commit.
| return stats, nil | ||
| } | ||
|
|
||
| func getNUMAFieldV2(stats *cgroups.PageUsageByNUMA, name string) *cgroups.PageStats { |
There was a problem hiding this comment.
Same here about V2 suffix.
| "github.com/opencontainers/runc/libcontainer/cgroups" | ||
| ) | ||
|
|
||
| func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats) { |
There was a problem hiding this comment.
Same here: maybe move this to fscommon_test and make available for both fs and fs2?
If you'll do something like this, please do it as a separate commit.
| if err := os.WriteFile(statPath, []byte(memoryStatContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(maxPath, []byte(memoryMaxUsageContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(lowPath, []byte(memoryLimitContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(currentPath, []byte(memoryUsageContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(swapMaxPath, []byte(memoryMaxUsageContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(numaStatPath, []byte(memoryNUMAStatContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.MkdirAll(fakesub1CgroupDir, 0o755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(subnuma1StatPath, []byte(memoryNUMAStatContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.MkdirAll(fakesub2CgroupDir, 0o755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(subnuma2StatPath, []byte(memoryNUMAStatContents), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } |
There was a problem hiding this comment.
You can also move writeFileContents to fscommon under some _test.go file and re-use it from here.
|
|
||
| func expectPageUsageByNUMAEquals(t *testing.T, expected, actual cgroups.PageUsageByNUMA) { | ||
| t.Helper() | ||
| if !reflect.DeepEqual(expected.Total, actual.Total) { |
There was a problem hiding this comment.
Hmm, why not reflect.DeepEqual(expected, actual)?
Signed-off-by: victoryang00 <yangyiwei2000@gmail.com>
Add the parsing for
/sys/fs/cgroup/memory.numa_statand add to the correspondingPageUsageByNUMA.