test timeouts

This commit is contained in:
Livio Spring 2024-12-04 07:23:41 +01:00
parent 14db628856
commit 498542c983
No known key found for this signature in database
GPG Key ID: 26BB1C2FA5952CF0
2 changed files with 10 additions and 4 deletions

View File

@ -76,6 +76,7 @@ type Config struct {
LogStore *logstore.Configs
Quotas *QuotasConfig
Telemetry *handlers.TelemetryPusherConfig
TimeoutTest test
}
type QuotasConfig struct {

View File

@ -344,7 +344,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
close(server)
}
return listen(ctx, router, config.Port, tlsConfig, shutdown)
return listen(ctx, router, config.Port, tlsConfig, shutdown, config.TimeoutTest)
}
func startAPIs(
@ -558,9 +558,14 @@ func startAPIs(
return apis, nil
}
func listen(ctx context.Context, router *mux.Router, port uint16, tlsConfig *tls.Config, shutdown <-chan os.Signal) error {
http2Server := &http2.Server{}
http1Server := &http.Server{Handler: h2c.NewHandler(router, http2Server), TLSConfig: tlsConfig}
type test struct {
IdleTimeout time.Duration
ReadTimeout time.Duration
}
func listen(ctx context.Context, router *mux.Router, port uint16, tlsConfig *tls.Config, shutdown <-chan os.Signal, test test) error {
http2Server := &http2.Server{IdleTimeout: test.IdleTimeout}
http1Server := &http.Server{Handler: h2c.NewHandler(router, http2Server), TLSConfig: tlsConfig, ReadTimeout: test.ReadTimeout, IdleTimeout: test.IdleTimeout}
lc := net.ListenConfig()
lis, err := lc.Listen(ctx, "tcp", fmt.Sprintf(":%d", port))