aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/ut/sync_client_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/messagebus/test/ut/sync_client_ut.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/test/ut/sync_client_ut.cpp')
-rw-r--r--library/cpp/messagebus/test/ut/sync_client_ut.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/library/cpp/messagebus/test/ut/sync_client_ut.cpp b/library/cpp/messagebus/test/ut/sync_client_ut.cpp
index 7a7189dbec..400128193f 100644
--- a/library/cpp/messagebus/test/ut/sync_client_ut.cpp
+++ b/library/cpp/messagebus/test/ut/sync_client_ut.cpp
@@ -2,67 +2,67 @@
#include <library/cpp/messagebus/test/helper/object_count_check.h>
namespace NBus {
- namespace NTest {
- using namespace std;
+ namespace NTest {
+ using namespace std;
- ////////////////////////////////////////////////////////////////////
- /// \brief Client for sending synchronous message to local server
- struct TSyncClient {
- TNetAddr ServerAddr;
+ ////////////////////////////////////////////////////////////////////
+ /// \brief Client for sending synchronous message to local server
+ struct TSyncClient {
+ TNetAddr ServerAddr;
- TExampleProtocol Proto;
- TBusMessageQueuePtr Bus;
- TBusSyncClientSessionPtr Session;
+ TExampleProtocol Proto;
+ TBusMessageQueuePtr Bus;
+ TBusSyncClientSessionPtr Session;
- int NumReplies;
- int NumMessages;
+ int NumReplies;
+ int NumMessages;
- /// constructor creates instances of queue, protocol and session
- TSyncClient(const TNetAddr& serverAddr)
- : ServerAddr(serverAddr)
- {
- /// create or get instance of message queue, need one per application
- Bus = CreateMessageQueue();
+ /// constructor creates instances of queue, protocol and session
+ TSyncClient(const TNetAddr& serverAddr)
+ : ServerAddr(serverAddr)
+ {
+ /// create or get instance of message queue, need one per application
+ Bus = CreateMessageQueue();
- NumReplies = 0;
- NumMessages = 10;
+ NumReplies = 0;
+ NumMessages = 10;
- /// register source/client session
- TBusClientSessionConfig sessionConfig;
- Session = Bus->CreateSyncSource(&Proto, sessionConfig);
- Session->RegisterService("localhost");
- }
+ /// register source/client session
+ TBusClientSessionConfig sessionConfig;
+ Session = Bus->CreateSyncSource(&Proto, sessionConfig);
+ Session->RegisterService("localhost");
+ }
- ~TSyncClient() {
- Session->Shutdown();
- }
+ ~TSyncClient() {
+ Session->Shutdown();
+ }
- /// dispatch of requests is done here
- void Work() {
- for (int i = 0; i < NumMessages; i++) {
- THolder<TExampleRequest> mess(new TExampleRequest(&Proto.RequestCount));
- EMessageStatus status;
- THolder<TBusMessage> reply(Session->SendSyncMessage(mess.Get(), status, &ServerAddr));
- if (!!reply) {
- NumReplies++;
- }
- }
- }
- };
+ /// dispatch of requests is done here
+ void Work() {
+ for (int i = 0; i < NumMessages; i++) {
+ THolder<TExampleRequest> mess(new TExampleRequest(&Proto.RequestCount));
+ EMessageStatus status;
+ THolder<TBusMessage> reply(Session->SendSyncMessage(mess.Get(), status, &ServerAddr));
+ if (!!reply) {
+ NumReplies++;
+ }
+ }
+ }
+ };
Y_UNIT_TEST_SUITE(SyncClientTest) {
Y_UNIT_TEST(TestSync) {
- TObjectCountCheck objectCountCheck;
+ TObjectCountCheck objectCountCheck;
- TExampleServer server;
- TSyncClient client(server.GetActualListenAddr());
- client.Work();
- // assert correct number of replies
- UNIT_ASSERT_EQUAL(client.NumReplies, client.NumMessages);
- // assert that there is no message left in flight
- UNIT_ASSERT_EQUAL(server.Session->GetInFlight(), 0);
- UNIT_ASSERT_EQUAL(client.Session->GetInFlight(), 0);
- }
+ TExampleServer server;
+ TSyncClient client(server.GetActualListenAddr());
+ client.Work();
+ // assert correct number of replies
+ UNIT_ASSERT_EQUAL(client.NumReplies, client.NumMessages);
+ // assert that there is no message left in flight
+ UNIT_ASSERT_EQUAL(server.Session->GetInFlight(), 0);
+ UNIT_ASSERT_EQUAL(client.Session->GetInFlight(), 0);
+ }
}
}