aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/server/http_ut.cpp
diff options
context:
space:
mode:
authorkulikov <kulikov@yandex-team.com>2023-08-22 22:35:57 +0300
committerkulikov <kulikov@yandex-team.com>2023-08-22 22:51:44 +0300
commitd6e7da05041ff86e301b9546870b41211945aec2 (patch)
tree4bbe1aafd7e1938ed0a57d2e642c66608ff6760b /library/cpp/http/server/http_ut.cpp
parent7c7ade4dcfda98626af0dd7eb774a855ba1111f5 (diff)
downloadydb-d6e7da05041ff86e301b9546870b41211945aec2.tar.gz
one shot poller
With WaitReadOneShot: - there is no need to do Unwait on connection activation, one less syscall per request; - this allows to make several listener threads over one epoll poller. Turn option on for search daemons (check it turned on by default here https://a.yandex-team.ru/review/4372795/details).
Diffstat (limited to 'library/cpp/http/server/http_ut.cpp')
-rw-r--r--library/cpp/http/server/http_ut.cpp77
1 files changed, 41 insertions, 36 deletions
diff --git a/library/cpp/http/server/http_ut.cpp b/library/cpp/http/server/http_ut.cpp
index a74e31c37e..b953a4ef2a 100644
--- a/library/cpp/http/server/http_ut.cpp
+++ b/library/cpp/http/server/http_ut.cpp
@@ -830,31 +830,33 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
TShooter shooter(threadCount, port);
TString res = TestData();
- TEchoServer serverImpl(res);
- THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true));
- for (size_t i = 0; i < 100; ++i) {
- UNIT_ASSERT(server.Start());
- shooter.WaitProgress();
-
- {
- auto before = shooter.GetCounters();
+ for (bool oneShot : {true, false}) {
+ TEchoServer serverImpl(res);
+ THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true).SetOneShotPoll(oneShot));
+ for (size_t i = 0; i < 100; ++i) {
+ UNIT_ASSERT(server.Start());
shooter.WaitProgress();
- auto after = shooter.GetCounters();
- for (size_t i = 0; i < before.size(); ++i) {
- UNIT_ASSERT(before[i].Success < after[i].Success);
- UNIT_ASSERT(before[i].Fail == after[i].Fail);
+
+ {
+ auto before = shooter.GetCounters();
+ shooter.WaitProgress();
+ auto after = shooter.GetCounters();
+ for (size_t i = 0; i < before.size(); ++i) {
+ UNIT_ASSERT(before[i].Success < after[i].Success);
+ UNIT_ASSERT(before[i].Fail == after[i].Fail);
+ }
}
- }
- server.Stop();
- shooter.WaitProgress();
- {
- auto before = shooter.GetCounters();
+ server.Stop();
shooter.WaitProgress();
- auto after = shooter.GetCounters();
- for (size_t i = 0; i < before.size(); ++i) {
- UNIT_ASSERT(before[i].Success == after[i].Success);
- UNIT_ASSERT(before[i].Fail < after[i].Fail);
+ {
+ auto before = shooter.GetCounters();
+ shooter.WaitProgress();
+ auto after = shooter.GetCounters();
+ for (size_t i = 0; i < before.size(); ++i) {
+ UNIT_ASSERT(before[i].Success == after[i].Success);
+ UNIT_ASSERT(before[i].Fail < after[i].Fail);
+ }
}
}
}
@@ -881,27 +883,30 @@ Y_UNIT_TEST_SUITE(THttpServerTest) {
const size_t maxConnections = 5;
TString res = TestData();
- TMaxConnServer serverImpl(res);
- THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true).SetMaxConnections(maxConnections));
- UNIT_ASSERT(server.Start());
+ for (bool oneShot : {true, false}) {
+ TMaxConnServer serverImpl(res);
+ THttpServer server(&serverImpl, THttpServer::TOptions(port).EnableKeepAlive(true).SetMaxConnections(maxConnections).SetOneShotPoll(oneShot));
- TShooter shooter(maxConnections + 1, port);
+ UNIT_ASSERT(server.Start());
- for (size_t i = 0; i < 100; ++i) {
- const size_t prev = serverImpl.MaxConns.load();
- while (serverImpl.MaxConns.load() < prev + 100) {
- Sleep(TDuration::MilliSeconds(1));
+ TShooter shooter(maxConnections + 1, port);
+
+ for (size_t i = 0; i < 100; ++i) {
+ const size_t prev = serverImpl.MaxConns.load();
+ while (serverImpl.MaxConns.load() < prev + 100) {
+ Sleep(TDuration::MilliSeconds(1));
+ }
}
- }
- shooter.Stop();
- server.Stop();
+ shooter.Stop();
+ server.Stop();
- for (const auto& c : shooter.GetCounters()) {
- UNIT_ASSERT(c.Success > 0);
- UNIT_ASSERT(c.Fail > 0);
- UNIT_ASSERT(c.Success > c.Fail);
+ for (const auto& c : shooter.GetCounters()) {
+ UNIT_ASSERT(c.Success > 0);
+ UNIT_ASSERT(c.Fail > 0);
+ UNIT_ASSERT(c.Success > c.Fail);
+ }
}
}
}