From 2389bbff8a50dc3a74c9fb98fac43bdb721303f2 Mon Sep 17 00:00:00 2001 From: antoshkka Date: Sun, 31 Mar 2024 19:55:01 +0300 Subject: [PATCH] feat docs: add changelog for March 2024 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests: протестировано локально и в CI 9be7181b472d5c699e564b5a42f833f1e5095f38 --- AUTHORS | 1 + .../basic_chaos/tests-deadline/test_client.py | 4 +- .../auth/digest/auth_checker_base.hpp | 3 +- .../ugrpc/client/impl/async_methods.hpp | 2 +- grpc/tests/src/wait_any_test.cpp | 2 +- .../metrics/tests/static/metrics_values.txt | 4 +- samples/testsuite-support/src/testpoint.cpp | 1 + samples/testsuite-support/tests/conftest.py | 1 + .../tests/test_logcapture.py | 2 +- scripts/docs/en/userver/functional_testing.md | 2 + .../docs/en/userver/roadmap_and_changelog.md | 68 +++++++++++++++++-- scripts/docs/en/userver/tutorial/build.md | 2 +- testsuite/SetupUserverTestsuiteEnv.cmake | 1 + .../pytest_plugins/pytest_userver/client.py | 16 ++++- .../pytest_userver/plugins/config.py | 17 ++++- .../include/userver/utils/default_dict.hpp | 2 + 16 files changed, 111 insertions(+), 17 deletions(-) diff --git a/AUTHORS b/AUTHORS index 54f87cac8aa0..ca7245dc9f5c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,6 +9,7 @@ Kulikov Vasily Lazarev Alexander Malkov Alexander Polukhin Antony +Rudenko Arkady Sudakov Dmitrii Trofimov Ivan Vatulin Aleksandr diff --git a/core/functional_tests/basic_chaos/tests-deadline/test_client.py b/core/functional_tests/basic_chaos/tests-deadline/test_client.py index fd2b839237db..5bedaf61cf38 100644 --- a/core/functional_tests/basic_chaos/tests-deadline/test_client.py +++ b/core/functional_tests/basic_chaos/tests-deadline/test_client.py @@ -89,7 +89,7 @@ async def test_timeout_expired( deadline, attempts, ): - async with service_client.capture_logs() as capture: + async with service_client.capture_logs(log_level='INFO') as capture: async with client_metrics: response = await call( headers={DP_TIMEOUT_MS: str(deadline)}, @@ -147,7 +147,7 @@ async def test_deadline_expired( deadline, attempts, ): - async with service_client.capture_logs() as capture: + async with service_client.capture_logs(log_level='INFO') as capture: async with client_metrics: response = await call( headers={DP_TIMEOUT_MS: str(deadline)}, diff --git a/core/include/userver/server/handlers/auth/digest/auth_checker_base.hpp b/core/include/userver/server/handlers/auth/digest/auth_checker_base.hpp index 1d6522d3b308..fa98cd023de0 100644 --- a/core/include/userver/server/handlers/auth/digest/auth_checker_base.hpp +++ b/core/include/userver/server/handlers/auth/digest/auth_checker_base.hpp @@ -35,7 +35,8 @@ class Hasher final { public: /// Constructor from the hash algorithm name from "crypto" namespace /// to be used for hashing and storages::secdist::SecdistConfig containing a - /// server secret key to be used for "nonce" generating. + /// server secret key `http_server_digest_auth_secret` + /// to be used for "nonce" generating. Hasher(std::string_view algorithm, const SecdistConfig& secdist_config); /// Returns "nonce" directive value in hexadecimal format. diff --git a/grpc/include/userver/ugrpc/client/impl/async_methods.hpp b/grpc/include/userver/ugrpc/client/impl/async_methods.hpp index 37c379e8ecb3..7a748252aa80 100644 --- a/grpc/include/userver/ugrpc/client/impl/async_methods.hpp +++ b/grpc/include/userver/ugrpc/client/impl/async_methods.hpp @@ -173,7 +173,7 @@ class RpcData final { // FinishAsyncMethodInvocation that will correctly close all our // tracing::Span objects and account everything in statistics. // In stream response, we use AsyncMethodInvocation for every intermediate - // Read* call, because we don't need to close span and/or accout stats + // Read* call, because we don't need to close span and/or account stats // when finishing Read* call. std::variant diff --git a/grpc/tests/src/wait_any_test.cpp b/grpc/tests/src/wait_any_test.cpp index 55ad7090b6d9..f72f545c303f 100644 --- a/grpc/tests/src/wait_any_test.cpp +++ b/grpc/tests/src/wait_any_test.cpp @@ -35,7 +35,7 @@ class AsyncTestService final : public sample::ugrpc::UnitTestServiceBase { // here, we have lock // drop flag back answers_count_--; - // lock is droped automatically upon exiting this scope + // lock is dropped automatically upon exiting this scope } if (!wait_result) { diff --git a/mongo/functional_tests/metrics/tests/static/metrics_values.txt b/mongo/functional_tests/metrics/tests/static/metrics_values.txt index 1c9627739c9f..333f351892ce 100644 --- a/mongo/functional_tests/metrics/tests/static/metrics_values.txt +++ b/mongo/functional_tests/metrics/tests/static/metrics_values.txt @@ -64,10 +64,10 @@ mongo.pool.conn-closed: mongo_database=key-value-database RATE 0 # Number of connections created since the service start mongo.pool.conn-created: mongo_database=key-value-database RATE 2 -# Connection initilization errors since the service start +# Connection initialization errors since the service start mongo.pool.conn-init.errors-total: mongo_database=key-value-database, mongo_error=total RATE 0 -# Connection initilization successes since the service start +# Connection initialization successes since the service start mongo.pool.conn-init.success: mongo_database=key-value-database RATE 2 # Connection initialization timings diff --git a/samples/testsuite-support/src/testpoint.cpp b/samples/testsuite-support/src/testpoint.cpp index 8e4dc792ae89..8dd1daadb524 100644 --- a/samples/testsuite-support/src/testpoint.cpp +++ b/samples/testsuite-support/src/testpoint.cpp @@ -1,6 +1,7 @@ #include "testpoint.hpp" /// [Testpoint - include] + #include /// [Testpoint - include] diff --git a/samples/testsuite-support/tests/conftest.py b/samples/testsuite-support/tests/conftest.py index 2a133d032d72..7c4d76a4eac8 100644 --- a/samples/testsuite-support/tests/conftest.py +++ b/samples/testsuite-support/tests/conftest.py @@ -1,3 +1,4 @@ # /// [testsuite - pytest_plugins] +# Adding a plugin from userver/testsuite/pytest_plugins/ pytest_plugins = ['pytest_userver.plugins.core'] # /// [testsuite - pytest_plugins] diff --git a/samples/testsuite-support/tests/test_logcapture.py b/samples/testsuite-support/tests/test_logcapture.py index e3ea729e36f3..09287ffaa069 100644 --- a/samples/testsuite-support/tests/test_logcapture.py +++ b/samples/testsuite-support/tests/test_logcapture.py @@ -1,6 +1,6 @@ # /// [select] async def test_select(service_client): - async with service_client.capture_logs() as capture: + async with service_client.capture_logs(log_level='INFO') as capture: response = await service_client.get('/logcapture') assert response.status == 200 diff --git a/scripts/docs/en/userver/functional_testing.md b/scripts/docs/en/userver/functional_testing.md index d36a32c311cd..cd2f55019cc2 100644 --- a/scripts/docs/en/userver/functional_testing.md +++ b/scripts/docs/en/userver/functional_testing.md @@ -355,6 +355,7 @@ Accessing testpoint userver is not aware of will raise an exception: * C++ code: @ref samples/testsuite-support/src/testpoint.cpp * Testcase: @ref samples/testsuite-support/tests/test_testpoint.py +@anchor testsuite_logs_capture #### Logs capture Testsuite can be used to test logs written by service. @@ -369,6 +370,7 @@ Example on logs capture usage could be found here: * C++ code: @ref samples/testsuite-support/src/logcapture.cpp * Testcase: @ref samples/testsuite-support/tests/test_logcapture.py + @anchor TESTSUITE_TASKS #### Testsuite tasks diff --git a/scripts/docs/en/userver/roadmap_and_changelog.md b/scripts/docs/en/userver/roadmap_and_changelog.md index b71124920061..19567fbc3619 100644 --- a/scripts/docs/en/userver/roadmap_and_changelog.md +++ b/scripts/docs/en/userver/roadmap_and_changelog.md @@ -21,11 +21,11 @@ Changelog news also go to the * ✓ LISTEN/NOTIFY support for PostgreSQL * ✓ New landing page for the website * ✓ Significantly reduce network data transmission for PostgreSQL -* Implement middlewares for HTTP server. -* Move most of the HTTP server functionality to middlewares. -* Document middlewares/plugins for HTTP client. +* ✓ Support `install` in CMake. +* ✓ Implement middlewares for HTTP server. +* ✓ Move most of the HTTP server functionality to middlewares. +* ✓ Document middlewares/plugins for HTTP client. * Codegen parsers and serializers by JSON schema -* Support `install` in CMake. * Add YDB driver. * Add retry budget or retry circuit breaker for clients. * Add web interface to the [uservice-dynconf](https://github.com/userver-framework/uservice-dynconf) @@ -34,6 +34,66 @@ Changelog news also go to the ## Changelog +### March 2024 + +* Installation via `cmake --install` was implemented. See @ref userver_install + for more info. +* Implemented @ref scripts/docs/en/userver/http_server_middlewares.md +* @ref USERVER_LOG_DYNAMIC_DEBUG now provides fine granted runtime control over + logging. +* Now all the modern versions of `libmongoc` are supported in `userver-mongo`. +* @ref POSTGRES_CONNLIMIT_MODE_AUTO_ENABLED is now `on` by default. +* A secret value for the digest nonce generating now could be provided in + `http_server_digest_auth_secret` key via components::Secdist. Many thanks to + [Mingaripov Niyaz](https://github.com/mnink275) for the PR! +* ugrpc::server::ServerComponent now has a `unix-socket-path` static option to + listen on unix domain socket path instead of an inet socket. +* All the `formats::*::ValueBuilder` now support std::string_view. Thanks to + Андрей Будиловский for the bug report! +* clients::http::Form is now movable and slightly more efficient. Thanks to + [Alexandr Kondratev](https://github.com/theg4sh) for the PR! +* Redis now supports `SSUBSCRIBE` and removes dead nodes. +* engine::WaitAny() now can wait for an engine::io::Socket/engine::io::TlsWrapper + to become readable or writable. For example: + `engine::WaitAny(socket.GetReadableBase(), task1, tls_socket.GetWritableBase(), future1);` +* New tracing::Span::MakeRootSpan() helper function. + +* Optimizations: + * Switched from unmaintained `http_parser` to a 156% faster `llhttp`. + * Implemented a concurrent::StripedCounter that allows to have a per-cpu data + in user space with kernel-provided transactional guarantees. Works + at least x2 faster than std::atomic on a single thread and scales + linearly (unlike std::atomic). As a result gives more than x10 performance + improvement under heavy contention. + * An explicit control over cache invalidations in testsuite. As a result, + less caches are invalidated between tests and the overall time to run tests + goes down significantly. + * Components start was optimized to copy less containers during component + dependencies detection. + * Per each incoming HTTP request: + * one less `std::chrono::steady_clock::now()` call + * one less `StrCaseHash` construction (2 calls into `std::uniform_int_distribution` over `std::mt19937`) + * one less `dynamic_config::Snapshot` construction (at least one atomic CAS) + * HTTP Clients now copies less std::shared_ptr`s in implementation. + * Optimized up to an order of magnitude the user types query in PostgreSQL + driver. + * pytest_userver.client.Client.capture_logs() now accepts `log_level` to + filter out messages with lower log level in the service itself and minimize + CPU and memory consumption during tests. + * Up to two times faster utils::statistics::RecentPeriod statistics in + PostgreSQL driver due to switching to a utils::datetime::SteadyCoarseClock. + +* Build: + * Workarounds for the Protobuf >= 5.26.0 + * Removed redundant semicolon, thanks to Oleksii Demchenko for the + [PR](https://github.com/userver-framework/userver/commit/b3abb84d6bb1da693). + * utils::FastScopeGuard now uses proper traits. Thanks to + [Илья Оплачкин](https://github.com/IoplachkinI) for the PR and to + [Artyom Kolpakov](https://github.com/ddvamp) for the report! + * Added missing dependency for Arch based distros. Thanks to + [VScdr](https://github.com/VS-CDR) for the PR! + + ### February 2024 * PostgreSQL driver now keeps processing the current queries and transactions diff --git a/scripts/docs/en/userver/tutorial/build.md b/scripts/docs/en/userver/tutorial/build.md index e4b1cc1d4ce1..574d5ad03533 100644 --- a/scripts/docs/en/userver/tutorial/build.md +++ b/scripts/docs/en/userver/tutorial/build.md @@ -422,7 +422,7 @@ find_package(userver REQUIRED COMPONENTS core postgresql grpc redis clickhouse m in your `CMakeLists.txt`. Choose only the necessary components. @see @ref userver_libraries -Finaly, link your source with userver component. +Finally, link your source with userver component. For instance: ``` diff --git a/testsuite/SetupUserverTestsuiteEnv.cmake b/testsuite/SetupUserverTestsuiteEnv.cmake index 79df158e354c..f48dbf1ca1bb 100644 --- a/testsuite/SetupUserverTestsuiteEnv.cmake +++ b/testsuite/SetupUserverTestsuiteEnv.cmake @@ -2,6 +2,7 @@ # It is not used for testing services based on userver. # /// [testsuite - UserverTestsuite] +# cmake include(UserverTestsuite) # /// [testsuite - UserverTestsuite] diff --git a/testsuite/pytest_plugins/pytest_userver/client.py b/testsuite/pytest_plugins/pytest_userver/client.py index 6751079dc5ed..03399dcd7d2b 100644 --- a/testsuite/pytest_plugins/pytest_userver/client.py +++ b/testsuite/pytest_plugins/pytest_userver/client.py @@ -1142,9 +1142,21 @@ def list_tasks(self) -> typing.List[str]: def spawn_task(self, name: str): return self._client.spawn_task(name) - def capture_logs(self, *, testsuite_skip_prepare: bool = False): + def capture_logs( + self, + *, + log_level: str = 'DEBUG', + testsuite_skip_prepare: bool = False, + ): + """ + Captures logs from the service. + + @param log_level Do not capture logs below this level. + + @see @ref testsuite_logs_capture + """ return self._client.capture_logs( - testsuite_skip_prepare=testsuite_skip_prepare, + log_level=log_level, testsuite_skip_prepare=testsuite_skip_prepare, ) @_wrap_client_error diff --git a/testsuite/pytest_plugins/pytest_userver/plugins/config.py b/testsuite/pytest_plugins/pytest_userver/plugins/config.py index 37b0bf269b85..e352b99a6433 100644 --- a/testsuite/pytest_plugins/pytest_userver/plugins/config.py +++ b/testsuite/pytest_plugins/pytest_userver/plugins/config.py @@ -400,12 +400,25 @@ def patch_config(config, config_vars): @pytest.fixture(scope='session') -def userver_default_log_level(): +def userver_default_log_level() -> str: + """ + Default log level to use in userver if no caoomand line option was provided. + + Returns 'debug'. + + @ingroup userver_testsuite_fixtures + """ return 'debug' @pytest.fixture(scope='session') -def userver_log_level(pytestconfig, userver_default_log_level): +def userver_log_level(pytestconfig, userver_default_log_level) -> str: + """ + Returns --service-log-level value if provided, otherwise returns + userver_default_log_level() value from fixture. + + @ingroup userver_testsuite_fixtures + """ if pytestconfig.option.service_log_level: return pytestconfig.option.service_log_level return userver_default_log_level diff --git a/universal/include/userver/utils/default_dict.hpp b/universal/include/userver/utils/default_dict.hpp index 9c02bdf53105..08817fe63cad 100644 --- a/universal/include/userver/utils/default_dict.hpp +++ b/universal/include/userver/utils/default_dict.hpp @@ -25,6 +25,8 @@ namespace impl { } // namespace impl +/// @ingroup userver_universal userver_containers +/// /// @brief Dictionary that for missing keys falls back to a default value /// stored by key utils::kDefaultDictDefaultName. ///