diff options
author | ignat <ignat@yandex-team.com> | 2024-09-05 10:15:33 +0300 |
---|---|---|
committer | ignat <ignat@yandex-team.com> | 2024-09-05 11:02:04 +0300 |
commit | 7797fb8f1275e6c9bc031e86d4075df929cd5295 (patch) | |
tree | ae2f80a5124cf8eb6476f3bf481007ddb0d87940 | |
parent | de89226020296884baebb46db1582db1359e21dd (diff) | |
download | ydb-7797fb8f1275e6c9bc031e86d4075df929cd5295.tar.gz |
YT-22751: Rename GetClientOpsFromEnv->GetClientOptionsFromEnv, move related tests to yt/yt/client/api/unittests
\[nodiff:caesar\]
878aead651e24a729a7613f0a0b3a33cde78814f
-rw-r--r-- | yt/yt/client/api/options.cpp | 6 | ||||
-rw-r--r-- | yt/yt/client/api/options.h | 4 | ||||
-rw-r--r-- | yt/yt/client/api/unittests/options_ut.cpp (renamed from yt/yt/client/cache/unittests/options_ut.cpp) | 12 | ||||
-rw-r--r-- | yt/yt/client/api/unittests/ya.make | 16 | ||||
-rw-r--r-- | yt/yt/client/cache/cache.cpp | 4 | ||||
-rw-r--r-- | yt/yt/client/cache/rpc.cpp | 4 | ||||
-rw-r--r-- | yt/yt/client/cache/unittests/ya.make | 1 | ||||
-rw-r--r-- | yt/yt/client/federated/unittests/cache_ut.cpp | 10 | ||||
-rw-r--r-- | yt/yt/client/ya.make | 1 |
9 files changed, 37 insertions, 21 deletions
diff --git a/yt/yt/client/api/options.cpp b/yt/yt/client/api/options.cpp index 7f30ab6092..c14982e645 100644 --- a/yt/yt/client/api/options.cpp +++ b/yt/yt/client/api/options.cpp @@ -12,7 +12,7 @@ namespace NYT::NApi { //////////////////////////////////////////////////////////////////////////////// -NApi::TClientOptions GetClientOpsFromEnv() +NApi::TClientOptions GetClientOptionsFromEnv() { NApi::TClientOptions options; @@ -37,9 +37,9 @@ NApi::TClientOptions GetClientOpsFromEnv() return options; } -const NApi::TClientOptions& GetClientOpsFromEnvStatic() +const NApi::TClientOptions& GetClientOptionsFromEnvStatic() { - static const NApi::TClientOptions options = GetClientOpsFromEnv(); + static const NApi::TClientOptions options = GetClientOptionsFromEnv(); return options; } diff --git a/yt/yt/client/api/options.h b/yt/yt/client/api/options.h index ba2c127c97..012a0341e5 100644 --- a/yt/yt/client/api/options.h +++ b/yt/yt/client/api/options.h @@ -13,10 +13,10 @@ namespace NYT::NApi { * UserName is extracted from YT_USER env variable or uses current system username. * Token is extracted from YT_TOKEN env variable or from file `~/.yt/token`. */ -TClientOptions GetClientOpsFromEnv(); +TClientOptions GetClientOptionsFromEnv(); //! Resolves options only once per launch and then returns the cached result. -const TClientOptions& GetClientOpsFromEnvStatic(); +const TClientOptions& GetClientOptionsFromEnvStatic(); //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/cache/unittests/options_ut.cpp b/yt/yt/client/api/unittests/options_ut.cpp index fd87cacc11..07cb357413 100644 --- a/yt/yt/client/cache/unittests/options_ut.cpp +++ b/yt/yt/client/api/unittests/options_ut.cpp @@ -10,7 +10,7 @@ #include <util/system/env.h> -namespace NYT::NClient::NCache { +namespace NYT::NApi { //////////////////////////////////////////////////////////////////////////////// @@ -29,7 +29,7 @@ TEST(TClientOptionsTest, TokenFromFile) {"YT_TOKEN", ""}, {"YT_TOKEN_PATH", ""}, }}; - const auto clientOptions = NApi::GetClientOpsFromEnv(); + const auto clientOptions = GetClientOptionsFromEnv(); EXPECT_TRUE(clientOptions.Token); EXPECT_EQ("AAAA-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", *clientOptions.Token); } @@ -46,7 +46,7 @@ TEST(TClientOptionsTest, TokenFromYtTokenPath) {"YT_TOKEN", ""}, {"YT_TOKEN_PATH", tokenPath}, }}; - const auto clientOptions = NApi::GetClientOpsFromEnv(); + const auto clientOptions = GetClientOptionsFromEnv(); EXPECT_TRUE(clientOptions.Token); EXPECT_EQ("BBBB-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", *clientOptions.Token); } @@ -54,7 +54,7 @@ TEST(TClientOptionsTest, TokenFromYtTokenPath) TEST(TClientOptionsTest, TokenFromEnv) { NTesting::TScopedEnvironment tokenGuard("YT_TOKEN", "BBBB-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); - const auto& clientOptions = NApi::GetClientOpsFromEnv(); + const auto& clientOptions = GetClientOptionsFromEnv(); EXPECT_TRUE(clientOptions.Token); EXPECT_EQ("BBBB-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", *clientOptions.Token); } @@ -65,7 +65,7 @@ TEST(TClientOptionsTest, UserFromEnv) {"YT_TOKEN", "BBBB-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"}, {"YT_USER", "yt_test_user"}, }}; - const auto& clientOptions = NApi::GetClientOpsFromEnv(); + const auto& clientOptions = GetClientOptionsFromEnv(); EXPECT_TRUE(clientOptions.User); EXPECT_EQ("yt_test_user", *clientOptions.User); } @@ -76,7 +76,7 @@ TEST(TClientOptionsTest, AllowEmptyUser) {"YT_TOKEN", "BBBB-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"}, {"YT_USER", ""}, }}; - const auto& clientOptions = NApi::GetClientOpsFromEnv(); + const auto& clientOptions = GetClientOptionsFromEnv(); EXPECT_TRUE(!clientOptions.User); } diff --git a/yt/yt/client/api/unittests/ya.make b/yt/yt/client/api/unittests/ya.make new file mode 100644 index 0000000000..54c35c9c28 --- /dev/null +++ b/yt/yt/client/api/unittests/ya.make @@ -0,0 +1,16 @@ +GTEST() + +INCLUDE(${ARCADIA_ROOT}/yt/ya_cpp.make.inc) + +SRCS( + options_ut.cpp +) + +INCLUDE(${ARCADIA_ROOT}/yt/opensource.inc) + +PEERDIR( + library/cpp/testing/common + yt/yt/client +) + +END() diff --git a/yt/yt/client/cache/cache.cpp b/yt/yt/client/cache/cache.cpp index 99137c4e46..4ff7559032 100644 --- a/yt/yt/client/cache/cache.cpp +++ b/yt/yt/client/cache/cache.cpp @@ -116,7 +116,7 @@ IClientsCachePtr CreateClientsCache( IClientsCachePtr CreateClientsCache(const TConnectionConfigPtr& config) { - return CreateClientsCache(config, NApi::GetClientOpsFromEnvStatic()); + return CreateClientsCache(config, NApi::GetClientOptionsFromEnvStatic()); } IClientsCachePtr CreateClientsCache(const NApi::TClientOptions& options) @@ -128,7 +128,7 @@ IClientsCachePtr CreateClientsCache(const NApi::TClientOptions& options) IClientsCachePtr CreateClientsCache() { - return CreateClientsCache(NApi::GetClientOpsFromEnvStatic()); + return CreateClientsCache(NApi::GetClientOptionsFromEnvStatic()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/cache/rpc.cpp b/yt/yt/client/cache/rpc.cpp index da65f90cba..da0200d5fc 100644 --- a/yt/yt/client/cache/rpc.cpp +++ b/yt/yt/client/cache/rpc.cpp @@ -60,12 +60,12 @@ NApi::IClientPtr CreateClient(const NApi::NRpcProxy::TConnectionConfigPtr& confi NApi::IClientPtr CreateClient(const NApi::NRpcProxy::TConnectionConfigPtr& config) { - return CreateClient(config, NApi::GetClientOpsFromEnvStatic()); + return CreateClient(config, NApi::GetClientOptionsFromEnvStatic()); } NApi::IClientPtr CreateClient(TStringBuf clusterUrl) { - return CreateClient(clusterUrl, NApi::GetClientOpsFromEnvStatic()); + return CreateClient(clusterUrl, NApi::GetClientOptionsFromEnvStatic()); } NApi::IClientPtr CreateClient(TStringBuf cluster, TStringBuf proxyRole) diff --git a/yt/yt/client/cache/unittests/ya.make b/yt/yt/client/cache/unittests/ya.make index e74573a87c..d395208a0b 100644 --- a/yt/yt/client/cache/unittests/ya.make +++ b/yt/yt/client/cache/unittests/ya.make @@ -4,7 +4,6 @@ INCLUDE(${ARCADIA_ROOT}/yt/ya_cpp.make.inc) SRCS( cache_ut.cpp - options_ut.cpp ) INCLUDE(${ARCADIA_ROOT}/yt/opensource.inc) diff --git a/yt/yt/client/federated/unittests/cache_ut.cpp b/yt/yt/client/federated/unittests/cache_ut.cpp index f66d41a383..e8d85797e3 100644 --- a/yt/yt/client/federated/unittests/cache_ut.cpp +++ b/yt/yt/client/federated/unittests/cache_ut.cpp @@ -22,7 +22,7 @@ TEST(TFederatedClientsCacheTest, GetSameClient) auto ytClientsCache = CreateFederatedClientsCache( New<TConnectionConfig>(), New<TClientsCacheConfig>(), - NApi::GetClientOpsFromEnvStatic()); + NApi::GetClientOptionsFromEnvStatic()); auto client1 = ytClientsCache->GetClient("localhost"); auto client2 = ytClientsCache->GetClient("localhost"); @@ -41,7 +41,7 @@ TEST(TFederatedClientsCacheTest, GetFederatedWithEmptyConfig) auto ytClientsCache = CreateFederatedClientsCache( New<TConnectionConfig>(), New<TClientsCacheConfig>(), - NApi::GetClientOpsFromEnvStatic()); + NApi::GetClientOptionsFromEnvStatic()); EXPECT_THROW( ytClientsCache->GetClient("primary+secondary"), @@ -61,7 +61,7 @@ TEST(TFederatedClientsCacheTest, ConfigurationAndClusterUrlMismatch1) auto ytClientsCache = CreateFederatedClientsCache( connectionConfig, New<TClientsCacheConfig>(), - NApi::GetClientOpsFromEnvStatic()); + NApi::GetClientOptionsFromEnvStatic()); EXPECT_THROW( ytClientsCache->GetClient("primary+tertiary"), @@ -83,7 +83,7 @@ TEST(TFederatedClientsCacheTest, ConfigurationAndClusterUrlMismatch2) auto ytClientsCache = CreateFederatedClientsCache( connectionConfig, New<TClientsCacheConfig>(), - NApi::GetClientOpsFromEnvStatic()); + NApi::GetClientOptionsFromEnvStatic()); EXPECT_THROW( ytClientsCache->GetClient("primary+tertiary"), @@ -103,7 +103,7 @@ TEST(TFederatedClientsCacheTest, ConfigurationMissingCluster) auto ytClientsCache = CreateFederatedClientsCache( connectionConfig, New<TClientsCacheConfig>(), - NApi::GetClientOpsFromEnvStatic()); + NApi::GetClientOptionsFromEnvStatic()); EXPECT_THROW( ytClientsCache->GetClient("primary+secondary+tertiary"), diff --git a/yt/yt/client/ya.make b/yt/yt/client/ya.make index 4eda047917..b9fc1d7953 100644 --- a/yt/yt/client/ya.make +++ b/yt/yt/client/ya.make @@ -227,6 +227,7 @@ RECURSE( ) RECURSE_FOR_TESTS( + api/unittests table_client/unittests unittests ) |