Skip to content

Commit

Permalink
fix ha witness ut (TuGraph-family#383)
Browse files Browse the repository at this point in the history
* fix ha witness ut

* fix ha witness ut
  • Loading branch information
lipanpan03 authored Jan 18, 2024
1 parent 477b6b0 commit 1b2f540
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test/test_ha_witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ TEST_F(TestHAWitness, HAWitnessDisableLeader) {
std::string cmd = FMA_FMT(cmd_f.c_str(), "ha" + std::to_string(stoi(output[1]) - 29091));
ret = system(cmd.c_str());
UT_EXPECT_EQ(ret, 0);
fma_common::SleepS(10);
fma_common::SleepS(15);
ret = client->ImportSchemaFromContent(result, schema) &&
client->ImportDataFromContent(result, data_desc, data_person, ",");
UT_EXPECT_TRUE(ret);
Expand All @@ -270,9 +270,18 @@ TEST_F(TestHAWitness, HAWitnessDisableLeader) {
cmd = FMA_FMT(cmd_f.c_str(), "ha" + std::to_string(stoi(output[1]) - 29091));
ret = system(cmd.c_str());
UT_EXPECT_EQ(ret, 0);
fma_common::SleepS(10);
fma_common::SleepS(15);

// start follower, witness which has newer log will be leader temporary
try {
client = std::make_unique<lgraph::RpcClient>(
this->host + ":29094", "admin", "73@TuGraph");
} catch (std::exception &e) {
cmd = FMA_FMT(witness_cmd_f, "ha3", host, "27074", "29094",
host + ":29092," + host + ":29093," + host + ":29094", true);
UT_EXPECT_EQ(system(cmd.c_str()), 0);
fma_common::SleepS(5);
}
boost::split(output, follower_rpc, boost::is_any_of(":"));
std::string ha_dir = "ha" + std::to_string(stoi(output[1]) - 29091);
cmd = FMA_FMT(server_cmd_f, ha_dir, host, stoi(output[1]) - 2020,
Expand All @@ -281,6 +290,7 @@ TEST_F(TestHAWitness, HAWitnessDisableLeader) {
UT_EXPECT_EQ(ret, 0);
fma_common::SleepS(15);
master_rpc.clear();
int times = 0;
do {
try {
client = std::make_unique<lgraph::RpcClient>(
Expand All @@ -306,7 +316,7 @@ TEST_F(TestHAWitness, HAWitnessDisableLeader) {
fma_common::SleepS(1);
continue;
}
} while (true);
} while (++times < 20);
fma_common::SleepS(5);
ret = client->CallCypherToLeader(result, "MATCH (n) RETURN COUNT(n)");
UT_EXPECT_TRUE(ret);
Expand Down

0 comments on commit 1b2f540

Please sign in to comment.