mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Fix swap feature gate check by introduting IsFeatureGateEnabled()
Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
parent
959d01cbbf
commit
13403e836a
@ -56,8 +56,7 @@ func SkipUnlessAtLeast(value int, minValue int, message string) {
|
||||
var featureGate featuregate.FeatureGate
|
||||
|
||||
// InitFeatureGates must be called in test suites that have a --feature-gates parameter.
|
||||
// If not called, SkipUnlessFeatureGateEnabled and SkipIfFeatureGateEnabled will
|
||||
// record a test failure.
|
||||
// If not called, SkipUnlessFeatureGateEnabled will record a test failure.
|
||||
func InitFeatureGates(defaults featuregate.FeatureGate, overrides map[string]bool) error {
|
||||
clone := defaults.DeepCopy()
|
||||
if err := clone.SetFromMap(overrides); err != nil {
|
||||
@ -67,6 +66,16 @@ func InitFeatureGates(defaults featuregate.FeatureGate, overrides map[string]boo
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsFeatureGateEnabled can be used during e2e tests to figure out if a certain feature gate is enabled.
|
||||
// This function is dependent on InitFeatureGates under the hood. Therefore, the test must be called with a
|
||||
// --feature-gates parameter.
|
||||
func IsFeatureGateEnabled(feature featuregate.Feature) bool {
|
||||
if featureGate == nil {
|
||||
framework.Failf("feature gate interface is not initialized")
|
||||
}
|
||||
return featureGate.Enabled(feature)
|
||||
}
|
||||
|
||||
// SkipUnlessFeatureGateEnabled skips if the feature is disabled.
|
||||
//
|
||||
// Beware that this only works in test suites that have a --feature-gate
|
||||
|
@ -19,6 +19,7 @@ package e2enode
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||
"k8s.io/kubernetes/test/e2e/nodefeature"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -29,7 +30,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/rand"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@ -147,7 +147,7 @@ func runPodAndWaitUntilScheduled(f *framework.Framework, pod *v1.Pod) *v1.Pod {
|
||||
|
||||
func isSwapFeatureGateEnabled() bool {
|
||||
ginkgo.By("figuring if NodeSwap feature gate is turned on")
|
||||
return utilfeature.DefaultFeatureGate.Enabled(features.NodeSwap)
|
||||
return e2eskipper.IsFeatureGateEnabled(features.NodeSwap)
|
||||
}
|
||||
|
||||
func readCgroupFile(f *framework.Framework, pod *v1.Pod, filename string) string {
|
||||
|
Loading…
Reference in New Issue
Block a user