mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Move validation of load balancers only supporting TCP ports to validation.go.
This commit is contained in:
		@@ -1583,6 +1583,22 @@ func TestValidateService(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 1,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "invalid load balancer protocol 1",
 | 
			
		||||
			tweakSvc: func(s *api.Service) {
 | 
			
		||||
				s.Spec.CreateExternalLoadBalancer = true
 | 
			
		||||
				s.Spec.Ports[0].Protocol = "UDP"
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 1,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "invalid load balancer protocol 2",
 | 
			
		||||
			tweakSvc: func(s *api.Service) {
 | 
			
		||||
				s.Spec.CreateExternalLoadBalancer = true
 | 
			
		||||
				s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345, Protocol: "UDP"})
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 1,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "valid 1",
 | 
			
		||||
			tweakSvc: func(s *api.Service) {
 | 
			
		||||
@@ -1620,6 +1636,21 @@ func TestValidateService(t *testing.T) {
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 0,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "valid external load balancer",
 | 
			
		||||
			tweakSvc: func(s *api.Service) {
 | 
			
		||||
				s.Spec.CreateExternalLoadBalancer = true
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 0,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "valid external load balancer 2 ports",
 | 
			
		||||
			tweakSvc: func(s *api.Service) {
 | 
			
		||||
				s.Spec.CreateExternalLoadBalancer = true
 | 
			
		||||
				s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345, Protocol: "TCP"})
 | 
			
		||||
			},
 | 
			
		||||
			numErrs: 0,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tc := range testCases {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user