diff options
| author | robot-piglet <[email protected]> | 2025-02-09 19:59:01 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2025-02-09 20:15:02 +0300 |
| commit | 0a78c1bb2dd2d0f319a451b4c1b629f5fae3b5ea (patch) | |
| tree | acee9a05ae32c1821f7c1ba43ccbf72a53670f0f | |
| parent | 41e6f263ca838bea7b80defd749f859c860c5338 (diff) | |
Intermediate changes
commit_hash:9d5db254f665362d1d5bfe280aa0646f83e28474
| -rw-r--r-- | contrib/python/pytest-lazy-fixtures/.dist-info/METADATA | 5 | ||||
| -rw-r--r-- | contrib/python/pytest-lazy-fixtures/README.md | 3 | ||||
| -rw-r--r-- | contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py | 13 | ||||
| -rw-r--r-- | contrib/python/pytest-lazy-fixtures/ya.make | 2 | ||||
| -rw-r--r-- | yt/yt/client/cache/cache.cpp | 15 | ||||
| -rw-r--r-- | yt/yt/client/cache/cache.h | 7 | ||||
| -rw-r--r-- | yt/yt/client/cache/unittests/cache_ut.cpp | 22 |
7 files changed, 49 insertions, 18 deletions
diff --git a/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA b/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA index 8b36c5866f6..1b4fad41ee3 100644 --- a/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA +++ b/contrib/python/pytest-lazy-fixtures/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-lazy-fixtures -Version: 1.1.1 +Version: 1.1.2 Summary: Allows you to use fixtures in @pytest.mark.parametrize. Home-page: https://github.com/dev-petrov/pytest-lazy-fixtures License: MIT @@ -23,7 +23,8 @@ Description-Content-Type: text/markdown [](https://codecov.io/gh/dev-petrov/pytest-lazy-fixtures) [](https://github.com/dev-petrov/pytest-lazy-fixtures/actions/workflows/ci-test.yml) -[](https://badge.fury.io/py/pytest-lazy-fixtures) +[](https://pypi.org/project/pytest-lazy-fixtures/) +[](https://pypistats.org/packages/pytest-lazy-fixtures) Use your fixtures in `@pytest.mark.parametrize`. diff --git a/contrib/python/pytest-lazy-fixtures/README.md b/contrib/python/pytest-lazy-fixtures/README.md index ba6ff870da3..956c5335754 100644 --- a/contrib/python/pytest-lazy-fixtures/README.md +++ b/contrib/python/pytest-lazy-fixtures/README.md @@ -2,7 +2,8 @@ [](https://codecov.io/gh/dev-petrov/pytest-lazy-fixtures) [](https://github.com/dev-petrov/pytest-lazy-fixtures/actions/workflows/ci-test.yml) -[](https://badge.fury.io/py/pytest-lazy-fixtures) +[](https://pypi.org/project/pytest-lazy-fixtures/) +[](https://pypistats.org/packages/pytest-lazy-fixtures) Use your fixtures in `@pytest.mark.parametrize`. diff --git a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py index a11b04091da..3cea3a95501 100644 --- a/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py +++ b/contrib/python/pytest-lazy-fixtures/pytest_lazy_fixtures/lazy_fixture_callable.py @@ -1,3 +1,4 @@ +from inspect import isfunction from typing import Callable, Optional, Union import pytest @@ -10,12 +11,14 @@ class LazyFixtureCallableWrapper(LazyFixtureWrapper): args: tuple kwargs: dict - def __init__(self, func_or_name: Union[Callable, str], *args, **kwargs): - if callable(func_or_name): - self._func = func_or_name - self.name = func_or_name.__name__ + def __init__(self, callable_or_name: Union[Callable, str], *args, **kwargs): + if callable(callable_or_name): + self._func = callable_or_name + self.name = ( + callable_or_name.__name__ if isfunction(callable_or_name) else callable_or_name.__class__.__name__ + ) else: - self.name = func_or_name + self.name = callable_or_name self._func = None self.args = args self.kwargs = kwargs diff --git a/contrib/python/pytest-lazy-fixtures/ya.make b/contrib/python/pytest-lazy-fixtures/ya.make index 43c43a87f9d..fd0a21e535a 100644 --- a/contrib/python/pytest-lazy-fixtures/ya.make +++ b/contrib/python/pytest-lazy-fixtures/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(1.1.1) +VERSION(1.1.2) LICENSE(MIT) diff --git a/yt/yt/client/cache/cache.cpp b/yt/yt/client/cache/cache.cpp index c466dacd9ef..a4351334fda 100644 --- a/yt/yt/client/cache/cache.cpp +++ b/yt/yt/client/cache/cache.cpp @@ -82,17 +82,20 @@ IClientsCachePtr CreateClientsCache(const TClientsCacheConfigPtr& config, const } IClientsCachePtr CreateClientsCache( - const TConnectionConfigPtr& config, + const TConnectionConfigPtr& connectionConfig, const NApi::TClientOptions& options) { - auto clustersConfig = New<TClientsCacheConfig>(); - clustersConfig->DefaultConnection = CloneYsonStruct(config, /*postprocess*/ false, /*setDefaults*/ false); - return CreateClientsCache(clustersConfig, options); + auto config = New<TClientsCacheConfig>(); + config->DefaultConnection = CloneYsonStruct(connectionConfig, /*postprocess*/ false, /*setDefaults*/ false); + if (config->DefaultConnection->ClusterName) { + config->PerClusterConnection[*config->DefaultConnection->ClusterName] = config->DefaultConnection; + } + return CreateClientsCache(config, options); } -IClientsCachePtr CreateClientsCache(const TConnectionConfigPtr& config) +IClientsCachePtr CreateClientsCache(const TConnectionConfigPtr& connectionConfig) { - return CreateClientsCache(config, NApi::GetClientOptionsFromEnvStatic()); + return CreateClientsCache(connectionConfig, NApi::GetClientOptionsFromEnvStatic()); } IClientsCachePtr CreateClientsCache(const NApi::TClientOptions& options) diff --git a/yt/yt/client/cache/cache.h b/yt/yt/client/cache/cache.h index b7209d71fa1..c07ab7cf1c7 100644 --- a/yt/yt/client/cache/cache.h +++ b/yt/yt/client/cache/cache.h @@ -30,14 +30,15 @@ IClientsCachePtr CreateClientsCache(const TClientsCacheConfigPtr& config, const IClientsCachePtr CreateClientsCache(const TClientsCacheConfigPtr& config, const NApi::TClientOptions& defaultClientOptions); //! Creates clients cache which shares same config (except server name). +//! Note: It also registers a connection in the cache for getting a client from the cache by |connectionConfig.ClusterName|. IClientsCachePtr CreateClientsCache( - const NApi::NRpcProxy::TConnectionConfigPtr& config, + const NApi::NRpcProxy::TConnectionConfigPtr& connectionConfig, const NApi::TClientOptions& options); //! Shortcut to use client options from env. -IClientsCachePtr CreateClientsCache(const NApi::NRpcProxy::TConnectionConfigPtr& config); +IClientsCachePtr CreateClientsCache(const NApi::NRpcProxy::TConnectionConfigPtr& connectionConfig); -//! Shortcut to create cache with custom options and proxy role. +//! Shortcut to create cache with custom options and default config. IClientsCachePtr CreateClientsCache(const NApi::TClientOptions& options); //! Shortcut to create cache with default config. diff --git a/yt/yt/client/cache/unittests/cache_ut.cpp b/yt/yt/client/cache/unittests/cache_ut.cpp index e7e72d42916..d28344ea12e 100644 --- a/yt/yt/client/cache/unittests/cache_ut.cpp +++ b/yt/yt/client/cache/unittests/cache_ut.cpp @@ -1,6 +1,8 @@ #include <yt/yt/client/cache/cache.h> #include <yt/yt/client/cache/config.h> +#include <yt/yt/core/ytree/convert.h> + #include <library/cpp/testing/gtest/gtest.h> #include <library/cpp/yt/string/format.h> @@ -46,6 +48,26 @@ TEST(TClientsCacheTest, GetClientWithProxyRole) client2->GetConnection()->Terminate(); } +TEST(TClientsCacheTest, GetClientByClusteName) +{ + SetEnv("YT_TOKEN", "AAAA-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + auto connectionConfig = New<NApi::NRpcProxy::TConnectionConfig>(); + connectionConfig->ClusterName = "test"; + connectionConfig->ClusterUrl = "localhost"; + auto cache = CreateClientsCache(connectionConfig); + auto client = cache->GetClient("test"); + auto connection = client->GetConnection(); + + EXPECT_EQ("test", connection->GetClusterName()); + auto newConnectionConfig = NYTree::ConvertTo<NApi::NRpcProxy::TConnectionConfigPtr>(connection->GetConfigYson()); + EXPECT_EQ("localhost", newConnectionConfig->ClusterUrl); + + // This is needed for TConnection.OnProxyUpdate to stop + // and to remove references to TConnection that it's holding. + // It's because we don't actually create YT Server. + connection->Terminate(); +} + TEST(TClientsCacheTest, MultiThreads) { SetEnv("YT_TOKEN", "AAAA-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); |
