Fix sticky session for ingress without host

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-12-28 19:56:13 -03:00
parent 8db541e24b
commit 6c92c80073
4 changed files with 75 additions and 5 deletions

View file

@ -333,4 +333,28 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions",
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring("Path=/foo/bar"))
})
It("should set sticky cookie without host", func() {
annotations := map[string]string{
"nginx.ingress.kubernetes.io/affinity": "cookie",
"nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID",
}
ing := framework.NewSingleIngress("default-no-host", "/", "", f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer("_",
func(server string) bool {
return strings.Contains(server, "server_name _")
})
time.Sleep(waitForLuaSync)
resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTP)).
End()
Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(resp.Header.Get("Set-Cookie")).Should(ContainSubstring("SERVERID="))
})
})