aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test
diff options
context:
space:
mode:
authorilnurkh <ilnurkh@yandex-team.com>2023-10-09 23:39:40 +0300
committerilnurkh <ilnurkh@yandex-team.com>2023-10-09 23:57:14 +0300
commite601ca03f859335d57ecff2e5aa6af234b6052ed (patch)
treede519a847e58a1b3993fcbfe05ff44cc946a3e24 /library/cpp/messagebus/test
parentbbf2b6878af3854815a2c0ecb07a687071787639 (diff)
downloadydb-e601ca03f859335d57ecff2e5aa6af234b6052ed.tar.gz
Y_VERIFY->Y_ABORT_UNLESS at ^l
https://clubs.at.yandex-team.ru/arcadia/29404
Diffstat (limited to 'library/cpp/messagebus/test')
-rw-r--r--library/cpp/messagebus/test/example/client/client.cpp2
-rw-r--r--library/cpp/messagebus/test/helper/alloc_counter.h2
-rw-r--r--library/cpp/messagebus/test/helper/example.cpp12
-rw-r--r--library/cpp/messagebus/test/helper/wait_for.h2
-rw-r--r--library/cpp/messagebus/test/perftest/perftest.cpp10
-rw-r--r--library/cpp/messagebus/test/perftest/simple_proto.cpp2
-rw-r--r--library/cpp/messagebus/test/ut/messagebus_ut.cpp30
-rw-r--r--library/cpp/messagebus/test/ut/module_client_ut.cpp14
-rw-r--r--library/cpp/messagebus/test/ut/module_server_ut.cpp4
-rw-r--r--library/cpp/messagebus/test/ut/one_way_ut.cpp2
10 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/messagebus/test/example/client/client.cpp b/library/cpp/messagebus/test/example/client/client.cpp
index 89b5f2c9be..8d0f0584e0 100644
--- a/library/cpp/messagebus/test/example/client/client.cpp
+++ b/library/cpp/messagebus/test/example/client/client.cpp
@@ -23,7 +23,7 @@ namespace NCalculator {
}
void OnReply(TAutoPtr<TBusMessage> request, TAutoPtr<TBusMessage> response0) override {
- Y_VERIFY(response0->GetHeader()->Type == TResponse::MessageType, "wrong response");
+ Y_ABORT_UNLESS(response0->GetHeader()->Type == TResponse::MessageType, "wrong response");
TResponse* response = VerifyDynamicCast<TResponse*>(response0.Get());
if (request->GetHeader()->Type == TRequestSum::MessageType) {
TRequestSum* requestSum = VerifyDynamicCast<TRequestSum*>(request.Get());
diff --git a/library/cpp/messagebus/test/helper/alloc_counter.h b/library/cpp/messagebus/test/helper/alloc_counter.h
index 7c4010714f..93972b52dd 100644
--- a/library/cpp/messagebus/test/helper/alloc_counter.h
+++ b/library/cpp/messagebus/test/helper/alloc_counter.h
@@ -16,6 +16,6 @@ public:
}
~TAllocCounter() {
- Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many");
+ Y_ABORT_UNLESS(AtomicDecrement(*CountPtr) >= 0, "released too many");
}
};
diff --git a/library/cpp/messagebus/test/helper/example.cpp b/library/cpp/messagebus/test/helper/example.cpp
index 7c6d704042..1ef2809111 100644
--- a/library/cpp/messagebus/test/helper/example.cpp
+++ b/library/cpp/messagebus/test/helper/example.cpp
@@ -68,11 +68,11 @@ TExampleProtocol::~TExampleProtocol() {
// so it could be reported in test
return;
}
- Y_VERIFY(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount));
- Y_VERIFY(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount));
- Y_VERIFY(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized));
- Y_VERIFY(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized));
- Y_VERIFY(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount));
+ Y_ABORT_UNLESS(0 == AtomicGet(RequestCount), "protocol %s: must be 0 requests allocated, actually %d", GetService(), int(RequestCount));
+ Y_ABORT_UNLESS(0 == AtomicGet(ResponseCount), "protocol %s: must be 0 responses allocated, actually %d", GetService(), int(ResponseCount));
+ Y_ABORT_UNLESS(0 == AtomicGet(RequestCountDeserialized), "protocol %s: must be 0 requests deserialized allocated, actually %d", GetService(), int(RequestCountDeserialized));
+ Y_ABORT_UNLESS(0 == AtomicGet(ResponseCountDeserialized), "protocol %s: must be 0 responses deserialized allocated, actually %d", GetService(), int(ResponseCountDeserialized));
+ Y_ABORT_UNLESS(0 == AtomicGet(StartCount), "protocol %s: must be 0 start objects allocated, actually %d", GetService(), int(StartCount));
}
void TExampleProtocol::Serialize(const TBusMessage* message, TBuffer& buffer) {
@@ -277,5 +277,5 @@ void TExampleServer::OnMessage(TOnMessageContext& mess) {
status = mess.SendReplyMove(reply);
}
- Y_VERIFY(status == MESSAGE_OK, "failed to send reply: %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to send reply: %s", ToString(status).data());
}
diff --git a/library/cpp/messagebus/test/helper/wait_for.h b/library/cpp/messagebus/test/helper/wait_for.h
index f09958d4c0..b8363900b8 100644
--- a/library/cpp/messagebus/test/helper/wait_for.h
+++ b/library/cpp/messagebus/test/helper/wait_for.h
@@ -10,5 +10,5 @@
Sleep(TDuration::MilliSeconds(1)); \
} \
/* TODO: use UNIT_ASSERT if in unittest thread */ \
- Y_VERIFY(condition, "condition failed after 10 seconds wait"); \
+ Y_ABORT_UNLESS(condition, "condition failed after 10 seconds wait"); \
} while (0)
diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp
index 8489319278..3084c9e01c 100644
--- a/library/cpp/messagebus/test/perftest/perftest.cpp
+++ b/library/cpp/messagebus/test/perftest/perftest.cpp
@@ -150,7 +150,7 @@ TAutoPtr<TBusMessage> NewRequest() {
void CheckRequest(TPerftestRequest* request) {
const TString& data = request->Record.GetData();
for (size_t i = 0; i != data.size(); ++i) {
- Y_VERIFY(data.at(i) == '?', "must be question mark");
+ Y_ABORT_UNLESS(data.at(i) == '?', "must be question mark");
}
}
@@ -164,7 +164,7 @@ TAutoPtr<TPerftestResponse> NewResponse(TPerftestRequest* request) {
void CheckResponse(TPerftestResponse* response) {
const TString& data = response->Record.GetData();
for (size_t i = 0; i != data.size(); ++i) {
- Y_VERIFY(data.at(i) == '.', "must be dot");
+ Y_ABORT_UNLESS(data.at(i) == '.', "must be dot");
}
}
@@ -416,8 +416,8 @@ public:
: TPerftestServerCommon("server")
, TBusModule("fast")
{
- Y_VERIFY(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module");
- Y_VERIFY(StartInput(), "failed to start input");
+ Y_ABORT_UNLESS(CreatePrivateSessions(Bus.Get()), "failed to initialize dupdetect module");
+ Y_ABORT_UNLESS(StartInput(), "failed to start input");
}
~TPerftestUsingModule() override {
@@ -479,7 +479,7 @@ TVector<TNetAddr> ParseNodes(const TString nodes) {
for (int i = 0; i < int(numh); i++) {
const TNetworkAddress& networkAddress = ParseNetworkAddress(hosts[i].data());
- Y_VERIFY(networkAddress.Begin() != networkAddress.End(), "no addresses");
+ Y_ABORT_UNLESS(networkAddress.Begin() != networkAddress.End(), "no addresses");
r.push_back(TNetAddr(networkAddress, &*networkAddress.Begin()));
}
diff --git a/library/cpp/messagebus/test/perftest/simple_proto.cpp b/library/cpp/messagebus/test/perftest/simple_proto.cpp
index 19d6c15b9d..3e28413325 100644
--- a/library/cpp/messagebus/test/perftest/simple_proto.cpp
+++ b/library/cpp/messagebus/test/perftest/simple_proto.cpp
@@ -7,7 +7,7 @@
using namespace NBus;
void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) {
- Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess));
+ Y_ABORT_UNLESS(typeid(TSimpleMessage) == typeid(*mess));
const TSimpleMessage* typed = static_cast<const TSimpleMessage*>(mess);
data.Append((const char*)&typed->Payload, 4);
}
diff --git a/library/cpp/messagebus/test/ut/messagebus_ut.cpp b/library/cpp/messagebus/test/ut/messagebus_ut.cpp
index 8d2f4aa444..8f6aa6a295 100644
--- a/library/cpp/messagebus/test/ut/messagebus_ut.cpp
+++ b/library/cpp/messagebus/test/ut/messagebus_ut.cpp
@@ -31,7 +31,7 @@ namespace {
}
void OnReply(TAutoPtr<TBusMessage> mess, TAutoPtr<TBusMessage> reply) override {
- Y_VERIFY(AtomicGet(SentCompleted), "must be completed");
+ Y_ABORT_UNLESS(AtomicGet(SentCompleted), "must be completed");
TExampleClient::OnReply(mess, reply);
@@ -138,7 +138,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override {
Y_UNUSED(message);
- Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data());
TestSync.CheckAndIncrement((failures++) * 2);
}
@@ -159,7 +159,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
status = client.Session->SendMessageAutoPtr(message, &noServerAddr);
}
- Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
if (count == 0) {
// lame way to wait until it is connected
@@ -266,7 +266,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
TSystemEvent ErrorHappened;
void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override {
- Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got status: %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got status: %s", ToString(status).data());
ErrorHappened.Signal();
}
};
@@ -327,7 +327,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
}
void OnMessage(TOnMessageContext& mess) override {
- Y_VERIFY(mess.IsConnectionAlive(), "connection should be alive here");
+ Y_ABORT_UNLESS(mess.IsConnectionAlive(), "connection should be alive here");
TAutoPtr<TOnMessageContext> delayedMsg(new TOnMessageContext);
delayedMsg->Swap(mess);
auto g(Guard(Lock_));
@@ -378,7 +378,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override {
Y_UNUSED(mess);
- Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "only shutdown allowed, got %s", ToString(status).data());
}
};
@@ -432,7 +432,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override {
Y_UNUSED(mess);
- Y_VERIFY(status == MESSAGE_SHUTDOWN, "only shutdown allowed");
+ Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "only shutdown allowed");
}
};
@@ -505,7 +505,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage>, EMessageStatus status) override {
TestSync.WaitForAndIncrement(1);
- Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "status");
+ Y_ABORT_UNLESS(status == MESSAGE_MESSAGE_TOO_LARGE, "status");
}
};
@@ -697,7 +697,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override {
TestSync.WaitForAndIncrement(0);
- Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "must be connection failed, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "must be connection failed, got %s", ToString(status).data());
mess.Destroy();
TestSync.CheckAndIncrement(1);
}
@@ -726,7 +726,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
void OnError(TAutoPtr<TBusMessage> message, EMessageStatus status) override {
TestSync.CheckAndIncrement(0);
- Y_VERIFY(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED, "must be MESSAGE_CONNECT_FAILED, got %s", ToString(status).data());
// check reset is possible here
message->Reset();
@@ -755,7 +755,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
client.Session->Shutdown();
ok = client.Session->SendMessageOneWay(message);
- Y_VERIFY(ok == MESSAGE_SHUTDOWN, "must be shutdown when sending during shutdown, got %s", ToString(ok).data());
+ Y_ABORT_UNLESS(ok == MESSAGE_SHUTDOWN, "must be shutdown when sending during shutdown, got %s", ToString(ok).data());
// check reset is possible here
message->Reset();
@@ -1074,7 +1074,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount),
&noServerAddr);
- Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
client.TestSync.WaitForAndIncrement(count * 2 + 1);
// First connection attempt is for connect call; second one is to get connect result.
@@ -1085,7 +1085,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount),
&noServerAddr);
- Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
client.TestSync.WaitForAndIncrement(count * 2 + 1);
// First connection attempt is for connect call; second one is to get connect result.
@@ -1107,7 +1107,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount),
&noServerAddr);
- Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
client.TestSync.WaitForAndIncrement(count * 2 + 1);
// First connection attempt is for connect call; second one is to get connect result.
@@ -1134,7 +1134,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests) {
EMessageStatus status = client.Session->SendMessageOneWay(new TExampleRequest(&client.Proto.RequestCount),
&noServerAddr);
- Y_VERIFY(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "must be MESSAGE_OK, got %s", ToString(status).data());
client.TestSync.WaitForAndIncrement(count * 2 + 1);
// First connection attempt is for connect call; second one is to get connect result.
diff --git a/library/cpp/messagebus/test/ut/module_client_ut.cpp b/library/cpp/messagebus/test/ut/module_client_ut.cpp
index ebfe185cc6..a172b06bd2 100644
--- a/library/cpp/messagebus/test/ut/module_client_ut.cpp
+++ b/library/cpp/messagebus/test/ut/module_client_ut.cpp
@@ -120,13 +120,13 @@ Y_UNIT_TEST_SUITE(BusJobTest) {
void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) {
Y_UNUSED(mess);
Y_UNUSED(reply);
- Y_VERIFY(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status));
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to get reply: %s", ToCString(status));
}
TJobHandler HandleReplies(TBusJob* job, TBusMessage* mess) {
Y_UNUSED(mess);
RepliesLatch.CountDown();
- Y_VERIFY(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers");
+ Y_ABORT_UNLESS(RepliesLatch.Await(TDuration::Seconds(10)), "failed to get answers");
job->Cancel(MESSAGE_UNKNOWN);
return nullptr;
}
@@ -178,9 +178,9 @@ Y_UNIT_TEST_SUITE(BusJobTest) {
}
void ReplyHandler(TBusJob*, EMessageStatus status, TBusMessage* req, TBusMessage* resp) {
- Y_VERIFY(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data());
- Y_VERIFY(req == SentMessage, "checking request");
- Y_VERIFY(resp == nullptr, "checking response");
+ Y_ABORT_UNLESS(status == MESSAGE_CONNECT_FAILED || status == MESSAGE_TIMEOUT, "got wrong status: %s", ToString(status).data());
+ Y_ABORT_UNLESS(req == SentMessage, "checking request");
+ Y_ABORT_UNLESS(resp == nullptr, "checking response");
GotReplyLatch.CountDown();
}
@@ -279,7 +279,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) {
void ReplyHandler(TBusJob* job, EMessageStatus status, TBusMessage* mess, TBusMessage* reply) {
Y_UNUSED(mess);
Y_UNUSED(reply);
- Y_VERIFY(status == MESSAGE_OK, "failed to get reply");
+ Y_ABORT_UNLESS(status == MESSAGE_OK, "failed to get reply");
if (AtomicIncrement(ReplyCount) == 1) {
TestSync->WaitForAndIncrement(1);
job->SendReply(new TExampleResponse(&Proto.ResponseCount));
@@ -338,7 +338,7 @@ Y_UNIT_TEST_SUITE(BusJobTest) {
}
void HandleReply(TBusJob*, EMessageStatus status, TBusMessage*, TBusMessage*) {
- Y_VERIFY(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status));
+ Y_ABORT_UNLESS(status == MESSAGE_SHUTDOWN, "got %s", ToCString(status));
TestSync.CheckAndIncrement(1);
}
diff --git a/library/cpp/messagebus/test/ut/module_server_ut.cpp b/library/cpp/messagebus/test/ut/module_server_ut.cpp
index 88fe1dd9b6..b0e6ac38da 100644
--- a/library/cpp/messagebus/test/ut/module_server_ut.cpp
+++ b/library/cpp/messagebus/test/ut/module_server_ut.cpp
@@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) {
TJobHandler Start(TBusJob* job, TBusMessage* mess) override {
WaitTwoRequestsLatch.CountDown();
- Y_VERIFY(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops");
+ Y_ABORT_UNLESS(WaitTwoRequestsLatch.Await(TDuration::Seconds(5)), "oops");
VerifyDynamicCast<TExampleRequest*>(mess);
@@ -83,7 +83,7 @@ Y_UNIT_TEST_SUITE(ModuleServerTests) {
MessageReceivedEvent.Signal();
- Y_VERIFY(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops");
+ Y_ABORT_UNLESS(ClientDiedEvent.WaitT(TDuration::Seconds(5)), "oops");
job->SendReply(new TExampleResponse(&Proto.ResponseCount));
return nullptr;
diff --git a/library/cpp/messagebus/test/ut/one_way_ut.cpp b/library/cpp/messagebus/test/ut/one_way_ut.cpp
index 9c21227e2b..0b90985289 100644
--- a/library/cpp/messagebus/test/ut/one_way_ut.cpp
+++ b/library/cpp/messagebus/test/ut/one_way_ut.cpp
@@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TMessageBusTests_OneWay) {
void OnError(TAutoPtr<TBusMessage> mess, EMessageStatus status) override {
Y_UNUSED(mess);
- Y_VERIFY(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status));
+ Y_ABORT_UNLESS(status == MESSAGE_MESSAGE_TOO_LARGE, "wrong status: %s", ToCString(status));
GotTooLarge.Signal();
}