Skip to content

Commit 08fe76a

Browse files
committed
e2e: update expected cpu.weight
The opencontainers/cgroups package has updated the v1 shares -> v2 weight conversion to a more accurate formula.
1 parent b82100a commit 08fe76a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

e2e/cgroups/cgroups.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,12 @@ var resourceFlagTests = []resourceFlagTest{
615615
controllerV1: "cpu",
616616
resourceV1: "cpu.shares",
617617
expectV1: "123",
618-
// Cgroups v2 has a conversion from shares to weight:
619-
// weight = (1 + ((cpuShares-2)*9999)/262142)
618+
// Cgroups v2 has a conversion from shares to weight. The formula has
619+
// changed between opencontainer/cgroups versions, and runc / crun
620+
// versions. See https://github.com/opencontainers/cgroups/pull/20
620621
delegationV2: "cpu",
621622
resourceV2: "cpu.weight",
622-
expectV2: "5",
623+
expectV2: "5|20",
623624
},
624625
{
625626
name: "cpuset-cpus",
@@ -729,7 +730,7 @@ func (c *ctx) actionFlagV1(t *testing.T, tt resourceFlagTest, profile e2e.Profil
729730

730731
exitFunc := []e2e.SingularityCmdResultOp{}
731732
if tt.expectV1 != "" {
732-
exitFunc = []e2e.SingularityCmdResultOp{e2e.ExpectOutput(e2e.ContainMatch, tt.expectV1)}
733+
exitFunc = []e2e.SingularityCmdResultOp{e2e.ExpectOutput(e2e.RegexMatch, tt.expectV1)}
733734
}
734735

735736
args := tt.args
@@ -759,7 +760,7 @@ func (c *ctx) actionFlagV2(t *testing.T, tt resourceFlagTest, profile e2e.Profil
759760

760761
exitFunc := []e2e.SingularityCmdResultOp{}
761762
if tt.expectV2 != "" {
762-
exitFunc = []e2e.SingularityCmdResultOp{e2e.ExpectOutput(e2e.ContainMatch, tt.expectV2)}
763+
exitFunc = []e2e.SingularityCmdResultOp{e2e.ExpectOutput(e2e.RegexMatch, tt.expectV2)}
763764
}
764765

765766
// Use shell in the container to find container cgroup and cat the value for the tested controller & resource.

0 commit comments

Comments
 (0)