userver: userver/testsuite/testsuite_support.hpp Source File
Loading...
Searching...
No Matches
testsuite_support.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/testsuite/testsuite_support.hpp
4/// @brief @copybrief components::TestsuiteSupport
5
6#include <userver/components/raw_component_base.hpp>
7#include <userver/testsuite/cache_control.hpp>
8#include <userver/testsuite/dump_control.hpp>
9#include <userver/testsuite/grpc_control.hpp>
10#include <userver/testsuite/http_allowed_urls_extra.hpp>
11#include <userver/testsuite/periodic_task_control.hpp>
12#include <userver/testsuite/postgres_control.hpp>
13#include <userver/testsuite/redis_control.hpp>
14#include <userver/testsuite/testpoint_control.hpp>
15
16USERVER_NAMESPACE_BEGIN
17
18/// Testsuite integration
19namespace testsuite {
20class TestsuiteTasks;
21}
22
23namespace components {
24
25/// @ingroup userver_components
26///
27/// @brief Testsuite support component
28///
29/// Provides additional functionality for testing, e.g. forced cache updates.
30///
31/// ## Static options of components::TestsuiteSupport :
32/// @include{doc} scripts/docs/en/components_schema/core/src/testsuite/testsuite_support.md
33///
34/// Options inherited from @ref components::ComponentBase :
35/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
36///
37/// ## Static configuration example:
38///
39/// @snippet components/common_component_list_test.cpp Sample testsuite support component config
40class TestsuiteSupport final : public components::RawComponentBase {
41public:
42 /// @ingroup userver_component_names
43 /// @brief The default name of components::TestsuiteSupport
44 static constexpr std::string_view kName = "testsuite-support";
45
46 TestsuiteSupport(
47 const components::ComponentConfig& component_config,
48 const components::ComponentContext& component_context
49 );
50 ~TestsuiteSupport() override;
51
52 testsuite::CacheControl& GetCacheControl();
53 testsuite::DumpControl& GetDumpControl();
54 testsuite::PeriodicTaskControl& GetPeriodicTaskControl();
55 testsuite::TestpointControl& GetTestpointControl();
56 const testsuite::PostgresControl& GetPostgresControl();
57 const testsuite::RedisControl& GetRedisControl();
58 testsuite::TestsuiteTasks& GetTestsuiteTasks();
59 testsuite::HttpAllowedUrlsExtra& GetHttpAllowedUrlsExtra();
60 testsuite::GrpcControl& GetGrpcControl();
61 /// @returns 0 if timeout was not increased via
62 /// `testsuite-increased-timeout` static option,
63 /// `testsuite-increased-timeout` value otherwise
64 std::chrono::milliseconds GetIncreasedTimeout() const noexcept;
65
66 static yaml_config::Schema GetStaticConfigSchema();
67
68private:
69 void OnAllComponentsAreStopping() override;
70
71 const std::chrono::milliseconds increased_timeout_;
72 testsuite::CacheControl cache_control_;
73 testsuite::DumpControl dump_control_;
74 testsuite::PeriodicTaskControl periodic_task_control_;
75 testsuite::TestpointControl testpoint_control_;
76 testsuite::PostgresControl postgres_control_;
77 testsuite::RedisControl redis_control_;
78 std::unique_ptr<testsuite::TestsuiteTasks> testsuite_tasks_;
79 testsuite::HttpAllowedUrlsExtra http_allowed_urls_extra_;
80 testsuite::GrpcControl grpc_control_;
81};
82
83template <>
84inline constexpr bool kHasValidate<TestsuiteSupport> = true;
85
86} // namespace components
87
88USERVER_NAMESPACE_END