Fix service type external name using the name

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-08-15 12:09:42 -04:00
parent 6948cd7d65
commit 816f4b0824
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
2 changed files with 58 additions and 5 deletions

View file

@ -177,4 +177,45 @@ var _ = framework.IngressNginxDescribe("Service Type ExternalName", func() {
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(503))
})
It("should return 200 for service type=ExternalName using a port name", func() {
host := "echo"
svc := &core.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "httpbin",
Namespace: f.Namespace,
},
Spec: corev1.ServiceSpec{
ExternalName: "httpbin.org",
Type: corev1.ServiceTypeExternalName,
Ports: []corev1.ServicePort{
{
Name: host,
Port: 80,
TargetPort: intstr.FromInt(80),
Protocol: "TCP",
},
},
},
}
f.EnsureService(svc)
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, "httpbin", 80, nil)
ing.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort = intstr.FromString(host)
f.EnsureIngress(ing)
f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "proxy_pass http://upstream_balancer;")
})
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)+"/get").
Set("Host", host).
End()
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(200))
})
})