diff --git a/core/include/userver/testsuite/testsuite_support.hpp b/core/include/userver/testsuite/testsuite_support.hpp index d844e43bb5a2..a912ccab99c2 100644 --- a/core/include/userver/testsuite/testsuite_support.hpp +++ b/core/include/userver/testsuite/testsuite_support.hpp @@ -41,6 +41,7 @@ namespace components { /// testsuite-redis-timeout-single | minimum single shard timeout for redis | - /// testsuite-redis-timeout-all | minimum command timeout for redis | - /// testsuite-tasks-enabled | enable testsuite tasks facility | false +/// testsuite-increased-timeout | increase timeouts for connections, statement executions, RPC timeouts to avoid timeouts happening in testing environments, where the hardware differs from production. Overrides postgres, redis and grpc timeouts if these are missing | 0ms /// /// ## Static configuration example: /// @@ -67,12 +68,17 @@ class TestsuiteSupport final : public components::impl::ComponentBase { testsuite::TestsuiteTasks& GetTestsuiteTasks(); testsuite::HttpAllowedUrlsExtra& GetHttpAllowedUrlsExtra(); testsuite::GrpcControl& GetGrpcControl(); + /// @returns 0 if timeout was not increased via + /// `testsuite-increased-timeout` static option, + /// `testsuite-increased-timeout` value otherwise + std::chrono::milliseconds GetIncreasedTimeout() const noexcept; static yaml_config::Schema GetStaticConfigSchema(); private: void OnAllComponentsAreStopping() override; + const std::chrono::milliseconds increased_timeout_; testsuite::CacheControl cache_control_; testsuite::DumpControl dump_control_; testsuite::PeriodicTaskControl periodic_task_control_; diff --git a/core/src/components/common_component_list_test.cpp b/core/src/components/common_component_list_test.cpp index fa3f7ca2a8e7..14a646c8af36 100644 --- a/core/src/components/common_component_list_test.cpp +++ b/core/src/components/common_component_list_test.cpp @@ -78,6 +78,7 @@ constexpr std::string_view kStaticConfig = R"( testsuite-redis-timeout-connect: 5s testsuite-redis-timeout-single: 1s testsuite-redis-timeout-all: 750ms + testsuite-increased-timeout: 40s # /// [Sample testsuite support component config] # /// [Sample http client component config] # yaml diff --git a/core/src/testsuite/testsuite_support.cpp b/core/src/testsuite/testsuite_support.cpp index f20717a4e31d..bbd55d06293b 100644 --- a/core/src/testsuite/testsuite_support.cpp +++ b/core/src/testsuite/testsuite_support.cpp @@ -67,7 +67,10 @@ testsuite::GrpcControl ParseGrpcControl( TestsuiteSupport::TestsuiteSupport(const components::ComponentConfig& config, const components::ComponentContext&) - : cache_control_( + : increased_timeout_( + config["testsuite-increased-timeout"].As( + 0)), + cache_control_( ParsePeriodicUpdatesMode(config["testsuite-periodic-update-enabled"] .As>())), dump_control_(ParseDumpControl(config)), @@ -114,6 +117,11 @@ testsuite::GrpcControl& TestsuiteSupport::GetGrpcControl() { return grpc_control_; } +std::chrono::milliseconds TestsuiteSupport::GetIncreasedTimeout() const + noexcept { + return increased_timeout_; +} + yaml_config::Schema TestsuiteSupport::GetStaticConfigSchema() { return yaml_config::MergeSchemas(R"( type: object @@ -157,6 +165,10 @@ additionalProperties: false type: boolean description: Weather or not testsuite tasks are enabled defaultDescription: false + testsuite-increased-timeout: + type: string + description: increase timeouts in testing environments. Overrides postgres, redis and grpc timeouts if these are missing + defaultDescription: 0ms )"); }