Просмотр исходного кода

Intermediate changes
commit_hash:42cbd3d6db0c8793544ceb2bba9ad42631021f52

robot-piglet 4 месяцев назад
Родитель
Сommit
ec272cd814

+ 13 - 2
yt/yt/core/rpc/unittests/lib/common.h

@@ -143,6 +143,11 @@ public:
         return false;
     }
 
+    static int GetMaxSimultaneousRequestCount()
+    {
+        return TImpl::MaxSimultaneousRequestCount;
+    }
+
 private:
     NConcurrency::IThreadPoolPtr WorkerPool_;
     TTestNodeMemoryTrackerPtr MemoryUsageTracker_;
@@ -158,6 +163,7 @@ class TRpcOverBus
 public:
     static constexpr bool AllowTransportErrors = false;
     static constexpr bool Secure = false;
+    static constexpr int MaxSimultaneousRequestCount = 1000;
 
     static TTestServerHostPtr CreateTestServerHost(
         NTesting::TPortHolder port,
@@ -361,6 +367,7 @@ class TRpcOverGrpcImpl
 public:
     static constexpr bool AllowTransportErrors = true;
     static constexpr bool Secure = EnableSsl;
+    static constexpr int MaxSimultaneousRequestCount = 1000;
 
     static IChannelPtr CreateChannel(
         const std::string& address,
@@ -467,6 +474,10 @@ public:
     // TODO(melkov): Fill ssl_credentials_ext in server code and enable the Secure flag.
     static constexpr bool Secure = false;
 
+    // HTTP will use at least two file descriptors per test connection.
+    // Allow tests to run when the limit for the file descriptors is low.
+    static constexpr int MaxSimultaneousRequestCount = 400;
+
     static IChannelPtr CreateChannel(
         const std::string& address,
         const std::string& /*serverAddress*/,
@@ -475,9 +486,9 @@ public:
         static auto poller = NConcurrency::CreateThreadPoolPoller(4, "HttpChannelTest");
         auto credentials = New<NHttps::TClientCredentialsConfig>();
         credentials->PrivateKey = New<NCrypto::TPemBlobConfig>();
-        credentials->PrivateKey->Value = ServerKey;
+        credentials->PrivateKey->Value = ClientKey;
         credentials->CertChain = New<NCrypto::TPemBlobConfig>();
-        credentials->CertChain->Value = ServerCert;
+        credentials->CertChain->Value = ClientCert;
         return NHttp::CreateHttpChannel(address, poller, EnableSsl, credentials);
     }
 

+ 3 - 0
yt/yt/core/rpc/unittests/lib/test_service.cpp

@@ -109,6 +109,9 @@ public:
     DECLARE_RPC_SERVICE_METHOD(NTestRpc, AllocationCall)
     {
         context->SetRequestInfo();
+        if (request->wait_on_latch()) {
+            Latch_()->Wait();
+        }
         response->set_allocated_string(TString("r", request->size()));
         context->Reply();
     }

+ 1 - 0
yt/yt/core/rpc/unittests/lib/test_service.proto

@@ -36,6 +36,7 @@ message TRspPassCall
 message TReqAllocationCall
 {
     required int64 size = 1;
+    optional bool wait_on_latch = 2 [default = true];
 }
 
 message TRspAllocationCall

+ 8 - 1
yt/yt/core/rpc/unittests/rpc_allocation_tags_ut.cpp

@@ -47,6 +47,8 @@ TYPED_TEST(TRpcTest, ResponseWithAllocationTags)
 
     TTestProxy proxy(this->CreateChannel());
 
+    MaybeInitLatch();
+
     constexpr auto size = 4_MB - 1_KB;
     constexpr auto numberOfLoops = 10;
     for (int i = 0; i < numberOfLoops; ++i) {
@@ -80,12 +82,17 @@ TYPED_TEST(TRpcTest, ResponseWithAllocationTags)
     }
 
     auto memoryUsageBefore = CollectMemoryUsageSnapshot()->GetUsage(MemoryAllocationTag, ToString(testMemoryTag));
-    EXPECT_LE(memoryUsageBefore, numberOfLoops * 2048_KB);
+    EXPECT_LE(memoryUsageBefore, numberOfLoops * 2048_KB)
+        << "InitialUsage: " << initialMemoryUsage << std::endl;
+
+    ReleaseLatchedCalls();
 
     for (const auto& rsp : responses) {
         WaitFor(rsp).ValueOrThrow();
     }
 
+    ResetLatch();
+
     auto memoryUsageAfter = CollectMemoryUsageSnapshot()->GetUsage(MemoryAllocationTag, ToString(testMemoryTag));
     auto deltaMemoryUsage = memoryUsageAfter - initialMemoryUsage - memoryUsageBefore;
     EXPECT_GE(deltaMemoryUsage, numberOfLoops * size * 6 / 5)

+ 1 - 3
yt/yt/core/rpc/unittests/rpc_ut.cpp

@@ -473,7 +473,7 @@ TYPED_TEST(TNotGrpcTest, DisableAcceptsBaggage)
 
 TYPED_TEST(TRpcTest, ManyAsyncRequests)
 {
-    const int RequestCount = 1000;
+    const int RequestCount = this->GetMaxSimultaneousRequestCount();
 
     std::vector<TFuture<void>> asyncResults;
 
@@ -622,8 +622,6 @@ TYPED_TEST(TNotGrpcTest, Compression)
 
 TYPED_TEST(TRpcTest, ResponseMemoryTag)
 {
-    // FIXME: YT-23048
-    return;
     static TMemoryTag testMemoryTag = 12345;
     testMemoryTag++;
     auto initialMemoryUsage = GetMemoryUsageForTag(testMemoryTag);