e2e: add corresponding featuregate label to node features

there are many cases of an e2e feature being the main filtering mechanism for a test.
However, this makes it tricky for suite authors to filter tests based on available features.
This mechanism is still useful for e.g. making sure a runtime on a suite is of the correct level,
but in general we should both label tests with the Feature set they require (whether runtime is correct) as well
as the feature gates they test.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
Peter Hunt
2025-05-13 12:56:57 -04:00
parent cdf61cd150
commit c5e4cab9b1
5 changed files with 17 additions and 13 deletions

View File

@@ -34,6 +34,7 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/test/e2e/feature"
"k8s.io/kubernetes/test/e2e/framework"
@@ -729,7 +730,7 @@ done
})
})
var _ = SIGDescribe(feature.SidecarContainers, "Probing restartable init container", func() {
var _ = SIGDescribe(feature.SidecarContainers, framework.WithFeatureGate(features.SidecarContainers), "Probing restartable init container", func() {
f := framework.NewDefaultFramework("container-probe")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient

View File

@@ -26,6 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
utilrand "k8s.io/apimachinery/pkg/util/rand"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/test/e2e/feature"
"k8s.io/kubernetes/test/e2e/framework"
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
@@ -255,7 +256,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() {
})
})
var _ = SIGDescribe(feature.SidecarContainers, "Restartable Init Container Lifecycle Hook", func() {
var _ = SIGDescribe(feature.SidecarContainers, framework.WithFeatureGate(features.SidecarContainers), "Restartable Init Container Lifecycle Hook", func() {
f := framework.NewDefaultFramework("restartable-init-container-lifecycle-hook")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient
@@ -551,7 +552,7 @@ func validDuration(duration time.Duration, low, high int64) bool {
return duration >= time.Second*time.Duration(low) && duration <= time.Second*time.Duration(high)
}
var _ = SIGDescribe(feature.PodLifecycleSleepAction, func() {
var _ = SIGDescribe(feature.PodLifecycleSleepAction, framework.WithFeatureGate(features.PodLifecycleSleepAction), func() {
f := framework.NewDefaultFramework("pod-lifecycle-sleep-action")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient
@@ -630,7 +631,7 @@ var _ = SIGDescribe(feature.PodLifecycleSleepAction, func() {
})
})
var _ = SIGDescribe(feature.PodLifecycleSleepActionAllowZero, func() {
var _ = SIGDescribe(feature.PodLifecycleSleepActionAllowZero, framework.WithFeatureGate(features.PodLifecycleSleepActionAllowZero), func() {
f := framework.NewDefaultFramework("pod-lifecycle-sleep-action-allow-zero")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient
@@ -663,7 +664,7 @@ var _ = SIGDescribe(feature.PodLifecycleSleepActionAllowZero, func() {
})
})
var _ = SIGDescribe(feature.ContainerStopSignals, func() {
var _ = SIGDescribe(feature.ContainerStopSignals, framework.WithFeatureGate(features.ContainerStopSignals), func() {
f := framework.NewDefaultFramework("container-stop-signals")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var podClient *e2epod.PodClient

View File

@@ -27,6 +27,7 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/test/e2e/common/node/framework/cgroups"
"k8s.io/kubernetes/test/e2e/feature"
"k8s.io/kubernetes/test/e2e/framework"
@@ -41,7 +42,7 @@ var (
cmd = e2epod.InfiniteSleepCommand
)
var _ = SIGDescribe("Pod Level Resources", framework.WithSerial(), feature.PodLevelResources, func() {
var _ = SIGDescribe("Pod Level Resources", framework.WithSerial(), feature.PodLevelResources, framework.WithFeatureGate(features.PodLevelResources), func() {
f := framework.NewDefaultFramework("pod-level-resources-tests")
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged

View File

@@ -90,7 +90,7 @@ var _ = SIGDescribe("Security Context", func() {
}
}
f.It("must create the user namespace if set to false [LinuxOnly]", feature.UserNamespacesSupport, func(ctx context.Context) {
f.It("must create the user namespace if set to false [LinuxOnly]", feature.UserNamespacesSupport, framework.WithFeatureGate(features.UserNamespacesSupport), func(ctx context.Context) {
// with hostUsers=false the pod must use a new user namespace
podClient := e2epod.PodClientNS(f, f.Namespace.Name)
@@ -128,7 +128,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
f.It("must create the user namespace in the configured hostUID/hostGID range [LinuxOnly]", feature.UserNamespacesSupport, func(ctx context.Context) {
f.It("must create the user namespace in the configured hostUID/hostGID range [LinuxOnly]", feature.UserNamespacesSupport, framework.WithFeatureGate(features.UserNamespacesSupport), func(ctx context.Context) {
// We need to check with the binary "getsubuids" the mappings for the kubelet.
// If something is not present, we skip the test as the node wasn't configured to run this test.
id, length, err := kubeletUsernsMappings(getsubuidsBinary)
@@ -196,7 +196,7 @@ var _ = SIGDescribe("Security Context", func() {
}
})
f.It("must not create the user namespace if set to true [LinuxOnly]", feature.UserNamespacesSupport, func(ctx context.Context) {
f.It("must not create the user namespace if set to true [LinuxOnly]", feature.UserNamespacesSupport, framework.WithFeatureGate(features.UserNamespacesSupport), func(ctx context.Context) {
// with hostUsers=true the pod must use the host user namespace
pod := makePod(true)
// When running in the host's user namespace, the /proc/self/uid_map file content looks like:
@@ -207,7 +207,7 @@ var _ = SIGDescribe("Security Context", func() {
})
})
f.It("should mount all volumes with proper permissions with hostUsers=false [LinuxOnly]", feature.UserNamespacesSupport, func(ctx context.Context) {
f.It("should mount all volumes with proper permissions with hostUsers=false [LinuxOnly]", feature.UserNamespacesSupport, framework.WithFeatureGate(features.UserNamespacesSupport), func(ctx context.Context) {
// Create configmap.
name := "userns-volumes-test-" + string(uuid.NewUUID())
configMap := newConfigMap(f, name)
@@ -329,7 +329,7 @@ var _ = SIGDescribe("Security Context", func() {
})
})
f.It("should set FSGroup to user inside the container with hostUsers=false [LinuxOnly]", feature.UserNamespacesSupport, func(ctx context.Context) {
f.It("should set FSGroup to user inside the container with hostUsers=false [LinuxOnly]", feature.UserNamespacesSupport, framework.WithFeatureGate(features.UserNamespacesSupport), func(ctx context.Context) {
// Create configmap.
name := "userns-volumes-test-" + string(uuid.NewUUID())
configMap := newConfigMap(f, name)
@@ -969,7 +969,7 @@ var _ = SIGDescribe("User Namespaces for Pod Security Standards [LinuxOnly]", fu
f.NamespacePodSecurityLevel = admissionapi.LevelRestricted
ginkgo.Context("with UserNamespacesSupport and UserNamespacesPodSecurityStandards enabled", func() {
f.It("should allow pod", feature.UserNamespacesPodSecurityStandards, func(ctx context.Context) {
f.It("should allow pod", feature.UserNamespacesPodSecurityStandards, framework.WithFeatureGate(features.UserNamespacesSupport), framework.WithFeatureGate(features.UserNamespacesPodSecurityStandards), func(ctx context.Context) {
name := "pod-user-namespaces-pss-" + string(uuid.NewUUID())
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: name},

View File

@@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/features"
admissionapi "k8s.io/pod-security-admission/api"
"k8s.io/kubernetes/test/e2e/feature"
@@ -642,7 +643,7 @@ var _ = SIGDescribe("kubelet", func() {
})
})
var _ = SIGDescribe("specific log stream", feature.PodLogsQuerySplitStreams, func() {
var _ = SIGDescribe("specific log stream", feature.PodLogsQuerySplitStreams, framework.WithFeatureGate(features.PodLogsQuerySplitStreams), func() {
var (
c clientset.Interface
ns string