Refactored client body buffer size TC-s.

This commit is contained in:
Balazs Szekeres 2020-03-02 13:06:21 +01:00
parent 5c2c052361
commit a182ca799b

View file

@ -17,6 +17,7 @@ limitations under the License.
package annotations package annotations
import ( import (
"fmt"
"strings" "strings"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
@ -32,92 +33,98 @@ var _ = framework.DescribeAnnotation("client-body-buffer-size", func() {
}) })
ginkgo.It("should set client_body_buffer_size to 1000", func() { ginkgo.It("should set client_body_buffer_size to 1000", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1000", clientBodyBufferSize := "1000"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "client_body_buffer_size 1000;") return strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
ginkgo.It("should set client_body_buffer_size to 1K", func() { ginkgo.It("should set client_body_buffer_size to 1K", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1K", clientBodyBufferSize := "1K"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "client_body_buffer_size 1K;") return strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
ginkgo.It("should set client_body_buffer_size to 1k", func() { ginkgo.It("should set client_body_buffer_size to 1k", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1k", clientBodyBufferSize := "1k"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "client_body_buffer_size 1k;") return strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
ginkgo.It("should set client_body_buffer_size to 1m", func() { ginkgo.It("should set client_body_buffer_size to 1m", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1m", clientBodyBufferSize := "1m"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "client_body_buffer_size 1m;") return strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
ginkgo.It("should set client_body_buffer_size to 1M", func() { ginkgo.It("should set client_body_buffer_size to 1M", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1M", clientBodyBufferSize := "1M"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return strings.Contains(server, "client_body_buffer_size 1M;") return strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
ginkgo.It("should not set client_body_buffer_size to invalid 1b", func() { ginkgo.It("should not set client_body_buffer_size to invalid 1b", func() {
host := "proxy.foo.com" host := "client-body-buffer-size.com"
annotations := map[string]string{
"nginx.ingress.kubernetes.io/client-body-buffer-size": "1b", clientBodyBufferSize := "1b"
} annotations := make(map[string]string)
annotations["nginx.ingress.kubernetes.io/client-body-buffer-size"] = clientBodyBufferSize
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations) ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing) f.EnsureIngress(ing)
f.WaitForNginxServer(host, f.WaitForNginxServer(host,
func(server string) bool { func(server string) bool {
return !strings.Contains(server, "client_body_buffer_size 1b;") return !strings.Contains(server, fmt.Sprintf("client_body_buffer_size %s;", clientBodyBufferSize))
}) })
}) })
}) })