Fix tests

This commit is contained in:
Manuel de Brito Fontes 2018-01-16 16:46:18 -03:00
parent cec4e62eae
commit 897c350c3d
2 changed files with 16 additions and 3 deletions

View file

@ -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{
@ -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

View file

@ -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: \"")
@ -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")
})