Skip to content

Commit

Permalink
remove some unused variables in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zerotacg committed Jun 11, 2024
1 parent 5de513a commit ebd74a1
Showing 1 changed file with 9 additions and 36 deletions.
45 changes: 9 additions & 36 deletions nelns/naming_service/tests/service_instance_manager.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,62 +102,41 @@ TEST(CServiceInstanceManager, addUniqueServiceShouldAddMachineUniqueService)
StartsWith("Online registered services:")));
}

TEST(CServiceInstanceManager, queryStartServiceShouldAddOnlineSercie)
TEST(CServiceInstanceManager, queryStartServiceShouldGrantSingleService)
{
CServiceInstanceManager instance;
TServiceId serviceId(123);
vector<CInetAddress> addresses = { "localhost:12345" };
string reason;
CLightMemDisplayer displayer;
CLog log(NLMISC::CLog::LOG_ASSERT);
log.addDisplayer(&displayer);

EXPECT_THAT(
instance.queryStartService("online-service", serviceId, addresses, reason),
instance.queryStartService("single-service", serviceId, addresses, reason),
IsTrue());

instance.displayInfo(&log);
EXPECT_THAT(
displayer.lockStrings(),
IsSupersetOf({ StartsWith("Online registered services:"),
StartsWith(serviceId.toString()) }));
}

TEST(CServiceInstanceManager, queryStartServiceShouldAddSingleShardUnqiueService)
TEST(CServiceInstanceManager, queryStartServiceShouldGrantSingleShardUnqiueService)
{
CServiceInstanceManager instance;
TServiceId serviceId(123);
vector<CInetAddress> addresses = { "localhost:12345" };
string reason;
CLightMemDisplayer displayer;
CLog log(NLMISC::CLog::LOG_ASSERT);
log.addDisplayer(&displayer);
string serviceName = "unique-shard-service-name";
instance.addUniqueService(serviceName, true);

EXPECT_THAT(
instance.queryStartService(serviceName, serviceId, addresses, reason),
IsTrue());

instance.displayInfo(&log);
EXPECT_THAT(
displayer.lockStrings(),
IsSupersetOf({ StartsWith("Online registered services:"),
StartsWith(serviceId.toString()) }));
}

TEST(CServiceInstanceManager, queryStartServiceShouldNotAddAdditionalShardUnqiueService)
TEST(CServiceInstanceManager, queryStartServiceShouldNotGrantAdditionalShardUnqiueService)
{
RegisteredServices.clear();
CServiceInstanceManager instance;
TServiceId serviceId(123);
vector<CInetAddress> addresses = { "localhost:12345" };
string reason;
CLightMemDisplayer displayer;
CLog log(NLMISC::CLog::LOG_ASSERT);
log.addDisplayer(&displayer);
string serviceName = "unique-shard-service-name";
RegisteredServices.push_back(CServiceEntry(InvalidSockId, addresses, serviceName, serviceId));
RegisteredServices.emplace_back(InvalidSockId, addresses, serviceName, serviceId);
instance.addUniqueService(serviceName, true);
instance.queryStartService(serviceName, serviceId, addresses, reason);

Expand All @@ -170,19 +149,16 @@ TEST(CServiceInstanceManager, queryStartServiceShouldNotAddAdditionalShardUnqiue
StrEq("Service unique-shard-service-name already found as 123, must be unique on shard"));
}

TEST(CServiceInstanceManager, queryStartServiceShouldAddAdditionalMachineUnqiueServiceOnDifferentMachine)
TEST(CServiceInstanceManager, queryStartServiceShouldGrantAdditionalMachineUnqiueServiceOnDifferentMachine)
{
RegisteredServices.clear();
CServiceInstanceManager instance;
TServiceId serviceId(123);
vector<CInetAddress> firstAddresses = { "127.0.0.1:12345" };
vector<CInetAddress> secondAddresses = { "127.0.0.2:12345" };
string reason;
CLightMemDisplayer displayer;
CLog log(NLMISC::CLog::LOG_ASSERT);
log.addDisplayer(&displayer);
string serviceName = "unique-machine-service-name";
RegisteredServices.push_back(CServiceEntry(InvalidSockId, firstAddresses, serviceName, serviceId));
RegisteredServices.emplace_back(InvalidSockId, firstAddresses, serviceName, serviceId);
instance.addUniqueService(serviceName, false);
instance.queryStartService(serviceName, serviceId, firstAddresses, reason);

Expand All @@ -191,18 +167,15 @@ TEST(CServiceInstanceManager, queryStartServiceShouldAddAdditionalMachineUnqiueS
IsTrue());
}

TEST(CServiceInstanceManager, queryStartServiceShouldNotAddAdditionalMachineUnqiueService)
TEST(CServiceInstanceManager, queryStartServiceShouldNotGrantAdditionalMachineUnqiueServiceOnSameMachine)
{
RegisteredServices.clear();
CServiceInstanceManager instance;
TServiceId serviceId(123);
vector<CInetAddress> addresses = { "localhost:12345" };
string reason;
CLightMemDisplayer displayer;
CLog log(NLMISC::CLog::LOG_ASSERT);
log.addDisplayer(&displayer);
string serviceName = "unique-machine-service-name";
RegisteredServices.push_back(CServiceEntry(InvalidSockId, addresses, serviceName, serviceId));
RegisteredServices.emplace_back(InvalidSockId, addresses, serviceName, serviceId);
instance.addUniqueService(serviceName, false);
instance.queryStartService(serviceName, serviceId, addresses, reason);

Expand Down

0 comments on commit ebd74a1

Please sign in to comment.