Skip to content

Commit

Permalink
fix metaserver_test port conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
cw123 committed Feb 21, 2022
1 parent 238278f commit 6abf07b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions curvefs/test/metaserver/metaserver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ namespace metaserver {
class MetaserverTest : public ::testing::Test {
protected:
void SetUp() override {
metaserverListenAddr_ = "127.0.0.1:16702";
topologyServiceAddr_ = "127.0.0.1:16700";
metaserverIp_ = "127.0.0.1";
metaserverPort_ = "56702";
topologyServiceAddr_ = "127.0.0.1:56700";
ASSERT_EQ(0, server_.AddService(&mockTopologyService_,
brpc::SERVER_DOESNT_OWN_SERVICE));
ASSERT_EQ(0, server_.AddService(&mockHeartbeatService_,
Expand All @@ -69,7 +70,8 @@ class MetaserverTest : public ::testing::Test {
return;
}

std::string metaserverListenAddr_;
std::string metaserverIp_;
std::string metaserverPort_;
std::string topologyServiceAddr_;
MockTopologyService mockTopologyService_;
MockHeartbeatService mockHeartbeatService_;
Expand All @@ -94,7 +96,9 @@ TEST_F(MetaserverTest, register_to_mds_success) {
auto conf = std::make_shared<Configuration>();
conf->SetConfigPath("curvefs/conf/metaserver.conf");
ASSERT_TRUE(conf->LoadConfig());
conf->SetStringValue("metaserver.listen.addr", metaserverListenAddr_);
conf->SetStringValue("mds.listen.addr", topologyServiceAddr_);
conf->SetStringValue("global.ip", metaserverIp_);
conf->SetStringValue("global.port", metaserverPort_);

// initialize MDS options
metaserver.InitOptions(conf);
Expand Down Expand Up @@ -136,7 +140,9 @@ TEST_F(MetaserverTest, test2) {
auto conf = std::make_shared<Configuration>();
conf->SetConfigPath("curvefs/conf/metaserver.conf");
ASSERT_TRUE(conf->LoadConfig());
conf->SetStringValue("metaserver.listen.addr", metaserverListenAddr_);
conf->SetStringValue("mds.listen.addr", topologyServiceAddr_);
conf->SetStringValue("global.ip", metaserverIp_);
conf->SetStringValue("global.port", metaserverPort_);

// mock RegistMetaServer
MetaServerRegistResponse response;
Expand Down

0 comments on commit 6abf07b

Please sign in to comment.