diff --git a/src/meta/test/MetaClientTest.cpp b/src/meta/test/MetaClientTest.cpp index 1ee1220b1b4..c72e7db70dd 100644 --- a/src/meta/test/MetaClientTest.cpp +++ b/src/meta/test/MetaClientTest.cpp @@ -1149,7 +1149,9 @@ TEST(MetaClientTest, HeartbeatTest) { FLAGS_heartbeat_interval_secs = 1; const nebula::ClusterID kClusterId = 10; fs::TempDir rootPath("/tmp/MetaClientTest.XXXXXX"); - auto sc = TestUtils::mockMetaServer(10001, rootPath.path(), kClusterId); + // Let the system choose an available port for us + int32_t localMetaPort = 0; + auto sc = TestUtils::mockMetaServer(localMetaPort, rootPath.path(), kClusterId); auto threadPool = std::make_shared(1); IPv4 localIp; @@ -1163,8 +1165,7 @@ TEST(MetaClientTest, HeartbeatTest) { options.clusterId_ = kClusterId; options.inStoraged_ = true; auto client = std::make_shared(threadPool, - std::vector{HostAddr(localIp, 10001)}, - options); + std::vector{HostAddr(localIp, sc->port_)}, options); client->waitForMetadReady(); client->registerListener(listener.get()); {