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