aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/rain_check
diff options
context:
space:
mode:
authorluckygeck <luckygeck@yandex-team.ru>2022-02-10 16:49:18 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:18 +0300
commit48ea53d4c114c948fa16fee5ec66de2552c93471 (patch)
treed443cad34860b58886dc7725a27c7fe0c9b5fe13 /library/cpp/messagebus/rain_check
parent30f4921b0fa8722e5531e72cb40a93b526f6973a (diff)
downloadydb-48ea53d4c114c948fa16fee5ec66de2552c93471.tar.gz
Restoring authorship annotation for <luckygeck@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/rain_check')
-rw-r--r--library/cpp/messagebus/rain_check/http/client.cpp22
-rw-r--r--library/cpp/messagebus/rain_check/http/client.h12
-rw-r--r--library/cpp/messagebus/rain_check/http/client_ut.cpp44
3 files changed, 39 insertions, 39 deletions
diff --git a/library/cpp/messagebus/rain_check/http/client.cpp b/library/cpp/messagebus/rain_check/http/client.cpp
index 5ef5ceeece..0d2d717cc8 100644
--- a/library/cpp/messagebus/rain_check/http/client.cpp
+++ b/library/cpp/messagebus/rain_check/http/client.cpp
@@ -10,8 +10,8 @@
#include <util/generic/ptr.h>
#include <util/generic/strbuf.h>
-#include <util/network/socket.h>
-#include <util/stream/str.h>
+#include <util/network/socket.h>
+#include <util/stream/str.h>
namespace NRainCheck {
class THttpCallback: public NNeh::IOnRecv {
@@ -66,11 +66,11 @@ namespace NRainCheck {
void THttpClientService::SendPost(TString addr, const TString& data, const THttpHeaders& headers, THttpFuture* future) {
Y_VERIFY(!!future, "future is NULL.");
-
+
TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
future->SetRunning(current);
future->Task = current;
-
+
THolder<THttpCallback> callback(new THttpCallback(future));
NNeh::TServiceStatRef stat;
try {
@@ -93,7 +93,7 @@ namespace NRainCheck {
TTaskRunnerBase* current = TTaskRunnerBase::CurrentTask();
future->SetRunning(current);
future->Task = current;
-
+
THolder<THttpCallback> callback(new THttpCallback(future));
NNeh::TServiceStatRef stat;
try {
@@ -107,11 +107,11 @@ namespace NRainCheck {
future->SetFail(THttpFuture::OtherError, err.AsStrBuf());
}
}
-
+
bool THttpFuture::HasHttpCode() const {
return !!HttpCode;
- }
-
+ }
+
bool THttpFuture::HasResponseBody() const {
return !!Response;
}
@@ -121,7 +121,7 @@ namespace NRainCheck {
Y_ASSERT(HasHttpCode());
return static_cast<ui32>(*HttpCode);
- }
+ }
TString THttpFuture::GetResponseBody() const {
Y_ASSERT(IsDone());
@@ -149,6 +149,6 @@ namespace NRainCheck {
ErrorDescription = errorDescription;
Response.Destroy();
SetDone();
- }
+ }
-}
+}
diff --git a/library/cpp/messagebus/rain_check/http/client.h b/library/cpp/messagebus/rain_check/http/client.h
index d4199c4c98..1d1e500509 100644
--- a/library/cpp/messagebus/rain_check/http/client.h
+++ b/library/cpp/messagebus/rain_check/http/client.h
@@ -10,8 +10,8 @@
#include <util/system/defaults.h>
#include <util/system/yassert.h>
-class THttpHeaders;
-
+class THttpHeaders;
+
namespace NNeh {
class IProtocol;
struct TResponse;
@@ -28,14 +28,14 @@ namespace NRainCheck {
CantResolveNameError = 1,
BadHttpCodeError = 2,
-
+
OtherError = 100
};
-
+
private:
friend class THttpCallback;
friend class THttpClientService;
-
+
public:
THttpFuture();
~THttpFuture() override;
@@ -53,7 +53,7 @@ namespace NRainCheck {
private:
void SetDoneAndSchedule(TAutoPtr<NNeh::TResponse> response);
void SetFail(EError errorCode, const TStringBuf& errorDescription);
-
+
private:
TTaskRunnerBase* Task;
TMaybe<HttpCodes> HttpCode;
diff --git a/library/cpp/messagebus/rain_check/http/client_ut.cpp b/library/cpp/messagebus/rain_check/http/client_ut.cpp
index 1628114391..97a726af44 100644
--- a/library/cpp/messagebus/rain_check/http/client_ut.cpp
+++ b/library/cpp/messagebus/rain_check/http/client_ut.cpp
@@ -43,7 +43,7 @@ namespace {
TString BuildServiceLocation(ui32 port) {
return Sprintf("http://*:%" PRIu32 "/%s", port, TEST_SERVICE.data());
}
-
+
TString BuildPostServiceLocation(ui32 port) {
return Sprintf("post://*:%" PRIu32 "/%s", port + 1, TEST_SERVICE.data());
}
@@ -64,7 +64,7 @@ namespace {
req->SendReply(response);
}
};
-
+
NNeh::IServicesRef RunServer(ui32 port, TSimpleServer& server) {
NNeh::IServicesRef runner = NNeh::CreateLoop();
runner->Add(BuildServiceLocation(port), server);
@@ -75,7 +75,7 @@ namespace {
runner->ForkLoop(THR_POOL_SIZE);
} catch (...) {
Y_FAIL("Can't run server: %s", CurrentExceptionMessage().data());
- }
+ }
return runner;
}
@@ -94,7 +94,7 @@ namespace {
, ReqType(param.second)
{
}
-
+
TContinueFunc Start() override {
switch (ReqType) {
case RT_HTTP_GET: {
@@ -104,7 +104,7 @@ namespace {
Env->HttpClientService.Send(getRequest, Requests[i].Get());
}
break;
- }
+ }
case RT_HTTP_POST: {
TString servicePath = BuildPostServiceLocation(ServerPort);
TStringInput headersText(TEST_POST_HEADERS);
@@ -114,8 +114,8 @@ namespace {
Env->HttpClientService.SendPost(servicePath, TEST_POST_PARAMS, headers, Requests[i].Get());
}
break;
- }
- }
+ }
+ }
return &THttpClientTask::GotReplies;
}
@@ -154,25 +154,25 @@ Y_UNIT_TEST_SUITE(RainCheckHttpClient) {
NNeh::IServicesRef runner = RunServer(SERVER_PORT, server);
THttpClientEnv env;
- TIntrusivePtr<TSimpleTaskRunner> task = env.SpawnTask<THttpClientTask>(TTaskParam(SERVER_PORT, RT_HTTP_GET));
+ TIntrusivePtr<TSimpleTaskRunner> task = env.SpawnTask<THttpClientTask>(TTaskParam(SERVER_PORT, RT_HTTP_GET));
env.TestSync.WaitForAndIncrement(1);
}
-
+
Y_UNIT_TEST(SimplePost) {
- // TODO: randomize port
- if (!IsFixedPortTestAllowed()) {
- return;
- }
-
- TSimpleServer server;
- NNeh::IServicesRef runner = RunServer(SERVER_PORT, server);
-
- THttpClientEnv env;
- TIntrusivePtr<TSimpleTaskRunner> task = env.SpawnTask<THttpClientTask>(TTaskParam(SERVER_PORT, RT_HTTP_POST));
-
- env.TestSync.WaitForAndIncrement(1);
- }
+ // TODO: randomize port
+ if (!IsFixedPortTestAllowed()) {
+ return;
+ }
+
+ TSimpleServer server;
+ NNeh::IServicesRef runner = RunServer(SERVER_PORT, server);
+
+ THttpClientEnv env;
+ TIntrusivePtr<TSimpleTaskRunner> task = env.SpawnTask<THttpClientTask>(TTaskParam(SERVER_PORT, RT_HTTP_POST));
+
+ env.TestSync.WaitForAndIncrement(1);
+ }
Y_UNIT_TEST(HttpCodeExtraction) {
// Find "request failed(" string, then copy len("HTTP/1.X NNN") chars and try to convert NNN to HTTP code.