From cfb08805ee7b93bdb1ae829d2ee7f44f0e3e592b Mon Sep 17 00:00:00 2001 From: Tobias Peters Date: Wed, 26 Jun 2024 19:38:23 +0000 Subject: [PATCH] add test for query port message --- .../tests/naming_service.it.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/nelns/naming_service/tests/naming_service.it.cpp b/nelns/naming_service/tests/naming_service.it.cpp index fc63e26d69..fd8897da37 100644 --- a/nelns/naming_service/tests/naming_service.it.cpp +++ b/nelns/naming_service/tests/naming_service.it.cpp @@ -127,12 +127,13 @@ class CNamingServiceIT : public testing::Test CCallbackClient client; CNamingService namingService; int port = 50000; + int minPort = 51000; void SetUp() override { CVar basePort; basePort.Type = NLMISC::CConfigFile::CVar::T_INT; - basePort.setAsInt(51000); + basePort.setAsInt(minPort); namingService.ConfigFile.insertVar("BasePort", basePort); CVar uniqueOnShardServices; @@ -213,6 +214,7 @@ TEST_F(CNamingServiceIT, shouldUpdateServiceRegistry) client.send(msgout); client.flush(); + client.update2(-1, 200); namingService.update(); client.update2(-1, 200); @@ -225,3 +227,24 @@ TEST_F(CNamingServiceIT, shouldUpdateServiceRegistry) Field(&CServiceEntry::Addr, ElementsAre(Property(&CInetAddress::asString, "[::1]:12345"))) ))); } + +TEST_F(CNamingServiceIT, shouldAnswerToQueryPort) +{ + CMessage msgout("QP"); + + uint16 response(0); + TCallbackItem callbackArray[] = { + { "QP", [&response](CMessage &msgin, TSockId from, CCallbackNetBase &netbase) { + msgin.serial(response); + } } + }; + client.addCallbackArray(callbackArray, sizeof(callbackArray) / sizeof(callbackArray[0])); + + client.send(msgout); + client.flush(); + client.update2(-1, 200); + namingService.update(); + client.update2(-1, 200); + + EXPECT_THAT(response, Eq(minPort)); +}