Add feature.LoadBalancer and remove provider-based skips from LB tests

This commit is contained in:
Dan Winship 2024-05-07 11:15:32 -04:00
parent 582a49599a
commit 2d5f148d4a
2 changed files with 27 additions and 43 deletions

View File

@ -175,6 +175,10 @@ var (
// TODO: document the feature (owning SIG, when to use this feature for a test) // TODO: document the feature (owning SIG, when to use this feature for a test)
LabelSelector = framework.WithFeature(framework.ValidFeatures.Add("LabelSelector")) LabelSelector = framework.WithFeature(framework.ValidFeatures.Add("LabelSelector"))
// Owner: sig-network
// Marks tests that require a cloud provider that implements LoadBalancer Services
LoadBalancer = framework.WithFeature(framework.ValidFeatures.Add("LoadBalancer"))
// TODO: document the feature (owning SIG, when to use this feature for a test) // TODO: document the feature (owning SIG, when to use this feature for a test)
LocalStorageCapacityIsolation = framework.WithFeature(framework.ValidFeatures.Add("LocalStorageCapacityIsolation")) LocalStorageCapacityIsolation = framework.WithFeature(framework.ValidFeatures.Add("LocalStorageCapacityIsolation"))

View File

@ -1,6 +1,3 @@
//go:build !providerless
// +build !providerless
/* /*
Copyright 2016 The Kubernetes Authors. Copyright 2016 The Kubernetes Authors.
@ -42,6 +39,7 @@ import (
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
podutil "k8s.io/kubernetes/pkg/api/v1/pod" podutil "k8s.io/kubernetes/pkg/api/v1/pod"
e2eapps "k8s.io/kubernetes/test/e2e/apps" e2eapps "k8s.io/kubernetes/test/e2e/apps"
"k8s.io/kubernetes/test/e2e/feature"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
e2edaemonset "k8s.io/kubernetes/test/e2e/framework/daemonset" e2edaemonset "k8s.io/kubernetes/test/e2e/framework/daemonset"
e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment" e2edeployment "k8s.io/kubernetes/test/e2e/framework/deployment"
@ -116,7 +114,7 @@ func getReadySchedulableWorkerNode(ctx context.Context, c clientset.Interface) (
return nil, fmt.Errorf("there are currently no ready, schedulable worker nodes in the cluster") return nil, fmt.Errorf("there are currently no ready, schedulable worker nodes in the cluster")
} }
var _ = common.SIGDescribe("LoadBalancers", func() { var _ = common.SIGDescribe("LoadBalancers", feature.LoadBalancer, func() {
f := framework.NewDefaultFramework("loadbalancers") f := framework.NewDefaultFramework("loadbalancers")
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
@ -133,13 +131,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
f.It("should be able to change the type and ports of a TCP service", f.WithSlow(), func(ctx context.Context) { f.It("should be able to change the type and ports of a TCP service", f.WithSlow(), func(ctx context.Context) {
// requires cloud load-balancer support // FIXME: need a better platform-independent timeout
e2eskipper.SkipUnlessProviderIs("gce", "gke", "aws") loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutAWS
loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutDefault
if framework.ProviderIs("aws") {
loadBalancerLagTimeout = e2eservice.LoadBalancerLagTimeoutAWS
}
loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs)
// This test is more monolithic than we'd like because LB turnup can be // This test is more monolithic than we'd like because LB turnup can be
@ -276,8 +269,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
f.It("should be able to change the type and ports of a UDP service", f.WithSlow(), func(ctx context.Context) { f.It("should be able to change the type and ports of a UDP service", f.WithSlow(), func(ctx context.Context) {
// requires cloud load-balancer support // FIXME: some cloud providers do not support UDP LoadBalancers
e2eskipper.SkipUnlessProviderIs("gce", "gke")
loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutDefault loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutDefault
loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs)
@ -428,9 +420,6 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
f.It("should only allow access from service loadbalancer source ranges", f.WithSlow(), func(ctx context.Context) { f.It("should only allow access from service loadbalancer source ranges", f.WithSlow(), func(ctx context.Context) {
// this feature currently supported only on GCE/GKE/AWS/AZURE
e2eskipper.SkipUnlessProviderIs("gce", "gke", "aws", "azure")
loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs)
namespace := f.Namespace.Name namespace := f.Namespace.Name
@ -513,8 +502,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
// [LinuxOnly]: Windows does not support session affinity. // [LinuxOnly]: Windows does not support session affinity.
f.It("should have session affinity work for LoadBalancer service with ESIPP on", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) { f.It("should have session affinity work for LoadBalancer service with ESIPP on", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) {
// L4 load balancer affinity `ClientIP` is not supported on AWS ELB. // FIXME: some cloud providers do not support k8s-compatible affinity
e2eskipper.SkipIfProviderIs("aws")
svc := getServeHostnameService("affinity-lb-esipp") svc := getServeHostnameService("affinity-lb-esipp")
svc.Spec.Type = v1.ServiceTypeLoadBalancer svc.Spec.Type = v1.ServiceTypeLoadBalancer
@ -524,8 +512,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
// [LinuxOnly]: Windows does not support session affinity. // [LinuxOnly]: Windows does not support session affinity.
f.It("should be able to switch session affinity for LoadBalancer service with ESIPP on", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) { f.It("should be able to switch session affinity for LoadBalancer service with ESIPP on", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) {
// L4 load balancer affinity `ClientIP` is not supported on AWS ELB. // FIXME: some cloud providers do not support k8s-compatible affinity
e2eskipper.SkipIfProviderIs("aws")
svc := getServeHostnameService("affinity-lb-esipp-transition") svc := getServeHostnameService("affinity-lb-esipp-transition")
svc.Spec.Type = v1.ServiceTypeLoadBalancer svc.Spec.Type = v1.ServiceTypeLoadBalancer
@ -535,8 +522,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
// [LinuxOnly]: Windows does not support session affinity. // [LinuxOnly]: Windows does not support session affinity.
f.It("should have session affinity work for LoadBalancer service with ESIPP off", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) { f.It("should have session affinity work for LoadBalancer service with ESIPP off", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) {
// L4 load balancer affinity `ClientIP` is not supported on AWS ELB. // FIXME: some cloud providers do not support k8s-compatible affinity
e2eskipper.SkipIfProviderIs("aws")
svc := getServeHostnameService("affinity-lb") svc := getServeHostnameService("affinity-lb")
svc.Spec.Type = v1.ServiceTypeLoadBalancer svc.Spec.Type = v1.ServiceTypeLoadBalancer
@ -546,8 +532,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
// [LinuxOnly]: Windows does not support session affinity. // [LinuxOnly]: Windows does not support session affinity.
f.It("should be able to switch session affinity for LoadBalancer service with ESIPP off", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) { f.It("should be able to switch session affinity for LoadBalancer service with ESIPP off", f.WithSlow(), "[LinuxOnly]", func(ctx context.Context) {
// L4 load balancer affinity `ClientIP` is not supported on AWS ELB. // FIXME: some cloud providers do not support k8s-compatible affinity
e2eskipper.SkipIfProviderIs("aws")
svc := getServeHostnameService("affinity-lb-transition") svc := getServeHostnameService("affinity-lb-transition")
svc.Spec.Type = v1.ServiceTypeLoadBalancer svc.Spec.Type = v1.ServiceTypeLoadBalancer
@ -594,13 +579,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
f.It("should be able to create LoadBalancer Service without NodePort and change it", f.WithSlow(), func(ctx context.Context) { f.It("should be able to create LoadBalancer Service without NodePort and change it", f.WithSlow(), func(ctx context.Context) {
// requires cloud load-balancer support // FIXME: need a better platform-independent timeout
e2eskipper.SkipUnlessProviderIs("gce", "gke", "aws") loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutAWS
loadBalancerLagTimeout := e2eservice.LoadBalancerLagTimeoutDefault
if framework.ProviderIs("aws") {
loadBalancerLagTimeout = e2eservice.LoadBalancerLagTimeoutAWS
}
loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) loadBalancerCreateTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs)
// This test is more monolithic than we'd like because LB turnup can be // This test is more monolithic than we'd like because LB turnup can be
@ -664,8 +644,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a LoadBalancer service on different nodes", func(ctx context.Context) { ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a LoadBalancer service on different nodes", func(ctx context.Context) {
// requires cloud load-balancer support // FIXME: some cloud providers do not support UDP LoadBalancers
e2eskipper.SkipUnlessProviderIs("gce", "gke", "azure")
ns := f.Namespace.Name ns := f.Namespace.Name
nodes, err := e2enode.GetBoundedReadySchedulableNodes(ctx, cs, 2) nodes, err := e2enode.GetBoundedReadySchedulableNodes(ctx, cs, 2)
framework.ExpectNoError(err) framework.ExpectNoError(err)
@ -796,8 +776,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a LoadBalancer service on the same nodes", func(ctx context.Context) { ginkgo.It("should be able to preserve UDP traffic when server pod cycles for a LoadBalancer service on the same nodes", func(ctx context.Context) {
// requires cloud load-balancer support // FIXME: some cloud providers do not support UDP LoadBalancers
e2eskipper.SkipUnlessProviderIs("gce", "gke", "azure")
ns := f.Namespace.Name ns := f.Namespace.Name
nodes, err := e2enode.GetBoundedReadySchedulableNodes(ctx, cs, 1) nodes, err := e2enode.GetBoundedReadySchedulableNodes(ctx, cs, 1)
framework.ExpectNoError(err) framework.ExpectNoError(err)
@ -946,7 +926,12 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
}) })
}) })
var _ = common.SIGDescribe("LoadBalancers ESIPP", framework.WithSlow(), func() { var _ = common.SIGDescribe("LoadBalancers ESIPP", feature.LoadBalancer, framework.WithSlow(), func() {
// FIXME: What are the expected semantics of requesting an
// "ExternalTrafficPolicy: Local" service from a cloud provider that does not
// support that? What are the expected semantics of "ExternalTrafficPolicy: Local"
// on `IPMode: Proxy`-type LoadBalancers?
f := framework.NewDefaultFramework("esipp") f := framework.NewDefaultFramework("esipp")
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
var loadBalancerCreateTimeout time.Duration var loadBalancerCreateTimeout time.Duration
@ -956,9 +941,6 @@ var _ = common.SIGDescribe("LoadBalancers ESIPP", framework.WithSlow(), func() {
var err error var err error
ginkgo.BeforeEach(func(ctx context.Context) { ginkgo.BeforeEach(func(ctx context.Context) {
// requires cloud load-balancer support - this feature currently supported only on GCE/GKE
e2eskipper.SkipUnlessProviderIs("gce", "gke")
cs = f.ClientSet cs = f.ClientSet
loadBalancerCreateTimeout = e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) loadBalancerCreateTimeout = e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs)
subnetPrefix, err = getSubnetPrefix(ctx, cs) subnetPrefix, err = getSubnetPrefix(ctx, cs)
@ -1415,10 +1397,8 @@ func testRollingUpdateLBConnectivityDisruption(ctx context.Context, f *framework
svcPort := int(service.Spec.Ports[0].Port) svcPort := int(service.Spec.Ports[0].Port)
ginkgo.By("Hitting the DaemonSet's pods through the service's load balancer") ginkgo.By("Hitting the DaemonSet's pods through the service's load balancer")
timeout := e2eservice.LoadBalancerLagTimeoutDefault // FIXME: need a better platform-independent timeout
if framework.ProviderIs("aws") { timeout := e2eservice.LoadBalancerLagTimeoutAWS
timeout = e2eservice.LoadBalancerLagTimeoutAWS
}
e2eservice.TestReachableHTTP(ctx, lbNameOrAddress, svcPort, timeout) e2eservice.TestReachableHTTP(ctx, lbNameOrAddress, svcPort, timeout)
ginkgo.By("Starting a goroutine to continuously hit the DaemonSet's pods through the service's load balancer") ginkgo.By("Starting a goroutine to continuously hit the DaemonSet's pods through the service's load balancer")