Skip to content

Commit

Permalink
Merge pull request #1739 from aledbf/cleanup-tests
Browse files Browse the repository at this point in the history
Improve e2e checks
  • Loading branch information
aledbf authored Nov 22, 2017
2 parents 51da945 + b6dfe3d commit 6657845
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
9 changes: 4 additions & 5 deletions test/e2e/annotations/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package annotations
import (
"fmt"
"net/http"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -78,8 +77,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name foo") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name foo")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -139,8 +138,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name foo") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name foo")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down
25 changes: 12 additions & 13 deletions test/e2e/annotations/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"net/http"
"os/exec"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -54,8 +53,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -83,8 +82,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).Should(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -117,8 +116,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -151,8 +150,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -186,8 +185,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -232,8 +231,8 @@ var _ = framework.IngressNginxDescribe("Annotations - Alias", func() {

err = f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "server_name auth") &&
!strings.Contains(server, "return 503")
return Expect(server).Should(ContainSubstring("server_name auth")) &&
Expect(server).ShouldNot(ContainSubstring("return 503"))
})
Expect(err).NotTo(HaveOccurred())

Expand Down
12 changes: 11 additions & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"

"github.com/golang/glog"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -215,7 +216,16 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
return false, err
}

if matcher(o) {
var match bool
errs := InterceptGomegaFailures(func() {
if matcher(o) {
match = true
}
})

glog.V(2).Infof("Errors waiting for conditions: %v", errs)

if match {
return true, nil
}

Expand Down

0 comments on commit 6657845

Please sign in to comment.