-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat dynamic_config: support Kill-switches
Tests: протестировано тестьютом и в тестинге commit_hash:1c7d271c30ba7d360077f2e14db7f7019983beb9
- Loading branch information
antonaksenov
committed
Nov 7, 2024
1 parent
281530e
commit 4ee4621
Showing
21 changed files
with
689 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
project(userver-core-tests-dynamic-configs CXX) | ||
|
||
add_executable(${PROJECT_NAME} "service.cpp") | ||
target_link_libraries(${PROJECT_NAME} userver-core) | ||
|
||
userver_chaos_testsuite_add() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# yaml | ||
server-name: test-dynamic-configs 1.0 | ||
service-name: test_dynamic_configs | ||
logger-level: info | ||
|
||
config-server-url: http://localhost:8083/ | ||
server-port: 8185 | ||
monitor-server-port: 8186 | ||
|
||
testsuite-enabled: false | ||
|
||
userver-dumps-root: /var/cache/test_dynamic_configs/userver-dumps/ | ||
access-log-path: /var/log/test_dynamic_configs/access.log | ||
access-tskv-log-path: /var/log/test_dynamic_configs/access_tskv.log | ||
default-log-path: /var/log/test_dynamic_configs/server.log | ||
|
||
config-cache: /var/cache/test_dynamic_configs/config_cache.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <string> | ||
|
||
#include <userver/utest/using_namespace_userver.hpp> | ||
|
||
#include <userver/alerts/handler.hpp> | ||
#include <userver/components/common_component_list.hpp> | ||
#include <userver/components/common_server_component_list.hpp> | ||
#include <userver/components/component.hpp> | ||
#include <userver/components/component_base.hpp> | ||
#include <userver/dynamic_config/source.hpp> | ||
#include <userver/dynamic_config/storage/component.hpp> | ||
#include <userver/server/handlers/ping.hpp> | ||
#include <userver/testsuite/testpoint.hpp> | ||
#include <userver/testsuite/testsuite_support.hpp> | ||
#include <userver/utils/daemon_run.hpp> | ||
|
||
namespace functional_tests { | ||
|
||
inline const dynamic_config::Key kTestConfig{"TEST_CONFIG_KEY", std::string("static_default")}; | ||
|
||
class DynamicConfigForwarder final : public components::ComponentBase { | ||
public: | ||
static constexpr std::string_view kName = "dynamic-config-forwarder"; | ||
|
||
DynamicConfigForwarder(const components::ComponentConfig& config, const components::ComponentContext& context) | ||
: components::ComponentBase(config, context), | ||
config_subscription_(context.FindComponent<components::DynamicConfig>().GetSource().UpdateAndListen( | ||
this, | ||
kName, | ||
&DynamicConfigForwarder::OnConfigUpdate | ||
)){}; | ||
|
||
private: | ||
void OnConfigUpdate(const dynamic_config::Snapshot& config) { | ||
TESTPOINT("config-update", [config] { | ||
return formats::json::ValueBuilder{config[kTestConfig]}.ExtractValue(); | ||
}()); | ||
} | ||
|
||
concurrent::AsyncEventSubscriberScope config_subscription_; | ||
}; | ||
|
||
} // namespace functional_tests | ||
|
||
int main(int argc, const char* const argv[]) { | ||
const auto component_list = components::ComponentList() | ||
.AppendComponentList(components::CommonComponentList()) | ||
.AppendComponentList(components::CommonServerComponentList()) | ||
.Append<functional_tests::DynamicConfigForwarder>() | ||
.Append<server::handlers::Ping>() | ||
.Append<alerts::Handler>(); | ||
return utils::DaemonMain(argc, argv, component_list); | ||
} |
156 changes: 156 additions & 0 deletions
156
core/functional_tests/dynamic_configs/static_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
components_manager: | ||
components: | ||
congestion-control: | ||
fake-mode: $testsuite-enabled | ||
load-enabled: true | ||
dump-configurator: | ||
dump-root: $userver-dumps-root | ||
handler-implicit-http-options: | ||
as_fallback: implicit-http-options | ||
method: OPTIONS | ||
task_processor: main-task-processor | ||
throttling_enabled: false | ||
dynamic-config-forwarder: | ||
handler-inspect-requests: | ||
path: /service/inspect-requests | ||
method: GET | ||
task_processor: monitor-task-processor | ||
handler-jemalloc: | ||
path: /service/jemalloc/prof/{command} | ||
method: POST | ||
task_processor: monitor-task-processor | ||
handler-log-level: | ||
path: /service/log-level/{level} | ||
method: GET,PUT | ||
task_processor: monitor-task-processor | ||
handler-on-log-rotate: | ||
path: /service/on-log-rotate/ | ||
method: POST | ||
task_processor: monitor-task-processor | ||
handler-dynamic-debug-log: | ||
path: /service/log/dynamic-debug | ||
method: GET,PUT,DELETE | ||
task_processor: monitor-task-processor | ||
handler-dns-client-control: | ||
path: /service/dnsclient/{command} | ||
method: POST | ||
task_processor: monitor-task-processor | ||
handler-server-monitor: | ||
path: /service/monitor | ||
method: GET | ||
task_processor: monitor-task-processor | ||
|
||
handler-ping: | ||
path: /ping | ||
method: GET | ||
task_processor: main-task-processor # !!! | ||
throttling_enabled: false | ||
url_trailing_slash: strict-match | ||
|
||
handler-fired-alerts: | ||
path: /service/fired-alerts | ||
method: GET | ||
task_processor: main-task-processor | ||
|
||
http-client: | ||
fs-task-processor: fs-task-processor | ||
user-agent: $server-name | ||
user-agent#fallback: 'userver-based-service 1.0' | ||
|
||
http-client-statistics: | ||
fs-task-processor: fs-task-processor | ||
pool-statistics-disable: true | ||
thread-name-prefix: stats | ||
user-agent: $server-name | ||
dns-client: | ||
fs-task-processor: fs-task-processor | ||
logging: | ||
fs-task-processor: fs-task-processor | ||
loggers: | ||
access: | ||
file_path: $access-log-path | ||
file_path#fallback: /var/log/company-name/service-name/access.log | ||
overflow_behavior: discard | ||
format: raw | ||
access-tskv: | ||
file_path: $access-tskv-log-path | ||
file_path#fallback: /var/log/company-name/service-name/access_tskv.log | ||
overflow_behavior: discard | ||
format: raw | ||
default: | ||
file_path: $default-log-path | ||
file_path#fallback: /var/log/company-name/service-name/server.log | ||
level: $logger-level | ||
level#fallback: info | ||
overflow_behavior: discard | ||
logging-configurator: | ||
limited-logging-enable: true | ||
limited-logging-interval: 1s | ||
server: | ||
listener: | ||
port: $server-port | ||
port#fallback: 8085 | ||
connection: | ||
in_buffer_size: 32768 | ||
requests_queue_size_threshold: 100 | ||
task_processor: main-task-processor | ||
listener-monitor: | ||
port: $monitor-server-port | ||
port#fallback: 8086 | ||
connection: | ||
in_buffer_size: 32768 | ||
requests_queue_size_threshold: 100 | ||
task_processor: monitor-task-processor | ||
logger_access: '' | ||
logger_access_tskv: '' | ||
max_response_size_in_flight: 1000000000 | ||
server-name: $server-name | ||
|
||
system-statistics-collector: | ||
fs-task-processor: fs-task-processor | ||
|
||
dynamic-config: | ||
updates-enabled: true | ||
fs-cache-path: $config-cache | ||
fs-task-processor: fs-task-processor | ||
dynamic-config-client: | ||
config-url: $config-server-url | ||
http-retries: 5 | ||
http-timeout: 20s | ||
service-name: $service-name | ||
dynamic-config-client-updater: | ||
config-settings: false | ||
first-update-fail-ok: true | ||
full-update-interval: 1m | ||
update-interval: 5s | ||
|
||
tests-control: | ||
load-enabled: $testsuite-enabled | ||
path: /tests/{action} | ||
method: POST | ||
task_processor: main-task-processor | ||
testpoint-timeout: 10s | ||
testpoint-url: $mockserver/testpoint | ||
throttling_enabled: false | ||
testsuite-support: | ||
|
||
|
||
|
||
|
||
|
||
default_task_processor: main-task-processor | ||
|
||
task_processors: | ||
fs-task-processor: | ||
worker_threads: $fs_worker_threads | ||
worker_threads#fallback: 2 | ||
main-task-processor: | ||
worker_threads: $main_worker_threads | ||
worker_threads#fallback: 6 | ||
monitor-task-processor: | ||
thread_name: mon-worker | ||
worker_threads: $monitor_worker_threads | ||
worker_threads#fallback: 1 | ||
event_thread_pool: | ||
threads: $event_threads | ||
threads#fallback: 2 |
Oops, something went wrong.