diff --git a/src/logservice/leader_coordinator/table_accessor.cpp b/src/logservice/leader_coordinator/table_accessor.cpp index 5d6130b857..fc1421c103 100644 --- a/src/logservice/leader_coordinator/table_accessor.cpp +++ b/src/logservice/leader_coordinator/table_accessor.cpp @@ -374,7 +374,7 @@ int LsElectionReferenceInfoRow::convert_table_info_to_user_info_() COORDINATOR_LOG_(WARN, "get ObAddr from ObString failed"); } else { ObArray split_by_comma; - if (!row_for_table_.element<4>().empty() && CLICK_FAIL(ObTableAccessHelper::split_string_by_char(row_for_table_.element<4>(), ',', split_by_comma))) { + if (!row_for_table_.element<4>().empty() && CLICK_FAIL(ObTableAccessHelper::split_string_by_char(row_for_table_.element<4>(), ';', split_by_comma))) { COORDINATOR_LOG_(WARN, "split blacklist by ',' failed"); } else { for (int64_t idx = 0; idx < split_by_comma.count() && OB_SUCC(ret); ++idx) { diff --git a/unittest/logservice/CMakeLists.txt b/unittest/logservice/CMakeLists.txt index aa4d7f9371..57eb742986 100644 --- a/unittest/logservice/CMakeLists.txt +++ b/unittest/logservice/CMakeLists.txt @@ -23,6 +23,7 @@ ob_unittest(test_fixed_sliding_window) ob_unittest(test_ob_election) ob_unittest(test_ob_election_with_priority) ob_unittest(test_ob_election_message_compat) +ob_unittest(test_ob_election_priority_seperate_blacklist) # ob_unittest(palf_performance_unittest) ob_unittest(test_ls_election_reference_info) ob_unittest(test_ob_tuple) diff --git a/unittest/logservice/test_ob_election_priority_seperate_blacklist.cpp b/unittest/logservice/test_ob_election_priority_seperate_blacklist.cpp new file mode 100644 index 0000000000..d8027163af --- /dev/null +++ b/unittest/logservice/test_ob_election_priority_seperate_blacklist.cpp @@ -0,0 +1,85 @@ +// Copyright (c) 2021 OceanBase +// OceanBase is licensed under Mulan PubL v2. +// You can use this software according to the terms and conditions of the Mulan PubL v2. +// You may obtain a copy of Mulan PubL v2 at: +// http://license.coscl.org.cn/MulanPubL-2.0 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PubL v2 for more details. +#include +#include +#define private public +#define protected public +#include "logservice/leader_coordinator/ob_failure_detector.h" +#include "common/ob_role.h" +#include "lib/list/ob_dlist.h" +#include "logservice/leader_coordinator/failure_event.h" +#include "logservice/palf/election/interface/election_msg_handler.h" +#include +#include +#include +#include "logservice/palf/election/interface/election.h" +#include "logservice/palf/log_meta_info.h" +#define UNITTEST +#include "logservice/palf/election/utils/election_common_define.h" +#include "logservice/palf/election/algorithm/election_impl.h" +#include "logservice/leader_coordinator/election_priority_impl/election_priority_impl.h" +#include "share/ob_occam_timer.h" +#include "share/rc/ob_tenant_base.h" +#include "mock_logservice_container/mock_election_user.h" +#include +#include +#include "logservice/leader_coordinator/table_accessor.h" + +using namespace std; + +#define SUCC_(stmt) ASSERT_EQ((stmt), OB_SUCCESS) +#define FAIL_(stmt) ASSERT_EQ((stmt), OB_FAIL) +#define TRUE_(stmt) ASSERT_EQ((stmt), true) +#define FALSE_(stmt) ASSERT_EQ((stmt), false) + +namespace oceanbase +{ +namespace unittest { + +class TestPrioritySeperateBlackList : public ::testing::Test { +public: + TestPrioritySeperateBlackList() {} + ~TestPrioritySeperateBlackList() {} + virtual void SetUp() {} + virtual void TearDown() { } +}; + +TEST_F(TestPrioritySeperateBlackList, main) +{ + logservice::coordinator::LsElectionReferenceInfoRow row(1, share::ObLSID(1)); + row.row_for_table_.element<0>() = 1; + row.row_for_table_.element<1>() = 1; + row.row_for_table_.element<2>().assign("z4,z5;z3;z2,z1"); + row.row_for_table_.element<3>().assign("127.0.0.1:1080"); + row.row_for_table_.element<4>().assign("127.0.0.1:1080(MIGRATE);127.0.0.1:1081(MIGRATE)"); + row.convert_table_info_to_user_info_(); + ASSERT_EQ(row.row_for_user_.element<4>().count(), 2); + ELECT_LOG(INFO, "print", K(row)); +} + +} +} + +int main(int argc, char **argv) +{ + system("rm -rf test_ob_election_priority_seperate_blacklist.log"); + oceanbase::palf::election::GLOBAL_INIT_ELECTION_MODULE(); + oceanbase::unittest::MockNetService::init(); + oceanbase::palf::election::INIT_TS = 0; + oceanbase::common::ObClockGenerator::init(); + oceanbase::common::ObLogger &logger = oceanbase::common::ObLogger::get_logger(); + oceanbase::share::ObTenantBase tenant_base(OB_SYS_TENANT_ID); + tenant_base.init(); + oceanbase::share::ObTenantEnv::set_tenant(&tenant_base); + logger.set_file_name("test_ob_election_priority_seperate_blacklist.log", false); + logger.set_log_level(OB_LOG_LEVEL_INFO); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}