Skip to content

Commit 2dc373a

Browse files
committed
feat core: add testsuite-increased-timeout option to TestsuiteSupport config
add `testsuite-increased-timeout` option to TestsuiteSupport config 8db3a5f4aa2719aa01a1bab39c5a8f092aa32258
1 parent 99bdb67 commit 2dc373a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

core/include/userver/testsuite/testsuite_support.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace components {
4141
/// testsuite-redis-timeout-single | minimum single shard timeout for redis | -
4242
/// testsuite-redis-timeout-all | minimum command timeout for redis | -
4343
/// testsuite-tasks-enabled | enable testsuite tasks facility | false
44+
/// 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
4445
///
4546
/// ## Static configuration example:
4647
///
@@ -67,12 +68,17 @@ class TestsuiteSupport final : public components::impl::ComponentBase {
6768
testsuite::TestsuiteTasks& GetTestsuiteTasks();
6869
testsuite::HttpAllowedUrlsExtra& GetHttpAllowedUrlsExtra();
6970
testsuite::GrpcControl& GetGrpcControl();
71+
/// @returns 0 if timeout was not increased via
72+
/// `testsuite-increased-timeout` static option,
73+
/// `testsuite-increased-timeout` value otherwise
74+
std::chrono::milliseconds GetIncreasedTimeout() const noexcept;
7075

7176
static yaml_config::Schema GetStaticConfigSchema();
7277

7378
private:
7479
void OnAllComponentsAreStopping() override;
7580

81+
const std::chrono::milliseconds increased_timeout_;
7682
testsuite::CacheControl cache_control_;
7783
testsuite::DumpControl dump_control_;
7884
testsuite::PeriodicTaskControl periodic_task_control_;

core/src/components/common_component_list_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ constexpr std::string_view kStaticConfig = R"(
7878
testsuite-redis-timeout-connect: 5s
7979
testsuite-redis-timeout-single: 1s
8080
testsuite-redis-timeout-all: 750ms
81+
testsuite-increased-timeout: 40s
8182
# /// [Sample testsuite support component config]
8283
# /// [Sample http client component config]
8384
# yaml

core/src/testsuite/testsuite_support.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ testsuite::GrpcControl ParseGrpcControl(
6767

6868
TestsuiteSupport::TestsuiteSupport(const components::ComponentConfig& config,
6969
const components::ComponentContext&)
70-
: cache_control_(
70+
: increased_timeout_(
71+
config["testsuite-increased-timeout"].As<std::chrono::milliseconds>(
72+
0)),
73+
cache_control_(
7174
ParsePeriodicUpdatesMode(config["testsuite-periodic-update-enabled"]
7275
.As<std::optional<bool>>())),
7376
dump_control_(ParseDumpControl(config)),
@@ -114,6 +117,11 @@ testsuite::GrpcControl& TestsuiteSupport::GetGrpcControl() {
114117
return grpc_control_;
115118
}
116119

120+
std::chrono::milliseconds TestsuiteSupport::GetIncreasedTimeout() const
121+
noexcept {
122+
return increased_timeout_;
123+
}
124+
117125
yaml_config::Schema TestsuiteSupport::GetStaticConfigSchema() {
118126
return yaml_config::MergeSchemas<impl::ComponentBase>(R"(
119127
type: object
@@ -157,6 +165,10 @@ additionalProperties: false
157165
type: boolean
158166
description: Weather or not testsuite tasks are enabled
159167
defaultDescription: false
168+
testsuite-increased-timeout:
169+
type: string
170+
description: increase timeouts in testing environments. Overrides postgres, redis and grpc timeouts if these are missing
171+
defaultDescription: 0ms
160172
)");
161173
}
162174

0 commit comments

Comments
 (0)