Skip to content

Commit

Permalink
Fix flaking e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jan 5, 2020
1 parent 9c0061f commit 2af6305
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
9 changes: 6 additions & 3 deletions test/e2e/defaultbackend/custom_default_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
"strings"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -37,19 +38,21 @@ var _ = framework.IngressNginxDescribe("Custom Default Backend", func() {
BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(1)

framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
func(deployment *appsv1.Deployment) error {
args := deployment.Spec.Template.Spec.Containers[0].Args
args = append(args, fmt.Sprintf("--default-backend-service=$(POD_NAMESPACE)/%v", framework.EchoService))
args = append(args, fmt.Sprintf("--default-backend-service=%v/%v", f.Namespace, framework.EchoService))
deployment.Spec.Template.Spec.Containers[0].Args = args
_, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment)

return err
})
Expect(err).NotTo(HaveOccurred())
time.Sleep(1 * time.Second)

f.WaitForNginxServer("_",
func(server string) bool {
return strings.Contains(server, "set $proxy_upstream_name \"upstream-default-backend\"")
return strings.Contains(server, `set $proxy_upstream_name "upstream-default-backend"`)
})
})

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ func (f *Framework) ScaleDeploymentToZero(name string) {
Expect(d).NotTo(BeNil(), "expected a deployment but none returned")

d.Spec.Replicas = NewInt32(0)
f.EnsureDeployment(d)

d = f.EnsureDeployment(d)
Expect(d).NotTo(BeNil(), "expected a deployment but none returned")
err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.Namespace, 0)
Expect(err).NotTo(HaveOccurred(), "failed to wait for no endpoints")
}
6 changes: 4 additions & 2 deletions test/e2e/gracefulshutdown/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() {
}

It("should shutdown after waiting 60 seconds for pending connections to be closed", func() {
framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
func(deployment *appsv1.Deployment) error {
grace := int64(3600)
deployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &grace
_, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment)
return err
})
Expect(err).NotTo(HaveOccurred())

annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-send-timeout": "600",
Expand Down Expand Up @@ -127,13 +128,14 @@ var _ = framework.IngressNginxDescribe("Shutdown ingress controller", func() {
})

It("should shutdown after waiting 150 seconds for pending connections to be closed", func() {
framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
func(deployment *appsv1.Deployment) error {
grace := int64(3600)
deployment.Spec.Template.Spec.TerminationGracePeriodSeconds = &grace
_, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment)
return err
})
Expect(err).NotTo(HaveOccurred())

annotations := map[string]string{
"nginx.ingress.kubernetes.io/proxy-send-timeout": "600",
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/settings/default_ssl_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = framework.IngressNginxDescribe("default-ssl-certificate", func() {
f.Namespace)
Expect(err).NotTo(HaveOccurred())

framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
err = framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
func(deployment *appsv1.Deployment) error {
args := deployment.Spec.Template.Spec.Containers[0].Args
args = append(args, "--default-ssl-certificate=$(POD_NAMESPACE)/"+secretName)
Expand All @@ -55,6 +55,7 @@ var _ = framework.IngressNginxDescribe("default-ssl-certificate", func() {

return err
})
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags")

// this asserts that it configures default custom ssl certificate without an ingress at all
framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig)
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/settings/disable_catch_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() {
BeforeEach(func() {
f.NewEchoDeploymentWithReplicas(1)

framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
func(deployment *appsv1.Deployment) error {
args := deployment.Spec.Template.Spec.Containers[0].Args
args = append(args, "--disable-catch-all=true")
Expand All @@ -46,6 +46,7 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() {

return err
})
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags")
})

AfterEach(func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/settings/ingress_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {

return err
})
Expect(err).To(BeNil())
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags")
})

It("should ignore Ingress with no class", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/settings/pod_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = framework.IngressNginxDescribe("Pod Security Policies", func() {

return err
})
Expect(err).NotTo(HaveOccurred())
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags")

f.NewEchoDeployment()
})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/settings/pod_security_policy_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var _ = framework.IngressNginxDescribe("Pod Security Policies with volumes", fun

return err
})
Expect(err).NotTo(HaveOccurred())
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment")

f.NewEchoDeployment()

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/status/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() {
}
}()

err = wait.Poll(10*time.Second, framework.DefaultTimeout, func() (done bool, err error) {
err = wait.Poll(10*time.Second, 4*time.Minute, func() (done bool, err error) {
ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(host, metav1.GetOptions{})
if err != nil {
return false, nil
Expand Down

0 comments on commit 2af6305

Please sign in to comment.