Skip to content

Commit 9d38a85

Browse files
committed
Ensure unit tests are guarded by a feature gate
Signed-off-by: Itamar Holder <[email protected]>
1 parent 18139b9 commit 9d38a85

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/kubelet/nodestatus/setters_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
utilfeature "k8s.io/apiserver/pkg/util/feature"
4141
cloudprovider "k8s.io/cloud-provider"
4242
fakecloud "k8s.io/cloud-provider/fake"
43+
"k8s.io/component-base/featuregate"
4344
featuregatetesting "k8s.io/component-base/featuregate/testing"
4445
"k8s.io/component-base/version"
4546
"k8s.io/kubernetes/pkg/features"
@@ -912,6 +913,7 @@ func TestMachineInfo(t *testing.T) {
912913
expectNode *v1.Node
913914
expectEvents []testEvent
914915
disableLocalStorageCapacityIsolation bool
916+
featureGateDependencies []featuregate.Feature
915917
}{
916918
{
917919
desc: "machine identifiers, basic capacity and allocatable",
@@ -1356,10 +1358,23 @@ func TestMachineInfo(t *testing.T) {
13561358
},
13571359
},
13581360
},
1361+
featureGateDependencies: []featuregate.Feature{features.NodeSwap},
13591362
},
13601363
}
13611364

13621365
for _, tc := range cases {
1366+
featureGatesMissing := false
1367+
for _, featureGateDependency := range tc.featureGateDependencies {
1368+
if !utilfeature.DefaultFeatureGate.Enabled(featureGateDependency) {
1369+
featureGatesMissing = true
1370+
break
1371+
}
1372+
}
1373+
1374+
if featureGatesMissing {
1375+
continue
1376+
}
1377+
13631378
t.Run(tc.desc, func(t *testing.T) {
13641379
ctx := context.Background()
13651380
machineInfoFunc := func() (*cadvisorapiv1.MachineInfo, error) {

0 commit comments

Comments
 (0)