(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestToResources(t *testing.T) { |
| 111 | var ( |
| 112 | quota int64 = 8000 |
| 113 | period uint64 = 10000 |
| 114 | shares uint64 = 5000 |
| 115 | |
| 116 | mem int64 = 300 |
| 117 | swap int64 = 500 |
| 118 | ) |
| 119 | weight := ConvertCPUSharesToCgroupV2Value(shares) |
| 120 | res := specs.LinuxResources{ |
| 121 | CPU: &specs.LinuxCPU{Quota: "a, Period: &period, Shares: &shares}, |
| 122 | Memory: &specs.LinuxMemory{Limit: &mem, Swap: &swap}, |
| 123 | } |
| 124 | v2resources := ToResources(&res) |
| 125 | |
| 126 | assert.Equal(t, weight, *v2resources.CPU.Weight) |
| 127 | assert.Equal(t, CPUMax("8000 10000"), v2resources.CPU.Max) |
| 128 | assert.Equal(t, swap-mem, *v2resources.Memory.Swap) |
| 129 | |
| 130 | res2 := specs.LinuxResources{CPU: &specs.LinuxCPU{Period: &period}} |
| 131 | v2resources2 := ToResources(&res2) |
| 132 | assert.Equal(t, CPUMax("max 10000"), v2resources2.CPU.Max) |
| 133 | } |
| 134 | |
| 135 | func BenchmarkGetStatFileContentUint64(b *testing.B) { |
| 136 | b.ReportAllocs() |
nothing calls this directly
no test coverage detected
searching dependent graphs…