(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestParseStatCPUPSI(t *testing.T) { |
| 49 | const examplePSIData = `some avg10=1.71 avg60=2.36 avg300=2.57 total=230548833 |
| 50 | full 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…