Fix golangci-lint errors (#10196)
* Fix golangci-lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix dupl errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Fix errcheck lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix assert in e2e test Signed-off-by: z1cheng <imchench@gmail.com> * Not interrupt the waitForPodsReady Signed-off-by: z1cheng <imchench@gmail.com> * Replace string with constant Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Revert write file permision Signed-off-by: z1cheng <imchench@gmail.com> --------- Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
46d87d3462
commit
b3060bfbd0
253 changed files with 2434 additions and 2113 deletions
|
|
@ -29,48 +29,50 @@ import (
|
|||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
var pathtype = networking.PathTypePrefix
|
||||
var _ = framework.IngressNginxDescribe("[Service] backend status code 503", func() {
|
||||
f := framework.NewDefaultFramework("service-backend")
|
||||
var (
|
||||
pathtype = networking.PathTypePrefix
|
||||
_ = framework.IngressNginxDescribe("[Service] backend status code 503", func() {
|
||||
f := framework.NewDefaultFramework("service-backend")
|
||||
|
||||
ginkgo.It("should return 503 when backend service does not exist", func() {
|
||||
host := "nonexistent.svc.com"
|
||||
ginkgo.It("should return 503 when backend service does not exist", func() {
|
||||
host := "nonexistent.svc.com"
|
||||
|
||||
bi := buildIngressWithNonexistentService(host, f.Namespace, "/")
|
||||
f.EnsureIngress(bi)
|
||||
bi := buildIngressWithNonexistentService(host, f.Namespace, "/")
|
||||
f.EnsureIngress(bi)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "proxy_pass http://upstream_balancer;")
|
||||
})
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "proxy_pass http://upstream_balancer;")
|
||||
})
|
||||
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusServiceUnavailable)
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusServiceUnavailable)
|
||||
})
|
||||
|
||||
ginkgo.It("should return 503 when all backend service endpoints are unavailable", func() {
|
||||
host := "unavailable.svc.com"
|
||||
|
||||
bi, bs := buildIngressWithUnavailableServiceEndpoints(host, f.Namespace, "/")
|
||||
|
||||
f.EnsureService(bs)
|
||||
f.EnsureIngress(bi)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "proxy_pass http://upstream_balancer;")
|
||||
})
|
||||
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusServiceUnavailable)
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("should return 503 when all backend service endpoints are unavailable", func() {
|
||||
host := "unavailable.svc.com"
|
||||
|
||||
bi, bs := buildIngressWithUnavailableServiceEndpoints(host, f.Namespace, "/")
|
||||
|
||||
f.EnsureService(bs)
|
||||
f.EnsureIngress(bi)
|
||||
|
||||
f.WaitForNginxServer(host,
|
||||
func(server string) bool {
|
||||
return strings.Contains(server, "proxy_pass http://upstream_balancer;")
|
||||
})
|
||||
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusServiceUnavailable)
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
func buildIngressWithNonexistentService(host, namespace, path string) *networking.Ingress {
|
||||
backendService := "nonexistent-svc"
|
||||
|
|
@ -146,14 +148,15 @@ func buildIngressWithUnavailableServiceEndpoints(host, namespace, path string) (
|
|||
Name: backendService,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: corev1.ServiceSpec{Ports: []corev1.ServicePort{
|
||||
{
|
||||
Name: "tcp",
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(80),
|
||||
Protocol: "TCP",
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{
|
||||
Name: "tcp",
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(80),
|
||||
Protocol: "TCP",
|
||||
},
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
"app": backendService,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ import (
|
|||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
const echoHost = "echo"
|
||||
|
||||
var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
||||
f := framework.NewDefaultFramework("type-externalname", framework.WithHTTPBunEnabled())
|
||||
|
||||
ginkgo.It("works with external name set to incomplete fqdn", func() {
|
||||
f.NewEchoDeployment()
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -74,7 +76,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should return 200 for service type=ExternalName without a port defined", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -114,7 +116,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should return 200 for service type=ExternalName with a port defined", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := framework.BuildNIPExternalNameService(f, f.HTTPBunIP, host)
|
||||
f.EnsureService(svc)
|
||||
|
|
@ -144,7 +146,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should return status 502 for service type=ExternalName with an invalid host", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -180,7 +182,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should return 200 for service type=ExternalName using a port name", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := framework.BuildNIPExternalNameService(f, f.HTTPBunIP, host)
|
||||
f.EnsureService(svc)
|
||||
|
|
@ -221,7 +223,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should return 200 for service type=ExternalName using FQDN with trailing dot", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
@ -257,7 +259,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should update the external name after a service update", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
svc := framework.BuildNIPExternalNameService(f, f.HTTPBunIP, host)
|
||||
f.EnsureService(svc)
|
||||
|
|
@ -306,7 +308,7 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
Get(context.TODO(), framework.NIPService, metav1.GetOptions{})
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error obtaining external service")
|
||||
|
||||
//Deploy a new instance to switch routing to
|
||||
// Deploy a new instance to switch routing to
|
||||
ip := f.NewHttpbunDeployment(framework.WithDeploymentName("eu-server"))
|
||||
svc.Spec.ExternalName = framework.BuildNIPHost(ip)
|
||||
|
||||
|
|
@ -335,12 +337,12 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
|||
assert.Contains(
|
||||
ginkgo.GinkgoT(),
|
||||
output,
|
||||
fmt.Sprintf(`"address": "%s"`, framework.BuildNIPHost(ip)),
|
||||
fmt.Sprintf(`"address": %q`, framework.BuildNIPHost(ip)),
|
||||
)
|
||||
})
|
||||
|
||||
ginkgo.It("should sync ingress on external name service addition/deletion", func() {
|
||||
host := "echo"
|
||||
host := echoHost
|
||||
|
||||
// Create the Ingress first
|
||||
ing := framework.NewSingleIngress(host,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ var _ = framework.IngressNginxDescribe("[Service] Nil Service Backend", func() {
|
|||
WithHeader("Host", invalidHost).
|
||||
Expect().
|
||||
Status(http.StatusNotFound)
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue