mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
Move two SCTP tests
There were two SCTP tests grouped together in test/e2e/network/service.go, but one of them wasn't a service test... so move the SCTP service test to be grouped with the other service tests, and the SCTP hostport tests to be grouped with other non-service tests.
This commit is contained in:
@@ -29,10 +29,12 @@ import (
|
||||
"k8s.io/kubernetes/pkg/cluster/ports"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
||||
"k8s.io/kubernetes/test/e2e/network/common"
|
||||
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
@@ -632,4 +634,35 @@ var _ = common.SIGDescribe("Networking", func() {
|
||||
}
|
||||
framework.ExpectNoError(err, "kubelet did not recreate its iptables rules")
|
||||
})
|
||||
|
||||
ginkgo.It("should allow creating a Pod with an SCTP HostPort [LinuxOnly]", func(ctx context.Context) {
|
||||
node, err := e2enode.GetRandomReadySchedulableNode(f.ClientSet)
|
||||
framework.ExpectNoError(err)
|
||||
hostExec := utils.NewHostExec(f)
|
||||
ginkgo.DeferCleanup(hostExec.Cleanup)
|
||||
|
||||
ginkgo.By("getting the state of the sctp module on the selected node")
|
||||
nodes := &v1.NodeList{}
|
||||
nodes.Items = append(nodes.Items, *node)
|
||||
sctpLoadedAtStart := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
|
||||
ginkgo.By("creating a pod with hostport on the selected node")
|
||||
podName := "hostport"
|
||||
ports := []v1.ContainerPort{{Protocol: v1.ProtocolSCTP, ContainerPort: 5060, HostPort: 5060}}
|
||||
podSpec := e2epod.NewAgnhostPod(f.Namespace.Name, podName, nil, nil, ports)
|
||||
nodeSelection := e2epod.NodeSelection{Name: node.Name}
|
||||
e2epod.SetNodeSelection(&podSpec.Spec, nodeSelection)
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Launching the pod on node %v", node.Name))
|
||||
e2epod.NewPodClient(f).CreateSync(podSpec)
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Delete(ctx, podName, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", podName, f.Namespace.Name)
|
||||
})
|
||||
ginkgo.By("validating sctp module is still not loaded")
|
||||
sctpLoadedAtEnd := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
if !sctpLoadedAtStart && sctpLoadedAtEnd {
|
||||
framework.Failf("The state of the sctp module has changed due to the test case")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@@ -70,7 +70,6 @@ import (
|
||||
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
|
||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||
"k8s.io/kubernetes/test/e2e/network/common"
|
||||
"k8s.io/kubernetes/test/e2e/storage/utils"
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
|
||||
@@ -3781,6 +3780,59 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
e2epod.DeletePodOrFail(cs, ns, podname1)
|
||||
})
|
||||
|
||||
ginkgo.It("should allow creating a basic SCTP service with pod and endpoints [LinuxOnly]", func(ctx context.Context) {
|
||||
serviceName := "sctp-endpoint-test"
|
||||
ns := f.Namespace.Name
|
||||
jig := e2eservice.NewTestJig(cs, ns, serviceName)
|
||||
|
||||
ginkgo.By("getting the state of the sctp module on nodes")
|
||||
nodes, err := e2enode.GetBoundedReadySchedulableNodes(cs, 2)
|
||||
framework.ExpectNoError(err)
|
||||
sctpLoadedAtStart := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
|
||||
ginkgo.By("creating service " + serviceName + " in namespace " + ns)
|
||||
_, err = jig.CreateSCTPServiceWithPort(nil, 5060)
|
||||
framework.ExpectNoError(err)
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
err := cs.CoreV1().Services(ns).Delete(ctx, serviceName, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete service: %s in namespace: %s", serviceName, ns)
|
||||
})
|
||||
|
||||
err = e2enetwork.WaitForService(f.ClientSet, ns, serviceName, true, 5*time.Second, e2eservice.TestTimeout)
|
||||
framework.ExpectNoError(err, fmt.Sprintf("error while waiting for service:%s err: %v", serviceName, err))
|
||||
|
||||
ginkgo.By("validating endpoints do not exist yet")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{})
|
||||
|
||||
ginkgo.By("creating a pod for the service")
|
||||
names := map[string]bool{}
|
||||
|
||||
name1 := "pod1"
|
||||
|
||||
createPodOrFail(f, ns, name1, jig.Labels, []v1.ContainerPort{{ContainerPort: 5060, Protocol: v1.ProtocolSCTP}})
|
||||
names[name1] = true
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
for name := range names {
|
||||
err := cs.CoreV1().Pods(ns).Delete(ctx, name, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", name, ns)
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.By("validating endpoints exists")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{name1: {5060}})
|
||||
|
||||
ginkgo.By("deleting the pod")
|
||||
e2epod.DeletePodOrFail(cs, ns, name1)
|
||||
delete(names, name1)
|
||||
ginkgo.By("validating endpoints do not exist anymore")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{})
|
||||
|
||||
ginkgo.By("validating sctp module is still not loaded")
|
||||
sctpLoadedAtEnd := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
if !sctpLoadedAtStart && sctpLoadedAtEnd {
|
||||
framework.Failf("The state of the sctp module has changed due to the test case")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// execAffinityTestForSessionAffinityTimeout is a helper function that wrap the logic of
|
||||
@@ -4310,99 +4362,3 @@ func validatePortsAndProtocols(ep, expectedEndpoints fullPortsByPodUID) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ = common.SIGDescribe("SCTP [LinuxOnly]", func() {
|
||||
f := framework.NewDefaultFramework("sctp")
|
||||
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
|
||||
|
||||
var cs clientset.Interface
|
||||
|
||||
ginkgo.BeforeEach(func() {
|
||||
cs = f.ClientSet
|
||||
})
|
||||
|
||||
ginkgo.It("should allow creating a basic SCTP service with pod and endpoints", func(ctx context.Context) {
|
||||
serviceName := "sctp-endpoint-test"
|
||||
ns := f.Namespace.Name
|
||||
jig := e2eservice.NewTestJig(cs, ns, serviceName)
|
||||
|
||||
ginkgo.By("getting the state of the sctp module on nodes")
|
||||
nodes, err := e2enode.GetBoundedReadySchedulableNodes(cs, 2)
|
||||
framework.ExpectNoError(err)
|
||||
sctpLoadedAtStart := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
|
||||
ginkgo.By("creating service " + serviceName + " in namespace " + ns)
|
||||
_, err = jig.CreateSCTPServiceWithPort(nil, 5060)
|
||||
framework.ExpectNoError(err)
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
err := cs.CoreV1().Services(ns).Delete(ctx, serviceName, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete service: %s in namespace: %s", serviceName, ns)
|
||||
})
|
||||
|
||||
err = e2enetwork.WaitForService(f.ClientSet, ns, serviceName, true, 5*time.Second, e2eservice.TestTimeout)
|
||||
framework.ExpectNoError(err, fmt.Sprintf("error while waiting for service:%s err: %v", serviceName, err))
|
||||
|
||||
ginkgo.By("validating endpoints do not exist yet")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{})
|
||||
|
||||
ginkgo.By("creating a pod for the service")
|
||||
names := map[string]bool{}
|
||||
|
||||
name1 := "pod1"
|
||||
|
||||
createPodOrFail(f, ns, name1, jig.Labels, []v1.ContainerPort{{ContainerPort: 5060, Protocol: v1.ProtocolSCTP}})
|
||||
names[name1] = true
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
for name := range names {
|
||||
err := cs.CoreV1().Pods(ns).Delete(ctx, name, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", name, ns)
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.By("validating endpoints exists")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{name1: {5060}})
|
||||
|
||||
ginkgo.By("deleting the pod")
|
||||
e2epod.DeletePodOrFail(cs, ns, name1)
|
||||
delete(names, name1)
|
||||
ginkgo.By("validating endpoints do not exist anymore")
|
||||
validateEndpointsPortsOrFail(cs, ns, serviceName, portsByPodName{})
|
||||
|
||||
ginkgo.By("validating sctp module is still not loaded")
|
||||
sctpLoadedAtEnd := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
if !sctpLoadedAtStart && sctpLoadedAtEnd {
|
||||
framework.Failf("The state of the sctp module has changed due to the test case")
|
||||
}
|
||||
})
|
||||
|
||||
ginkgo.It("should allow creating a Pod with an SCTP HostPort", func(ctx context.Context) {
|
||||
node, err := e2enode.GetRandomReadySchedulableNode(cs)
|
||||
framework.ExpectNoError(err)
|
||||
hostExec := utils.NewHostExec(f)
|
||||
ginkgo.DeferCleanup(hostExec.Cleanup)
|
||||
|
||||
ginkgo.By("getting the state of the sctp module on the selected node")
|
||||
nodes := &v1.NodeList{}
|
||||
nodes.Items = append(nodes.Items, *node)
|
||||
sctpLoadedAtStart := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
|
||||
ginkgo.By("creating a pod with hostport on the selected node")
|
||||
podName := "hostport"
|
||||
ports := []v1.ContainerPort{{Protocol: v1.ProtocolSCTP, ContainerPort: 5060, HostPort: 5060}}
|
||||
podSpec := e2epod.NewAgnhostPod(f.Namespace.Name, podName, nil, nil, ports)
|
||||
nodeSelection := e2epod.NodeSelection{Name: node.Name}
|
||||
e2epod.SetNodeSelection(&podSpec.Spec, nodeSelection)
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Launching the pod on node %v", node.Name))
|
||||
e2epod.NewPodClient(f).CreateSync(podSpec)
|
||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||
err := cs.CoreV1().Pods(f.Namespace.Name).Delete(ctx, podName, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "failed to delete pod: %s in namespace: %s", podName, f.Namespace.Name)
|
||||
})
|
||||
ginkgo.By("validating sctp module is still not loaded")
|
||||
sctpLoadedAtEnd := CheckSCTPModuleLoadedOnNodes(f, nodes)
|
||||
if !sctpLoadedAtStart && sctpLoadedAtEnd {
|
||||
framework.Failf("The state of the sctp module has changed due to the test case")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user