MCPcopy Create free account
hub / github.com/containerd/cgroups / TestParseStatCPUPSI

Function TestParseStatCPUPSI

cgroup2/utils_test.go:48–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestParseStatCPUPSI(t *testing.T) {
49 const examplePSIData = `some avg10=1.71 avg60=2.36 avg300=2.57 total=230548833
50full avg10=1.00 avg60=1.01 avg300=1.00 total=157622356`
51
52 fakeCgroupDir := t.TempDir()
53 statPath := filepath.Join(fakeCgroupDir, "cpu.pressure")
54
55 if err := os.WriteFile(statPath, []byte(examplePSIData), 0o644); err != nil {
56 t.Fatal(err)
57 }
58
59 st := getStatPSIFromFile(filepath.Join(fakeCgroupDir, "cpu.pressure"))
60 expected := stats.PSIStats{
61 Some: &stats.PSIData{
62 Avg10: 1.71,
63 Avg60: 2.36,
64 Avg300: 2.57,
65 Total: 230548833,
66 },
67 Full: &stats.PSIData{
68 Avg10: 1.00,
69 Avg60: 1.01,
70 Avg300: 1.00,
71 Total: 157622356,
72 },
73 }
74 assert.Equal(t, &st.Some, &expected.Some)
75 assert.Equal(t, &st.Full, &expected.Full)
76}
77
78// TestConvertCPUSharesToCgroupV2Value tests the ConvertCPUSharesToCgroupV2Value function.
79// Taken from https://github.com/opencontainers/cgroups/blob/v0.0.5/utils_test.go#L537-L564

Callers

nothing calls this directly

Calls 1

getStatPSIFromFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…