Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jan 16, 2018
1 parent cec4e62 commit 897c350
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) boo
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions(name, matcher))
}

// WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration
func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool) error {
// initial wait to allow the update of the ingress controller
time.Sleep(5 * time.Second)
return wait.PollImmediate(Poll, time.Minute*2, f.matchNginxConditions("", matcher))
}

// NginxLogs returns the logs of the nginx ingress controller pod running
func (f *Framework) NginxLogs() (string, error) {
l, err := f.KubeClientSet.CoreV1().Pods("ingress-nginx").List(metav1.ListOptions{
Expand Down Expand Up @@ -210,7 +217,13 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
return false, fmt.Errorf("unexpected number of nginx ingress controller pod is running (%v)", len(l.Items))
}

cmd := fmt.Sprintf("cat /etc/nginx/nginx.conf | awk '/## start server %v/,/## end server %v/'", name, name)
var cmd string
if name == "" {
cmd = fmt.Sprintf("cat /etc/nginx/nginx.conf")
} else {
cmd = fmt.Sprintf("cat /etc/nginx/nginx.conf | awk '/## start server %v/,/## end server %v/'", name, name)
}

o, err := f.ExecCommand(&l.Items[0], cmd)
if err != nil {
return false, err
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/settings/server_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() {
Expect(err).NotTo(HaveOccurred())
Expect(ing).NotTo(BeNil())

err = f.WaitForNginxServer(serverTokens,
err = f.WaitForNginxConfiguration(
func(server string) bool {
return strings.Contains(server, "server_tokens off") &&
strings.Contains(server, "more_set_headers \"Server: \"")
Expand Down Expand Up @@ -119,7 +119,7 @@ var _ = framework.IngressNginxDescribe("Server Tokens", func() {
Expect(err).NotTo(HaveOccurred())
Expect(ing).NotTo(BeNil())

err = f.WaitForNginxServer(serverTokens,
err = f.WaitForNginxConfiguration(
func(server string) bool {
return strings.Contains(server, "server_tokens on")
})
Expand Down

0 comments on commit 897c350

Please sign in to comment.