mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 14:23:37 +00:00
Add unit test for checking dup NodePort with protocols
This commit is contained in:
parent
17515a9f87
commit
139c136494
@ -1570,6 +1570,92 @@ func TestUpdateNodePorts(t *testing.T) {
|
||||
},
|
||||
expectSpecifiedNodePorts: []int{},
|
||||
},
|
||||
{
|
||||
name: "Add new ServicePort with a different protocol without changing port numbers",
|
||||
oldService: &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
SessionAffinity: api.ServiceAffinityNone,
|
||||
Type: api.ServiceTypeNodePort,
|
||||
Ports: []api.ServicePort{
|
||||
{
|
||||
Name: "port-tcp",
|
||||
Port: 53,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
Protocol: api.ProtocolTCP,
|
||||
NodePort: 30053,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
newService: &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
SessionAffinity: api.ServiceAffinityNone,
|
||||
Type: api.ServiceTypeNodePort,
|
||||
Ports: []api.ServicePort{
|
||||
{
|
||||
Name: "port-tcp",
|
||||
Port: 53,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
Protocol: api.ProtocolTCP,
|
||||
NodePort: 30053,
|
||||
},
|
||||
{
|
||||
Name: "port-udp",
|
||||
Port: 53,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
Protocol: api.ProtocolUDP,
|
||||
NodePort: 30053,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectSpecifiedNodePorts: []int{30053, 30053},
|
||||
},
|
||||
{
|
||||
name: "Change service type from ClusterIP to NodePort with same NodePort number but different protocols",
|
||||
oldService: &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
SessionAffinity: api.ServiceAffinityNone,
|
||||
Type: api.ServiceTypeClusterIP,
|
||||
Ports: []api.ServicePort{{
|
||||
Port: 53,
|
||||
Protocol: api.ProtocolTCP,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
}},
|
||||
},
|
||||
},
|
||||
newService: &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
SessionAffinity: api.ServiceAffinityNone,
|
||||
Type: api.ServiceTypeNodePort,
|
||||
Ports: []api.ServicePort{
|
||||
{
|
||||
Name: "port-tcp",
|
||||
Port: 53,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
Protocol: api.ProtocolTCP,
|
||||
NodePort: 30053,
|
||||
},
|
||||
{
|
||||
Name: "port-udp",
|
||||
Port: 53,
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
Protocol: api.ProtocolUDP,
|
||||
NodePort: 30053,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectSpecifiedNodePorts: []int{30053, 30053},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user