Skip to content

Commit 327ebcf

Browse files
committed
node: cpumgr: e2e: Define constants and use them instead of literals
Signed-off-by: Swati Sehgal <[email protected]>
1 parent c90f053 commit 327ebcf

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

test/e2e_node/cpu_manager_test.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ import (
4949
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
5050
)
5151

52+
const (
53+
minSMTLevel = 2
54+
minCPUCapacity = 2
55+
)
56+
5257
// Helper for makeCPUManagerPod().
5358
type ctnAttribute struct {
5459
ctnName string
@@ -880,9 +885,9 @@ func runCPUManagerTests(f *framework.Framework) {
880885
ginkgo.It("should assign CPUs as expected based on the Pod spec", func(ctx context.Context) {
881886
cpuCap, cpuAlloc, _ = getLocalNodeCPUDetails(ctx, f)
882887

883-
// Skip CPU Manager tests altogether if the CPU capacity < 2.
884-
if cpuCap < 2 {
885-
e2eskipper.Skipf("Skipping CPU Manager tests since the CPU capacity < 2")
888+
// Skip CPU Manager tests altogether if the CPU capacity < minCPUCapacity.
889+
if cpuCap < minCPUCapacity {
890+
e2eskipper.Skipf("Skipping CPU Manager tests since the CPU capacity < %d", minCPUCapacity)
886891
}
887892

888893
// Enable CPU Manager in the kubelet.
@@ -925,13 +930,14 @@ func runCPUManagerTests(f *framework.Framework) {
925930
smtLevel := getSMTLevel()
926931

927932
// strict SMT alignment is trivially verified and granted on non-SMT systems
928-
if smtLevel < 2 {
933+
if smtLevel < minSMTLevel {
929934
e2eskipper.Skipf("Skipping CPU Manager %s tests since SMT disabled", fullCPUsOnlyOpt)
930935
}
931936

932-
// our tests want to allocate a full core, so we need at last 2*2=4 virtual cpus
933-
if cpuAlloc < int64(smtLevel*2) {
934-
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < 4", fullCPUsOnlyOpt)
937+
// our tests want to allocate a full core, so we need at least 2*2=4 virtual cpus
938+
minCPUCount := int64(smtLevel * minCPUCapacity)
939+
if cpuAlloc < minCPUCount {
940+
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < %d", fullCPUsOnlyOpt, minCPUCount)
935941
}
936942

937943
framework.Logf("SMT level %d", smtLevel)
@@ -1075,13 +1081,14 @@ func runCPUManagerTests(f *framework.Framework) {
10751081
smtLevel := getSMTLevel()
10761082

10771083
// strict SMT alignment is trivially verified and granted on non-SMT systems
1078-
if smtLevel < 2 {
1084+
if smtLevel < minSMTLevel {
10791085
e2eskipper.Skipf("Skipping CPU Manager %s tests since SMT disabled", fullCPUsOnlyOpt)
10801086
}
10811087

1082-
// our tests want to allocate a full core, so we need at last 2*2=4 virtual cpus
1083-
if cpuAlloc < int64(smtLevel*2) {
1084-
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < 4", fullCPUsOnlyOpt)
1088+
// our tests want to allocate a full core, so we need at least 2*2=4 virtual cpus
1089+
minCPUCount := int64(smtLevel * minCPUCapacity)
1090+
if cpuAlloc < minCPUCount {
1091+
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < %d", fullCPUsOnlyOpt, minCPUCount)
10851092
}
10861093

10871094
framework.Logf("SMT level %d", smtLevel)
@@ -1139,13 +1146,14 @@ func runCPUManagerTests(f *framework.Framework) {
11391146
framework.Logf("SMT level %d", smtLevel)
11401147

11411148
// strict SMT alignment is trivially verified and granted on non-SMT systems
1142-
if smtLevel < 2 {
1149+
if smtLevel < minSMTLevel {
11431150
e2eskipper.Skipf("Skipping CPU Manager %s tests since SMT disabled", fullCPUsOnlyOpt)
11441151
}
11451152

1146-
// our tests want to allocate a full core, so we need at last 2*2=4 virtual cpus
1147-
if cpuAlloc < int64(smtLevel*2) {
1148-
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < 4", fullCPUsOnlyOpt)
1153+
// our tests want to allocate a full core, so we need at least 2*2=4 virtual cpus
1154+
minCPUCount := int64(smtLevel * minCPUCapacity)
1155+
if cpuAlloc < minCPUCount {
1156+
e2eskipper.Skipf("Skipping CPU Manager %s tests since the CPU capacity < %d", fullCPUsOnlyOpt, minCPUCount)
11491157
}
11501158

11511159
// this test is intended to be run on a multi-node NUMA system and

0 commit comments

Comments
 (0)