@@ -102,6 +102,8 @@ TEST_P(SnapshotReplicaTest, AddReplicate) {
102102}
103103
104104TEST_P (SnapshotReplicaTest, LeaderAndFollower) {
105+ FLAGS_endpoint = " 127.0.0.1:18529" ;
106+ std::string leader_point = " 127.0.0.1:18529" ;
105107 ::openmldb::tablet::TabletImpl* tablet = new ::openmldb::tablet::TabletImpl ();
106108 tablet->Init (" " );
107109 brpc::Server server;
@@ -110,7 +112,6 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollower) {
110112 exit (1 );
111113 }
112114 brpc::ServerOptions options;
113- std::string leader_point = " 127.0.0.1:18529" ;
114115 if (server.Start (leader_point.c_str (), &options) != 0 ) {
115116 PDLOG (WARNING, " fail to start server %s" , leader_point.c_str ());
116117 exit (1 );
@@ -140,10 +141,7 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollower) {
140141 }
141142
142143 sleep (3 );
143-
144- ::openmldb::test::TempPath temp_path;
145- FLAGS_db_root_path = temp_path.GetTempPath ();
146- FLAGS_hdd_root_path = temp_path.GetTempPath ();
144+ ::openmldb::test::ResetRandomDiskFlags ();
147145 FLAGS_endpoint = " 127.0.0.1:18530" ;
148146 ::openmldb::tablet::TabletImpl* tablet1 = new ::openmldb::tablet::TabletImpl ();
149147 tablet1->Init (" " );
@@ -213,6 +211,8 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollower) {
213211
214212TEST_P (SnapshotReplicaTest, SendSnapshot) {
215213 FLAGS_make_snapshot_threshold_offset = 0 ;
214+ FLAGS_endpoint = " 127.0.0.1:18529" ;
215+ std::string leader_point = " 127.0.0.1:18529" ;
216216 ::openmldb::tablet::TabletImpl* tablet = new ::openmldb::tablet::TabletImpl ();
217217 MockClosure closure;
218218 tablet->Init (" " );
@@ -222,7 +222,6 @@ TEST_P(SnapshotReplicaTest, SendSnapshot) {
222222 exit (1 );
223223 }
224224 brpc::ServerOptions options;
225- std::string leader_point = " 127.0.0.1:18529" ;
226225 if (server.Start (leader_point.c_str (), &options) != 0 ) {
227226 PDLOG (WARNING, " fail to start server %s" , leader_point.c_str ());
228227 exit (1 );
@@ -257,9 +256,7 @@ TEST_P(SnapshotReplicaTest, SendSnapshot) {
257256 tablet->MakeSnapshot (NULL , &grq, &grp, &closure);
258257
259258 sleep (3 );
260- ::openmldb::test::TempPath temp_path;
261- FLAGS_db_root_path = temp_path.GetTempPath ();
262- FLAGS_hdd_root_path = temp_path.GetTempPath ();
259+ ::openmldb::test::ResetRandomDiskFlags ();
263260 FLAGS_endpoint = " 127.0.0.1:18530" ;
264261 ::openmldb::tablet::TabletImpl* tablet1 = new ::openmldb::tablet::TabletImpl ();
265262 tablet1->Init (" " );
@@ -319,6 +316,8 @@ TEST_P(SnapshotReplicaTest, SendSnapshot) {
319316 tablet->DropTable (NULL , &dr, &drs, &closure);
320317 tablet1->DropTable (NULL , &dr, &drs, &closure);
321318 sleep (2 );
319+ server.Stop (10 );
320+ server1.Stop (10 );
322321}
323322
324323TEST_P (SnapshotReplicaTest, IncompleteSnapshot) {
@@ -540,7 +539,10 @@ TEST_P(SnapshotReplicaTest, IncompleteSnapshot) {
540539}
541540
542541TEST_P (SnapshotReplicaTest, LeaderAndFollowerTS) {
542+ ::openmldb::test::ResetRandomDiskFlags ();
543543 auto storage_mode = GetParam ();
544+ FLAGS_endpoint = " 127.0.0.1:18529" ;
545+ std::string leader_point = " 127.0.0.1:18529" ;
544546 ::openmldb::tablet::TabletImpl* tablet = new ::openmldb::tablet::TabletImpl ();
545547 tablet->Init (" " );
546548 brpc::Server server;
@@ -549,7 +551,6 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollowerTS) {
549551 exit (1 );
550552 }
551553 brpc::ServerOptions options;
552- std::string leader_point = " 127.0.0.1:18529" ;
553554 if (server.Start (leader_point.c_str (), &options) != 0 ) {
554555 PDLOG (WARNING, " fail to start server %s" , leader_point.c_str ());
555556 exit (1 );
@@ -586,9 +587,8 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollowerTS) {
586587 ASSERT_TRUE (client.Put (tid, pid, cur_time, value, dimensions).OK ());
587588
588589 sleep (3 );
589- ::openmldb::test::TempPath temp_path;
590- FLAGS_db_root_path = temp_path.GetTempPath ();
591- FLAGS_hdd_root_path = temp_path.GetTempPath ();
590+
591+ ::openmldb::test::ResetRandomDiskFlags ();
592592 FLAGS_endpoint = " 127.0.0.1:18530" ;
593593 ::openmldb::tablet::TabletImpl* tablet1 = new ::openmldb::tablet::TabletImpl ();
594594 tablet1->Init (" " );
@@ -628,7 +628,10 @@ TEST_P(SnapshotReplicaTest, LeaderAndFollowerTS) {
628628 ::openmldb::api::DropTableResponse drs;
629629 tablet->DropTable (NULL , &dr, &drs, &closure);
630630 tablet1->DropTable (NULL , &dr, &drs, &closure);
631+
631632 sleep (1 );
633+ server.Stop (10 );
634+ server1.Stop (10 );
632635}
633636
634637INSTANTIATE_TEST_SUITE_P (DBSDK, SnapshotReplicaTest,
0 commit comments