mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
Add e2e test for checking dup NodePort with protocols
This commit is contained in:
parent
139c136494
commit
0c7ef059db
@ -803,6 +803,53 @@ var _ = SIGDescribe("Services", func() {
|
||||
}
|
||||
})
|
||||
|
||||
It("should be able to update NodePorts with two same port numbers but different protocols", func() {
|
||||
serviceName := "nodeport-update-service"
|
||||
ns := f.Namespace.Name
|
||||
jig := framework.NewServiceTestJig(cs, serviceName)
|
||||
|
||||
By("creating a TCP service " + serviceName + " with type=ClusterIP in namespace " + ns)
|
||||
tcpService := jig.CreateTCPServiceOrFail(ns, nil)
|
||||
defer func() {
|
||||
framework.Logf("Cleaning up the updating NodePorts test service")
|
||||
err := cs.Core().Services(ns).Delete(serviceName, nil)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}()
|
||||
jig.SanityCheckService(tcpService, v1.ServiceTypeClusterIP)
|
||||
svcPort := int(tcpService.Spec.Ports[0].Port)
|
||||
framework.Logf("service port TCP: %d", svcPort)
|
||||
|
||||
// Change the services to NodePort and add a UDP port.
|
||||
|
||||
By("changing the TCP service to type=NodePort and add a UDP port")
|
||||
newService := jig.UpdateServiceOrFail(ns, tcpService.Name, func(s *v1.Service) {
|
||||
s.Spec.Type = v1.ServiceTypeNodePort
|
||||
s.Spec.Ports = []v1.ServicePort{
|
||||
{
|
||||
Name: "tcp-port",
|
||||
Port: 80,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
Name: "udp-port",
|
||||
Port: 80,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
},
|
||||
}
|
||||
})
|
||||
jig.SanityCheckService(newService, v1.ServiceTypeNodePort)
|
||||
if len(newService.Spec.Ports) != 2 {
|
||||
framework.Failf("new service should have two Ports")
|
||||
}
|
||||
for _, port := range newService.Spec.Ports {
|
||||
if port.NodePort == 0 {
|
||||
framework.Failf("new service failed to allocate NodePort for Port %s", port.Name)
|
||||
}
|
||||
|
||||
framework.Logf("new service allocates NodePort %d for Port %s", port.NodePort, port.Name)
|
||||
}
|
||||
})
|
||||
|
||||
It("should be able to change the type from ExternalName to ClusterIP", func() {
|
||||
serviceName := "externalname-service"
|
||||
ns := f.Namespace.Name
|
||||
|
Loading…
Reference in New Issue
Block a user