diff --git a/src/braft/configuration.h b/src/braft/configuration.h index 6006fda..cc11399 100644 --- a/src/braft/configuration.h +++ b/src/braft/configuration.h @@ -85,7 +85,6 @@ struct PeerId { // |- ip:port // |- [ipv6]:port // |- unix:path/to/sock - // clang-format off std::regex peerid_reg("((([^:]+)|(\\[.*\\])):[^:]+)(:(\\d)?)?(:(\\d+)?)?"); // ^ ^ ^ ^ @@ -93,7 +92,6 @@ struct PeerId { // unix,host,ipv4 | idx(6)(opt) | // ipv6 role(8)(opt) // clang-format on - std::cmatch m; auto ret = std::regex_match(str.c_str(), m, peerid_reg); if (!ret || m.size() != 9) { diff --git a/test/test_node.cpp b/test/test_node.cpp index bceda08..40a2bcf 100644 --- a/test/test_node.cpp +++ b/test/test_node.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include "../test/util.h" diff --git a/test/util.h b/test/util.h index 6bf6f6d..58e5c14 100644 --- a/test/util.h +++ b/test/util.h @@ -18,7 +18,10 @@ #define PUBLIC_RAFT_TEST_UTIL_H #include +#include +#include "_deps/brpc/src/src/butil/endpoint.h" +#include "brpc/server.h" #include "butil/time.h" #include "braft/enum.pb.h" #include "braft/errno.pb.h" @@ -278,12 +281,15 @@ class Cluster { } options.fsm = fsm; options.node_owns_fsm = true; + std::string endpoint_str = butil::endpoint2str(listen_addr).c_str(); butil::string_printf(&options.log_uri, "local://./data/%s/log", - butil::endpoint2str(listen_addr).c_str()); - butil::string_printf(&options.raft_meta_uri, "local://./data/%s/raft_meta", - butil::endpoint2str(listen_addr).c_str()); - butil::string_printf(&options.snapshot_uri, "local://./data/%s/snapshot", - butil::endpoint2str(listen_addr).c_str()); + endpoint_str.c_str()); + butil::string_printf(&options.raft_meta_uri, + "local://./data/%s/raft_meta", + endpoint_str.c_str()); + butil::string_printf(&options.snapshot_uri, + "local://./data/%s/snapshot", + endpoint_str.c_str()); options.snapshot_throttle = &_throttle; @@ -523,7 +529,7 @@ class Cluster { braft::Node* node = NULL; std::vector new_nodes; for (size_t i = 0; i < _nodes.size(); i++) { - if (addr.port == _nodes[i]->node_id().peer_id.addr.port) { + if (addr == _nodes[i]->node_id().peer_id.addr) { node = _nodes[i]; } else { new_nodes.push_back(_nodes[i]);