@@ -35,16 +35,17 @@ import (
3535 "k8s.io/ingress-nginx/test/e2e/framework"
3636)
3737
38- const echoHost = "echo"
38+ const (
39+ echoHost = "echo"
40+ host = "grpc"
41+ )
3942
4043var _ = framework .DescribeAnnotation ("backend-protocol - GRPC" , func () {
4144 f := framework .NewDefaultFramework ("grpc" , framework .WithHTTPBunEnabled ())
4245
4346 ginkgo .It ("should use grpc_pass in the configuration file" , func () {
4447 f .NewGRPCFortuneTellerDeployment ()
4548
46- host := "grpc"
47-
4849 annotations := map [string ]string {
4950 "nginx.ingress.kubernetes.io/backend-protocol" : "GRPC" ,
5051 }
@@ -259,4 +260,48 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
259260 metadata := res .GetMetadata ()
260261 assert .Equal (ginkgo .GinkgoT (), metadata ["content-type" ].Values [0 ], "application/grpc" )
261262 })
263+
264+ ginkgo .It ("should set valid grpc timeouts for grpc" , func () {
265+ proxyConnectTimeout := "5"
266+ proxySendTimeout := "30"
267+ proxyReadtimeout := "30"
268+
269+ annotations := make (map [string ]string )
270+ annotations ["nginx.ingress.kubernetes.io/backend-protocol" ] = "grpc"
271+ annotations ["nginx.ingress.kubernetes.io/proxy-connect-timeout" ] = proxyConnectTimeout
272+ annotations ["nginx.ingress.kubernetes.io/proxy-send-timeout" ] = proxySendTimeout
273+ annotations ["nginx.ingress.kubernetes.io/proxy-read-timeout" ] = proxyReadtimeout
274+
275+ ing := framework .NewSingleIngress (host , "/" , host , f .Namespace , framework .EchoService , 80 , annotations )
276+ f .EnsureIngress (ing )
277+
278+ f .WaitForNginxServer (host ,
279+ func (server string ) bool {
280+ return strings .Contains (server , fmt .Sprintf ("grpc_connect_timeout %ss;" , proxyConnectTimeout )) &&
281+ strings .Contains (server , fmt .Sprintf ("grpc_send_timeout %ss;" , proxySendTimeout )) &&
282+ strings .Contains (server , fmt .Sprintf ("grpc_read_timeout %ss;" , proxyReadtimeout ))
283+ })
284+ })
285+
286+ ginkgo .It ("should set valid grpc timeouts for grpcs" , func () {
287+ proxyConnectTimeout := "5"
288+ proxySendTimeout := "30"
289+ proxyReadtimeout := "30"
290+
291+ annotations := make (map [string ]string )
292+ annotations ["nginx.ingress.kubernetes.io/backend-protocol" ] = "grpcs"
293+ annotations ["nginx.ingress.kubernetes.io/proxy-connect-timeout" ] = proxyConnectTimeout
294+ annotations ["nginx.ingress.kubernetes.io/proxy-send-timeout" ] = proxySendTimeout
295+ annotations ["nginx.ingress.kubernetes.io/proxy-read-timeout" ] = proxyReadtimeout
296+
297+ ing := framework .NewSingleIngress (host , "/" , host , f .Namespace , framework .EchoService , 80 , annotations )
298+ f .EnsureIngress (ing )
299+
300+ f .WaitForNginxServer (host ,
301+ func (server string ) bool {
302+ return strings .Contains (server , fmt .Sprintf ("grpc_connect_timeout %ss;" , proxyConnectTimeout )) &&
303+ strings .Contains (server , fmt .Sprintf ("grpc_send_timeout %ss;" , proxySendTimeout )) &&
304+ strings .Contains (server , fmt .Sprintf ("grpc_read_timeout %ss;" , proxyReadtimeout ))
305+ })
306+ })
262307})
0 commit comments