Ensure headless service port equal to targetPort

This commit is contained in:
feihujiang
2015-11-27 16:09:13 +08:00
parent 70d2a02959
commit 81b095ee52
2 changed files with 37 additions and 2 deletions

View File

@@ -1874,6 +1874,33 @@ func TestValidateService(t *testing.T) {
},
numErrs: 1,
},
{
name: "valid port headless",
tweakSvc: func(s *api.Service) {
s.Spec.Ports[0].Port = 11722
s.Spec.Ports[0].TargetPort = intstr.FromInt(11722)
s.Spec.ClusterIP = api.ClusterIPNone
},
numErrs: 0,
},
{
name: "invalid port headless",
tweakSvc: func(s *api.Service) {
s.Spec.Ports[0].Port = 11722
s.Spec.Ports[0].TargetPort = intstr.FromInt(11721)
s.Spec.ClusterIP = api.ClusterIPNone
},
numErrs: 1,
},
{
name: "invalid port headless",
tweakSvc: func(s *api.Service) {
s.Spec.Ports[0].Port = 11722
s.Spec.Ports[0].TargetPort = intstr.FromString("target")
s.Spec.ClusterIP = api.ClusterIPNone
},
numErrs: 1,
},
{
name: "invalid publicIPs localhost",
tweakSvc: func(s *api.Service) {